How to use the openjij.cast_var_type function in openjij

To help you get started, we’ve selected a few openjij examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenJij / OpenJij / tests / test_model.py View on Github external
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)
github OpenJij / OpenJij / tests / test_sampler.py View on Github external
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)
github OpenJij / OpenJij / tests / test_model.py View on Github external
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)
github OpenJij / OpenJij / tests / test_sampler.py View on Github external
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)
github OpenJij / OpenJij / openjij / model / king_graph.py View on Github external
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:
github OpenJij / OpenJij / openjij / sampler / response.py View on Github external
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 = {}