choco.cp.solver.variables.integer
Class AbstractBijectiveVar

java.lang.Object
  extended by choco.kernel.solver.variables.AbstractVar
      extended by choco.cp.solver.variables.integer.AbstractBijectiveVar
All Implemented Interfaces:
IExtensionnable, IPretty, IIndex, IntExp, IntDomainVar, IntVar, Var
Direct Known Subclasses:
BoolVarNot, IntDomainVarAddCste, IntDomainVarTimePosCste

public abstract class AbstractBijectiveVar
extends AbstractVar
implements IntDomainVar


Since:
05/05/11
Author:
Charles Prud'homme

Field Summary
 
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
AbstractBijectiveVar(Solver solver, String name, IntDomainVar variable)
          Build a variable Y such as Y = X op c.
 
Method Summary
 int addConstraint(SConstraint c, int varIdx, boolean dynamicAddition)
          Adds a new constraints on the stack of constraints the addition can be dynamic (undone upon backtracking) or not.
 boolean canBeEqualTo(IntDomainVar x)
          Public user API: Domains : testing whether two variables have intersecting domains.
 void eraseConstraint(SConstraint c)
          Removes (permanently) a constraint from the list of constraints connected to the variable.
 int fastNextDomainValue(int i)
          retrieves the value immediately (but strictly) after i in the domain, assuming the value is greater or equal to the lower bound.
 int fastPrevDomainValue(int i)
          retrieves the value immediately (but strictly) before i in the domain, assuming the value is less or equal to the upper bound.
 SConstraint getConstraint(int i)
          Retrieve the constraint i involving the variable.
 DisposableIterator<SConstraint> getConstraintsIterator()
          This methods should be used if one want to access the different constraints currently posted on this variable.
 PartiallyStoredVector<? extends SConstraint> getConstraintVector()
          Access the data structure storing constraints involving a given variable.
 IntDomain getDomain()
          Public user API: Domains : returns the object responsible for storing the enumeration of values in the domain
 int getDomainSize()
          Public user API: Domains : retrieves the number of values in the domain.
 VarEvent<? extends Var> getEvent()
          Returns the variable event.
 PartiallyStoredIntVector getIndexVector()
          Access the data structure storing indices associated to constraints involving a given variable.
 int getNbConstraints()
          Returns the number of constraints involving the variable.
 int getVarIndex(int constraintIndex)
          Returns the index of the variable in its constraint i.
 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 isInstantiated()
          Public user API: Domains : testing whether a variable is instantiated or not.
 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.kernel.solver.variables.AbstractVar
addExtension, getAbstractVarExtensionNumber, getExtension, getIndex, getName, getPriority, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface choco.kernel.solver.variables.integer.IntDomainVar
canBeInstantiatedTo, fastCanBeInstantiatedTo, getInf, getNextDomainValue, getPrevDomainValue, getRandomDomainValue, getSup, getValue, instantiate, instantiate, removeInterval, removeInterval, removeVal, removeVal, remVal, setInf, setMax, setMin, setSup, updateInf, updateInf, updateSup, updateSup
 
Methods inherited from interface choco.kernel.solver.variables.integer.IntVar
getVal, isInstantiatedTo, setVal
 
Methods inherited from interface choco.kernel.solver.variables.Var
getName, getPriority
 
Methods inherited from interface choco.IPretty
pretty
 
Methods inherited from interface choco.kernel.common.IIndex
getIndex
 
Methods inherited from interface choco.IExtensionnable
addExtension, getExtension
 

Constructor Detail

AbstractBijectiveVar

public AbstractBijectiveVar(Solver solver,
                            String name,
                            IntDomainVar variable)
Build a variable Y such as Y = X op c.

Parameters:
solver - The model this variable belongs to
name - The name of the variable
variable - constraints stored specific structure
Method Detail

wipeOut

public void wipeOut()
             throws ContradictionException
Description copied from interface: IntDomainVar
Public user API: Propagation events wiping out the domain of the variable (removing all values) and throwing a contradiction

Specified by:
wipeOut in interface IntDomainVar
Throws:
ContradictionException - contradiction exception

fastNextDomainValue

public int fastNextDomainValue(int i)
Description copied from interface: IntDomainVar
retrieves the value immediately (but strictly) after i in the domain, assuming the value is greater or equal to the lower bound.

Specified by:
fastNextDomainValue in interface IntDomainVar

fastPrevDomainValue

public int fastPrevDomainValue(int i)
Description copied from interface: IntDomainVar
retrieves the value immediately (but strictly) before i in the domain, assuming the value is less or equal to the upper bound.

Specified by:
fastPrevDomainValue in interface IntDomainVar

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
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
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
Returns:
the objects responsible for storing the enumeration of values in the domain

canBeEqualTo

public boolean canBeEqualTo(IntDomainVar x)
Description copied from interface: IntDomainVar
Public user API: Domains : testing whether two variables have intersecting domains.

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

getDomainSize

public int getDomainSize()
Description copied from interface: IntDomainVar
Public user API: Domains : retrieves the number of values in the domain.

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

isInstantiated

public boolean isInstantiated()
Description copied from interface: Var
Public user API: Domains : testing whether a variable is instantiated or not.

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

getEvent

public VarEvent<? extends Var> getEvent()
Description copied from class: AbstractVar
Returns the variable event.

Specified by:
getEvent in interface Var
Overrides:
getEvent in class AbstractVar
Returns:
the event responsible for propagating variable modifications

getConstraint

public SConstraint getConstraint(int i)
Description copied from class: AbstractVar
Retrieve the constraint i involving the variable. Be careful to use the correct constraint index (constraints are not numbered from 0 to number of constraints minus one, since an offset is used for some of the constraints).

Specified by:
getConstraint in interface Var
Overrides:
getConstraint in class AbstractVar
Parameters:
i - the number of the required constraint
Returns:
the constraint number i according to the variable

getNbConstraints

public int getNbConstraints()
Description copied from class: AbstractVar
Returns the number of constraints involving the variable.

Specified by:
getNbConstraints in interface Var
Overrides:
getNbConstraints in class AbstractVar
Returns:
the number of constraints containing this variable

getConstraintVector

public PartiallyStoredVector<? extends SConstraint> getConstraintVector()
Description copied from class: AbstractVar
Access the data structure storing constraints involving a given variable.

Specified by:
getConstraintVector in interface Var
Overrides:
getConstraintVector in class AbstractVar
Returns:
the backtrackable structure containing the constraints

getIndexVector

public PartiallyStoredIntVector getIndexVector()
Description copied from class: AbstractVar
Access the data structure storing indices associated to constraints involving a given variable.

Specified by:
getIndexVector in interface Var
Overrides:
getIndexVector in class AbstractVar
Returns:
the indices associated to this variable in each constraint

getVarIndex

public int getVarIndex(int constraintIndex)
Description copied from class: AbstractVar
Returns the index of the variable in its constraint i.

Specified by:
getVarIndex in interface Var
Overrides:
getVarIndex in class AbstractVar
Parameters:
constraintIndex - the index of the constraint (among all constraints linked to the variable)
Returns:
the index of the variable

eraseConstraint

public void eraseConstraint(SConstraint c)
Description copied from class: AbstractVar
Removes (permanently) a constraint from the list of constraints connected to the variable.

Overrides:
eraseConstraint in class AbstractVar
Parameters:
c - the constraint that should be removed from the list this variable maintains.

addConstraint

public int addConstraint(SConstraint c,
                         int varIdx,
                         boolean dynamicAddition)
Description copied from class: AbstractVar
Adds a new constraints on the stack of constraints the addition can be dynamic (undone upon backtracking) or not.

Specified by:
addConstraint in interface Var
Overrides:
addConstraint in class AbstractVar
Parameters:
c - the constraint to add
varIdx - the variable index accrding to the added constraint
dynamicAddition - states if the addition is definitic (cut) or subject to backtracking (standard constraint)
Returns:
the index affected to the constraint according to this variable

getConstraintsIterator

public DisposableIterator<SConstraint> getConstraintsIterator()
Description copied from class: AbstractVar
This methods should be used if one want to access the different constraints currently posted on this variable. Indeed, since indices are not always consecutive, it is the only simple way to achieve this. Warning ! this iterator should not be used to remove elements. The remove method throws an UnsupportedOperationException.

Specified by:
getConstraintsIterator in interface Var
Overrides:
getConstraintsIterator in class AbstractVar
Returns:
an iterator over all constraints involving this variable


Copyright © 2012. All Rights Reserved.