choco.cp.solver.variables.integer
Class BooleanVarImpl<C extends AbstractSConstraint & IntPropagator>

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

public class BooleanVarImpl<C extends AbstractSConstraint & IntPropagator>
extends IntDomainVarImpl<C>

A variable implementation dedicated to boolean domains


Field Summary
protected  BooleanDomain booldomain
          A reference to the domain
 
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
BooleanVarImpl(Solver solver, String name)
           
 
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 that x is 0 or 1
 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 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, 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
 

Field Detail

booldomain

protected BooleanDomain booldomain
A reference to the domain

Constructor Detail

BooleanVarImpl

public BooleanVarImpl(Solver solver,
                      String name)
Method Detail

isInstantiatedTo

public final 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<C extends AbstractSConstraint & IntPropagator>
Parameters:
x - the tested value
Returns:
wether the value of an instantiated variables is equal to a x.

isInstantiated

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

Specified by:
isInstantiated in interface Var
Overrides:
isInstantiated in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>
Returns:
a boolean giving if a variable is instanciated or not

canBeInstantiatedTo

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

Specified by:
canBeInstantiatedTo in interface IntDomainVar
Overrides:
canBeInstantiatedTo in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>
Parameters:
x - the tested value
Returns:
wether a value is in the domain

fastCanBeInstantiatedTo

public final boolean fastCanBeInstantiatedTo(int x)
Checks if a value is still in the domain assuming that x is 0 or 1

Specified by:
fastCanBeInstantiatedTo in interface IntDomainVar
Overrides:
fastCanBeInstantiatedTo in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>

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<C extends AbstractSConstraint & IntPropagator>
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<C extends AbstractSConstraint & IntPropagator>
Returns:
wether the domain is a 0/1 domain

getDomainSize

public final int getDomainSize()
Gets the domain size.

Specified by:
getDomainSize in interface IntDomainVar
Overrides:
getDomainSize in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>
Returns:
the number of values in the domain

canBeEqualTo

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

Specified by:
canBeEqualTo in interface IntDomainVar
Overrides:
canBeEqualTo in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>
Parameters:
x - the other variable
Returns:
wether two variables have intersecting domains

getDomain

public final 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<C extends AbstractSConstraint & IntPropagator>
Returns:
the objects responsible for storing the enumeration of values in the domain

canBeInstantiatedIn

public final boolean canBeInstantiatedIn(int[] sortedValList,
                                         int nVals)
Checks if the variables can be instantiated to at least one value in the array. todo: this method seems completely deprecated

Overrides:
canBeInstantiatedIn in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>
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<C extends AbstractSConstraint & IntPropagator>
Returns:
a value drawn at random from the domain

getNextDomainValue

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

Specified by:
getNextDomainValue in interface IntDomainVar
Overrides:
getNextDomainValue in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>
Parameters:
currentv - the pivot value. May or may not be in the domain
Returns:
the value immediatly after the domain

getPrevDomainValue

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

Specified by:
getPrevDomainValue in interface IntDomainVar
Overrides:
getPrevDomainValue in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>
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<C extends AbstractSConstraint & IntPropagator>
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<C extends AbstractSConstraint & IntPropagator>
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<C extends AbstractSConstraint & IntPropagator>
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<C extends AbstractSConstraint & IntPropagator>
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 final 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<C extends AbstractSConstraint & IntPropagator>
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 final int getInf()
Gets the minimal value of the variable.

Specified by:
getInf in interface IntDomainVar
Overrides:
getInf in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>
Returns:
the domain lower bound

getSup

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

Specified by:
getSup in interface IntDomainVar
Overrides:
getSup in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>
Returns:
the domain upper bound

getVal

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

Specified by:
getVal in interface IntVar
Overrides:
getVal in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>
Returns:
the value of the variable

getValue

public final int getValue()
Deprecated. replaced by getVal

Specified by:
getValue in interface IntDomainVar
Overrides:
getValue in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>
Returns:
the value of the variable if known

toString

public String toString()
pretty printing

Overrides:
toString in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>
Returns:
a String representation of the variable

pretty

public String pretty()
Description copied from class: IntDomainVarImpl
pretty printing

Specified by:
pretty in interface IPretty
Overrides:
pretty in class IntDomainVarImpl<C extends AbstractSConstraint & IntPropagator>
Returns:
a String representation of the variable


Copyright © 2012. All Rights Reserved.