View
233
Download
2
Tags:
Embed Size (px)
Citation preview
Arc-consistency for alldiff(x,y,...,z)
Example: P=(X,D,C)Variables: {w,x,y,z}XDomains:
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(wd, xb, y a, zc) = true
value b for w is not supported!
alldiff: value graph
Variables {w,x,y,z}XDomains 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
alldiff: value graph
Variables {w,x,y,z}XDomains 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 ME such that no two edges of M share a vertex
alldiff: value graph
Variables {w,x,y,z}XDomains 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 matchingcovering all the variables
We want to remove edgesthat do not belong to any max-card matching
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
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
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 SV if it covers all the vertices of S
A vertex v is M-free is M does not cover v
f
a b
c
e d
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
a b
c
e d
Step 1
Finding M-augmenting paths
w
x
y
z
b
c
d
e
a
Step 1
Finding M-augmenting paths
w
x
y
z
b
c
d
e
a Direct the graph
Step 1
Finding M-augmenting paths is easy for bipartite graphs
w
x
y
z
b
c
d
e
a Find a path from anM-free vertex on theleft to an M-free vertex on the right
Step 1
Finding M-augmenting paths is easy for bipartite graphs
w
x
y
z
b
c
d
e
a Find a path from anM-free vertex on theleft to an M-free vertex on the right
Step 1
Finding M-augmenting paths is easy for bipartite graphs
w
x
y
z
b
c
d
e
a Find a path from anM-free vertex on theleft to an M-free vertex on the right
Step 1
w
x
y
z
b
c
d
e
a Find a path from anM-free vertex on theleft to an M-free vertex on the right
n breadth-first traversalsO(n e)
Can be improved toO(n0.5 e)
Step 2:
Compute all even-length M-alternating circuit
w
x
y
z
b
c
d
e
a
Step 2:
Compute all even-length M-alternating circuit
w
x
y
z
b
c
d
e
a Direct the graph
Step 2:
Compute all even-length M-alternating circuit
w
x
y
z
b
c
d
e
a Compute all stronglyConnected components[Tarjan 72] O(e)
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|)
Step 3:
Compute all even-length M-alternating paths starting at a M-free vertex
w
x
y
z
b
c
d
e
a
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
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)
Step 4
w
x
y
z
b
c
d
e
a
Remove Edges not identified in previous steps
Step 4
w
x
y
z
b
c
d
e
a
Remove Edges not identified in previous steps
Step 4
w
x
y
z
b
c
d
e
a
Remove Edges not identified in previous steps
Step 4
w
x
y
z
b
c
d
e
a
Remove Edges not identified in previous steps
Step 4
w
x
y
z
b
c
d
e
a
Remove Edges not identified in previous steps
knapsack constraint
Notation: L ≤ ax+by+...+cz ≤ UL, U, a, b, ..., c positive integer constantsx, y,..., z integer variables (posit.
domains) Example:
Variables: x,y,v,zDomains: {0, 1}10 ≤ 2x + 3y + 4v + 5z ≤ 12
Applications: everywhere
knapsack constraint
Example: Variables: x,y,v,zDomains: {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!!
knapsack: propagation Knapsack graph10 ≤ 2x + 3y + 4v + 5z ≤ 12
x y v z
12
11
10
9
8
7
6
5
4
3
2
1
0
knapsack: propagation Knapsack graph10 ≤ 2x + 3y + 4v + 5z ≤ 12
x y v z
12
11
10
9
8
7
6
5
4
3
2
1
0
knapsack: propagation Knapsack graph10 ≤ 2x + 3y + 4v + 5z ≤ 12
x y v z
12
11
10
9
8
7
6
5
4
3
2
1
0
knapsack: propagation Knapsack graph10 ≤ 2x + 3y + 4v + 5z ≤ 12
x y v z
12
11
10
9
8
7
6
5
4
3
2
1
0
knapsack: propagation Knapsack graph10 ≤ 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
knapsack: propagation Knapsack graph10 ≤ 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
knapsack: propagation Knapsack graph10 ≤ 2x + 3y + 4v + 5z ≤ 12 Reduced graph
Value 0 of z can be removed Complexity: O(nU2)
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