choco.cp.solver.variables.integer
Class ViewIntDomainVarImpl

java.lang.Object
  extended by choco.kernel.solver.variables.AbstractVar
      extended by choco.cp.solver.variables.integer.IntDomainVarImpl
          extended by choco.cp.solver.variables.integer.ViewIntDomainVarImpl
All Implemented Interfaces:
IExtensionnable, IPretty, IIndex, IntExp, IntDomainVar, IntVar, Var

public class ViewIntDomainVarImpl
extends IntDomainVarImpl


Field Summary
 
Fields inherited from class choco.cp.solver.variables.integer.IntDomainVarImpl
domain
 
Fields inherited from class choco.kernel.solver.variables.AbstractVar
constraints, event, extensions, name, propagationEngine
 
Fields inherited from interface choco.kernel.solver.variables.integer.IntDomainVar
BINARYTREE, BIPARTITELIST, BITSET, BOOLEAN, BOUNDS, LINKEDLIST, ONE_VALUE
 
Fields inherited from interface choco.kernel.solver.variables.Var
LOGGER
 
Constructor Summary
ViewIntDomainVarImpl(Solver solver, String name, int domainType, int[] sortedValues, int coeff, int cst)
           
ViewIntDomainVarImpl(Solver solver, String name, int domainType, int a, int b, int coeff, int cst)
          Constructs a new variable for the specified model 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.
 boolean fastCanBeInstantiatedTo(int x)
          Checks if a value is still in the domain assuming the value is in the initial bound of the domain
 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.
 boolean hasBooleanDomain()
          Public user API: Domains : whether the domain is a 0/1 domain
 boolean hasEnumeratedDomain()
          Public user API: Domains : whether an enumeration of values (in addition to the enclosing interval) is stored
 boolean instantiate(int x, SConstraint cause, boolean forceAwake)
          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.
 String pretty()
          pretty printing
 boolean removeInterval(int a, int b, SConstraint cause, boolean forceAwake)
          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, SConstraint cause, boolean forceAwake)
          Internal var: update (value removal) on the domain of a variable caused by its i-th constraint.
 String toString()
          pretty printing
 boolean updateInf(int x, SConstraint cause, boolean forceAwake)
          Internal var: update on the variable lower bound caused by its i-th constraint.
 boolean updateSup(int x, SConstraint cause, boolean forceAwake)
          Internal var: update on the variable upper bound caused by its i-th constraint.
 
Methods inherited from class choco.cp.solver.variables.integer.IntDomainVarImpl
fastNextDomainValue, fastPrevDomainValue, getActiveConstraints, getEventsVector, getValue, instantiate, removeInterval, removeVal, remVal, setInf, setMax, setMin, setSup, setVal, updateInf, updateSup, wipeOut
 
Methods inherited from class choco.kernel.solver.variables.AbstractVar
addConstraint, addExtension, eraseConstraint, getAbstractVarExtensionNumber, getConstraint, getConstraintsIterator, getConstraintVector, getEvent, getExtension, getIndex, getIndexVector, getName, getNbConstraints, getPriority, getVarIndex, hashCode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface choco.kernel.solver.variables.Var
addConstraint, getConstraint, getConstraintsIterator, getConstraintVector, getEvent, getIndexVector, getName, getNbConstraints, getPriority, getVarIndex
 
Methods inherited from interface choco.kernel.common.IIndex
getIndex
 
Methods inherited from interface choco.IExtensionnable
addExtension, getExtension
 

Constructor Detail

ViewIntDomainVarImpl

public ViewIntDomainVarImpl(Solver solver,
                            String name,
                            int domainType,
                            int a,
                            int b,
                            int coeff,
                            int cst)
Constructs a new variable for the specified model and with the specified name and bounds.

Parameters:
solver - The model of the variable.
name - Its name.
domainType - the type of encoding for the domain (BOUNDS, BITSET, ...)
a - Its minimal value.
b - Its maximal value.

ViewIntDomainVarImpl

public ViewIntDomainVarImpl(Solver solver,
                            String name,
                            int domainType,
                            int[] sortedValues,
                            int coeff,
                            int cst)
Method Detail

isInstantiatedTo

public boolean isInstantiatedTo(int x)
Checks if the variable is instantiated to a specific value.

Specified by:
isInstantiatedTo in interface IntVar
Overrides:
isInstantiatedTo in class IntDomainVarImpl
Parameters:
x - the tested value
Returns:
wether the value of an instantiated variables is equal to a x.

isInstantiated

public boolean isInstantiated()
Checks if the variables is instantiated to any value.

Specified by:
isInstantiated in interface Var
Overrides:
isInstantiated in class IntDomainVarImpl
Returns:
a boolean giving if a variable is instanciated or not

canBeInstantiatedTo

public boolean canBeInstantiatedTo(int x)
Checks if a value is still in the domain.

Specified by:
canBeInstantiatedTo in interface IntDomainVar
Overrides:
canBeInstantiatedTo in class IntDomainVarImpl
Parameters:
x - the tested value
Returns:
wether a value is in the domain

fastCanBeInstantiatedTo

public boolean fastCanBeInstantiatedTo(int x)
Checks if a value is still in the domain assuming the value is in the initial bound of the domain

Specified by:
fastCanBeInstantiatedTo in interface IntDomainVar
Overrides:
fastCanBeInstantiatedTo in class IntDomainVarImpl

hasEnumeratedDomain

public boolean hasEnumeratedDomain()
Description copied from interface: IntDomainVar
Public user API: Domains : whether an enumeration of values (in addition to the enclosing interval) is stored

Specified by:
hasEnumeratedDomain in interface IntDomainVar
Overrides:
hasEnumeratedDomain in class IntDomainVarImpl
Returns:
wether an enumeration of values is stored

hasBooleanDomain

public boolean hasBooleanDomain()
Description copied from interface: IntDomainVar
Public user API: Domains : whether the domain is a 0/1 domain

Specified by:
hasBooleanDomain in interface IntDomainVar
Overrides:
hasBooleanDomain in class IntDomainVarImpl
Returns:
wether the domain is a 0/1 domain

getDomain

public IntDomain getDomain()
Description copied from interface: IntDomainVar
Public user API: Domains : returns the object responsible for storing the enumeration of values in the domain

Specified by:
getDomain in interface IntDomainVar
Overrides:
getDomain in class IntDomainVarImpl
Returns:
the objects responsible for storing the enumeration of values in the domain

getDomainSize

public int getDomainSize()
Gets the domain size.

Specified by:
getDomainSize in interface IntDomainVar
Overrides:
getDomainSize in class IntDomainVarImpl
Returns:
the number of values in the domain

canBeEqualTo

public boolean canBeEqualTo(IntDomainVar x)
Checks if it can be equals to another variable.

Specified by:
canBeEqualTo in interface IntDomainVar
Overrides:
canBeEqualTo in class IntDomainVarImpl
Parameters:
x - the other variable
Returns:
wether two variables have intersecting domains

canBeInstantiatedIn

public boolean canBeInstantiatedIn(int[] sortedValList,
                                   int nVals)
Checks if the variables can be instantiated to at least one value in the array.

Overrides:
canBeInstantiatedIn in class IntDomainVarImpl
Parameters:
sortedValList - The value array.
nVals - The number of interesting value in this array.

getRandomDomainValue

public int getRandomDomainValue()
Returns a randomly choosed value in the domain.

Not implemented yet.

Specified by:
getRandomDomainValue in interface IntDomainVar
Overrides:
getRandomDomainValue in class IntDomainVarImpl
Returns:
a value drawn at random from the domain

getNextDomainValue

public int getNextDomainValue(int currentv)
Gets the next value in the domain.

Specified by:
getNextDomainValue in interface IntDomainVar
Overrides:
getNextDomainValue in class IntDomainVarImpl
Parameters:
currentv - the pivot value. May or may not be in the domain
Returns:
the value immediatly after the domain

getPrevDomainValue

public int getPrevDomainValue(int currentv)
Gets the previous value in the domain.

Specified by:
getPrevDomainValue in interface IntDomainVar
Overrides:
getPrevDomainValue in class IntDomainVarImpl
Parameters:
currentv - the pivot value. May or may not be in the domain
Returns:
the value immediatly before the domain

updateInf

public boolean updateInf(int x,
                         SConstraint cause,
                         boolean forceAwake)
                  throws ContradictionException
Internal var: update on the variable lower bound caused by its i-th constraint. Returns a boolean indicating whether the call indeed added new information

Specified by:
updateInf in interface IntDomainVar
Overrides:
updateInf in class IntDomainVarImpl
Parameters:
x - The new lower bound.
cause -
forceAwake -
Returns:
a boolean indicating whether this method call added new information or not
Throws:
ContradictionException - contradiction exception

updateSup

public boolean updateSup(int x,
                         SConstraint cause,
                         boolean forceAwake)
                  throws ContradictionException
Internal var: update on the variable upper bound caused by its i-th constraint. Returns a boolean indicating whether the call indeed added new information.

Specified by:
updateSup in interface IntDomainVar
Overrides:
updateSup in class IntDomainVarImpl
Parameters:
x - The new upper bound
cause -
forceAwake -
Returns:
a boolean indicating whether this method call added new information or not
Throws:
ContradictionException - contradiction exception

removeVal

public boolean removeVal(int x,
                         SConstraint cause,
                         boolean forceAwake)
                  throws ContradictionException
Internal var: update (value removal) on the domain of a variable caused by its i-th constraint. Note: Whenever the hole results in a stronger var (such as a bound update or an instantiation, then we forget about the index of the var generating constraint. Indeed the propagated var is stronger than the initial one that was generated; thus the generating constraint should be informed about such a new var. Returns a boolean indicating whether the call indeed added new information.

Specified by:
removeVal in interface IntDomainVar
Overrides:
removeVal in class IntDomainVarImpl
Parameters:
x - The removed value
cause -
forceAwake -
Returns:
a boolean indicating whether this method call added new information or not
Throws:
ContradictionException - contradiction exception

removeInterval

public boolean removeInterval(int a,
                              int b,
                              SConstraint cause,
                              boolean forceAwake)
                       throws ContradictionException
Internal var: remove an interval (a sequence of consecutive values) from the domain of a variable caused by its i-th constraint. Returns a boolean indicating whether the call indeed added new information.

Specified by:
removeInterval in interface IntDomainVar
Overrides:
removeInterval in class IntDomainVarImpl
Parameters:
a - the first removed value
b - the last removed value
cause -
forceAwake -
Returns:
a boolean indicating whether this method call added new information or not
Throws:
ContradictionException - contradiction exception

instantiate

public boolean instantiate(int x,
                           SConstraint cause,
                           boolean forceAwake)
                    throws ContradictionException
Internal var: instantiation of the variable caused by its i-th constraint Returns a boolean indicating whether the call indeed added new information.

Specified by:
instantiate in interface IntDomainVar
Overrides:
instantiate in class IntDomainVarImpl
Parameters:
x - the new upper bound
cause -
forceAwake -
Returns:
a boolean indicating whether this method call added new information or not
Throws:
ContradictionException - contradiction exception

getInf

public int getInf()
Gets the minimal value of the variable.

Specified by:
getInf in interface IntDomainVar
Overrides:
getInf in class IntDomainVarImpl
Returns:
the domain lower bound

getSup

public int getSup()
Gets the maximal value of the variable.

Specified by:
getSup in interface IntDomainVar
Overrides:
getSup in class IntDomainVarImpl
Returns:
the domain upper bound

getVal

public int getVal()
Gets the value of the variable if instantiated.

Specified by:
getVal in interface IntVar
Overrides:
getVal in class IntDomainVarImpl
Returns:
the value of the variable

toString

public String toString()
pretty printing

Overrides:
toString in class IntDomainVarImpl
Returns:
a String representation of the variable

pretty

public String pretty()
pretty printing

Specified by:
pretty in interface IPretty
Overrides:
pretty in class IntDomainVarImpl
Returns:
a String representation of the variable


Copyright © 2012. All Rights Reserved.