choco.cp.solver.constraints.global.tree.filtering.structuralFiltering.globalCardConstraint
Class AbstractBipartGraph

java.lang.Object
  extended by choco.cp.solver.constraints.global.tree.filtering.structuralFiltering.globalCardConstraint.AbstractBipartGraph
Direct Known Subclasses:
AbstractBipartFlow

public abstract class AbstractBipartGraph
extends Object


Nested Class Summary
protected static class AbstractBipartGraph.IntQueue
           
 
Field Summary
protected  int[] component
           
protected  boolean[][] componentOrder
           
protected  int currentComponent
           
protected  int currentNode
           
protected  int[] finishDate
           
protected  BitSet[] graph
           
protected  int[] index
           
protected  boolean isFeasible
           
protected  int[] left2rightArc
           
protected static Logger LOGGER
           
protected  int matchingSize
           
protected  int maxValue
           
protected  int minValue
           
protected  int nbLeftVertices
           
protected  int nbRightVertices
           
protected  int nbVertices
           
protected  IntDomainVar nTree
           
protected  AbstractBipartGraph.IntQueue queue
           
protected  int[] refMatch
           
protected  int[] right2leftArc
           
protected  boolean[] seen
           
protected  Solver solver
           
protected  int source
           
protected  StructuresAdvisor struct
           
protected  int time
           
protected  TreeParameters tree
           
 
Constructor Summary
protected AbstractBipartGraph(Solver solver, Object[] pack)
          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, RemovalsAdvisor rem)
          implement one of the two main events: when an edge is definitely removed from the bipartite assignment graph
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()
           
 int getPriority()
           
abstract  void increaseMatchingSize(int j)
          updates the matching size when one more left vertex is matched with j
protected  void init(Object[] pack)
           
 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
 int[] mayMatch(int i)
          Accessing the edges of the bipartite graph access from the left vertex set
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(RemovalsAdvisor rem)
           
abstract  void putRefMatch(int i, int j)
          adding the arc i-j in the reference matching without any updates
 void removeUselessEdges(RemovalsAdvisor rem)
          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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final Logger LOGGER

nbLeftVertices

protected int nbLeftVertices

nbRightVertices

protected int nbRightVertices

nbVertices

protected int nbVertices

minValue

protected int minValue

maxValue

protected int maxValue

source

protected int source

refMatch

protected int[] refMatch

matchingSize

protected int matchingSize

left2rightArc

protected int[] left2rightArc

right2leftArc

protected int[] right2leftArc

queue

protected AbstractBipartGraph.IntQueue queue

solver

protected Solver solver

nTree

protected IntDomainVar nTree

graph

protected BitSet[] graph

isFeasible

protected boolean isFeasible

tree

protected TreeParameters tree

index

protected int[] index

struct

protected StructuresAdvisor struct

time

protected int time

finishDate

protected int[] finishDate

seen

protected boolean[] seen

currentNode

protected int currentNode

currentComponent

protected int currentComponent

component

protected int[] component

componentOrder

protected boolean[][] componentOrder
Constructor Detail

AbstractBipartGraph

protected AbstractBipartGraph(Solver solver,
                              Object[] pack)
Constructor

Parameters:
solver - the choco solver involving the constraint
pack - a set of parameters such as the original set of variables fvars, the contracted graph structure associated and the table of indices
Method Detail

init

protected void init(Object[] pack)

mayMatch

public int[] mayMatch(int i)
Accessing the edges of the bipartite graph access from the left vertex set

Parameters:
i -
Returns:
ret

mayInverseMatch

public int[] mayInverseMatch(int j)
reverse, access from the right vertex set: iterating over the variables (left vertex set) and reading their domains

Parameters:
j -
Returns:
ret2

match

public int match(int i)
Parameters:
i - left vextex index
Returns:
accessing the right vertex matched to i

mayGrowFlowToSink

public boolean mayGrowFlowToSink(int i)
whether the flow from i (a left vertex) to the sink may be increased

Parameters:
i -
Returns:
boolean

mayGrowFlowBetween

public 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)

Parameters:
j -
i -
Returns:
boolean

mayDiminishFlowBetween

public boolean mayDiminishFlowBetween(int j,
                                      int i)
whether the flow from j (a right vertex) to i (a left vertex) may be increased

Parameters:
j -
i -
Returns:
boolean

increaseMatchingSize

public abstract void increaseMatchingSize(int j)
updates the matching size when one more left vertex is matched with j

Parameters:
j -

decreaseMatchingSize

public abstract void decreaseMatchingSize(int j)
updates the matching size when one more left vertex is de-matched with j

Parameters:
j -

deleteMatch

public abstract void deleteMatch(int i,
                                 int j)
removing the arc i-j from the reference matching & update matchingSize

Parameters:
i -
j -

putRefMatch

public abstract void putRefMatch(int i,
                                 int j)
adding the arc i-j in the reference matching without any updates

Parameters:
i - left node index
j - right node index

setMatch

public abstract void setMatch(int i,
                              int j)
adding the arc i-j in the reference matching & update matchingSize

Parameters:
i -
j -

mayDiminishFlowFromSource

public abstract boolean mayDiminishFlowFromSource(int j)
whether the flow from the source to j (a right vertex) may be decreased

Parameters:
j -
Returns:
boolean

mayGrowFlowFromSource

public abstract boolean mayGrowFlowFromSource(int j)
whether the flow from the source to j (a right vertex) may be increased

Parameters:
j -
Returns:
boolean

mustGrowFlowFromSource

public 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

Parameters:
j -
Returns:
boolean

findAlternatingPath

public int findAlternatingPath()
First pass: use Ford & Fulkerson algorithm to compute a reference flow (assignment) finds an augmenting path using a fifo queue

Returns:
0 if none found, otherwise the end of the path

augment

public 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)

Parameters:
x -

augmentFlow

public void augmentFlow()
keeps augmenting the flow until a maximal flow is reached


initSCCGraph

public void initSCCGraph()
initialize the graph data structure storing the SCC decomposition


addComponentVertex

public void addComponentVertex()
adds a new vertex to the component graph (= a component = a set of s. connected vertices in the original graph)


addComponentEdge

public 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

Parameters:
compi -
compj -

firstPassDFS

public void firstPassDFS()

firstDFSearch

public void firstDFSearch(int i)
the first search explores (DFS) the reduced graph

Parameters:
i -

secondPassDFS

public void secondPassDFS()

secondDFSearch

public void secondDFSearch(int i)
the second search explores (DFS) the inverse of the reduced graph

Parameters:
i -

deleteEdgeAndPublish

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

Parameters:
i - the variable to unmatch
j - the value to remove

removeUselessEdges

public void removeUselessEdges(RemovalsAdvisor rem)
                        throws ContradictionException
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

Throws:
ContradictionException

propagate

public void propagate(RemovalsAdvisor rem)
               throws ContradictionException
Throws:
ContradictionException

getPriority

public int getPriority()


Copyright © 2012. All Rights Reserved.