Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_variable_type(self):
spin = oj.cast_var_type('SPIN')
self.assertEqual(spin, oj.SPIN)
binary = oj.cast_var_type('BINARY')
self.assertEqual(binary, oj.BINARY)
def test_cast(self):
spin_var = oj.cast_var_type('SPIN')
self.assertEqual(spin_var, oj.SPIN)
binary_var = oj.cast_var_type('BINARY')
self.assertEqual(binary_var, oj.BINARY)
def test_variable_type(self):
spin = oj.cast_var_type('SPIN')
self.assertEqual(spin, oj.SPIN)
binary = oj.cast_var_type('BINARY')
self.assertEqual(binary, oj.BINARY)
def test_cast(self):
spin_var = oj.cast_var_type('SPIN')
self.assertEqual(spin_var, oj.SPIN)
binary_var = oj.cast_var_type('BINARY')
self.assertEqual(binary_var, oj.BINARY)
def __init__(self, linear=None, quadratic=None, offset=0.0,
king_graph=None, var_type=openjij.SPIN, machine_type=''):
"""
The constructor reformat interactions to Web API format (ising king graph),
and validates that the interaction is in King Graph.
----------
machine_type : str
choose 'ASIC' or 'FPGA'
king_graph : list of list
represents ising or QUBO interaction.
Each spins are decided by 2-d corrdinate x, y.
Quadratic term [x1, y1, x2, y2, value]
Linear term [x1, y1, x1, y1, value]
"""
var_type = openjij.cast_var_type(var_type)
# set parameter ranges
self.machine_type = machine_type
if self.machine_type == "ASIC":
self.xrange = [0, 351+1]
self.yrange = [0, 175+1]
self.prange = [-3, 3]
elif self.machine_type == "FPGA":
self.xrange = [0, 79+1]
self.yrange = [0, 79+1]
self.prange = [-127, 127]
else:
raise ValueError('machine type should be ASIC or FPGA')
# convert format h, J, Q and initilize BQM
if king_graph is not None:
def __init__(self, var_type, indices):
self.states = []
self.energies = []
self.var_type = openjij.cast_var_type(var_type)
self.q_states = []
self.q_energies = []
self.indices = indices
self.min_samples = {}
self.info = {}