|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectchoco.AbstractEntity
choco.AbstractVar
choco.integer.var.IntDomainVarImpl
public class IntDomainVarImpl
Implements search valued domain variables.
Field Summary | |
---|---|
protected AbstractIntDomain |
domain
The backtrackable domain of the variable. |
protected static java.util.logging.Logger |
logger
Reference to an object for logging trace statements related to IntDomainVar (using the java.util.logging package) |
StoredInt |
value
The backtrackable value of the variable, if instantiated. |
Fields inherited from class choco.AbstractVar |
---|
constraints, event, indices, name |
Fields inherited from class choco.AbstractEntity |
---|
hook, problem |
Fields inherited from interface choco.integer.IntDomainVar |
---|
BOUNDS, LIST |
Constructor Summary | |
---|---|
IntDomainVarImpl(AbstractProblem pb,
java.lang.String name,
int[] sortedValues)
|
|
IntDomainVarImpl(AbstractProblem pb,
java.lang.String name,
int domainType,
int a,
int b)
Constructs a new variable for the specified problem and with the specified name and bounds. |
Method Summary | |
---|---|
boolean |
canBeEqualTo(IntDomainVar x)
Checks if it can be equals to another variable. |
boolean |
canBeInstantiatedIn(int[] sortedValList,
int nVals)
Checks if the variables can be instantiated to at least one value in the array. |
boolean |
canBeInstantiatedTo(int x)
Checks if a value is still in the domain. |
void |
fail()
a constraint may fail during propagation, raising a contradiction |
IntDomain |
getDomain()
Public user API: Domains : returns the object responsible for storing the enumeration of values in the domain |
int |
getDomainSize()
Gets the domain size. |
int |
getInf()
Gets the minimal value of the variable. |
int |
getNextDomainValue(int currentv)
Gets the next value in the domain. |
int |
getPrevDomainValue(int currentv)
Gets the previous value in the domain. |
int |
getRandomDomainValue()
Returns a randomly choosed value in the domain. |
int |
getSup()
Gets the maximal value of the variable. |
int |
getVal()
Gets the value of the variable if instantiated. |
int |
getValue()
Deprecated. replaced by getVal |
boolean |
hasEnumeratedDomain()
Public user API: Domains : whether an enumeration of values (in addition to the enclosing interval) is stored |
boolean |
instantiate(int x,
int idx)
Internal var: instantiation of the variable caused by its i-th constraint Returns a boolean indicating whether the call indeed added new information. |
boolean |
isInstantiated()
Checks if the variables is instantiated to any value. |
boolean |
isInstantiatedTo(int x)
Checks if the variable is instantiated to a specific value. |
java.lang.String |
pretty()
pretty printing |
boolean |
removeInterval(int a,
int b,
int idx)
Internal var: remove an interval (a sequence of consecutive values) from the domain of a variable caused by its i-th constraint. |
boolean |
removeVal(int x,
int idx)
Internal var: update (value removal) on the domain of a variable caused by its i-th constraint. |
void |
remVal(int x)
Removes a value. |
void |
setInf(int x)
Sets the minimum value. |
void |
setMax(int x)
Deprecated. replaced by setSup |
void |
setMin(int x)
Deprecated. replaced by setInf |
void |
setSup(int x)
Sets the maximal value. |
void |
setVal(int x)
Instantiates the variable. |
java.lang.String |
toString()
pretty printing |
boolean |
updateInf(int x,
int idx)
Internal var: update on the variable lower bound caused by its i-th constraint. |
boolean |
updateSup(int x,
int idx)
Internal var: update on the variable upper bound caused by its i-th constraint. |
void |
wipeOut()
Public user API: Propagation events wiping out the domain of the variable (removing all values) and throwing a contradiction |
Methods inherited from class choco.AbstractVar |
---|
addConstraint, eraseConstraint, getConstraint, getConstraintsIterator, getConstraintVector, getEvent, getIndexVector, getNbConstraints, getVarIndex |
Methods inherited from class choco.AbstractEntity |
---|
getProblem |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface choco.integer.IntDomainVar |
---|
getProblem |
Methods inherited from interface choco.Var |
---|
addConstraint, getConstraint, getConstraintsIterator, getConstraintVector, getEvent, getIndexVector, getNbConstraints, getVarIndex |
Field Detail |
---|
public final StoredInt value
protected AbstractIntDomain domain
protected static java.util.logging.Logger logger
Constructor Detail |
---|
public IntDomainVarImpl(AbstractProblem pb, java.lang.String name, int domainType, int a, int b)
pb
- The problem of the variable.name
- Its name.domainType
- the type of encoding for the domain (BOUNDS, LIST, ...)a
- Its minimal value.b
- Its maximal value.public IntDomainVarImpl(AbstractProblem pb, java.lang.String name, int[] sortedValues)
Method Detail |
---|
public boolean isInstantiatedTo(int x)
isInstantiatedTo
in interface IntDomainVar
public boolean isInstantiated()
isInstantiated
in interface Var
public boolean canBeInstantiatedTo(int x)
canBeInstantiatedTo
in interface IntDomainVar
x
- the tested valuepublic void setInf(int x) throws ContradictionException
setInf
in interface IntDomainVar
x
- the new lower bound
ContradictionException
public void setMin(int x) throws ContradictionException
setMin
in interface IntDomainVar
ContradictionException
public void setSup(int x) throws ContradictionException
setSup
in interface IntDomainVar
x
- the new upper bound
ContradictionException
public void setMax(int x) throws ContradictionException
setMax
in interface IntDomainVar
ContradictionException
public void setVal(int x) throws ContradictionException
setVal
in interface IntDomainVar
x
- the value that is assigned to the variable
ContradictionException
public void remVal(int x) throws ContradictionException
remVal
in interface IntDomainVar
x
- the removed value
ContradictionException
public void wipeOut() throws ContradictionException
IntDomainVar
wipeOut
in interface IntDomainVar
ContradictionException
public boolean hasEnumeratedDomain()
IntDomainVar
hasEnumeratedDomain
in interface IntDomainVar
public IntDomain getDomain()
IntDomainVar
getDomain
in interface IntDomainVar
public int getDomainSize()
getDomainSize
in interface IntDomainVar
public boolean canBeEqualTo(IntDomainVar x)
canBeEqualTo
in interface IntDomainVar
x
- the other variablepublic boolean canBeInstantiatedIn(int[] sortedValList, int nVals)
canBeInstantiatedIn
in interface IntDomainVar
sortedValList
- The value array.nVals
- The number of interesting value in this array.public int getRandomDomainValue()
getRandomDomainValue
in interface IntDomainVar
public int getNextDomainValue(int currentv)
getNextDomainValue
in interface IntDomainVar
currentv
- the pivot value. May or may not be in the domainpublic int getPrevDomainValue(int currentv)
getPrevDomainValue
in interface IntDomainVar
currentv
- the pivot value. May or may not be in the domainpublic boolean updateInf(int x, int idx) throws ContradictionException
updateInf
in interface IntDomainVar
x
- The new lower bound.idx
- The index of the constraint (among all constraints linked to
the variable) responsible for the update.
ContradictionException
public boolean updateSup(int x, int idx) throws ContradictionException
updateSup
in interface IntDomainVar
x
- The new upper boundidx
- The index of the constraint (among all constraints linked to
the variable) responsible for the update
ContradictionException
public boolean removeVal(int x, int idx) throws ContradictionException
removeVal
in interface IntDomainVar
x
- The removed valueidx
- The index of the constraint (among all constraints linked to the variable) responsible for the update
ContradictionException
public boolean removeInterval(int a, int b, int idx) throws ContradictionException
removeInterval
in interface IntDomainVar
a
- the first removed valueb
- the last removed valueidx
- the index of the constraint (among all constraints linked to the variable)
responsible for the update
ContradictionException
public boolean instantiate(int x, int idx) throws ContradictionException
instantiate
in interface IntDomainVar
x
- the new upper boundidx
- the index of the constraint (among all constraints linked to the
variable) responsible for the update
ContradictionException
public void fail() throws ContradictionException
Var
fail
in interface Var
ContradictionException
public int getInf()
getInf
in interface IntDomainVar
public int getSup()
getSup
in interface IntDomainVar
public int getVal()
getVal
in interface IntDomainVar
public int getValue()
getValue
in interface IntDomainVar
public java.lang.String toString()
toString
in class AbstractVar
public java.lang.String pretty()
pretty
in interface Entity
pretty
in class AbstractEntity
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |