Is the quadratic model which represents the QUBO model with real coefficients.

The class abstracts a “logical model” from multivariate polynomial, matrix, and constraints. The “logical model” is a formulation for inputting into the ising machines. This class generates a logical model by reducing the order of multivariate polynomial to quadratic and reallocating variable index.

The class converts to a logical model from the below objects.

• Multivariate polynomial

• Includes polynomial with the order greater than three.

• Matrix

• Constraint

• Includes multiple constraints

Note

For more details of the conversion source, see __init__() and its examples.

Through attributes of this class, you can get a raw input model, a converted logical model, and mapping from an input model to a logical model.

Note

The following operators are defined for the class.

__init__(*args, **kwargs)

Returns the QUBO quadratic model initialized by input and constraints.

1. __init__(poly, constraints)
2. __init__(matrix, constant, constraints)
Parameters

Example

>>> from amplify import (gen_symbols,
>>> from amplify.constraint import equal_to
>>> model = BinaryQuadraticModel(q + q + q, equal_to(q, 1))
>>> model.input_poly
q_0 + q_1 + q_2
>>> from amplify import (BinaryMatrix,
>>> mat = BinaryMatrix(3)
>>> mat[0, 1] = 1
>>> mat[0, 2] = 2
>>> mat[1, 2] = 3
>>> model.input_matrix
([[0, 1, 2],
[0, 0, 3],
[0, 0, 0]], 4.0)

Methods

 __init__(*args, **kwargs) Returns the QUBO quadratic model initialized by input and constraints. check_constraints(*args, **kwargs) Overloaded function.

Attributes

 input_constraints Returns the constraints of the QUBO quadratic model. input_matrix Equivalent to logical_matrix. input_poly Returns the input BinaryPoly. logical_mapping Returns the mapping from input varieties to logical varieties. logical_matrix Returns the pair of BinaryMatrix and the constant term of the QUBO quadratic model. logical_model_matrix Is almost same as logical_matrix, but includes the constraint terms. logical_model_poly Is almost same as logical_poly, but includes the constraint terms. logical_poly Returns BinaryPoly, which represents the QUBO quadratic model. num_input_vars Returns the number of variables in the input QUBO quadratic model. num_logical_vars Returns the number of variables in the converted QUBO quadratic model. substituion_multiplier
check_constraints(*args, **kwargs)

1. check_constraints(self: amplify.BinaryQuadraticModel, arg0: List[int]) -> List[Tuple[amplify.BinaryConstraintTermRef, bool]]

no docstring

1. check_constraints(self: amplify.BinaryQuadraticModel, arg0: Dict[int, int]) -> List[Tuple[amplify.BinaryConstraintTermRef, bool]]

2. check_constraints(self: amplify.BinaryQuadraticModel, arg0: function) -> List[Tuple[amplify.BinaryConstraintTermRef, bool]]

property input_constraints

Returns the constraints of the QUBO quadratic model.

Example

>>> from amplify import (gen_symbols,
... BinaryPoly,
>>> from amplify.constraint import equal_to
>>> q = gen_symbols(BinaryPoly, 1)
>>> eq = model.input_constraints.pop()
>>> eq.is_satisfied()
False
>>> eq.is_satisfied()
True
property input_matrix

Equivalent to logical_matrix.

property input_poly

Returns the input BinaryPoly.

Example

>>> from amplify import (BinaryPoly,
>>> poly = BinaryPoly({(0, 1, 2) : 1})
>>> model.input_poly
q_0 q_1 q_2
property logical_mapping

Returns the mapping from input varieties to logical varieties.

Example

>>> from amplify import (BinaryMatrix,
>>> mat = BinaryMatrix(3)
>>> model.logical_mapping
{2: 2, 0: 0, 1: 1}
property logical_matrix

Returns the pair of BinaryMatrix and the constant term of the QUBO quadratic model.

Example

>>> from amplify import (BinaryMatrix,
>>> mat = BinaryMatrix(3)
>>> mat[0, 1] = 1
>>> mat[0, 2] = 2
>>> mat[1, 2] = 3
>>> poly = mat.to_Poly()
>>> poly += 4
>>> model.logical_matrix
([[0, 1, 2],
[0, 0, 3],
[0, 0, 0]], 4.0)
property logical_model_matrix

Is almost same as logical_matrix, but includes the constraint terms.

Example

>>> from amplify import (BinaryMatrix,
>>> from amplify.constraint import equal_to
>>> mat = BinaryMatrix(3)
>>> mat[0, 1] = 1
>>> mat[0, 2] = 2
>>> mat[1, 2] = 3
>>> poly = mat.to_Poly()
>>> poly += 4
>>> model = BinaryQuadraticModel(poly, equal_to(q, 1))
>>> model.logical_model_matrix
([[-1, 1, 2],
[0, 0, 3],
[0, 0, 0]], 5.0)
property logical_model_poly

Is almost same as logical_poly, but includes the constraint terms.

Example

>>> from amplify import (gen_symbols,
>>> from amplify.constraint import equal_to
>>> model = BinaryQuadraticModel(q + q + q, equal_to(q, 1))
>>> model.logical_model_poly
q_0 + q_1 + 1.000000
property logical_poly

Returns BinaryPoly, which represents the QUBO quadratic model.

Note

The logical_poly variables don’t always correspond to the input_poly variables, even if input_poly is quadratic.

Example

>>> from amplify import (BinaryPoly,
>>> poly = BinaryPoly({(0, 1, 2) : 1})
>>> model.logical_poly
q_0 q_1 + q_0 q_2 - q_0 q_3 + q_1 q_2 - q_1 q_3 - q_2 q_3 + q_3
property num_input_vars

Returns the number of variables in the input QUBO quadratic model.

Example

>>> from amplify import (BinaryPoly,
>>> poly = BinaryPoly({(0, 1, 2) : 1})
>>> model.num_input_vars
3
property num_logical_vars

Returns the number of variables in the converted QUBO quadratic model.

Example

>>> from amplify import (BinaryPoly,