- All Superinterfaces:
ConcreteIntVar,ConcreteVar,CPVar,Expression,IntExpression,IntVar,Serializable,Var
- All Known Subinterfaces:
CPBoolVar
- All Known Implementing Classes:
CPBoolVarImpl,CPBoolVarIsEqual,CPIntVarConstant,CPIntVarImpl,CPIntVarViewMul,CPIntVarViewOffset,CPIntVarViewOpposite
-
Method Summary
Modifier and TypeMethodDescriptiondefault IntExpressionabs()default intafter(int value) Returns the value that is just after the given value in the domain of the variable if any, if the value is greater than or equal to the maximum of the domain, the value is returned.default intbefore(int value) Returns the value that is just before the given value in the domain of the variable if any, if the value is less than or equal to the minimum of the domain, the value is returned.booleancontains(int v) Returns true if the domain contains the specified value.Returns a delta object allowing to retrieve the changes in the domain of the variable (removed values) since the previous call to theConstraint.propagateof the constraint.default intevaluate()Evaluate this expression.intfillArray(int[] dest) Copies the values of the domain into an array.intfillDeltaArray(int oldMin, int oldMax, int oldSize, int[] dest) Copies the values of the domain that have been removed (delta set) wrt to a previous state of the domain described by oldMin, oldMax and oldSize.voidfix(int v) Fixes the specified value.Returns the solver in which this variable was created.booleanisFixed()Returns true if the domain of the variable has a single value.intmax()Returns the maximum of the domain of the variableintmin()Returns the minimum of the domain of the variabledefault IntExpressionminus(int v) default IntExpressiondefault IntExpressionplus(int v) default IntExpressionvoidAsks thatCPConstraint.propagate()is called whenever the bound (maximum or minimum values) of the domain of this variable is changes.voidAsks thatCPConstraint.propagate()is called whenever the domain of this variable changes.voidAsks thatCPConstraint.propagate()is called whenever the domain of this variable is reduced to a singleton.voidremove(int v) Removes the specified value.voidremoveAbove(int v) Removes all the values above a given value.voidremoveBelow(int v) Removes all the values less than a given value.intsize()Returns the size of the domain of the variablevoidAsks that the closure is called whenever the max or min setValue of the domain of this variable changesvoidAsks that the closure is called whenever the domain change of this variable changesvoidAsks that the consumer is called whenever the domain change of this variable changes.voidAsks that the closure is called whenever the domain of this variable is reduced to a single setValue.Methods inherited from interface org.maxicp.modeling.algebra.Expression
getModelProxy, subexpressionsMethods inherited from interface org.maxicp.modeling.algebra.integer.IntExpression
showMethods inherited from interface org.maxicp.modeling.IntVar
computeSubexpressions, mapSubexpressionsMethods inherited from interface org.maxicp.modeling.Var
getModelProxy
-
Method Details
-
getSolver
CPSolver getSolver()Returns the solver in which this variable was created.- Returns:
- the solver in which this variable was created
-
whenFixed
Asks that the closure is called whenever the domain of this variable is reduced to a single setValue.- Parameters:
f- the closure
-
whenBoundChange
Asks that the closure is called whenever the max or min setValue of the domain of this variable changes- Parameters:
f- the closure
-
whenDomainChange
Asks that the closure is called whenever the domain change of this variable changes- Parameters:
f- the closure
-
whenDomainChange
Asks that the consumer is called whenever the domain change of this variable changes. The consumer is called with a delta object that allows to retrieve the changes in the domain of the variable (removed values) since the previous call.- Parameters:
f- the consumer with the delta of the domain since last call
-
propagateOnDomainChange
Asks thatCPConstraint.propagate()is called whenever the domain of this variable changes. We say that a change event occurs.- Parameters:
c- the constraint for which theCPConstraint.propagate()method should be called on change events of this variable.
-
propagateOnFix
Asks thatCPConstraint.propagate()is called whenever the domain of this variable is reduced to a singleton. In such a state the variable is bind and we say that a bind event occurs.- Parameters:
c- the constraint for which theCPConstraint.propagate()method should be called on bind events of this variable.
-
propagateOnBoundChange
Asks thatCPConstraint.propagate()is called whenever the bound (maximum or minimum values) of the domain of this variable is changes. We say that a bound change event occurs in this case.- Parameters:
c- the constraint for which theCPConstraint.propagate()method should be called on bound change events of this variable.
-
min
int min()Returns the minimum of the domain of the variable- Specified by:
minin interfaceIntExpression- Returns:
- the minimum of the domain of the variable
-
max
int max()Returns the maximum of the domain of the variable- Specified by:
maxin interfaceIntExpression- Returns:
- the maximum of the domain of the variable
-
before
default int before(int value) Returns the value that is just before the given value in the domain of the variable if any, if the value is less than or equal to the minimum of the domain, the value is returned.- Parameters:
value-- Returns:
- the value that is just before the given value in the domain of the variable
-
after
default int after(int value) Returns the value that is just after the given value in the domain of the variable if any, if the value is greater than or equal to the maximum of the domain, the value is returned.- Parameters:
value-- Returns:
- the value that is just after the given value in the domain of the variable
-
size
int size()Returns the size of the domain of the variable- Specified by:
sizein interfaceIntExpression- Returns:
- the size of the domain of the variable
-
fillArray
int fillArray(int[] dest) Copies the values of the domain into an array.- Specified by:
fillArrayin interfaceIntExpression- Parameters:
dest- an array large enoughdest.length >= size()- Returns:
- the size of the domain and
dest[0,...,size-1]contains the values in the domain in an arbitrary order
-
isFixed
boolean isFixed()Returns true if the domain of the variable has a single value. -
contains
boolean contains(int v) Returns true if the domain contains the specified value.- Specified by:
containsin interfaceIntExpression- Parameters:
v- the value whose presence in the domain is to be tested- Returns:
- true if the domain contains the specified value
-
remove
void remove(int v) Removes the specified value.- Parameters:
v- the value to remove- Throws:
InconsistencyException- is thrown if the domain becomes empty
-
fix
void fix(int v) Fixes the specified value.- Parameters:
v- the value to assign.- Throws:
InconsistencyException- is thrown if the value is not in the domain
-
removeBelow
void removeBelow(int v) Removes all the values less than a given value.- Parameters:
v- the value such that all the values less than v are removed- Throws:
InconsistencyException- is thrown if the domain becomes empty
-
removeAbove
void removeAbove(int v) Removes all the values above a given value.- Parameters:
v- the value such that all the values larger than v are removed- Throws:
InconsistencyException- is thrown if the domain becomes empty
-
fillDeltaArray
int fillDeltaArray(int oldMin, int oldMax, int oldSize, int[] dest) Copies the values of the domain that have been removed (delta set) wrt to a previous state of the domain described by oldMin, oldMax and oldSize.- Parameters:
dest- an array large enoughdest.length >= oldSize-size()- Returns:
- the size of delta set stored in prefix of dest
-
delta
Returns a delta object allowing to retrieve the changes in the domain of the variable (removed values) since the previous call to theConstraint.propagateof the constraint. This can be useful to implement some constraint with incremental reasoning.- Parameters:
c- the constraint wrt the delta set is computed- Returns:
- the delta object
-
evaluate
Description copied from interface:IntExpressionEvaluate this expression. All variables referenced have to be fixed.- Specified by:
evaluatein interfaceIntExpression- Returns:
- the value of this expression
- Throws:
VariableNotFixedException- when a variable is not fixed
-
plus
- Specified by:
plusin interfaceIntExpression
-
minus
- Specified by:
minusin interfaceIntExpression
-
plus
- Specified by:
plusin interfaceIntExpression
-
minus
- Specified by:
minusin interfaceIntExpression
-
abs
- Specified by:
absin interfaceIntExpression
-