choco.global.matching
Class GlobalCardinality

java.lang.Object
  extended by choco.AbstractEntity
      extended by choco.AbstractConstraint
          extended by choco.integer.constraints.AbstractIntConstraint
              extended by choco.integer.constraints.AbstractLargeIntConstraint
                  extended by choco.global.matching.AbstractBipartiteGraph
                      extended by choco.global.matching.AbstractBipartiteFlow
                          extended by choco.global.matching.GlobalCardinality
All Implemented Interfaces:
Constraint, Entity, IntConstraint, IntVarEventListener, VarEventListener, Propagator, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
PalmCardinality

public class GlobalCardinality
extends AbstractBipartiteFlow
implements IntConstraint

very simple version of the cardinality constraint where the values the set of values whose occurrences are counted in the interval (minValue .. maxValue)


Nested Class Summary
 
Nested classes/interfaces inherited from class choco.global.matching.AbstractBipartiteGraph
AbstractBipartiteGraph.IntQueue
 
Field Summary
 
Fields inherited from class choco.global.matching.AbstractBipartiteFlow
compatibleFlow, flow, maxFlow, minFlow
 
Fields inherited from class choco.global.matching.AbstractBipartiteGraph
component, componentOrder, currentComponent, currentNode, finishDate, left2rightArc, matchingSize, maxValue, minValue, nbLeftVertices, nbRightVertices, nbVertices, queue, refMatch, right2leftArc, seen, source, time
 
Fields inherited from class choco.integer.constraints.AbstractLargeIntConstraint
cIndices, cste, vars
 
Fields inherited from class choco.AbstractConstraint
active, constAwakeEvent, hook, priority
 
Fields inherited from class choco.AbstractEntity
problem
 
Constructor Summary
GlobalCardinality(IntDomainVar[] vars, int[] low, int[] up)
          Constructor, Global cardinality constraint API, short cut when smallest value equals 0 note : maxVal - minVal + 1 = low.length = up.length
GlobalCardinality(IntDomainVar[] vars, int minValue, int maxValue, int[] low, int[] up)
          Constructor, Global cardinality constraint API note : maxVal - minVal + 1 = valueMinOccurence.length = valueMaxOccurence.length
 
Method Summary
 void awake()
          performing the initial propagation, reduce variables domain to the candidate assign values
 void awakeOnInf(int idx)
          update the reference matching before redoing the strongly connected components analysis when removing value in the domain of variable idx
 void awakeOnInst(int idx)
          update the reference matching before redoing the strongly connected components analysis when idx is instantiated
 void awakeOnRem(int idx, int x)
          Implement reaction to edge removal
 void awakeOnSup(int idx)
          update the reference matching before redoing the strongly connected components analysis when removing value in the domain of variable idx
 void awakeOnVar(int idx)
          Needs to be defined to update the reference matching before redoing the strongly connected components analysis.
 java.lang.Object clone()
          returns a copy of the constraint.
 void deleteEdgeAndPublish(int i, int j)
          implement one of the two main events: when an edge is definitely removed from the bipartite assignment graph
 boolean isSatisfied()
          TODO : not implemented
 java.lang.String pretty()
          pretty printing of the object.
 void setEdgeAndPublish(int i, int j)
          implement the other main event: when an edge is definitely set in the bipartite assignment graph
 
Methods inherited from class choco.global.matching.AbstractBipartiteFlow
augment, decreaseMatchingSize, deleteMatch, findAlternatingPath, increaseMatchingSize, initAbstractBipartiteFlow, mayDiminishFlowFromSource, mayGrowFlowFromSource, mustGrowFlowFromSource, putRefMatch, setMatch
 
Methods inherited from class choco.global.matching.AbstractBipartiteGraph
addComponentEdge, addComponentVertex, augmentFlow, firstDFSearch, firstPassDFS, getPriority, init, initSCCGraph, match, mayDiminishFlowBetween, mayGrowFlowBetween, mayGrowFlowToSink, mayInverseMatch, mayMatch, propagate, removeUselessEdges, secondDFSearch, secondPassDFS
 
Methods inherited from class choco.integer.constraints.AbstractLargeIntConstraint
assignIndices, getConstraintIdx, getIntVar, getNbVars, getVar, isCompletelyInstantiated, setConstraintIndex, setVar
 
Methods inherited from class choco.integer.constraints.AbstractIntConstraint
awakeOnBounds, awakeOnRemovals, getSelfIndex, isConsistent
 
Methods inherited from class choco.AbstractConstraint
addListener, connectVar, constAwake, delete, fail, getEvent, getPlugIn, getProblem, getVarIdxInOpposite, isActive, isEntailed, isEquivalentTo, opposite, setActive, setEntailed, setPassive, setPlugIn, substituteVar
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface choco.integer.IntConstraint
awakeOnBounds, awakeOnRemovals, getIntVar
 
Methods inherited from interface choco.Propagator
assignIndices, constAwake, delete, getEvent, getPlugIn, getPriority, isCompletelyInstantiated, isConsistent, isEntailed, propagate
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 
Methods inherited from interface choco.integer.var.IntVarEventListener
getConstraintIdx, setConstraintIndex
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 

Constructor Detail

GlobalCardinality

public GlobalCardinality(IntDomainVar[] vars,
                         int minValue,
                         int maxValue,
                         int[] low,
                         int[] up)
Constructor, Global cardinality constraint API note : maxVal - minVal + 1 = valueMinOccurence.length = valueMaxOccurence.length

Parameters:
vars - the variable list
minValue - smallest value that could be assigned to variable
maxValue - greatest value that could be assigned to variable
low - minimum for each value
up - maximum occurences for each value

GlobalCardinality

public GlobalCardinality(IntDomainVar[] vars,
                         int[] low,
                         int[] up)
Constructor, Global cardinality constraint API, short cut when smallest value equals 0 note : maxVal - minVal + 1 = low.length = up.length

Parameters:
vars - the variable list
low - minimum for each value
up - maximum occurences for each value
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from interface: Constraint
returns a copy of the constraint. This copy is a new object, may be a recursive copy in case of composite constraints. The original and the copy share the same variables & plugins

Specified by:
clone in interface Constraint
Overrides:
clone in class AbstractBipartiteFlow
Returns:
Throws:
java.lang.CloneNotSupportedException

deleteEdgeAndPublish

public void deleteEdgeAndPublish(int i,
                                 int j)
                          throws ContradictionException
implement one of the two main events: when an edge is definitely removed from the bipartite assignment graph

Specified by:
deleteEdgeAndPublish in class AbstractBipartiteGraph
Parameters:
i - the variable to unmatch
j - the value to remove
Throws:
ContradictionException - if the removal generates a contradiction

setEdgeAndPublish

public void setEdgeAndPublish(int i,
                              int j)
                       throws ContradictionException
implement the other main event: when an edge is definitely set in the bipartite assignment graph

Parameters:
i - the variable to assign
j - the assignement value
Throws:
ContradictionException

awakeOnRem

public void awakeOnRem(int idx,
                       int x)
                throws ContradictionException
Implement reaction to edge removal

Specified by:
awakeOnRem in interface IntVarEventListener
Overrides:
awakeOnRem in class AbstractIntConstraint
Parameters:
idx - variable index
x - value to remove
Throws:
ContradictionException

awakeOnVar

public void awakeOnVar(int idx)
Needs to be defined to update the reference matching before redoing the strongly connected components analysis.

Specified by:
awakeOnVar in interface VarEventListener
Specified by:
awakeOnVar in interface Propagator
Overrides:
awakeOnVar in class AbstractConstraint
Parameters:
idx - variable index

awakeOnInf

public void awakeOnInf(int idx)
                throws ContradictionException
update the reference matching before redoing the strongly connected components analysis when removing value in the domain of variable idx

Specified by:
awakeOnInf in interface IntVarEventListener
Overrides:
awakeOnInf in class AbstractIntConstraint
Parameters:
idx - variable index
Throws:
ContradictionException

awakeOnSup

public void awakeOnSup(int idx)
                throws ContradictionException
update the reference matching before redoing the strongly connected components analysis when removing value in the domain of variable idx

Specified by:
awakeOnSup in interface IntVarEventListener
Overrides:
awakeOnSup in class AbstractIntConstraint
Parameters:
idx - variable index
Throws:
ContradictionException

awakeOnInst

public void awakeOnInst(int idx)
update the reference matching before redoing the strongly connected components analysis when idx is instantiated

Specified by:
awakeOnInst in interface IntVarEventListener
Overrides:
awakeOnInst in class AbstractIntConstraint
Parameters:
idx - variable index

awake

public void awake()
           throws ContradictionException
performing the initial propagation, reduce variables domain to the candidate assign values

Specified by:
awake in interface Propagator
Overrides:
awake in class AbstractConstraint
Throws:
ContradictionException

isSatisfied

public boolean isSatisfied()
TODO : not implemented

Specified by:
isSatisfied in interface Constraint
Returns:
false

pretty

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

Specified by:
pretty in interface Entity
Overrides:
pretty in class AbstractEntity
Returns:
a readable string representation of the object