How to use the openjij.model.KingGraph 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 / openjij / sampler / cmos_annealer.py View on Github external
>>> print(response)
            number of state: 10, minimun energy: -4.0, spin_type: ising
            info:
                averaged_spins: [[2, 0, 1.0], [0, 1, -1.0], [0, 0, 1.0], [1, 0, 1.0]]
                averaged_energy: -4.0
                execution_time: 58769171
                job_id: XXXXXXXXXXXXXXXXX

        """

        var_type = 'SPIN'
        if king_graph is not None:
            _king_graph = KingGraph(machine_type=self.machine_type, king_graph=king_graph, var_type=var_type)
            return self._sampling(_king_graph, var_type=var_type, token=self.token)
        elif (h is not None) and (J is not None):
            _king_graph = KingGraph(machine_type=self.machine_type, h=h, J=J, var_type=var_type)
            return self._sampling(_king_graph, var_type=var_type, token=self.token)
        else:
            raise ValueError('intput "h and J" or king_graph model')
github OpenJij / OpenJij / openjij / sampler / cmos_annealer.py View on Github external
>>> import openjij as oj
            >>> sampler = oj.CMOSAnnealer(token="YOUR_TOKEN", iteration=10)
            >>> response = sampler.sample_qubo({(0, 0): 1, (0, 1): -1, (1, 2): -1, (0, 80): 3})
            >>> print(response)
            number of state: 10, minimun energy: -4.0, spin_type: binary
            info:
                averaged_spins: [[2, 0, 1.0], [0, 1, -1.0], [0, 0, 1.0], [1, 0, 1.0]]
                averaged_energy: -4.0
                execution_time: 58769171
                job_id: XXXXXXXXXXXXXXXXX

        """

        var_type = 'BINARY'
        if king_graph is not None:
            _king_graph = KingGraph(machine_type=self.machine_type, king_graph=king_graph, var_type=var_type)
            return self._sampling(_king_graph, var_type=var_type, token=self.token)
        elif Q is not None:
            _king_graph = KingGraph(machine_type=self.machine_type, Q=Q, var_type=var_type)
            return self._sampling(_king_graph, var_type=var_type, token=self.token)
        else:
            raise ValueError('intput Q or king_graph model')
github OpenJij / OpenJij / openjij / sampler / cmos_annealer.py View on Github external
>>> import openjij as oj
            >>> sampler = oj.CMOSAnnealer(token="YOUR_TOKEN", iteration=10)
            >>> response = sampler.sample_ising({0: 1}, {(0, 1): -1, (1, 2): -1, (0, 80): 3})
            >>> print(response)
            number of state: 10, minimun energy: -4.0, spin_type: ising
            info:
                averaged_spins: [[2, 0, 1.0], [0, 1, -1.0], [0, 0, 1.0], [1, 0, 1.0]]
                averaged_energy: -4.0
                execution_time: 58769171
                job_id: XXXXXXXXXXXXXXXXX

        """

        var_type = 'SPIN'
        if king_graph is not None:
            _king_graph = KingGraph(machine_type=self.machine_type, king_graph=king_graph, var_type=var_type)
            return self._sampling(_king_graph, var_type=var_type, token=self.token)
        elif (h is not None) and (J is not None):
            _king_graph = KingGraph(machine_type=self.machine_type, h=h, J=J, var_type=var_type)
            return self._sampling(_king_graph, var_type=var_type, token=self.token)
        else:
            raise ValueError('intput "h and J" or king_graph model')
github OpenJij / OpenJij / openjij / sampler / cmos_annealer.py View on Github external
>>> print(response)
            number of state: 10, minimun energy: -4.0, spin_type: binary
            info:
                averaged_spins: [[2, 0, 1.0], [0, 1, -1.0], [0, 0, 1.0], [1, 0, 1.0]]
                averaged_energy: -4.0
                execution_time: 58769171
                job_id: XXXXXXXXXXXXXXXXX

        """

        var_type = 'BINARY'
        if king_graph is not None:
            _king_graph = KingGraph(machine_type=self.machine_type, king_graph=king_graph, var_type=var_type)
            return self._sampling(_king_graph, var_type=var_type, token=self.token)
        elif Q is not None:
            _king_graph = KingGraph(machine_type=self.machine_type, Q=Q, var_type=var_type)
            return self._sampling(_king_graph, var_type=var_type, token=self.token)
        else:
            raise ValueError('intput Q or king_graph model')