choco.set.var
Class SetVarImpl

java.lang.Object
  extended by choco.AbstractEntity
      extended by choco.AbstractVar
          extended by choco.set.var.SetVarImpl
All Implemented Interfaces:
Entity, SetVar, Var

public class SetVarImpl
extends AbstractVar
implements SetVar

Created by IntelliJ IDEA. User: Hadrien Date: 6 juin 2004 Time: 14:22:32 To change this template use File | Settings | File Templates.


Field Summary
protected  SetDomainImpl domain
           
 
Fields inherited from class choco.AbstractVar
constraints, event, indices, name
 
Fields inherited from class choco.AbstractEntity
hook, problem
 
Constructor Summary
SetVarImpl(AbstractProblem pb, java.lang.String name, int a, int b)
           
 
Method Summary
 boolean addToKernel(int x, int idx)
          Propagation events updating the kernel of a variable (i.e adding a value)
 boolean canBeEqualTo(SetVar x)
          Check if the both domain intersects
 void fail()
          a constraint may fail during propagation, raising a contradiction
 SetDomain getDomain()
          Public user API: Domains : returns the object responsible for storing the enumeration of values in the domain
 int getEnveloppeDomainSize()
          Public user API: Domains : retrieves the number of values in the enveloppe domain.
 int getEnveloppeInf()
          Returns the lower bound of the enveloppe variable domain.
 int getEnveloppeSup()
           
 int getKernelDomainSize()
          Public user API: Domains : retrieves the number of values in the kernel domain.
 int getKernelInf()
           
 int getKernelSup()
           
 int[] getValue()
          Returns the value of the variable if instantiated.
 boolean instantiate(int[] x, int idx)
          Propagation events instantiated a set var to a specific set of values
 boolean isInDomainEnveloppe(int x)
          Public user API: Domains : testing whether a value is in the enveloppe domain.
 boolean isInDomainKernel(int x)
          Public user API: Domains : testing whether a value is in the kernel domain
 boolean isInstantiated()
          Public user API: Domains : testing whether a variable is instantiated or not.
 java.lang.String pretty()
          pretty printing
 boolean remFromEnveloppe(int x, int idx)
          Propagation events updating the enveloppe of a variable (i.e removing a value)
 void setVal(int[] val)
          set the value of the variable to the set val.
 void setValIn(int x)
          Public user API: setting a value to the kernel of a set variable
 void setValOut(int x)
          Public user API: removing a value from the Enveloppe of a set variable.
 
Methods inherited from class choco.AbstractVar
addConstraint, eraseConstraint, getConstraint, getConstraintsIterator, getConstraintVector, getEvent, getIndexVector, getNbConstraints, getVarIndex, toString
 
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.Var
addConstraint, getConstraint, getConstraintsIterator, getConstraintVector, getEvent, getIndexVector, getNbConstraints, getVarIndex
 
Methods inherited from interface choco.Entity
getProblem
 

Field Detail

domain

protected SetDomainImpl domain
Constructor Detail

SetVarImpl

public SetVarImpl(AbstractProblem pb,
                  java.lang.String name,
                  int a,
                  int b)
Method Detail

fail

public void fail()
          throws ContradictionException
Description copied from interface: Var
a constraint may fail during propagation, raising a contradiction

Specified by:
fail in interface Var
Throws:
ContradictionException

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

setValIn

public void setValIn(int x)
              throws ContradictionException
Description copied from interface: SetVar
Public user API: setting a value to the kernel of a set variable

Specified by:
setValIn in interface SetVar
Parameters:
x - the value that is set to the variable
Throws:
ContradictionException

setValOut

public void setValOut(int x)
               throws ContradictionException
Description copied from interface: SetVar
Public user API: removing a value from the Enveloppe of a set variable.

Specified by:
setValOut in interface SetVar
Parameters:
x - the removed value
Throws:
ContradictionException

isInDomainKernel

public boolean isInDomainKernel(int x)
Description copied from interface: SetVar
Public user API: Domains : testing whether a value is in the kernel domain

Specified by:
isInDomainKernel in interface SetVar
Parameters:
x - the tested value

isInDomainEnveloppe

public boolean isInDomainEnveloppe(int x)
Description copied from interface: SetVar
Public user API: Domains : testing whether a value is in the enveloppe domain.

Specified by:
isInDomainEnveloppe in interface SetVar
Parameters:
x - the tested value

getDomain

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

Specified by:
getDomain in interface SetVar

canBeEqualTo

public boolean canBeEqualTo(SetVar x)
Check if the both domain intersects

Specified by:
canBeEqualTo in interface SetVar
Parameters:
x -
Returns:

getKernelDomainSize

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

Specified by:
getKernelDomainSize in interface SetVar

getEnveloppeDomainSize

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

Specified by:
getEnveloppeDomainSize in interface SetVar

getEnveloppeInf

public int getEnveloppeInf()
Description copied from interface: SetVar
Returns the lower bound of the enveloppe variable domain. (i.e the smallest value contained in the enveloppe)

Specified by:
getEnveloppeInf in interface SetVar
Returns:
the enveloppe domain lower bound

getEnveloppeSup

public int getEnveloppeSup()
Specified by:
getEnveloppeSup in interface SetVar

getKernelInf

public int getKernelInf()
Specified by:
getKernelInf in interface SetVar

getKernelSup

public int getKernelSup()
Specified by:
getKernelSup in interface SetVar

getValue

public int[] getValue()
Description copied from interface: SetVar
Returns the value of the variable if instantiated.

Specified by:
getValue in interface SetVar
Returns:
the value of the variable

setVal

public void setVal(int[] val)
            throws ContradictionException
Description copied from interface: SetVar
set the value of the variable to the set val.

Specified by:
setVal in interface SetVar
Parameters:
val - the value to be set
Throws:
ContradictionException

addToKernel

public boolean addToKernel(int x,
                           int idx)
                    throws ContradictionException
Description copied from interface: SetVar
Propagation events updating the kernel of a variable (i.e adding a value)

Specified by:
addToKernel in interface SetVar
Parameters:
x - a value of the enveloppe domain to be added to the kernel
idx - the index of the constraint that generated the var
Returns:
a boolean indicating whether this method call added new information or not
Throws:
ContradictionException

remFromEnveloppe

public boolean remFromEnveloppe(int x,
                                int idx)
                         throws ContradictionException
Description copied from interface: SetVar
Propagation events updating the enveloppe of a variable (i.e removing a value)

Specified by:
remFromEnveloppe in interface SetVar
Parameters:
x - a value of the enveloppe domain to be removed
idx - the index of the constraint that generated the var
Returns:
a boolean indicating whether this method call added new information or not
Throws:
ContradictionException

instantiate

public boolean instantiate(int[] x,
                           int idx)
                    throws ContradictionException
Description copied from interface: SetVar
Propagation events instantiated a set var to a specific set of values

Specified by:
instantiate in interface SetVar
Parameters:
x - a set of values describing the final instantiated kernel
idx - the index of the constraint that generated the var
Returns:
a boolean indicating whether this method call added new information or not
Throws:
ContradictionException

pretty

public java.lang.String pretty()
pretty printing

Specified by:
pretty in interface Entity
Overrides:
pretty in class AbstractEntity
Returns:
a String representation of the variable