Matrix¶
- class Matrix¶
This class represents a quadratic objective in coefficient-matrix form, expressed as \(x^\top Q x + p^\top x + c\).
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. evaluate
Substitute variables in
xwith the givenvaluesand evaluatex^\top Q x + p^\top x + c. Ifdefaultis not specified, variables not included invaluesare substituted with a reasonable default value.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.
- 戻り値の型:
- 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.- 戻り値の型: