choco.cp.solver.variables.set
Class SetVarImpl<C extends AbstractSConstraint & SetPropagator>

java.lang.Object
  extended by choco.kernel.solver.variables.AbstractVar
      extended by choco.cp.solver.variables.set.SetVarImpl<C>
All Implemented Interfaces:
IExtensionnable, IPretty, IIndex, SetVar, Var

public final class SetVarImpl<C extends AbstractSConstraint & SetPropagator>
extends AbstractVar
implements SetVar

History: 2007-12-07 : FR_1873619 CPRU: DomOverDeg+DomOverWDeg


Field Summary
protected  IntDomainVar card
           
protected  SetDomain domain
           
 
Fields inherited from class choco.kernel.solver.variables.AbstractVar
constraints, event, extensions, name, propagationEngine
 
Fields inherited from interface choco.kernel.solver.variables.set.SetVar
BOUNDSET_BOUNDCARD, BOUNDSET_CONSTANT, BOUNDSET_ENUMCARD
 
Fields inherited from interface choco.kernel.solver.variables.Var
LOGGER
 
Constructor Summary
SetVarImpl(Solver solver, String name, int[] sortedValues, IntDomainVar card)
           
SetVarImpl(Solver solver, String name, int[] sortedValues, IntDomainVar card, int type)
          Constructor of a SetVar
SetVarImpl(Solver solver, String name, int a, int b, IntDomainVar card)
           
SetVarImpl(Solver solver, String name, int a, int b, IntDomainVar card, int type)
          Constructor of SetVar
 
Method Summary
 boolean addToKernel(int x, int idx)
          Deprecated. 
 boolean addToKernel(int x, SConstraint cause, boolean forceAwake)
          Propagation events updating the kernel of a variable (i.e adding a value)
 boolean canBeEqualTo(SetVar x)
          Check if the both domain intersects
 DisposableIterator<Couple<C>> getActiveConstraints(C cstrCause)
           
 IntDomainVar getCard()
           
 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)
          Deprecated. 
 boolean instantiate(int[] x, SConstraint cause, boolean forceAwake)
          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.
 String pretty()
          pretty printing
 boolean remFromEnveloppe(int x, int idx)
          Deprecated. 
 boolean remFromEnveloppe(int x, SConstraint cause, boolean forceAwake)
          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.
 String toString()
          Useful for debugging.
 
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

domain

protected SetDomain domain

card

protected IntDomainVar card
Constructor Detail

SetVarImpl

public SetVarImpl(Solver solver,
                  String name,
                  int a,
                  int b,
                  IntDomainVar card)

SetVarImpl

public SetVarImpl(Solver solver,
                  String name,
                  int a,
                  int b,
                  IntDomainVar card,
                  int type)
Constructor of SetVar

Parameters:
solver -
name -
a -
b -
card - IntDomainvar representing the cardinality, CAN BE NULL
type -

SetVarImpl

public SetVarImpl(Solver solver,
                  String name,
                  int[] sortedValues,
                  IntDomainVar card)

SetVarImpl

public SetVarImpl(Solver solver,
                  String name,
                  int[] sortedValues,
                  IntDomainVar card,
                  int type)
Constructor of a SetVar

Parameters:
solver -
name -
sortedValues -
card - IntDomainvar representing the cardinality, CAN BE NULL
type -
Method Detail

getActiveConstraints

public final DisposableIterator<Couple<C>> getActiveConstraints(C cstrCause)

getCard

public IntDomainVar getCard()
Specified by:
getCard in interface SetVar
Returns:
the IntDomainVar representing the cardinality of this set

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

setValIn

public final 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 final 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 - SetVar to be checked with
Returns:
a boolean

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 final 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,
                           SConstraint cause,
                           boolean forceAwake)
                    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
Returns:
a boolean indicating whether this method call added new information or not
Throws:
ContradictionException

remFromEnveloppe

public boolean remFromEnveloppe(int x,
                                SConstraint cause,
                                boolean forceAwake)
                         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
Returns:
a boolean indicating whether this method call added new information or not
Throws:
ContradictionException

instantiate

public boolean instantiate(int[] x,
                           SConstraint cause,
                           boolean forceAwake)
                    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
Returns:
a boolean indicating whether this method call added new information or not
Throws:
ContradictionException

addToKernel

@Deprecated
public boolean addToKernel(int x,
                                      int idx)
                    throws ContradictionException
Deprecated. 

Specified by:
addToKernel in interface SetVar
Throws:
ContradictionException

remFromEnveloppe

@Deprecated
public boolean remFromEnveloppe(int x,
                                           int idx)
                         throws ContradictionException
Deprecated. 

Specified by:
remFromEnveloppe in interface SetVar
Throws:
ContradictionException

instantiate

@Deprecated
public boolean instantiate(int[] x,
                                      int idx)
                    throws ContradictionException
Deprecated. 

Specified by:
instantiate in interface SetVar
Throws:
ContradictionException

pretty

public String pretty()
pretty printing

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

toString

public String toString()
Description copied from class: AbstractVar
Useful for debugging.

Overrides:
toString in class AbstractVar
Returns:
the name of the variable


Copyright © 2012. All Rights Reserved.