BinaryQuadraticModel¶
- class BinaryQuadraticModel¶
Bases:
QuadraticModelA model of binary variables. Deprecated alias of
Model.The intermediate model takes a quadratic polynomial of binary variables. This class still works, and it emits a DeprecationWarning.
Methods
Test every input constraint against the values.
Attributes
The constraints that the model received.
The objective function as a matrix.
The objective function that the model received.
The map from the input variables to the intermediate variables.
The intermediate model as a matrix.
The unconstrained intermediate model as a matrix.
The intermediate model as one polynomial with no constraint.
The objective function of the intermediate model.
The number of the variables that the input model uses.
The number of the variables that the intermediate model uses.
The multiplier of the penalty that the quadratization adds.
- __add__(arg: Constraint | ConstraintList)¶
Return a new model that holds this model and the constraint.
- Parameters:
arg – The constraint to add.
- Returns:
A model of the same class.
- __iadd__(arg: Constraint | ConstraintList)¶
Add the constraint to this model and return this model.
- Parameters:
arg – The constraint to add.
- Returns:
This model.
- __init__(arg0, arg1=None, *, method: QuadratizationMethod = QuadratizationMethod.IshikawaKZFD)¶
- __radd__(arg: Constraint | ConstraintList)¶
Return a new model that holds the constraint and this model.
- Parameters:
arg – The constraint to add.
- Returns:
A model of the same class.
- check_constraints(values: Values) list[tuple[Constraint, bool]]¶
Test every input constraint against the values.
- Parameters:
values – The values to substitute, such as result.best.values.
- Returns:
One pair of a constraint and a bool for each input constraint. The bool says whether the values satisfy that constraint.
- __deprecated__ = 'BinaryQuadraticModel is deprecated since amplify v1.0.0 and will no longer support in the near future.\nUse Model instead. Please see the migration guide for details: https://amplify.fixstars.com/docs/amplify/v1/migration.html'¶
- property input_constraints: ConstraintList¶
The constraints that the model received.
- Returns:
The constraints of the model, before the conversion.
- property input_matrix¶
The objective function as a matrix. Removed in v1.7.0.
Use
input_poly. A model holds its objective function as aPoly.- Raises:
NotImplementedError – Always.
- property input_poly: Poly | None¶
The objective function that the model received.
- Returns:
The objective function, or None when the model has none.
- property logical_mapping: IntermediateMapping¶
The map from the input variables to the intermediate variables.
- Returns:
The mapping that the conversion to the intermediate model made.
- property logical_matrix¶
The intermediate model as a matrix. Removed in v1.7.0.
Use
logical_model_poly. A model holds its objective function as aPoly.- Raises:
NotImplementedError – Always.
- property logical_model_matrix¶
The unconstrained intermediate model as a matrix. Obsolete.
Use
logical_model_poly.- Raises:
NotImplementedError – Always.
- property logical_model_poly: Poly¶
The intermediate model as one polynomial with no constraint.
- Returns:
The objective function of the intermediate model, with the penalty function of every constraint added to it.
- property logical_poly: Poly | None¶
The objective function of the intermediate model.
The constraints are not in it. Use
logical_model_polyto get them too.- Returns:
The objective function, or None when the intermediate model has none.
- property num_input_vars: int¶
The number of the variables that the input model uses.
- Returns:
The count.
- property num_logical_vars: int¶
The number of the variables that the intermediate model uses.
The quadratization adds a variable, so this count is not less than
num_input_vars.- Returns:
The count.
- property substitution_multiplier: float¶
The multiplier of the penalty that the quadratization adds.
The conversion to the intermediate model multiplies the penalty function of a substitution by this value. Raise it when the solution breaks a substitution. The setter raises ValueError when the value is not a positive float.
- Returns:
The multiplier. It is positive.