Download presentation
Presentation is loading. Please wait.
1
Arc-consistency for alldiff(x,y,...,z) Example: P=(X,D,C) Variables: {w,x,y,z} X Domains: w {b,c,d,e} x {b,c} y {a,b,c,d} z {b,c} Constraints: alldiff(w,x,y,z) C value d for w is supported: alldiff(w d, x b, y a, z c) = true value b for w is not supported!
2
alldiff: value graph Variables {w,x,y,z} X Domains D(w)={b,c,d,e}, D(x)={b,c}, D(y)={a,b,c,d}, D(z)={b,c} Constraint alldiff(w,x,y,z) C w x y z b c d e a
3
alldiff: value graph Variables {w,x,y,z} X Domains D(w)={b,c,d,e}, D(x)={b,c}, D(y)={a,b,c,d}, D(z)={b,c} Constraint alldiff(w,x,y,z) C w x y z b c d e a Given a graph G=(V,E), a matching is M E such that no two edges of M share a vertex
4
alldiff: value graph Variables {w,x,y,z} X Domains D(w)={b,c,d,e}, D(x)={b,c}, D(y)={a,b,c,d}, D(z)={b,c} Constraint alldiff(w,x,y,z) C w x y z b c d e a Consistent assignment = maximal cardinality matching covering all the variables We want to remove edges that do not belong to any max-card matching
5
AC characterization Theorem: Let G be a graph and M a maximum-cardinality matching. An edge e belongs to some max-card matching iff e is in M, or e is on an even-length M-alternating circuit e is on an even-length M-alternating path starting at a M-free vertex
6
AC Algorithm 1. Compute a maximum-cardinality matching. 2. Compute all even-length M-alternating circuits 3. Compute all even-length M-alternating paths starting at a M-free vertex 4. Remove all edges not identified in the previous 3 steps
7
Step 1. Find Max-card matching A matching M covers a vertex v if v belongs to some edge in M A matching M covers a set S V if it covers all the vertices of S A vertex v is M-free is M does not cover v f ab c ed
8
Paths A path is M-alternating if its edges are are alternatingly out of and in M A M-alternating path is M-augmenting if has odd length, Its ends are not covered by M f ab c ed
9
Step 1 Finding M-augmenting paths w x y z b c d e a
10
Step 1 Finding M-augmenting paths w x y z b c d e a Direct the graph
11
Step 1 Finding M-augmenting paths is easy for bipartite graphs w x y z b c d e a Find a path from an M-free vertex on the left to an M-free vertex on the right
12
Step 1 Finding M-augmenting paths is easy for bipartite graphs w x y z b c d e a Find a path from an M-free vertex on the left to an M-free vertex on the right
13
Step 1 Finding M-augmenting paths is easy for bipartite graphs w x y z b c d e a Find a path from an M-free vertex on the left to an M-free vertex on the right
14
Step 1 w x y z b c d e a Find a path from an M-free vertex on the left to an M-free vertex on the right n breadth-first traversals O(n e) Can be improved to O(n 0.5 e)
15
Step 2: Compute all even-length M-alternating circuit w x y z b c d e a
16
Step 2: Compute all even-length M-alternating circuit w x y z b c d e a Direct the graph
17
Step 2: Compute all even-length M-alternating circuit w x y z b c d e a Compute all strongly Connected components [Tarjan 72] O(e)
18
Tarjan (Kosaraju’s) 1. Do a DFS 2. Reverse the direction of edges 3. Do a DFS starting with the vertex visited last in the original DFS 4. Each tree in the forest returned is a SCC O(|V|+|A|)
19
Step 3: Compute all even-length M-alternating paths starting at a M-free vertex w x y z b c d e a
20
Step 3: Compute all even-length M-alternating paths starting at a M-free vertex w x y z b c d e a Direct the graph
21
Step 3: Compute all even-length M-alternating paths starting at a M-free vertex w x y z b c d e a Compute alternating Paths starting from free Vertices Breadth-first O(e)
22
Step 4 w x y z b c d e a Remove Edges not identified in previous steps
23
Step 4 w x y z b c d e a Remove Edges not identified in previous steps
24
Step 4 w x y z b c d e a Remove Edges not identified in previous steps
25
Step 4 w x y z b c d e a Remove Edges not identified in previous steps
26
Step 4 w x y z b c d e a Remove Edges not identified in previous steps
27
knapsack constraint Notation: L ≤ ax+by+...+cz ≤ U L, U, a, b,..., cpositive integer constants x, y,..., z integer variables (posit. domains) Example: Variables: x,y,v,z Domains: {0, 1} 10 ≤ 2x + 3y + 4v + 5z ≤ 12 Applications: everywhere
28
knapsack constraint Example: Variables: x,y,v,z Domains: {0, 1} 10 ≤ 2x + 3y + 4v + 5z ≤ 12 Value 0 of x is supported (0+3+4+5=12) Value 1 of x is supported (2+0+4+5=11) Value 0 of z is not supported!!
29
knapsack: propagation Knapsack graph 10 ≤ 2x + 3y + 4v + 5z ≤ 12 x y v z 12 11 10 9 8 7 6 5 4 3 2 1 0
30
knapsack: propagation Knapsack graph 10 ≤ 2x + 3y + 4v + 5z ≤ 12 x y v z 12 11 10 9 8 7 6 5 4 3 2 1 0
31
knapsack: propagation Knapsack graph 10 ≤ 2x + 3y + 4v + 5z ≤ 12 x y v z 12 11 10 9 8 7 6 5 4 3 2 1 0
32
knapsack: propagation Knapsack graph 10 ≤ 2x + 3y + 4v + 5z ≤ 12 x y v z 12 11 10 9 8 7 6 5 4 3 2 1 0
33
knapsack: propagation Knapsack graph 10 ≤ 2x + 3y + 4v + 5z ≤ 12 Reduced graph Value 0 of z can be removed x y v z 12 11 10 9 8 7 6 5 4 3 2 1 0
34
knapsack: propagation Knapsack graph 10 ≤ 2x + 3y + 4v + 5z ≤ 12 Reduced graph Value 0 of z can be removed x y v z 12 11 10 9 8 7 6 5 4 3 2 1 0
35
knapsack: propagation Knapsack graph 10 ≤ 2x + 3y + 4v + 5z ≤ 12 Reduced graph Value 0 of z can be removed Complexity: O(nU 2 ) n is the number of variables Pseudo-polynomial x y v z 12 11 10 9 8 7 6 5 4 3 2 1 0
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.