Variable
class¶
Bases: Term
, ABC
Represents a base class for variable terms in an optimization model.
The Variable
class is a subclass of Term
and serves as a foundation for representing variable terms in
optimization models. It is designed to be inherited by subclasses that represent specific types of
variables. As an abstract base class (ABC), Variable
defines the common behavior and interface
for all variable terms.
Source code in pyorlib/algebra/terms/variables/variable.py
Attributes¶
raw
abstractmethod
property
¶
Returns the raw representation of the mathematical element.
The raw
method, when implemented by subclasses, returns the mathematical element in its raw format.
The raw format can take various forms, such as an expression used by solvers or engines, or a
mathematical expression that represents the entity itself.
RETURNS | DESCRIPTION |
---|---|
Any
|
The raw representation of the mathematical element. |
term_type
property
¶
term_type: TermType
Retrieves the type of the term.
RETURNS | DESCRIPTION |
---|---|
TermType
|
A TermType enumeration. |
value_type
property
¶
value_type: ValueType
Retrieves the type of the term's value.
RETURNS | DESCRIPTION |
---|---|
ValueType
|
A ValueType enumeration |
name
abstractmethod
property
¶
Retrieves the name of the term.
RETURNS | DESCRIPTION |
---|---|
str
|
A string with name of the term. |
lower_bound
abstractmethod
property
¶
Retrieves the lower bound of the term's value. For variable terms, the lower bound denotes the minimum value that the term can assume. For constant terms, the lower bound is equivalent to its value.
RETURNS | DESCRIPTION |
---|---|
float
|
A float representing the lower bound of the term's value. If the upper bound is negative infinity, the method returns |
upper_bound
abstractmethod
property
¶
Retrieves the upper bound of the term's value. For variable terms, the upper bound denotes the maximum value that the term can assume. For constant terms, the upper bound is equivalent to its value.
RETURNS | DESCRIPTION |
---|---|
float
|
A float representing the upper bound of the term's value. If the upper bound is infinity, the method returns |
value
abstractmethod
property
¶
Retrieves the value of the term.
For variable terms, the value corresponds to the current value of the term.
If the term has not been solved yet, the value is -0.0
.
For constant terms, the value remains the constant value.
RETURNS | DESCRIPTION |
---|---|
float
|
A float representing the value of the term. |
is_variable
property
¶
Determines whether the term is a variable or not.
RETURNS | DESCRIPTION |
---|---|
bool
|
|
is_constant
property
¶
Determines whether the term is a constant or not.
RETURNS | DESCRIPTION |
---|---|
bool
|
|
Functions¶
__add__
¶
__add__(other: Any) -> Element
Addition operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__radd__
¶
__radd__(other: Any) -> Element
Right addition operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__sub__
¶
__sub__(other: Any) -> Element
Subtraction operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__rsub__
¶
__rsub__(other: Any) -> Element
Right subtraction operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__mul__
¶
__mul__(other: Any) -> Element
Multiplication operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__rmul__
¶
__rmul__(other: Any) -> Element
Right multiplication operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__truediv__
¶
__truediv__(other: Any) -> Element
Division operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__rtruediv__
¶
__rtruediv__(other: Any) -> Element
Right division operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__floordiv__
¶
__floordiv__(other: Any) -> Element
Floor division operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__rfloordiv__
¶
__rfloordiv__(other: Any) -> Element
Right floor division operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__mod__
¶
__mod__(other: Any) -> Element
Modulo operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__rmod__
¶
__rmod__(other: Any) -> Element
Right modulo operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__pow__
¶
__pow__(other: Any) -> Element
Exponentiation operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__rpow__
¶
__rpow__(other: Any) -> Element
Right exponentiation operation.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__neg__
¶
__neg__() -> Element
Negation operation.
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
__pos__
¶
__pos__() -> Element
Positive operation.
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
__abs__
¶
__abs__() -> Element
Absolute value operation.
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
__eq__
¶
__eq__(other: Any) -> Element
Equal to comparison.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__ne__
¶
__ne__(other: Any) -> Element
Not equal to comparison.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__lt__
¶
__lt__(other: Any) -> Element
Less than comparison.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__le__
¶
__le__(other: Any) -> Element
Less than or equal to comparison.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__gt__
¶
__gt__(other: Any) -> Element
Greater than comparison.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__ge__
¶
__ge__(other: Any) -> Element
Greater than or equal to comparison.
PARAMETER | DESCRIPTION |
---|---|
other |
The
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Element
|
A new |
Source code in pyorlib/algebra/element.py
__init__
¶
__init__(name: str, value_type: ValueType, lower_bound: float = 0, upper_bound: float = inf)
Initializes a new Variable
object with the specified attributes.
PARAMETER | DESCRIPTION |
---|---|
name |
The name of the variable.
TYPE:
|
value_type |
An enumeration representing the type of the variable's value.
TYPE:
|
lower_bound |
The lower bound of the variable. Default is 0.
TYPE:
|
upper_bound |
The upper bound of the variable. Default is infinity.
TYPE:
|