choco.cp.solver.constraints.global.matching
Class GlobalCardinality

java.lang.Object
  extended by choco.kernel.solver.propagation.Propagator
      extended by choco.kernel.solver.constraints.AbstractSConstraint<IntDomainVar>
          extended by choco.kernel.solver.constraints.integer.AbstractIntSConstraint
              extended by choco.kernel.solver.constraints.integer.AbstractLargeIntSConstraint
                  extended by choco.kernel.solver.constraints.global.matching.AbstractBipartiteGraph
                      extended by choco.kernel.solver.constraints.global.matching.AbstractBipartiteFlow
                          extended by choco.cp.solver.constraints.global.matching.GlobalCardinality
All Implemented Interfaces:
IExtensionnable, IPretty, SConstraint<IntDomainVar>, IntPropagator, Cloneable, EventListener
Direct Known Subclasses:
GlobalCardinalityVar

public class GlobalCardinality
extends AbstractBipartiteFlow

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.kernel.solver.constraints.global.matching.AbstractBipartiteGraph
AbstractBipartiteGraph.IntQueue
 
Field Summary
 
Fields inherited from class choco.kernel.solver.constraints.global.matching.AbstractBipartiteFlow
compatibleFlow, compatibleSupport, flow, maxFlow, minFlow
 
Fields inherited from class choco.kernel.solver.constraints.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.kernel.solver.constraints.AbstractSConstraint
cIndices, constraintType, extensions, vars
 
Fields inherited from class choco.kernel.solver.propagation.Propagator
active, constAwakeEvent, priority, propagationEngine
 
Fields inherited from interface choco.kernel.solver.constraints.SConstraint
LOGGER
 
Constructor Summary
GlobalCardinality(IntDomainVar[] vars, int[] low, int[] up, IEnvironment environment)
          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, IEnvironment environment)
          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
 Object clone()
          Clone 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(int[] tuple)
          TEMPORARY: if not overriden by the constraint, throws an error to avoid bug using reified constraints in constraints that have not been changed to fulfill this api yet !
 String pretty()
          pretty printing of the object.
 void propagate()
          Achieves generalized arc consistency in one call
 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.kernel.solver.constraints.global.matching.AbstractBipartiteFlow
augment, decreaseMatchingSize, deleteMatch, findAlternatingPath, getMaxFlow, getMinFlow, increaseMatchingSize, init, mayDiminishFlowFromSource, mayGrowFlowFromSource, mustGrowFlowFromSource, putRefMatch, removeUselessEdges, setMatch
 
Methods inherited from class choco.kernel.solver.constraints.global.matching.AbstractBipartiteGraph
addComponentEdge, addComponentVertex, augmentFlow, firstDFSearch, firstPassDFS, getNbComponents, initSCCGraph, match, mayDiminishFlowBetween, mayGrowFlowBetween, mayGrowFlowToSink, mayInverseMatch, mayMatch, prettyPrintForDebug, refreshSCC, secondDFSearch, secondPassDFS
 
Methods inherited from class choco.kernel.solver.constraints.integer.AbstractIntSConstraint
awakeOnBounds, awakeOnRemovals, getConstraintType, isConsistent, isSatisfied
 
Methods inherited from class choco.kernel.solver.constraints.AbstractSConstraint
addExtension, addListener, getAbstractSConstraintExtensionNumber, getConstraintIdx, getExtension, getFineDegree, getNbVarNotInst, getNbVars, getVar, getVarQuick, isCompletelyInstantiated, isEntailed, opposite, setConstraintIndex, setExtension, setVar, toString
 
Methods inherited from class choco.kernel.solver.propagation.Propagator
activate, constAwake, fail, getEvent, getFilteredEventMask, getPriority, isActive, setActive, setActiveSilently, setEntailed, setPassive, setPropagationEngine
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GlobalCardinality

public GlobalCardinality(IntDomainVar[] vars,
                         int minValue,
                         int maxValue,
                         int[] low,
                         int[] up,
                         IEnvironment environment)
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
environment -

GlobalCardinality

public GlobalCardinality(IntDomainVar[] vars,
                         int[] low,
                         int[] up,
                         IEnvironment environment)
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
environment -
Method Detail

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from class: AbstractSConstraint
Clone the constraint

Overrides:
clone in class AbstractSConstraint<IntDomainVar>
Returns:
the clone of the constraint
Throws:
CloneNotSupportedException - Clone not supported exception

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 IntPropagator
Overrides:
awakeOnRem in class AbstractIntSConstraint
Parameters:
idx - variable index
x - value to remove
Throws:
ContradictionException

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 IntPropagator
Overrides:
awakeOnInf in class AbstractIntSConstraint
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 IntPropagator
Overrides:
awakeOnSup in class AbstractIntSConstraint
Parameters:
idx - variable index
Throws:
ContradictionException

awakeOnInst

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

Specified by:
awakeOnInst in interface IntPropagator
Overrides:
awakeOnInst in class AbstractIntSConstraint
Parameters:
idx - variable index
Throws:
ContradictionException

awake

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

Overrides:
awake in class Propagator
Throws:
ContradictionException

propagate

public void propagate()
               throws ContradictionException
Description copied from class: AbstractBipartiteGraph
Achieves generalized arc consistency in one call

Overrides:
propagate in class AbstractBipartiteGraph
Throws:
ContradictionException - contradiction exception

isSatisfied

public boolean isSatisfied(int[] tuple)
Description copied from class: AbstractIntSConstraint
TEMPORARY: if not overriden by the constraint, throws an error to avoid bug using reified constraints in constraints that have not been changed to fulfill this api yet !

Specified by:
isSatisfied in interface IntPropagator
Overrides:
isSatisfied in class AbstractIntSConstraint

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
Overrides:
pretty in class AbstractSConstraint<IntDomainVar>
Returns:
a readable string representation of the object


Copyright © 2012. All Rights Reserved.