Consistency algorithms Chapter 3 Fall 2010 1 Consistency methods - - PowerPoint PPT Presentation

consistency algorithms
SMART_READER_LITE
LIVE PREVIEW

Consistency algorithms Chapter 3 Fall 2010 1 Consistency methods - - PowerPoint PPT Presentation

Consistency algorithms Chapter 3 Fall 2010 1 Consistency methods Approximation of inference: Arc, path and i-consistecy Methods that transform the original network into tighter and tighter representations Fall 2010 2 Arc-consistency X


slide-1
SLIDE 1

1

Consistency algorithms

Chapter 3

Fall 2010

slide-2
SLIDE 2

Fall 2010 2

Consistency methods

Approximation of inference: Arc, path and i-consistecy Methods that transform the original network into tighter and tighter representations

slide-3
SLIDE 3

Fall 2010 3

Arc-consistency

3 2, 1, 3 2, 1, 3 2, 1, 1 X, Y, Z, T 3   X Y  Y = Z T Z  X T  X Y T Z 3 2, 1,

 =  

slide-4
SLIDE 4

Fall 2010 4

1 X, Y, Z, T 3   X Y  Y = Z T Z  X T  X Y T Z

 =  

1 3 2 3

Arc-consistency

slide-5
SLIDE 5

Fall 2010 5

Arc-consistency

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level
slide-6
SLIDE 6

Fall 2010 6

Revise for arc-consistency

) (

j ij i i i

D R D D ⊗ ∩ ← π

slide-7
SLIDE 7

Fall 2010 7

A matching diagram describing a network of constraints that is not arc-consistent (b) An arc- consistent equivalent network.

slide-8
SLIDE 8

Fall 2010 8

AC-1

Complexity (Mackworth and Freuder, 1986): e = number of arcs, n variables, k values

(ek^2, each loop, nk number of loops), best-case = ek, Arc-consistency is: ) (

3

enk O

) (

2

ek Ω

slide-9
SLIDE 9

Fall 2010 9

AC-3

Complexity: since each arc may be processed in O(2k) Best case O(ek),

) (

3

ek O

slide-10
SLIDE 10

Fall 2010 10

Example: A 3 variables network with 2 constraints: z divides x and z divides y (a) before and (b) after AC-3 is applied.

slide-11
SLIDE 11

Fall 2010 11

AC-4

Complexity:

(Counter is the number of supports to ai in xi from xj. S_(xi,ai) is the set

  • f pairs that (xi,ai) supports)

) (

2

ek O

slide-12
SLIDE 12

Fall 2010 12

Example applying AC-4

slide-13
SLIDE 13

Fall 2010 13

Distributed arc-consistency (Constraint propagation)

Implement AC-1 distributedly. Node x_j sends the message to node x_i Node x_i updates its domain: Messages can be sent asynchronously or scheduled in a topological order

) (

j ij i j i

D R h ⊗ ← π

) (

j ij i i i

D R D D ⊗ ∩ ← π

j i i i j ij i i i

h D D D R D D ∩ ← = ⊗ ∩ ← ) ( π

slide-14
SLIDE 14

Fall 2010 14

Exercise: make the following network arc-consistent

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

slide-15
SLIDE 15

Fall 2010 15

Arc-consistency Algorithms

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 (n number of variables, e=#constraints, k=domain size)

Mackworth and Freuder (1977,1983), Mohr and Anderson, (1985)…

) (

3

ek O

) (

3

nek O

) (

2

ek O

slide-16
SLIDE 16

Fall 2010 16

Using constraint tightness in analysis

t = number of tuples bounding a constraint

AC-1: brute-force, AC-3, queue-based AC-4, context-based, optimal AC-5,6,7,…. Good in special cases

Important: applied at every node of search (n number of variables, e=#constraints, k=domain size)

Mackworth and Freuder (1977,1983), Mohr and Anderson, (1985)…

) (ekt O

) (nekt O

) (et O ) (

3

ek O

) (

3

nek O

slide-17
SLIDE 17

17

Constraint checking

Arc-consistency

[ 5.... 18] [ 4.... 15] [ 1.... 10 ] B < C A < B B A 2 < C - A < 5 C 2- A: [ 2 .. 10 ] C: [ 6 .. 14 ] 3- B: [ 5 .. 13 ] C: [ 6 .. 15 ] 1- B: [ 5 .. 14 ]

14 13 6 2 14

Fall 2010

slide-18
SLIDE 18

Fall 2010 18

Is arc-consistency enough?

Example: a triangle graph-coloring with 2 values.

Is it arc-consistent? Is it consistent?

It is not path, or 3-consistent.

slide-19
SLIDE 19

Fall 2010 19

Path-consistency

slide-20
SLIDE 20

Fall 2010 20

Path-consistency

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level
slide-21
SLIDE 21

Fall 2010 21

Revise-3

Complexity: O(k^3) Best-case: O(t) Worst-case O(tk)

) (

kj k ik ij ij ij

R D R R R

⊗ ⊗ ∩ ← π

slide-22
SLIDE 22

Fall 2010 22

PC-1

Complexity:

O(n^3) triplets, each take O(k^3) steps O(n^3 k^3)  Max number of loops: O(n^2 k^2) .

) (

5 5k

n O

slide-23
SLIDE 23

Fall 2010 23

PC-2

Complexity: Optimal PC-4:

(each pair deleted may add: 2n-1 triplets, number of pairs: O(n^2 k^2) size of  Q is O(n^3 k^2), processing is O(k^3))

) (

5 3k

n O

) (

3 3k

n O

slide-24
SLIDE 24

Fall 2010 24

Example: before and after path- consistency

PC-1 requires 2 processings of each arc while PC-2 may not Can we do path-consistency distributedly?

slide-25
SLIDE 25

Fall 2010 25

Example: before and after path- consistency

PC-1 requires 2 processings of each arc while PC-2 may not Can we do path-consistency distributedly?

slide-26
SLIDE 26

Fall 2010 26

Path-consistency Algorithms

Apply Revise-3 (O(k^3)) until no change Path-consistency (3-consistency) adds binary constraints. PC-1: PC-2: PC-4 optimal:

) (

kj k ik ij ij ij

R D R R R ⊗ ⊗ ∩ ← π

) (

5 5k

n O

) (

5 3k

n O

) (

3 3k

n O

slide-27
SLIDE 27

Fall 2010 27

I-consistency

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level
slide-28
SLIDE 28

Fall 2010 28

Higher levels of consistency, global-consistency

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level

Definition:

slide-29
SLIDE 29

Fall 2010 29

Revise-i

Complexity: for binary constraints For arbitrary constraints: ) (

i

k O ) ) 2 ((

i

k O

slide-30
SLIDE 30

Fall 2010 30

4-queen example

slide-31
SLIDE 31

Fall 2010 31

I-consistency

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level
slide-32
SLIDE 32

Fall 2010 32

I-consistency

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level
slide-33
SLIDE 33

Fall 2010 33

Arc-consistency for non-binary constraints:

Generalized arc-consistency

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level

Complexity: O(t k), t bounds number of tuples. Relational arc-consistency: ) (

} {x S S x x x

D R D D

⊗ ∩ ← π

) (

} { } { x S x S x S

D R R ⊗ ←

− −

π

slide-34
SLIDE 34

Fall 2010 34

Examples of generalized arc- consistency

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

B A G G B A ¬ ∨ ¬ ⇒ ¬ → ∧ , ,

slide-35
SLIDE 35

Fall 2010 35

More arc-based consistency

Global constraints: e.g., all-different constraints Special semantic constraints that appears often in practice and a specialized constraint propagation. Used in constraint programming. Bounds-consistency: pruning the boundaries of domains

slide-36
SLIDE 36

Fall 2010 36

Sudoku – Constraint Satisfaction

Each row, column and major block must be alldifferent “Well posed” if it has unique solution: 27 constraints

2 3 4 6

2

  • Variables: empty slots
  • Domains =

{1,2,3,4,5,6,7,8,9}

  • Constraints:
  • 27 all-

different

  • Constraint
  • Propagation
  • Inference
slide-37
SLIDE 37

Fall 2010 37

Example for alldiff

A = {3,4,5,6} B = {3,4} C= {2,3,4,5} D= {2,3,4} E = {3,4} F= {1,2,3,4,5,6} Alldiff (A,B,C,D,E} Arc-consistency does nothing Apply GAC to sol(A,B,C,D,E,F)?  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)

slide-38
SLIDE 38

Fall 2010 38

Global constraints

Alldifferent Sum constraint (variable equal the sum of

  • thers)

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)

slide-39
SLIDE 39

Fall 2010 39

Bounds consistency

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level
slide-40
SLIDE 40

Fall 2010 40

Bounds consistency

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level
slide-41
SLIDE 41

Fall 2010 41

Boolean constraint propagation

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

Relational arc-consistency rule = unit-resolution

B A G G B A ¬ ∨ ¬ ⇒ ¬ → ∧ , ,

slide-42
SLIDE 42

Fall 2010 42

Constraint propagation for Boolean constraints: Unit propagation

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level

Click to edit Master text styles Second level

  • Third level
  • Fourth level
slide-43
SLIDE 43

Example (if there is time)

–– M: The unicorn is mythical – I: The unicorn is immortal – L: The unicorn is mammal – H: The unicorn is horned – G: The unicorn is magical (M → I ) ( ∧ ¬ M → ( ¬ I L)) ((I L) → H) (H → G) ∧ ∧ ∨ ∧ A Logic Puzzle IV

  • Is the unicorn mythical? Is it magical? Is it horned?

(M → I ) ( ∧ ¬ M → ( ¬ I L)) ((I L) → H) (H → G) ∧ ∧ ∨ ∧ ⊢ ( ¬ M I ) (M ( ∨ ∧ ∨ ¬ I L)) ((I L) → H) (H → G) ∧ ∧ ∨ ∧ ⊢ ( ¬ M I ) (M ∨ ∧ ∨ ¬ I ) (M L) ((I L) → H) (H → G) ∧ ∨ ∧ ∨ ∧ ⊢ (I L) ((I L) → H) (H → G) H G ∨ ∧ ∨ ∧ ⊢ ∧

  • Hence, the unicorn is not necessarily mythical, but it is horned and

magical !

Fall 2010 43

slide-44
SLIDE 44

Fall 2010 44

Consistency for numeric constraints (Gausian elimination)

3 , 10 , 7 3 ], 10 , 10 [ 5 , 10 ] 9 , 5 [ ], 5 , 1 [ 10 ], 15 , 5 [ ], 10 , 1 [ − ≥ − − = + − − ≥ − ⇒ − ≤ + − ∈ − ≤ − = + − − ∈ ∈ ⇒ − = + ∈ ∈ z y y x adding by

  • btained

z x y consistenc path z y z y y x adding by y x y consistenc arc y x y x

slide-45
SLIDE 45

Fall 2010 45

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

slide-46
SLIDE 46

Fall 2010 46

Distributed arc-consistency (Constraint propagation)

Implement AC-1 distributedly. Node x_j sends the message to node x_i Node x_i updates its domain:

Relational and generalized arc-consistency can be implemented distributedly: sending messages between constraints over the dual graph

) (

j ij i j i

D R h ⊗ ← π

) (

j ij i i i

D R D D ⊗ ∩ ← π

j i i i

h D D ∩ ←

) (

} { } { x S x S x S

D R R ⊗ ←

− −

π

slide-47
SLIDE 47

Fall 2010 47 A 1 2 3 A C 1 2 3 2 A B 1 2 1 3 2 1 2 3 3 1 3 2 B C F 1 2 3 3 2 1 A B D 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1 D F G 1 2 3 2 1 3

Relational Arc-consistency

A B C D F G

The message that R2 sends to R1 is R1 updates its relation and domains and sends messages to neighbors

1

R

2

R

4

R

3

R

5

R

6

R

slide-48
SLIDE 48

Fall 2010 48

Distributed Relational Arc-Consistency

DRAC can be applied to the dual problem

  • f any constraint network:
slide-49
SLIDE 49

Fall 2010 49 A 1 2 3 A C 1 2 3 2 A B 1 2 1 3 2 1 2 3 3 1 3 2 B C F 1 2 3 3 2 1 A B D 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1 D F G 1 2 3 2 1 3

A AB AC ABD BCF DFG

B

4 5 3 6 2

B D F A A A C

1

DRAC on the dual join-graph

1

R

2

R

4

R

3

R

5

R

6

R

slide-50
SLIDE 50

Fall 2010 50

Node 6 sends messages Node 5 sends messages Node 4 sends messages Node 3 sends messages Node 2 sends messages

A 1 2 3 A C 1 2 3 2 A B 1 2 1 3 2 1 2 3 3 1 3 2 B C F 1 2 3 3 2 1 A B D 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1 D F G 1 2 3 2 1 3 2 1 3 A 2 1 3 A 2 1 3 A 2 1 3 A 1 3 A 1 2 3 2 1 3 2 3 3 2 B 1 1 A 1 3 B 2 1 3 A 1 3 B 1 2 D 1 2 3 2 1 3 2 3 3 2 B 1 1 A 1 3 F 2 1 3 D 2 C 2 1 3 B 2 C 2 1 3 B 1 3 F

Iteration 1

1 3 A 2 1 3 A

Node 1 sends messages

A AB AC ABD BCF DFG

AB

4 5 3 6 2

B D B F A A A A C A

1 3 A 2 1 3 A 1

1

R

2

R

4

R

3

R

5

R

6

R

2 1

h

3 1

h

3 2

h

1 2

h

2 3

h

2 4

h

2 5

h

4 1

h

4 5

h

4 6

h

4 2

h

6 5

h

6 4

h

5 3

h

5 2

h

3 5

h

5 4

h

5 6

h

1 3

h

1 4

h

4 3

h

3 4

h

slide-51
SLIDE 51

Fall 2010 51 A 1 3 A C 1 2 3 2 A B 1 3 2 1 2 3 3 1 B C F 1 2 3 3 2 1 A B D 1 3 2 2 3 1 3 1 2 3 2 1 D F G 2 1 3

A AB AC ABD BCF DFG

B

4 5 3 6 2

B D F A A A C

1

Iteration 1

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level

1

R

2

R

4

R

3

R

5

R

6

R

slide-52
SLIDE 52

Fall 2010 52 A 1 3 A C 1 2 3 2 A B 1 3 2 1 2 3 3 1 B C F 1 2 3 3 2 1 A B D 1 3 2 2 3 1 3 1 2 3 2 1 D F G 2 1 3 A 1 3 A 1 3 A 1 2 3 A 1 3 A 1 3 D 2 F 1 3 D 1 2 C 2 B 1 3 C 2 F 1 A 1 2 3 B 1 3 B 1 2 3

A AB AC ABD BCF DFG

B

4 5 3 6 2

B D F A A A C

1

Iteration 2

1 3 B

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level

2 1

h

3 1

h

1 3

h

1 2

h

1 4

h

3 5

h

2 4

h

2 5

h

4 1

h

4 6

h

4 2

h

6 5

h

6 4

h

5 2

h

5 3

h

5 6

h

1

R

2

R

4

R

3

R

5

R

6

R

slide-53
SLIDE 53

Fall 2010 53 A 1 3 A C 1 2 3 2 A B 1 3 3 1 B C F 3 2 1 A B D 1 3 2 3 1 2 D F G 2 1 3

Iteration 2

A AB AC ABD BCF DFG

B

4 5 3 6 2

B D F A A A C

1

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level

1

R

2

R

4

R

3

R

5

R

6

R

slide-54
SLIDE 54

Fall 2010 54 A 1 3 A 1 3 A 1 3 B 3 A 1 3 D 2 F 1 D 2 C 2 B 1 3 C 2 F 1 A 1 3 A 1 3 A 1 3 A C 1 2 3 2 A B 1 3 3 1 B C F 3 2 1 A B D 1 3 2 3 1 2 D F G 2 1 3 B 1 3 B 1 3

A AB AC ABD BCF DFG

B

4 5 3 6 2

B D F A A A C

1

Iteration 3

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level

2 1

h

3 1

h

1 3

h

1 2

h

1 4

h

3 5

h

2 4

h

2 5

h

4 1

h

4 6

h

4 2

h

6 5

h

6 4

h

5 2

h

5 3

h

5 6

h

1

R

2

R

4

R

3

R

5

R

6

R

slide-55
SLIDE 55

Fall 2010 55 A 1 3 A C 1 2 3 2 A B 1 3 B C F 3 2 1 A B D 1 3 2 3 1 2 D F G 2 1 3

A AB AC ABD BCF DFG

B

4 5 3 6 2

B D F A A A C

1

Iteration 3

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level

1

R

2

R

4

R

3

R

5

R

6

R

slide-56
SLIDE 56

Fall 2010 56 A 1 3 A 1 3 A 1 B 3 A 1 3 D 2 F 1 D 2 C 2 B 3 C 2 F 1 A 1 3 A 1 3 A 1 3 A C 1 2 3 2 A B 1 3 B C F 3 2 1 A B D 1 3 2 3 1 2 D F G 2 1 3 B 1 3 B 1 3

A AB AC ABD BCF DFG

B

4 5 3 6 2

B D F A A A C

1

Iteration 4

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level

2 1

h

3 1

h

1 3

h

1 2

h

1 4

h

3 5

h

2 4

h

2 5

h

4 1

h

4 6

h

4 2

h

6 5

h

6 4

h

5 2

h

5 3

h

5 6

h

1

R

2

R

4

R

3

R

5

R

6

R

slide-57
SLIDE 57

Fall 2010 57 A 1 A C 1 2 3 2 A B 1 3 B C F 3 2 1 A B D 1 3 2 D F G 2 1 3

A AB AC ABD BCF DFG

B

4 5 3 6 2

B D F A A A C

1

Iteration 4

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level

1

R

2

R

4

R

3

R

5

R

6

R

slide-58
SLIDE 58

Fall 2010 58 A 1 A 1 A 1 B 3 B 3 B 3 A 1 D 2 F 1 D 2 C 2 B 3 C 2 F 1 A 1 A 1 A 1 A C 1 2 3 2 A B 1 3 B C F 3 2 1 A B D 1 3 2 D F G 2 1 3

A AB AC ABD BCF DFG

B

4 5 3 6 2

B D F A A A C

1

Iteration 5

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level

2 1

h

3 1

h

1 3

h

1 2

h

1 4

h

3 5

h

2 4

h

2 5

h

4 1

h

4 6

h

4 2

h

6 5

h

6 4

h

5 2

h

5 3

h

5 6

h

1

R

2

R

4

R

3

R

5

R

6

R

slide-59
SLIDE 59

Fall 2010 59 A 1 A C 1 2 A B 1 3 B C F 3 2 1 A B D 1 3 2 D F G 2 1 3

A AB AC ABD BCF DFG

B

4 5 3 6 2

B D F A A A C

1

Iteration 5

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level

1

R

2

R

4

R

3

R

5

R

6

R

slide-60
SLIDE 60

Fall 2010 60

Tractable classes

Click to edit Master text styles Second level

  • Third level
  • Fourth level
  • Fifth level