|
|
delpi
0.0.1
DElta-complete LP solver
|
Symbolic expression representing an addition between linear monomials. More...
#include <ExpressionCell.h>
Public Member Functions | |
| ExpressionCell & | Add (const Variable &var, const mpq_class &coeff) |
| Add a linear monomial \( c \cdot x \), where \( c \) is a constant and \( x \) is a Variable, to the current expression. | |
| ExpressionCell & | Multiply (const mpq_class &coeff) |
| Multiply all terms of the summation by a coeff. | |
| ExpressionCell & | Divide (const mpq_class &coeff) |
| Divide all terms of the summation by a coeff. | |
| template<MapFromTo< Variable, mpq_class > T> | |
| mpq_class | Evaluate (const T &env={}) const |
| Evaluates using a given environment (by default, an empty environment). | |
| Expression | Substitute (const SubstitutionMap &s) const |
| Create a copy of this expression, replacing all occurrences of the variables in s with corresponding expressions in s. | |
Protected Attributes | |
| std::size_t | hash_ |
| Cached hash of the object. | |
| Expression::Addends | addends_ |
| Map between each variable and it coefficient as terms of the summation. | |
Additional Inherited Members | |
| Protected Member Functions inherited from delpi::SelfReferenceCountingObject | |
| virtual | ~SelfReferenceCountingObject ()=default |
| Virtual destructor for the SelfReferenceCountingObject. | |
Symbolic expression representing an addition between linear monomials.
It can be used to encode expression of the kind
\[ \sum c_i \cdot x_i \]
where \( c_i \) is a constant and \( x_i \) is a Variable. Internally this class maintains a member variable addends_ to represent a mapping between each variable \( x_i \) to its rational \( c_i \).
Definition at line 27 of file ExpressionCell.h.
| ExpressionCell & delpi::ExpressionCell::Add | ( | const Variable & | var, |
| const mpq_class & | coeff ) |
Add a linear monomial \( c \cdot x \), where \( c \) is a constant and \( x \) is a Variable, to the current expression.
| var | variable of the linear monomial |
| coeff | coefficient of the linear monomial |
Definition at line 70 of file ExpressionCell.cpp.
| ExpressionCell & delpi::ExpressionCell::Divide | ( | const mpq_class & | coeff | ) |
Divide all terms of the summation by a coeff.
| coeff | coefficient all the terms will be divided by |
| delpi::DelpiException | division by 0 detected |
Definition at line 92 of file ExpressionCell.cpp.
|
nodiscard |
Evaluates using a given environment (by default, an empty environment).
| T | map from variable to value (i.e. std::map<Variable, mpq_class>, std::unordered_map<Variable, mpq_class>) |
| env | map between each variable and its value |
| std::exception | if there exists variable in this expression whose assignment is not provided by env |
Definition at line 101 of file ExpressionCell.cpp.
| ExpressionCell & delpi::ExpressionCell::Multiply | ( | const mpq_class & | coeff | ) |
Multiply all terms of the summation by a coeff.
| coeff | coefficient all the terms will be mutiplied by |
Definition at line 85 of file ExpressionCell.cpp.
|
nodiscard |
Create a copy of this expression, replacing all occurrences of the variables in s with corresponding expressions in s.
Note that the substitutions occur simultaneously.
Definition at line 108 of file ExpressionCell.cpp.