Consistency algorithms Chapter 3 1 Consistency methods l

  • Slides: 57
Download presentation
Consistency algorithms Chapter 3 1

Consistency algorithms Chapter 3 1

Consistency methods l Approximation of inference: l Methods that transform the original network into

Consistency methods l Approximation of inference: l Methods that transform the original network into a tighter and tighter representations • Arc, path and i-consistecy Spring 2007 ICS 275 A - Constraint Networks 2

Arc-consistency X 1 X, Y, Z, T 3 X Y Y=Z T Z X

Arc-consistency X 1 X, Y, Z, T 3 X Y Y=Z T Z X T 1, 2, 3 Y 1, 2, 3 = 1, 2, 3 T Spring 2007 ICS 275 A - Constraint Networks Z 3

Arc-consistency X 1 X, Y, Z, T 3 X Y Y=Z T Z X

Arc-consistency X 1 X, Y, Z, T 3 X Y Y=Z T Z X T 1 3 = 2 T Spring 2007 Y ICS 275 A - Constraint Networks 3 Z 4

Arc-consistency Spring 2007 ICS 275 A - Constraint Networks 5

Arc-consistency Spring 2007 ICS 275 A - Constraint Networks 5

Revise for arc-consistency Spring 2007 ICS 275 A - Constraint Networks 7

Revise for arc-consistency Spring 2007 ICS 275 A - Constraint Networks 7

Figure 3. 3: (a) Matching diagram describing a network of constraints that is not

Figure 3. 3: (a) Matching diagram describing a network of constraints that is not arc-consistent (b) An arc-consistent equivalent network. Spring 2007 ICS 275 A - Constraint Networks 8

AC-1 l Complexity (Mackworth and Freuder, 1986): e = number of arcs, n variables,

AC-1 l Complexity (Mackworth and Freuder, 1986): e = number of arcs, n variables, k values l (ek^2, each loop, nk number of loops), best-case = ek, l Arc-consistency is: l Spring 2007 ICS 275 A - Constraint Networks 9

AC-3 l l Complexity: Best case O(ek), since each arc may be processed in

AC-3 l l Complexity: Best case O(ek), since each arc may be processed in O(2 k) Spring 2007 ICS 275 A - Constraint Networks 10

Example: A three variable network, with two constraints: z divides x and z divides

Example: A three variable network, with two constraints: z divides x and z divides y (a) before and (b) after AC-3 is applied. Spring 2007 ICS 275 A - Constraint Networks 11

AC-4 l Complexity: l (Counter is the number of supports to ai in xi

AC-4 l Complexity: l (Counter is the number of supports to ai in xi from xj. S_(xi, ai) is the set of pairs that (xi, ai) supports) Spring 2007 ICS 275 A - Constraint Networks 12

Example applying AC-4 Spring 2007 ICS 275 A - Constraint Networks 13

Example applying AC-4 Spring 2007 ICS 275 A - Constraint Networks 13

Distributed arc-consistency (Constraint propagation) l Implement AC-1 distributedly. l Node x_j sends the message

Distributed arc-consistency (Constraint propagation) l Implement AC-1 distributedly. l Node x_j sends the message to node x_i l Node x_i updates its domain: l Messages can be sent asynchronously or scheduled in a topological order Spring 2007 ICS 275 A - Constraint Networks 14

Exercise: make the following network arc-consistent l l Draw the network’s primal and dual

Exercise: make the following network arc-consistent l l Draw the network’s primal and dual constraint graph Network = • Domains {1, 2, 3, 4} • Constraints: y < x, z < y, t < z, f<t, x<=t+1, Y<f+2 Spring 2007 ICS 275 A - Constraint Networks 15

Arc-consistency Algorithms l l l AC-1: brute-force, distributed AC-3, queue-based AC-4, context-based, optimal AC-5,

Arc-consistency Algorithms l l l AC-1: brute-force, distributed AC-3, queue-based AC-4, context-based, optimal AC-5, 6, 7, …. Good in special cases Important: applied at every node of search l (n number of variables, e=#constraints, k=domain size) l Mackworth and Freuder (1977, 1983), Mohr and Anderson, (1985)… Spring 2007 ICS 275 A - Constraint Networks 16

Is arc-consistency enough? l Example: a triangle graph-coloring with 2 values. • • l

Is arc-consistency enough? l Example: a triangle graph-coloring with 2 values. • • l Is it arc-consistent? Is it consistent? It is not path, or 3 -consistent. Spring 2007 ICS 275 A - Constraint Networks 17

Path-consistency Spring 2007 ICS 275 A - Constraint Networks 18

Path-consistency Spring 2007 ICS 275 A - Constraint Networks 18

Path-consistency Spring 2007 ICS 275 A - Constraint Networks 19

Path-consistency Spring 2007 ICS 275 A - Constraint Networks 19

Revise-3 l l l Complexity: O(k^3) Best-case: O(t) Worst-case O(tk) Spring 2007 ICS 275

Revise-3 l l l Complexity: O(k^3) Best-case: O(t) Worst-case O(tk) Spring 2007 ICS 275 A - Constraint Networks 20

PC-1 l Complexity: l O(n^3) triplets, each take O(k^3) steps O(n^3 k^3) Max number

PC-1 l Complexity: l O(n^3) triplets, each take O(k^3) steps O(n^3 k^3) Max number of loops: O(n^2 k^2). l Spring 2007 ICS 275 A - Constraint Networks 21

PC-2 l Complexity: Optimal PC-4: l (each pair deleted may add: 2 n-1 triplets,

PC-2 l Complexity: Optimal PC-4: l (each pair deleted may add: 2 n-1 triplets, number of pairs: O(n^2 k^2) l size of Q is O(n^3 k^2), processing is O(k^3)) Spring 2007 ICS 275 A - Constraint Networks 22

Example: before and after pathconsistency l l PC-1 requires 2 processings of each arc

Example: before and after pathconsistency l l PC-1 requires 2 processings of each arc while PC-2 may not Can we do path-consistency distributedly? Spring 2007 ICS 275 A - Constraint Networks 23

Path-consistency Algorithms l Apply Revise-3 (O(k^3)) until no change l Path-consistency (3 -consistency) adds

Path-consistency Algorithms l Apply Revise-3 (O(k^3)) until no change l Path-consistency (3 -consistency) adds binary constraints. PC-1: PC-2: PC-4 optimal: l l l Spring 2007 ICS 275 A - Constraint Networks 25

I-consistency Spring 2007 ICS 275 A - Constraint Networks 26

I-consistency Spring 2007 ICS 275 A - Constraint Networks 26

Higher levels of consistency, global-consistency Spring 2007 ICS 275 A - Constraint Networks 27

Higher levels of consistency, global-consistency Spring 2007 ICS 275 A - Constraint Networks 27

Revise-i l l Complexity: for binary constraints For arbitrary constraints: Spring 2007 ICS 275

Revise-i l l Complexity: for binary constraints For arbitrary constraints: Spring 2007 ICS 275 A - Constraint Networks 28

4 -queen example Spring 2007 ICS 275 A - Constraint Networks 29

4 -queen example Spring 2007 ICS 275 A - Constraint Networks 29

I-consistency Spring 2007 ICS 275 A - Constraint Networks 30

I-consistency Spring 2007 ICS 275 A - Constraint Networks 30

Arc-consistency for non-binary constraints: Generalized arc-consistency Complexity: O(t k), t bounds number of tuples.

Arc-consistency for non-binary constraints: Generalized arc-consistency Complexity: O(t k), t bounds number of tuples. Relational arc-consistency: Spring 2007 ICS 275 A - Constraint Networks 32

Examples of generalized arc-consistency x+y+z <= 15 and z >= 13 implies x<=2, y<=2

Examples of generalized arc-consistency x+y+z <= 15 and z >= 13 implies x<=2, y<=2 l l Example of relational arc-consistency Spring 2007 ICS 275 A - Constraint Networks 33

More arc-based consistency l Global constraints: e. g. , all-different constraints • Special semantic

More arc-based consistency l Global constraints: e. g. , all-different constraints • Special semantic constraints that appears often in practice and a specialized constraint propagation. Used in constraint programming. l Bounds-consistency: pruning the boundaries of domains Spring 2007 ICS 275 A - Constraint Networks 34

Example for alldiff l l l A = {3, 4, 5, 6} B =

Example for alldiff l l l A = {3, 4, 5, 6} B = {3, 4} C= {2, 3, 4, 5} D= {2, 3, 4} E = {3, 4} Alldiff (A, B, C, D, E} Arc-consistency does nothing Apply GAC to sol(A, B, C, D, E)? A = {6}, F = {1}…. Alg: bipartite matching kn^1. 5 (Lopez-Ortiz, et. Al, IJCAI-03 pp 245 (A fast and simple algorithm for bounds consistency of alldifferent constraint) Spring 2007 ICS 275 A - Constraint Networks 37

Global constraints l l Alldifferent Sum constraint (variable equal the sum of others) Global

Global constraints l l Alldifferent Sum constraint (variable equal the sum of others) Global cardinality constraint (a value can be assigned a bounded number of times to a set of variables) The cummulative constraint (related to scheduling tasks) Spring 2007 ICS 275 A - Constraint Networks 38

Bounds consistency Spring 2007 ICS 275 A - Constraint Networks 39

Bounds consistency Spring 2007 ICS 275 A - Constraint Networks 39

Bounds consistency for Alldifferent constraints Spring 2007 ICS 275 A - Constraint Networks 40

Bounds consistency for Alldifferent constraints Spring 2007 ICS 275 A - Constraint Networks 40

Boolean constraint propagation l l (A V ~B) and (B) • B is arc-consistent

Boolean constraint propagation l l (A V ~B) and (B) • B is arc-consistent relative to A but not vice-versa Arc-consistency by resolution: res((A V ~B), B) = A Given also (B V C), path-consistency: Res((A V ~B), (B V C) = (A V C) What will generalized arc-consistency can do to cnfs? Relational arc-consistency rule = unit-resolution Spring 2007 ICS 275 A - Constraint Networks 41

Boolean constraint propagation Example: party problem l l l If Alex goes, then Becky

Boolean constraint propagation Example: party problem l l l If Alex goes, then Becky goes: If Chris goes, then Alex goes: Query: Is it possible that Chris goes to the party but Becky does not? Spring 2007 ICS 275 A - Constraint Networks 42

Gausian and Boolean propagation l Linear inequalities l Boolean constraint propagation Spring 2007 ICS

Gausian and Boolean propagation l Linear inequalities l Boolean constraint propagation Spring 2007 ICS 275 A - Constraint Networks 43

Constraint propagation for Boolean constraints: Unit propagation Spring 2007 ICS 275 A - Constraint

Constraint propagation for Boolean constraints: Unit propagation Spring 2007 ICS 275 A - Constraint Networks 44

Consistency for numeric constraints Spring 2007 ICS 275 A - Constraint Networks 47

Consistency for numeric constraints Spring 2007 ICS 275 A - Constraint Networks 47

Tractable classes Spring 2007 ICS 275 A - Constraint Networks 48

Tractable classes Spring 2007 ICS 275 A - Constraint Networks 48

Changes in the network graph as a result of arc-consistency, path-consistency and 4 consistency.

Changes in the network graph as a result of arc-consistency, path-consistency and 4 consistency. Spring 2007 ICS 275 A - Constraint Networks 49

Distributed arc-consistency (Constraint propagation) l Implement AC-1 distributedly. l Node x_j sends the message

Distributed arc-consistency (Constraint propagation) l Implement AC-1 distributedly. l Node x_j sends the message to node x_i l Node x_i updates its domain: l Generalized arc-consistency can be implemented distributedly: sending messages between constraints over the dual graph: Spring 2007 ICS 275 A - Constraint Networks 50

Distributed Arc-Consistency • Arc-consistency can be formulated as a distributed algorithm: A B C

Distributed Arc-Consistency • Arc-consistency can be formulated as a distributed algorithm: A B C D F G a Constraint network Spring 2007 ICS 275 A - Constraint Networks 51

Relational Arc-consistency The message that R 2 sends to R 1 is A 1

Relational Arc-consistency The message that R 2 sends to R 1 is A 1 1 2 B 2 3 1 A 2 3 3 1 3 2 R 1 updates its relation and domains and sends messages to neighbors A 1 1 2 2 3 3 Spring 2007 A 1 2 3 B 2 3 1 2 D 3 2 3 1 2 1 ICS 275 A - Constraint Networks B C D F G 1 2 3 2 1 3 52 A C 1 2 3 2 B C F 1 2 3 3 2 1

DRAC on the dual join-graph A 1 2 3 A 1 1 2 2

DRAC on the dual join-graph A 1 2 3 A 1 1 2 2 3 3 B 2 3 1 2 1 A A A 2 AB B AC B A C 5 4 A 1 1 2 2 3 3 Spring 2007 B 2 3 1 2 D 3 2 3 1 2 1 3 A C 1 2 3 2 ABD BCF D 6 F B C F 1 2 3 3 2 1 DFG D F G 1 2 3 2 1 3 ICS 275 A - Constraint Networks 53

Distributed Relational Arc-Consistency l DRAC can be applied to the dual problem of any

Distributed Relational Arc-Consistency l DRAC can be applied to the dual problem of any constraint network: Spring 2007 ICS 275 A - Constraint Networks 54

Iteration 1 B 1 3 A 1 1 2 2 3 3 B 2

Iteration 1 B 1 3 A 1 1 2 2 3 3 B 2 3 1 2 Node 123456 sends messages A 1 2 3 A 1 1 2 2 3 3 B 2 3 1 2 B 1 3 A 1 1 2 2 3 3 B 2 3 1 2 Spring 2007 A 1 1 2 2 3 3 B 2 3 1 2 D 3 2 3 1 2 1 A 1 2 3 A A A 2 A AB 3 A C 1 2 3 2 AC A 1 2 3 C 2 A A B 4 A 1 2 3 A 1 3 1 AB D 1 2 A 1 2 3 B ABD D 6 C 5 BCF F DFG D F G 1 2 3 2 1 3 D 1 2 3 B C F 1 2 3 3 2 1 B 1 2 3 F 1 3 ICS 275 A - Constraint Networks 56 C 2 B 1 2 3 F 1 3

Iteration 1 A 1 2 2 3 B 3 1 A 1 3 1

Iteration 1 A 1 2 2 3 B 3 1 A 1 3 1 A A A 2 AB B AC B A C 5 4 A 1 2 3 3 B 3 3 1 2 D 2 1 3 A C 1 2 3 2 ABD BCF D 6 F DFG B C F 1 2 3 3 2 1 D F G 2 1 3 Spring 2007 ICS 275 A - Constraint Networks 58

Iteration 2 B 1 3 B 1 2 3 A 1 2 2 3

Iteration 2 B 1 3 B 1 2 3 A 1 2 2 3 B 3 1 A 1 3 A 1 2 3 A 1 3 1 A A A 2 AB B B 1 3 A 1 2 3 3 B 3 3 1 2 D 2 1 3 AC B A A C 1 2 3 2 C 2 A 1 3 C 5 4 D 2 A 1 2 3 ABD BCF D 6 F DFG D F 1 1 2 3 ICS 275 A - Constraint Networks B C F 1 2 3 3 2 1 B 1 3 D F G 2 1 3 Spring 2007 59 C 2 F 1

Iteration 2 A 1 3 A B 1 3 3 1 1 A A

Iteration 2 A 1 3 A B 1 3 3 1 1 A A A 2 AB B AC B A C 5 4 A B D 1 3 2 3 1 2 3 A C 1 2 3 2 ABD BCF D 6 B C F 3 2 1 F DFG D F G 2 1 3 Spring 2007 ICS 275 A - Constraint Networks 60

Iteration 3 B 1 3 A B 1 3 3 1 A 1 3

Iteration 3 B 1 3 A B 1 3 3 1 A 1 3 1 A A A 2 AB B 3 AC B A B 1 3 A B D 1 3 2 3 1 2 5 ABD BCF D 6 F DFG D F G 2 1 3 Spring 2007 C 2 A 1 3 C 4 D 2 A C 1 2 3 2 D 2 B C F 3 2 1 B 1 3 F 1 ICS 275 A - Constraint Networks 61 C 2 F 1

Iteration 3 A 1 3 A B 1 3 1 A A A 2

Iteration 3 A 1 3 A B 1 3 1 A A A 2 AB B AC B A C 5 4 A B D 1 3 2 3 1 2 3 A C 1 2 3 2 ABD BCF D 6 B C F 3 2 1 F DFG D F G 2 1 3 Spring 2007 ICS 275 A - Constraint Networks 62

Iteration 4 B 3 B 1 3 A 1 3 A 1 3 1

Iteration 4 B 3 B 1 3 A 1 3 A 1 3 1 A A A 2 AB B 3 AC B A B 1 3 A B D 1 3 2 3 1 2 5 ABD BCF D 6 B C F 3 2 1 B 3 F DFG D F G 2 1 3 Spring 2007 C 2 A 1 3 C 4 D 2 A C 1 2 3 2 D 2 F 1 ICS 275 A - Constraint Networks 63 C 2 F 1

Iteration 4 A 1 A B 1 3 1 A A A 2 AB

Iteration 4 A 1 A B 1 3 1 A A A 2 AB B AC B A C 5 4 A B D 1 3 2 3 A C 1 2 3 2 ABD BCF D 6 B C F 3 2 1 F DFG D F G 2 1 3 Spring 2007 ICS 275 A - Constraint Networks 64

Iteration 5 B 3 A 1 A B 1 3 A 1 A 1

Iteration 5 B 3 A 1 A B 1 3 A 1 A 1 1 A A A 2 AB B 3 AC B A B 3 A 1 A B D 1 3 2 C 2 A 1 C 5 4 D 2 A C 1 2 3 2 ABD BCF D 6 B C F 3 2 1 B 3 F DFG D F G 2 1 3 Spring 2007 D 2 F 1 ICS 275 A - Constraint Networks 65 C 2 F 1

Iteration 5 A 1 A B 1 3 1 A A A 2 AB

Iteration 5 A 1 A B 1 3 1 A A A 2 AB B AC B A C 5 4 A B D 1 3 2 3 A C 1 2 ABD BCF D 6 B C F 3 2 1 F DFG D F G 2 1 3 Spring 2007 ICS 275 A - Constraint Networks 66