QuadraticModel¶
- class QuadraticModel¶
Bases:
ABCThe base of the deprecated quadratic models of Amplify v0.
Use
Model. A subclass fixes the type of the variable that the intermediate model accepts, and this class holds aModeland converts it on demand. Do not use this class itself: it is abstract, and only the subclasses below name a variable type.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: Poly,
- arg1: Constraint | ConstraintList | None = None,
- *,
- method: QuadratizationMethod = QuadratizationMethod.IshikawaKZFD,
- __init__(
- arg0: Matrix,
- arg1: Constraint | ConstraintList | None = None,
- *,
- method: QuadratizationMethod = QuadratizationMethod.IshikawaKZFD,
- __init__(arg0: Model, arg1=None, *, method: QuadratizationMethod = QuadratizationMethod.IshikawaKZFD)
- __init__(
- arg0: Constraint | ConstraintList,
- 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.
- 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.