BinaryMatrix¶
- class BinaryMatrix¶
ベースクラス:
MatrixA matrix form of binary variables. Deprecated alias of
Matrix.Amplify v1 gives the variable its type when the generator makes it, so the matrix no longer carries the type. This class still works, and it emits a DeprecationWarning.
Methods
Evaluate the matrix objective using the provided variable assignments.
Convert this matrix form to
Poly.Attributes
Constant term
c.Linear coefficient array
p.Quadratic coefficient array
Q.Variable array
xused in the matrix representation.- __add__(self, arg: Constraint | ConstraintList, /) Model¶
Create a
Modelwhose objective is this matrix form, with the given constraints.- パラメータ:
arg (Constraint | ConstraintList) -- Constraints to include.
- 戻り値:
Model containing this objective and the given constraints.
- 戻り値の型:
- __init__(*args, **kwargs)¶
- __radd__(self, arg: Constraint | ConstraintList, /) Model¶
Create a
Modelwhose objective is this matrix form, with the given constraints.- パラメータ:
arg (Constraint | ConstraintList) -- Constraints to include.
- 戻り値:
Model containing this objective and the given constraints.
- 戻り値の型:
- evaluate(self, values: Values) float¶
- evaluate(self, values: Values, default: float) float
Evaluate the matrix objective using the provided variable assignments.
Substitute variables in
xwith the givenvaluesand evaluatex^\top Q x + p^\top x + c. Ifdefaultis not specified, a variable thatvaluesdoes not give takes the default value of its type:0for a binary variable,-1for an Ising variable, and, for an integer or a real variable,0if the bounds hold0, else the upper bound, or the lower bound when the variable has no upper bound.Overload 1.
- Args:
values (amplify.Values): Variable values obtained from optimization results, e.g.
result.best.values.
- Returns:
float: Evaluated objective value.
Overload 2.
- Args:
values (amplify.Values): Variable values obtained from optimization results, e.g.
result.best.values.default (float): Default value used for variables not included in
values.
- Returns:
float: Evaluated objective value.
- to_poly(self) Poly¶
Convert this matrix form to
Poly.- 戻り値:
Polynomial converted from this matrix form.
- 戻り値の型:
- __deprecated__ = 'BinaryMatrix is deprecated since amplify v1.0.0 and will no longer support in the near future.\nUse Matrix instead. Please see the migration guide for details: https://amplify.fixstars.com/docs/amplify/v1/migration.html'¶
- property linear¶
Linear coefficient array
p.For a variable array
xwithndimensions, the linear coefficient arraypalso hasndimensions. Whenxis one-dimensional,pis a 1D vector.- 戻り値の型:
- property quadratic¶
Quadratic coefficient array
Q.For a variable array
xwithndimensions, the quadratic coefficient arrayQhas2ndimensions. Whenxis one-dimensional,Qis a 2D matrix.- 戻り値の型: