Variable¶
- class Variable¶
Bases:
object
A base class representing a decision variable for the optimization problem.
Methods
Initialize a decision variable.
Converts the variable to the Amplify SDK's polynomial representation.
Attributes
Returns the bounds of the variable.
Returns the encoding method for the variable.
Returns the name of the variable.
Returns a list of possible values for a discrete variable, or a pair of boundary values for a continuous variable.
Returns the type of the variable.
- __init__(
- var_type: VariableType,
- bounds: tuple[float, float] | None = None,
- encoding: _EncodingMethodBase | None = None,
Initialize a decision variable.
- __neg__() Poly ¶
- __pos__() Poly ¶
- to_poly() Poly ¶
Converts the variable to the Amplify SDK’s polynomial representation.
- Returns:
The Amplify SDK’s polynomial representation of the variable.
- Return type:
amplify.Poly
- __dict__ = mappingproxy({'__module__': 'amplify_bbopt.variable', '__doc__': 'A base class representing a decision variable for the optimization problem.', '__init__': <function Variable.__init__>, 'name': <property object>, 'type': <property object>, 'possible_values': <property object>, 'bounds': <property object>, 'encoding': <property object>, 'to_poly': <function Variable.to_poly>, '__add__': <function Variable.__add__>, '__radd__': <function Variable.__radd__>, '__sub__': <function Variable.__sub__>, '__rsub__': <function Variable.__rsub__>, '__mul__': <function Variable.__mul__>, '__rmul__': <function Variable.__rmul__>, '__truediv__': <function Variable.__truediv__>, '__pos__': <function Variable.__pos__>, '__neg__': <function Variable.__neg__>, '__pow__': <function Variable.__pow__>, '__eq__': <function Variable.__eq__>, '__hash__': <function Variable.__hash__>, '__ne__': <function Variable.__ne__>, '__str__': <function Variable.__str__>, '__repr__': <function Variable.__repr__>, '_repr_latex_': <function Variable._repr_latex_>, '__dict__': <attribute '__dict__' of 'Variable' objects>, '__weakref__': <attribute '__weakref__' of 'Variable' objects>, '__annotations__': {}})¶
- __weakref__¶
list of weak references to the object (if defined)
- property encoding: _EncodingMethodBase¶
Returns the encoding method for the variable.
- property possible_values: list[float | int] | tuple[float, float]¶
Returns a list of possible values for a discrete variable, or a pair of boundary values for a continuous variable.
- property type: VariableType¶
Returns the type of the variable.