public class IntVarImpl extends Object implements IntVar
SparseSetDomain
.Constructor and Description |
---|
IntVarImpl(Solver cp,
int n)
Creates a variable with the elements {@code {0,...
|
IntVarImpl(Solver cp,
int min,
int max)
Creates a variable with the elements {@code {min,...
|
IntVarImpl(Solver cp,
Set<Integer> values)
Creates a variable with a given set of values as initial domain.
|
Modifier and Type | Method and Description |
---|---|
void |
assign(int v)
Assigns the specified value
|
boolean |
contains(int v)
Returns true if the domain contains the specified value.
|
int |
fillArray(int[] dest)
Copies the values of the domain into an array.
|
Solver |
getSolver()
Returns the solver in which this variable was created.
|
boolean |
isBound()
Returns true if the domain of the variable has a single value.
|
int |
max()
Returns the maximum of the domain of the variable
|
int |
min()
Returns the minimum of the domain of the variable
|
void |
propagateOnBind(Constraint c)
Asks that
Constraint.propagate() is called whenever the domain
of this variable is reduced to a singleton. |
void |
propagateOnBoundChange(Constraint c)
Asks that
Constraint.propagate() is called whenever the
bound (maximum or minimum values) of the domain
of this variable is changes. |
void |
propagateOnDomainChange(Constraint c)
Asks that
Constraint.propagate() is called whenever the domain
of this variable changes. |
void |
remove(int v)
Removes the specified value.
|
void |
removeAbove(int v)
Remove all the values above a given value
|
void |
removeBelow(int v)
Remove all the values less than a given value
|
protected void |
scheduleAll(StateStack<Constraint> constraints) |
int |
size()
Returns the size of the domain of the variable
|
String |
toString() |
void |
whenBind(Procedure f)
Asks that the closure is called whenever the domain
of this variable is reduced to a single setValue
|
void |
whenBoundsChange(Procedure f)
Asks that the closure is called whenever
the max or min setValue of the domain of this variable changes
|
void |
whenDomainChange(Procedure f)
Asks that the closure is called whenever the domain change
of this variable changes
|
public IntVarImpl(Solver cp, int n)
{0,...,n-1}
as initial domain.cp
- the solver in which the variable is createdn
- the number of values with n > 0
public IntVarImpl(Solver cp, int min, int max)
{min,...,max}
as initial domain.cp
- the solver in which the variable is createdmin
- the minimum value of the domainmax
- the maximum value of the domain with max >= min
public Solver getSolver()
IntVar
public boolean isBound()
IntVar
public void whenBind(Procedure f)
IntVar
public void whenBoundsChange(Procedure f)
IntVar
whenBoundsChange
in interface IntVar
f
- the closurepublic void whenDomainChange(Procedure f)
IntVar
whenDomainChange
in interface IntVar
f
- the closurepublic void propagateOnDomainChange(Constraint c)
IntVar
Constraint.propagate()
is called whenever the domain
of this variable changes.
We say that a change event occurs.propagateOnDomainChange
in interface IntVar
c
- the constraint for which the Constraint.propagate()
method should be called on change events of this variable.public void propagateOnBind(Constraint c)
IntVar
Constraint.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.propagateOnBind
in interface IntVar
c
- the constraint for which the Constraint.propagate()
method should be called on bind events of this variable.public void propagateOnBoundChange(Constraint c)
IntVar
Constraint.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.propagateOnBoundChange
in interface IntVar
c
- the constraint for which the Constraint.propagate()
method should be called on bound change events of this variable.protected void scheduleAll(StateStack<Constraint> constraints)
public int min()
IntVar
public int max()
IntVar
public int size()
IntVar
public int fillArray(int[] dest)
IntVar
public boolean contains(int v)
IntVar
public void remove(int v)
IntVar
public void assign(int v)
IntVar
public void removeBelow(int v)
IntVar
removeBelow
in interface IntVar
v
- the value such that all the values less than v are removedpublic void removeAbove(int v)
IntVar
removeAbove
in interface IntVar
v
- the value such that all the values larger than v are removedCopyright © 2018 Laurent Michel, Pierre Schaus, Pascal Van Hentenryck. All rights reserved.