choco.kernel.solver.constraints.global
Class MetaSConstraint

java.lang.Object
  extended by choco.kernel.solver.constraints.global.MetaSConstraint
All Implemented Interfaces:
IExtensionnable, IPretty, IResource<TaskVar>, IResourceParameters, SConstraint, Serializable, Cloneable

public class MetaSConstraint
extends Object
implements SConstraint, IResource<TaskVar>

See Also:
Serialized Form

Field Summary
 SConstraint[] constraints
           
protected  String name
           
 TaskVar[] tasks
           
 SConstraintType type
           
 IntDomainVar[] vars
           
 
Fields inherited from interface choco.kernel.solver.constraints.SConstraint
LOGGER
 
Constructor Summary
MetaSConstraint(SConstraint[] constraints, TaskVar[] tasks, IntDomainVar[] vars)
           
MetaSConstraint(String name, SConstraint[] constraints, TaskVar[] tasks, IntDomainVar[] vars)
           
 
Method Summary
 void addExtension(int extensionNumber)
          Adds a new extension.
 void addListener(boolean dynamicAddition)
          does not really add a listener as it is useless for propagation.
 List<IRTask> asRTaskList()
           
 List<TaskVar> asTaskList()
          A view of the resource as an immutable list.
 Object clone()
           
 int getConstraintIdx(int idx)
          Network management: Among all listeners linked to the idx-th variable of c, find the index of constraint c.
 SConstraintType getConstraintType()
          Return the type of constraint, ie the type of variable involved in the constraint
 Extension getExtension(int extensionNumber)
          Returns the queried extension
 int getFineDegree(int idx)
          Some global constraint might be able to provide some fine grained information about the "real" degree of a variables.
 String getName()
           
 int getNbOptionalTasks()
           
 int getNbRegularTasks()
           
 int getNbSubConstraints()
           
 int getNbTasks()
           
 int getNbVars()
          Network management: Get the number of variables involved in the constraint.
 String getRscName()
           
 IRTask getRTask(int idx)
           
 Iterator<IRTask> getRTaskIterator()
           
 SConstraint getSubConstraints(int i)
           
 TaskVar getTask(int i)
          get the task with the given index
 Iterator<TaskVar> getTaskIterator()
          an iterator over all tasks
 Var getVar(int i)
          Network management: Accessing the ith variable of a constraint.
 Var getVarQuick(int i)
          Network management: Accessing the ith variable of a constraint.
 boolean isSatisfied()
          Semantic: Testing if the constraint is satisfied.
 AbstractSConstraint opposite(Solver solver)
          computes the constraint modelling the counter-opposite condition of this
 String pretty()
          pretty printing of the object.
 void setConstraintIndex(int i, int idx)
          Network management: Storing that among all listeners linked to the i-th variable of c, this (the current constraint) is found at index idx.
 void setName(String name)
           
 void setVar(int i, Var v)
          Network management: Setting (or overwriting) the ith variable of a constraint.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vars

public final IntDomainVar[] vars

tasks

public final TaskVar[] tasks

constraints

public final SConstraint[] constraints

type

public final SConstraintType type

name

protected String name
Constructor Detail

MetaSConstraint

public MetaSConstraint(String name,
                       SConstraint[] constraints,
                       TaskVar[] tasks,
                       IntDomainVar[] vars)

MetaSConstraint

public MetaSConstraint(SConstraint[] constraints,
                       TaskVar[] tasks,
                       IntDomainVar[] vars)
Method Detail

getName

public final String getName()

setName

public final void setName(String name)

addListener

public void addListener(boolean dynamicAddition)
does not really add a listener as it is useless for propagation. it only records a list of constraints for a task variables.

Parameters:
dynamicAddition -

getConstraintIdx

public final int getConstraintIdx(int idx)
Description copied from interface: SConstraint
Network management: Among all listeners linked to the idx-th variable of c, find the index of constraint c.

Specified by:
getConstraintIdx in interface SConstraint
Parameters:
idx - index of the variable in the constraint
Returns:
index of the constraint within the variable network

getNbVars

public final int getNbVars()
Description copied from interface: SConstraint
Network management: Get the number of variables involved in the constraint.

Specified by:
getNbVars in interface SConstraint
Returns:
number of variables involved in the constraint

getVar

public final Var getVar(int i)
Description copied from interface: SConstraint
Network management: Accessing the ith variable of a constraint.

Specified by:
getVar in interface SConstraint
Parameters:
i - index of the variable in the constraint
Returns:
the i^th variable involved in the constraint

getVarQuick

public final Var getVarQuick(int i)
Description copied from interface: SConstraint
Network management: Accessing the ith variable of a constraint.

Specified by:
getVarQuick in interface SConstraint
Parameters:
i - index of the variable in the constraint
Returns:
the i^th variable involved in the constraint

getTask

public final TaskVar getTask(int i)
Description copied from interface: IResource
get the task with the given index

Specified by:
getTask in interface IResource<TaskVar>
Parameters:
i - index of the task

getNbSubConstraints

public final int getNbSubConstraints()

getSubConstraints

public final SConstraint getSubConstraints(int i)

isSatisfied

public boolean isSatisfied()
Description copied from interface: SConstraint
Semantic: Testing if the constraint is satisfied. Note that all variables involved in the constraint must be instantiated when this method is called.

Specified by:
isSatisfied in interface SConstraint
Returns:
true if the constraint is satisfied

opposite

public AbstractSConstraint opposite(Solver solver)
Description copied from interface: SConstraint
computes the constraint modelling the counter-opposite condition of this

Specified by:
opposite in interface SConstraint
Parameters:
solver - the current solver
Returns:
a new constraint (modelling the opposite condition) @param solver

setConstraintIndex

public final void setConstraintIndex(int i,
                                     int idx)
Description copied from interface: SConstraint
Network management: Storing that among all listeners linked to the i-th variable of c, this (the current constraint) is found at index idx.

Specified by:
setConstraintIndex in interface SConstraint
Parameters:
i - index of the variable in the constraint
idx - index of the constraint in the among all listeners linked to that variable

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

setVar

public final void setVar(int i,
                         Var v)
Description copied from interface: SConstraint
Network management: Setting (or overwriting) the ith variable of a constraint.

Specified by:
setVar in interface SConstraint
Parameters:
i - index of the variable in the constraint
v - the variable (may be an IntDomainVar, SetVar, RealVar, ...

pretty

public String pretty()
Description copied from interface: IPretty
pretty printing of the object. This String is not constant and may depend on the context.

Specified by:
pretty in interface IPretty
Returns:
a readable string representation of the object

asTaskList

public List<TaskVar> asTaskList()
Description copied from interface: IResource
A view of the resource as an immutable list.

Specified by:
asTaskList in interface IResource<TaskVar>

getNbTasks

public int getNbTasks()
Specified by:
getNbTasks in interface IResource<TaskVar>
Specified by:
getNbTasks in interface IResourceParameters

getRscName

public String getRscName()
Specified by:
getRscName in interface IResourceParameters

getRTask

public IRTask getRTask(int idx)
Specified by:
getRTask in interface IResource<TaskVar>

asRTaskList

public List<IRTask> asRTaskList()
Specified by:
asRTaskList in interface IResource<TaskVar>

getRTaskIterator

public Iterator<IRTask> getRTaskIterator()
Specified by:
getRTaskIterator in interface IResource<TaskVar>

getTaskIterator

public Iterator<TaskVar> getTaskIterator()
Description copied from interface: IResource
an iterator over all tasks

Specified by:
getTaskIterator in interface IResource<TaskVar>
Returns:

getConstraintType

public SConstraintType getConstraintType()
Return the type of constraint, ie the type of variable involved in the constraint

Specified by:
getConstraintType in interface SConstraint
Returns:

getNbOptionalTasks

public int getNbOptionalTasks()
Specified by:
getNbOptionalTasks in interface IResourceParameters

getNbRegularTasks

public int getNbRegularTasks()
Specified by:
getNbRegularTasks in interface IResourceParameters

getExtension

public Extension getExtension(int extensionNumber)
Description copied from interface: IExtensionnable
Returns the queried extension

Specified by:
getExtension in interface IExtensionnable
Parameters:
extensionNumber - should use the number returned by getAbstractSConstraintExtensionNumber
Returns:
the queried extension

addExtension

public void addExtension(int extensionNumber)
Adds a new extension.

Specified by:
addExtension in interface IExtensionnable
Parameters:
extensionNumber - should use the number returned by getAbstractSConstraintExtensionNumber

getFineDegree

public int getFineDegree(int idx)
Description copied from interface: SConstraint
Some global constraint might be able to provide some fine grained information about the "real" degree of a variables. For example the global constraint on clauses can give the real number of clauses on each variable

Specified by:
getFineDegree in interface SConstraint
Parameters:
idx - index of the variable in the constraint
Returns:
a weight given to the variable by the constraint


Copyright © 2012. All Rights Reserved.