openjij.model#

Submodules#

Functions#

BinaryPolynomialModel(*args, **kwargs)

BinaryQuadraticModel(linear, quadratic, *args, **kwargs)

Generate BinaryQuadraticModel object.

bqm_from_numpy_matrix(mat[, variables, offset, vartype])

make_BinaryPolynomialModel(polynomial[, index_type, ...])

make_BinaryPolynomialModel_from_JSON(obj)

make_BinaryPolynomialModel_from_hising(*args, **kwargs)

make_BinaryPolynomialModel_from_hubo(*args, **kwargs)

make_BinaryQuadraticModel(linear, quadratic, sparse)

BinaryQuadraticModel factory.

Package Contents#

openjij.model.BinaryPolynomialModel(*args, **kwargs)[source]#
openjij.model.BinaryQuadraticModel(linear, quadratic, *args, **kwargs)[source]#

Generate BinaryQuadraticModel object.

openjij.model.vartype#

variable type SPIN or BINARY

Type:

dimod.Vartype

openjij.model.linear#

represents linear term

Type:

dict

openjij.model.quadratic#

represents quadratic term

Type:

dict

openjij.model.offset#

represents constant energy term when convert to SPIN from BINARY

Type:

float

openjij.model.num_variables#

represents number of variables in the model

Type:

int

openjij.model.variables#

represents variables of the binary quadratic model

Type:

list

Parameters:
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.bqm_from_numpy_matrix(mat, variables: list = None, offset=0.0, vartype='BINARY', **kwargs)[source]#
Parameters:

variables (list)

openjij.model.make_BinaryPolynomialModel(polynomial, index_type=None, tuple_size=0)[source]#
openjij.model.make_BinaryPolynomialModel_from_JSON(obj)[source]#
openjij.model.make_BinaryPolynomialModel_from_hising(*args, **kwargs)[source]#
openjij.model.make_BinaryPolynomialModel_from_hubo(*args, **kwargs)[source]#
openjij.model.make_BinaryQuadraticModel(linear: dict, quadratic: dict, sparse)[source]#

BinaryQuadraticModel factory.

Returns:

generated BinaryQuadraticModel class

Parameters: