Java Reference
Java Reference
Detailed Description
This is the base class for all expressions that are not variables.
It provides 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, 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 monotonic with respect to SetMin() and SetMax(). For instance, if 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)), we will deduce that both A and B have domain [0 .. 4]. In that case, Max(Plus(A, B)) is 8 and not 4. To get back monotonicity, we '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 14 of file BaseIntExpr.java.
Public Member Functions | |
| synchronized void | delete () |
| IntVar | var () |
| Creates a variable from the expression. More... | |
| IntVar | castToVar () |
| long | min () |
| void | setMin (long m) |
| long | max () |
| void | setMax (long m) |
| void | range (int[] l, int[] u) |
| By default calls Min() and Max(), but can be redefined when Min and Max code can be factorized. More... | |
| void | setRange (long l, long u) |
| This method sets both the min and the max of the expression. More... | |
| void | setValue (long v) |
| This method sets the value of the expression. More... | |
| boolean | bound () |
| Returns true if the min and the max of the expression are equal. More... | |
| boolean | isVar () |
| Returns true if the expression is indeed a variable. More... | |
| IntVar | varWithName (String name) |
| Creates a variable from the expression and set the name of the resulting var. More... | |
| void | whenRange (Demon d) |
| Attach a demon that will watch the min or the max of the expression. More... | |
| void | whenRange (Runnable closure) |
| Attach a demon that will watch the min or the max of the expression. More... | |
| void | accept (ModelVisitor visitor) |
| Accepts the given visitor. More... | |
| String | toString () |
| Solver | solver () |
| void | freezeQueue () |
| This method freezes the propagation queue. More... | |
| void | unfreezeQueue () |
| This method unfreezes the propagation queue. More... | |
| void | enqueueDelayedDemon (Demon d) |
| This method pushes the demon onto the propagation queue. More... | |
| void | enqueueVar (Demon d) |
| void | reset_action_on_fail () |
| This method clears the failure callback. More... | |
| void | set_variable_to_clean_on_fail (IntVar v) |
| Shortcut for variable cleaner. More... | |
| String | name () |
| Object naming. More... | |
| void | setName (String name) |
| boolean | hasName () |
| Returns whether the object has been named or not. More... | |
| String | baseName () |
| Returns a base name for automatic naming. More... | |
Protected Member Functions | |
| BaseIntExpr (long cPtr, boolean cMemoryOwn) | |
Constructor & Destructor Documentation
◆ BaseIntExpr()
|
inlineprotected |
Definition at line 17 of file BaseIntExpr.java.
Member Function Documentation
◆ accept()
|
inlineinherited |
◆ baseName()
|
inlineinherited |
Returns a base name for automatic naming.
Reimplemented in BooleanVar.
Definition at line 115 of file PropagationBaseObject.java.
◆ bound()
|
inlineinherited |
Returns true if the min and the max of the expression are equal.
Reimplemented in BooleanVar.
Definition at line 82 of file IntExpr.java.
◆ castToVar()
|
inline |
Definition at line 47 of file BaseIntExpr.java.
◆ delete()
|
inline |
Reimplemented from IntExpr.
Definition at line 31 of file BaseIntExpr.java.
◆ enqueueDelayedDemon()
|
inlineinherited |
This method pushes the demon onto the propagation queue.
It will be processed directly if the queue is empty. It will be enqueued according to its priority otherwise.
Definition at line 72 of file PropagationBaseObject.java.
◆ enqueueVar()
|
inlineinherited |
Definition at line 76 of file PropagationBaseObject.java.
◆ freezeQueue()
|
inlineinherited |
This method freezes the propagation queue.
It is useful when you need to apply multiple modifications at once.
Definition at line 58 of file PropagationBaseObject.java.
◆ hasName()
|
inlineinherited |
Returns whether the object has been named or not.
Definition at line 108 of file PropagationBaseObject.java.
◆ isVar()
|
inlineinherited |
Returns true if the expression is indeed a variable.
Reimplemented in IntVar.
Definition at line 89 of file IntExpr.java.
◆ max()
|
inlineinherited |
Reimplemented in BooleanVar.
Definition at line 50 of file IntExpr.java.
◆ min()
|
inlineinherited |
Reimplemented in BooleanVar.
Definition at line 42 of file IntExpr.java.
◆ name()
|
inlineinherited |
Object naming.
Definition at line 97 of file PropagationBaseObject.java.
◆ range()
|
inlineinherited |
By default calls Min() and Max(), but can be redefined when Min and Max code can be factorized.
Definition at line 61 of file IntExpr.java.
◆ reset_action_on_fail()
|
inlineinherited |
This method clears the failure callback.
Definition at line 83 of file PropagationBaseObject.java.
◆ set_variable_to_clean_on_fail()
|
inlineinherited |
Shortcut for variable cleaner.
Definition at line 90 of file PropagationBaseObject.java.
◆ setMax()
|
inlineinherited |
Reimplemented in BooleanVar.
Definition at line 54 of file IntExpr.java.
◆ setMin()
|
inlineinherited |
Reimplemented in BooleanVar.
Definition at line 46 of file IntExpr.java.
◆ setName()
|
inlineinherited |
Definition at line 101 of file PropagationBaseObject.java.
◆ setRange()
|
inlineinherited |
This method sets both the min and the max of the expression.
Reimplemented in BooleanVar.
Definition at line 68 of file IntExpr.java.
◆ setValue()
|
inlineinherited |
This method sets the value of the expression.
Definition at line 75 of file IntExpr.java.
◆ solver()
|
inlineinherited |
Definition at line 50 of file PropagationBaseObject.java.
◆ toString()
|
inlineinherited |
Reimplemented from BaseObject.
Reimplemented in Assignment, Pack, BooleanVar, Constraint, GlobalVehicleBreaksConstraint, and SequenceVar.
Definition at line 46 of file PropagationBaseObject.java.
◆ unfreezeQueue()
|
inlineinherited |
This method unfreezes the propagation queue.
All modifications that happened when the queue was frozen will be processed.
Definition at line 65 of file PropagationBaseObject.java.
◆ var()
|
inline |
Creates a variable from the expression.
Reimplemented from IntExpr.
Definition at line 42 of file BaseIntExpr.java.
◆ varWithName()
|
inlineinherited |
Creates a variable from the expression and set the name of the resulting var.
If the expression is already a variable, then it will set the name of the expression, possibly overwriting it. This is just a shortcut to Var() followed by set_name().
Definition at line 104 of file IntExpr.java.
◆ whenRange() [1/2]
|
inlineinherited |
Attach a demon that will watch the min or the max of the expression.
Reimplemented in BooleanVar.
Definition at line 112 of file IntExpr.java.
◆ whenRange() [2/2]
|
inlineinherited |
Attach a demon that will watch the min or the max of the expression.
Definition at line 119 of file IntExpr.java.
The documentation for this class was generated from the following file: