Term
class¶
Bases: Element
, ABC
A base class representing a term in an optimization model.
The Term
class serves as a base class for representing terms in an optimization model. It is designed to
be inherited by subclasses that represent specific types of terms. The Term
class itself is an abstract
base class (ABC) that defines the common behavior and interface for all terms.
Source code in pyorlib/algebra/terms/term.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
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__
¶
Initializes a new Term object.
PARAMETER | DESCRIPTION |
---|---|
term_type |
An enumeration representing the type of the term.
TYPE:
|
value_type |
An enumeration representing the type of the term's value.
TYPE:
|
Source code in pyorlib/algebra/terms/term.py
get_pretty_string
abstractmethod
¶
Returns a formatted string representation of the term.
PARAMETER | DESCRIPTION |
---|---|
float_precision |
It represents the number of digits used in printing the solution and objective.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
A formatted string representing the term. |