delpi  0.0.1
DElta-complete LP solver
Loading...
Searching...
No Matches
delpi::Formula Class Reference

Symbolic formula used to represent a constraint in the LP problem. More...

#include <Formula.h>

Public Member Functions

Formula Substitute (const Expression::SubstitutionMap &s) const
 Create a copy of this formula with the expression having all occurrences of the variables in s replaced with the corresponding variable in s.
template<MapFromTo< Variable, mpq_class > T>
bool Evaluate (const T &env) const
 Evaluates the formula using a given environment (by default, an empty environment).

Public Attributes

Expression expression_
 Left-hand side expression.
FormulaKind kind_
 Kind of the formula \( \in \\{ =\, \ne\, \le\, \ge\, <\, > \\} \).
mpq_class rhs_
 Right-hand side constant.

Detailed Description

Symbolic formula used to represent a constraint in the LP problem.

A symbolic formula is therefore a comparison between an expression and a constant. If two expressions are used as the left-hand side and right-hand side of the comparison, a new expression is created by subtracting the right-hand side from the left-hand side and the comparison is made with zero.

Variable x{"x"}, y{"y"}; // Variables
Formula row1 = x + 2 * y >= 0;
Formula row2 = x == 0;
Formula row3 = y != x; // row3 is equivalent to y - x != 0
Formula row4 = 2 * y - 5 * x < x + y; // row4 is equivalent to 2 * y - 5 * x - (x + y) < 0
Real symbolic variable.
Definition Variable.h:20

Definition at line 32 of file Formula.h.

Member Function Documentation

◆ Evaluate()

template<MapFromTo< Variable, mpq_class > T>
template bool delpi::Formula::Evaluate ( const T & env) const
nodiscard

Evaluates the formula using a given environment (by default, an empty environment).

Template Parameters
Tmap from variable to value (i.e. std::map<Variable, mpq_class>, std::unordered_map<Variable, mpq_class>)
Parameters
envmap between each variable and its value
Returns
true if the formula is satisfied within the given environment
false if the formula is not satisfied within the given environment
Exceptions
std::exceptionif there exists variable in this expression whose assignment is not provided by env

Definition at line 25 of file Formula.cpp.

◆ Substitute()

Formula delpi::Formula::Substitute ( const Expression::SubstitutionMap & s) const
nodiscard

Create a copy of this formula with the expression having all occurrences of the variables in s replaced with the corresponding variable in s.

Note that the substitutions occur simultaneously.

Formula f = x + 2 * y == 0;
Substitution s = {{x, y}, {y, x}};
f.Substitute(s); // returns y + 2 * x == 0
Formula Substitute(const Expression::SubstitutionMap &s) const
Create a copy of this formula with the expression having all occurrences of the variables in s replac...
Definition Formula.cpp:21
Parameters
smap of substitutions. Maps the old variable to the new one.
Returns
formula produced by the substitution

Definition at line 21 of file Formula.cpp.


The documentation for this class was generated from the following files: