Generated on: Thu Mar 29 07:46:58 PDT 2012 for custom file set | ||
|
||
// doxy/ or-tools/ src/ constraint_solver/ |
#include <constraint_solveri.h>
Public Member Functions | |
BaseIntExpr (Solver *const s) | |
virtual | ~BaseIntExpr () |
virtual IntVar * | Var () |
Creates a variable from the expression. | |
virtual IntVar * | CastToVar () |
It proposes a basic 'CastToVar()' implementation. The class of expressions represent two types of objects: variables and subclasses of BaseIntExpr. Variables are stateful objects that provide a rich API (remove values, WhenBound...). On the other hand, subclasses of BaseIntExpr represent range-only stateless objects. That is the min(A + B) is recomputed each time as min(A) + min(B). Furthermore, sometimes, the propagation on an expression is not complete, and Min(), Max() are not monononic with respect to SetMin() and SetMax(). For instance, A is a var with domain [0 .. 5], and B another variable with domain [0 .. 5]. Then Plus(A, B) has domain [0, 10]. If we apply SetMax(Plus(A, B), 4)). Then we will deduce that both A and B will have domain [0 .. 4]. In that case, Max(Plus(A, B)) is 8 and not 4. To get back monotonicity, we will 'cast' the expression into a variable using the Var() method (that will call CastToVar() internally). The resulting variable will be stateful and monotonic.
Finally, one should never store a pointer to a IntExpr, or BaseIntExpr in the code. The safe code should always call Var() on an expression built by the solver, and store the object as an IntVar*. This is a consequence of the stateless nature of the expressions that makes the code error-prone.
Definition at line 111 of file constraint_solveri.h.
operations_research::BaseIntExpr::BaseIntExpr | ( | Solver *const | s | ) | [inline, explicit] |
Definition at line 113 of file constraint_solveri.h.
virtual operations_research::BaseIntExpr::~BaseIntExpr | ( | ) | [inline, virtual] |
Definition at line 114 of file constraint_solveri.h.
IntVar * operations_research::BaseIntExpr::Var | ( | ) | [virtual] |
Creates a variable from the expression.
Implements operations_research::IntExpr.
Definition at line 5031 of file expressions.cc.
IntVar * operations_research::BaseIntExpr::CastToVar | ( | ) | [virtual] |
Definition at line 5039 of file expressions.cc.