BinaryMatrix

class BinaryMatrix

ベースクラス: Matrix

A 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

__init__

evaluate

Evaluate the matrix objective using the provided variable assignments.

to_poly

Convert this matrix form to Poly.

Attributes

constant

Constant term c.

linear

Linear coefficient array p.

quadratic

Quadratic coefficient array Q.

variable_array

Variable array x used in the matrix representation.

__add__(self, arg: Constraint | ConstraintList, /) Model

Create a Model whose objective is this matrix form, with the given constraints.

パラメータ:

arg (Constraint | ConstraintList) -- Constraints to include.

戻り値:

Model containing this objective and the given constraints.

戻り値の型:

Model

__eq__(self, arg: object, /) bool
パラメータ:

arg (object)

戻り値の型:

bool

__init__(*args, **kwargs)
__ne__(self, arg: object, /) bool
パラメータ:

arg (object)

戻り値の型:

bool

__radd__(self, arg: Constraint | ConstraintList, /) Model

Create a Model whose objective is this matrix form, with the given constraints.

パラメータ:

arg (Constraint | ConstraintList) -- Constraints to include.

戻り値:

Model containing this objective and the given constraints.

戻り値の型:

Model

__repr__(self) str

Return a developer-friendly string representation of the matrix form.

戻り値の型:

str

__str__(self) str

Return a human-readable string representation of the matrix form.

戻り値の型:

str

evaluate(self, values: Values) float
evaluate(self, values: Values, default: float) float

Evaluate the matrix objective using the provided variable assignments.

Substitute variables in x with the given values and evaluate x^\top Q x + p^\top x + c. If default is not specified, a variable that values does not give takes the default value of its type: 0 for a binary variable, -1 for an Ising variable, and, for an integer or a real variable, 0 if the bounds hold 0, 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.

戻り値の型:

Poly

__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 constant

Constant term c.

戻り値の型:

float

property linear

Linear coefficient array p.

For a variable array x with n dimensions, the linear coefficient array p also has n dimensions. When x is one-dimensional, p is a 1D vector.

戻り値の型:

ndarray

property quadratic

Quadratic coefficient array Q.

For a variable array x with n dimensions, the quadratic coefficient array Q has 2n dimensions. When x is one-dimensional, Q is a 2D matrix.

戻り値の型:

ndarray

property variable_array

Variable array x used in the matrix representation.

Use this array when constructing constraints for a matrix objective.

戻り値:

Variable array used in this representation.

戻り値の型:

PolyArray[Dim]