DiscreteVariable¶
- class DiscreteVariable¶
Bases:
Variable
Represents a discrete variable.
Methods
Initializes a discrete variable with specified values and encoding method.
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__(
- values: list[float],
- encoding: Literal[EncodingMethod.OneHot, EncodingMethod.DomainWall] = EncodingMethod.DomainWall,
Initializes a discrete variable with specified values and encoding method.
- Parameters:
- Raises:
ValueError – If the values list is empty.
ValueError – If the values list contains duplicates.
ValueError – If the values list is not sorted.
TypeError – If the encoding method is invalid.
- __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__': 'Represents a discrete variable.', '__init__': <function DiscreteVariable.__init__>, '__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.