openjij.model.model#
Functions#
|
|
|
Generate BinaryQuadraticModel object. |
|
|
|
|
|
|
|
|
|
|
|
|
|
BinaryQuadraticModel factory. |
Make BinaryQuadraticModel from JSON. |
Module Contents#
- openjij.model.model.BinaryQuadraticModel(linear, quadratic, *args, **kwargs)[source]#
Generate BinaryQuadraticModel object.
- openjij.model.model.vartype#
variable type SPIN or BINARY
- Type:
- openjij.model.model.offset#
represents constant energy term when convert to SPIN from BINARY
- Type:
- Parameters:
linear (
dict
) – linear biasesquadratic (
dict
) – quadratic biasesoffset (
float
) – offsetvartype (
openjij.variable_type.Vartype
) – vartype (‘SPIN’ or ‘BINARY’)kwargs
- Returns:
generated BinaryQuadraticModel
Examples
BinaryQuadraticModel can be initialized by specifing h and J:
>>> h = {0: 1, 1: -2} >>> J = {(0, 1): -1, (1, 2): -3, (2, 3): 0.5} >>> bqm = oj.BinaryQuadraticModel(self.h, self.J)
You can also use strings and tuples of integers (up to 4 elements) as indices:
>>> h = {'a': 1, 'b': -2} >>> J = {('a', 'b'): -1, ('b', 'c'): -3, ('c', 'd'): 0.5} >>> bqm = oj.BinaryQuadraticModel(self.h, self.J)
- openjij.model.model.bqm_from_numpy_matrix(mat, variables: list = None, offset=0.0, vartype='BINARY', **kwargs)[source]#
- Parameters:
variables (list)