|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectchoco.kernel.solver.propagation.Propagator
choco.kernel.solver.constraints.AbstractSConstraint<IntDomainVar>
choco.kernel.solver.constraints.integer.AbstractIntSConstraint
choco.kernel.solver.constraints.integer.AbstractLargeIntSConstraint
choco.kernel.solver.constraints.global.matching.AbstractBipartiteGraph
public abstract class AbstractBipartiteGraph
An abstract class encoding assignment graphs (matching each left vertex with one single right vertex) We consider a flow in the graph by adding a source linked to all right vertices and a sink linked to all left vertices
It is based on computing the strongly connected components of the residual graph, then remove arcs connecting two different strongly connected components Computing the strongly connected components is done by an algorithm of Aho, Hopcroft, Ullman using depth first search (Cormen, Leiserson, p. 478, p. 489) Note (EGA) on ice traduction from claire to java : class StrongConnectionDecomposition have been included in this one
Nested Class Summary | |
---|---|
protected static class |
AbstractBipartiteGraph.IntQueue
|
Field Summary | |
---|---|
protected int[] |
component
|
protected boolean[][] |
componentOrder
|
protected int |
currentComponent
|
protected int |
currentNode
|
protected int[] |
finishDate
|
protected int[] |
left2rightArc
|
protected IStateInt |
matchingSize
|
protected int |
maxValue
|
protected int |
minValue
|
protected int |
nbLeftVertices
|
protected int |
nbRightVertices
|
protected int |
nbVertices
|
protected AbstractBipartiteGraph.IntQueue |
queue
|
protected IStateIntVector |
refMatch
|
protected int[] |
right2leftArc
|
protected boolean[] |
seen
|
protected int |
source
|
protected int |
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 | |
---|---|
AbstractBipartiteGraph(IEnvironment environment,
IntDomainVar[] vars,
int nbLeft,
int nbRight)
Constructor |
Method Summary | |
---|---|
void |
addComponentEdge(int compi,
int compj)
add an edge in the component graph between compi and compj: componentOrder stores the transitive closure of that graph |
void |
addComponentVertex()
adds a new vertex to the component graph (= a component = a set of s. connected vertices in the original graph) |
void |
augment(int x)
augment the matching along one alternating path note: throughout the following code, we assume (1 <= x <= c.nbLeftVertices), (1 <= y <= c.nbRightVertices) |
void |
augmentFlow()
keeps augmenting the flow until a maximal flow is reached |
abstract void |
decreaseMatchingSize(int j)
updates the matching size when one more left vertex is de-matched with j |
abstract void |
deleteEdgeAndPublish(int i,
int j)
two methods used for detecting that an edge should be removed from the bipartite assignment graph deleteMatch -> removes it from the graph data strutures deleteEdgeAndPublish -> same + publishes the information outside the constraint |
abstract void |
deleteMatch(int i,
int j)
removing the arc i-j from the reference matching & update matchingSize |
int |
findAlternatingPath()
First pass: use Ford & Fulkerson algorithm to compute a reference flow (assignment) finds an augmenting path using a fifo queue |
void |
firstDFSearch(int i)
the first search explores (DFS) the reduced graph |
void |
firstPassDFS()
seen[i] = false <=> color[i] = white (in book) = true % {gray, black} |
int |
getNbComponents()
|
abstract void |
increaseMatchingSize(int j)
updates the matching size when one more left vertex is matched with j |
protected void |
init()
|
void |
initSCCGraph()
initialize the graph data structure storing the SCC decomposition |
int |
match(int i)
|
boolean |
mayDiminishFlowBetween(int j,
int i)
|
abstract boolean |
mayDiminishFlowFromSource(int j)
|
boolean |
mayGrowFlowBetween(int j,
int i)
|
abstract boolean |
mayGrowFlowFromSource(int j)
|
boolean |
mayGrowFlowToSink(int i)
|
int[] |
mayInverseMatch(int j)
reverse, access from the right vertex set: iterating over the variables (left vertex set) and reading their domains |
int[] |
mayMatch(int i)
Accessing the edges of the bipartite graph access from the left vertex set: reading domains of modeling variables |
abstract boolean |
mustGrowFlowFromSource(int j)
|
void |
prettyPrintForDebug()
|
void |
propagate()
Achieves generalized arc consistency in one call |
abstract void |
putRefMatch(int i,
int j)
adding the arc i-j in the reference matching without any updates |
void |
refreshSCC()
|
protected void |
removeUselessEdges()
remove arcs connecting two different strongly connected components the event generated by the flow algorithm: discovering that an edge is no longer valid, and posting this event to the constraint strategy: since we are already achieving GAC consistency in one single loop, there is no need to post a constAwake |
void |
secondDFSearch(int i)
the second search explores (DFS) the inverse of the reduced graph |
void |
secondPassDFS()
|
abstract void |
setMatch(int i,
int j)
adding the arc i-j in the reference matching & update matchingSize |
Methods inherited from class choco.kernel.solver.constraints.integer.AbstractIntSConstraint |
---|
awakeOnBounds, awakeOnInf, awakeOnInst, awakeOnRem, awakeOnRemovals, awakeOnSup, getConstraintType, isConsistent, isSatisfied, isSatisfied |
Methods inherited from class choco.kernel.solver.constraints.AbstractSConstraint |
---|
addExtension, addListener, clone, getAbstractSConstraintExtensionNumber, getConstraintIdx, getExtension, getFineDegree, getNbVarNotInst, getNbVars, getVar, getVarQuick, isCompletelyInstantiated, isEntailed, opposite, pretty, setConstraintIndex, setExtension, setVar, toString |
Methods inherited from class choco.kernel.solver.propagation.Propagator |
---|
activate, awake, 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 |
Field Detail |
---|
protected int nbLeftVertices
protected int nbRightVertices
protected int nbVertices
protected int minValue
protected int maxValue
protected int source
protected IStateIntVector refMatch
protected IStateInt matchingSize
protected int[] left2rightArc
protected int[] right2leftArc
protected AbstractBipartiteGraph.IntQueue queue
protected int time
protected int[] finishDate
protected boolean[] seen
protected int currentNode
protected int currentComponent
protected int[] component
protected boolean[][] componentOrder
Constructor Detail |
---|
public AbstractBipartiteGraph(IEnvironment environment, IntDomainVar[] vars, int nbLeft, int nbRight)
environment
- vars
- the graph, a left vextex per vars, a right vertex per domain valuenbLeft
- number of left nodes, = vars.lengthnbRight
- number of right nodes, domain values of varsMethod Detail |
---|
protected void init()
public final int[] mayMatch(int i)
i
- the left vertex
public final int[] mayInverseMatch(int j)
j
- the right vertex
public final int match(int i)
i
- left vextex index
public final boolean mayGrowFlowToSink(int i)
i
- a left vertex
public final boolean mayGrowFlowBetween(int j, int i)
j
- a right vertexi
- a left vertex
public final boolean mayDiminishFlowBetween(int j, int i)
j
- a right vertexi
- a left vertex
public abstract void increaseMatchingSize(int j)
j
- a right vertexpublic abstract void decreaseMatchingSize(int j)
j
- a right vertexpublic abstract void deleteMatch(int i, int j)
i
- a left vertexj
- a right vertexpublic abstract void putRefMatch(int i, int j)
i
- a left vertexj
- a right vertexpublic abstract void setMatch(int i, int j)
i
- a left vertexj
- a right vertexpublic abstract boolean mayDiminishFlowFromSource(int j)
j
- a right vertex
public abstract boolean mayGrowFlowFromSource(int j)
j
- a right vertex
public abstract boolean mustGrowFlowFromSource(int j)
j
- a right vertex
public abstract void deleteEdgeAndPublish(int i, int j) throws ContradictionException
i
- a left vertexj
- a right vertex
ContradictionException
public int findAlternatingPath()
public void augment(int x)
x
- public final void augmentFlow() throws ContradictionException
ContradictionException
public final void initSCCGraph()
public final void addComponentVertex()
public final int getNbComponents()
public final void addComponentEdge(int compi, int compj)
compi
- compj
- public final void firstPassDFS()
public final void firstDFSearch(int i)
i
- public final void secondPassDFS()
public final void secondDFSearch(int i)
i
- protected void removeUselessEdges() throws ContradictionException
ContradictionException
public final void refreshSCC()
public void propagate() throws ContradictionException
propagate
in class Propagator
ContradictionException
public final void prettyPrintForDebug()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |