|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectchoco.AbstractEntity
choco.AbstractConstraint
choco.integer.constraints.AbstractIntConstraint
choco.integer.constraints.AbstractLargeIntConstraint
choco.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 class |
AbstractBipartiteGraph.IntQueue
|
Field Summary | |
---|---|
protected int[] |
component
|
protected boolean[][] |
componentOrder
|
protected int |
currentComponent
|
protected int |
currentNode
|
protected int[] |
finishDate
|
protected int[] |
left2rightArc
|
protected java.util.logging.Logger |
logger
|
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.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 | |
---|---|
AbstractBipartiteGraph(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 |
java.lang.Object |
clone()
returns a copy of the constraint. |
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 |
getPriority()
Returns the priority. |
abstract void |
increaseMatchingSize(int j)
updates the matching size when one more left vertex is matched with j |
protected void |
init(int nbLeft,
int nbRight)
|
void |
initSCCGraph()
initialize the graph data structure storing the SCC decomposition |
int |
match(int i)
|
boolean |
mayDiminishFlowBetween(int j,
int i)
whether the flow from j (a right vertex) to i (a left vertex) may be increased |
abstract boolean |
mayDiminishFlowFromSource(int j)
whether the flow from the source to j (a right vertex) may be decreased |
boolean |
mayGrowFlowBetween(int j,
int i)
whether the flow from j (a right vertex) to i (a left vertex) may be increased (the additional flow is able to arrive to j, we don't care yet whether it will be able to leave i) |
abstract boolean |
mayGrowFlowFromSource(int j)
whether the flow from the source to j (a right vertex) may be increased |
boolean |
mayGrowFlowToSink(int i)
whether the flow from i (a left vertex) to the sink may be increased |
int[] |
mayInverseMatch(int j)
reverse, access from the right vertex set: iterating over the variables (left vertex set) and reading their domains TODO abstract in claire ice |
int[] |
mayMatch(int i)
Accessing the edges of the bipartite graph access from the left vertex set: reading domains of modeling variables TODO abstract in claire ice |
abstract boolean |
mustGrowFlowFromSource(int j)
whether the flow from the source to j (a right vertex) must be increased in order to get a maximal (sink/left vertex set saturating) flow |
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 |
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 solver: 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.integer.constraints.AbstractLargeIntConstraint |
---|
assignIndices, getConstraintIdx, getIntVar, getNbVars, getVar, isCompletelyInstantiated, setConstraintIndex, setVar |
Methods inherited from class choco.integer.constraints.AbstractIntConstraint |
---|
awakeOnBounds, awakeOnInf, awakeOnInst, awakeOnRem, awakeOnRemovals, awakeOnSup, getSelfIndex, isConsistent |
Methods inherited from class choco.AbstractConstraint |
---|
addListener, awake, awakeOnVar, connectVar, constAwake, delete, fail, getEvent, getPlugIn, getProblem, getVarIdxInOpposite, isActive, isEntailed, isEquivalentTo, opposite, setActive, setEntailed, setPassive, setPlugIn, substituteVar |
Methods inherited from class choco.AbstractEntity |
---|
pretty |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface choco.Propagator |
---|
awake, awakeOnVar, constAwake, delete, getEvent, getPlugIn, isEntailed |
Methods inherited from interface choco.prop.VarEventListener |
---|
addListener, isActive, setActive, setPassive |
Methods inherited from interface choco.prop.VarEventListener |
---|
addListener, isActive, setActive, setPassive |
Field Detail |
---|
protected java.util.logging.Logger logger
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(IntDomainVar[] vars, int nbLeft, int nbRight)
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 |
---|
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Constraint
clone
in interface Constraint
clone
in class AbstractLargeIntConstraint
java.lang.CloneNotSupportedException
protected void init(int nbLeft, int nbRight)
public int[] mayMatch(int i)
i
-
public int[] mayInverseMatch(int j)
j
-
public int match(int i)
i
- left vextex index
public boolean mayGrowFlowToSink(int i)
i
-
public boolean mayGrowFlowBetween(int j, int i)
j
- i
-
public boolean mayDiminishFlowBetween(int j, int i)
j
- i
-
public abstract void increaseMatchingSize(int j)
j
- public abstract void decreaseMatchingSize(int j)
j
- public abstract void deleteMatch(int i, int j)
i
- j
- public abstract void putRefMatch(int i, int j)
i
- left node indexj
- right node indexpublic abstract void setMatch(int i, int j)
i
- j
- public abstract boolean mayDiminishFlowFromSource(int j)
j
-
public abstract boolean mayGrowFlowFromSource(int j)
j
-
public abstract boolean mustGrowFlowFromSource(int j)
j
-
public abstract void deleteEdgeAndPublish(int i, int j) throws ContradictionException
i
- j
-
ContradictionException
public int findAlternatingPath()
public void augment(int x)
x
- public void augmentFlow() throws ContradictionException
ContradictionException
public void initSCCGraph()
public void addComponentVertex()
public void addComponentEdge(int compi, int compj)
compi
- compj
- public void firstPassDFS()
public void firstDFSearch(int i)
i
- public void secondPassDFS()
public void secondDFSearch(int i)
i
- protected void removeUselessEdges() throws ContradictionException
ContradictionException
public void propagate() throws ContradictionException
propagate
in interface Propagator
propagate
in class AbstractLargeIntConstraint
ContradictionException
public int getPriority()
AbstractConstraint
getPriority
in interface Propagator
getPriority
in class AbstractConstraint
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |