solving constraint satisfaction problems arc consistency
play

Solving Constraint Satisfaction Problems: Arc Consistency and - PDF document

Solving Constraint Satisfaction Problems: Arc Consistency and Constraint Propagation Brian Williams 16.410 - 13 September 29 th , 2003 Slides adapted from: 6.034 Tomas Lozano Perez and AIMA Stuart Russell & Peter Norvig 1 1 Outline


  1. Solving Constraint Satisfaction Problems: Arc Consistency and Constraint Propagation Brian Williams 16.410 - 13 September 29 th , 2003 Slides adapted from: 6.034 Tomas Lozano Perez and AIMA Stuart Russell & Peter Norvig 1 1 Outline • Recap: constraint satisfaction problems (CSP) • Solving CSPs • Arc-consistency and propagation • Analysis of constraint propagation • Search 2

  2. Solving CSPs Solving CSPs involves some combination of: 1. Constraint propagation • eliminates values that can’t be part of any solution 2. Search • explores valid assignments 3 Arc Consistency Arc consistency eliminates values of each variable domain that can never satisfy a particular constraint (an arc). V i V j = {1,2,3} {1,2} • Directed arc (V i , V j ) is arc consistent if • For every x in D i , there exists some y in D j such that assignment (x,y) is allowed by constraint C ij • Or ∀ x ∈ D i ∃ y ∈ D j such that (x,y) is allowed by constraint C ij where • ∀ denotes “for all” • ∃ denotes “there exists” • ∈ denotes “in” 4

  3. Arc Consistency Arc consistency eliminates values of each variable domain that can never satisfy a particular constraint (an arc). V i V j = {1,2} {1,2,3} • Directed arc (V i , V j ) is arc consistent if • ∀ x ∈ D i ∃ y ∈ D j such that (x,y) is allowed by constraint C ij Example: Given: Variables V 1 and V 2 with Domain {1,2,3,4} Constraint: {(1, 3) (1, 4) (2, 1)} What is the result of arc consistency? 5 Achieving Arc Consistency via Constraint Propagation Arc consistency eliminates values of each variable domain that can never satisfy a particular constraint (an arc). • Directed arc (V i , V j ) is arc consistent if ∀ x ∈ D i ∃ y ∈ D j such that (x,y) is allowed by constraint C ij Constraint propagation: To achieve arc consistency: • Delete every value from each tail domain D i of each arc that fails this condition, • Repeat until quiescence: • If element deleted from D i then •check directed arc consistency for each arc with head D i • Maintain arcs to be checked on FIFO queue (no duplicates). 6

  4. Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G Each undirected constraint arc denotes two directed constraint arcs. 7 Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R,G,B V 2 V 3 R, G G Arcs to examine V 1 - V 2 , V 1 - V 3 , V 2 - V 3 • Introduce queue of arcs to be examined. • Start by adding all arcs to the queue. 8

  5. Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R,G,B V 1 > V 2 V 2 V 3 R, G G Arcs to examine V 1 < V 2 , V 1 - V 3 , V 2 - V 3 • Delete unmentioned tail values • V i – V j denotes two arcs between V i and V j . • Vi < Vj denotes an arc from V j and V i . 9 Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R,G,B none V 1 > V 2 V 2 V 3 R, G G Arcs to examine V 1 < V 2 , V 1 - V 3 , V 2 - V 3 • Delete unmentioned tail values • V i – V j denotes two arcs between V i and V j . • Vi < Vj denotes an arc from V j and V i . 10

  6. Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R,G,B V 1 > V 2 none V 2 V 3 V 2 > V 1 R, G G Arcs to examine V 1 - V 3 , V 2 - V 3 • Delete unmentioned tail values • V i – V j denotes two arcs between V i and V j . • Vi < Vj denotes an arc from V j and V i . 11 Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R,G,B V 1 > V 2 none V 2 V 3 V 2 > V 1 none R, G G Arcs to examine V 1 - V 3 , V 2 - V 3 • Delete unmentioned tail values • V i – V j denotes two arcs between V i and V j . • Vi < Vj denotes an arc from V j and V i . 12

  7. Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R,G,B V 1 – V 2 none V 2 V 3 R, G G Arcs to examine V 1 - V 3 , V 2 - V 3 • Delete unmentioned tail values • V i – V j denotes two arcs between V i and V j . • Vi < Vj denotes an arc from V j and V i . 13 Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R,G,B V 1 – V 2 none V 2 V 3 V 1 >V 3 R, G G Arcs to examine V 1 < V 3 , V 2 - V 3 • Delete unmentioned tail values • V i – V j denotes two arcs between V i and V j . • Vi < Vj denotes an arc from V j and V i . 14

  8. Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R,G,B V 1 – V 2 none V 2 V 3 V 1 > V 3 V 1 ( G ) R, G G Arcs to examine V 1 < V 3 , V 2 - V 3 IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue. 15 Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R,G,B V 1 – V 2 none V 2 V 3 V 1 > V 3 V 1 ( G ) R, G G Arcs to examine V 1 < V 3 , V 2 - V 3 , V 2 >V 1 , V 1 <V 3 , IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue. 16

  9. Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R, B V 1 – V 2 none V 2 V 3 V 1 > V 3 V 1 ( G ) R, G G V 1 <V 3 Arcs to examine V 2 - V 3 , V 2 > V 1 • Delete unmentioned tail values IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue. 17 Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R, B V 1 – V 2 none V 2 V 3 V 1 > V 3 V 1 ( G ) R, G G V 1 < V 3 none Arcs to examine V 2 - V 3 , V 2 > V 1 • Delete unmentioned tail values IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue. 18

  10. Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R, B V 1 – V 2 none V 2 V 3 V 1 - V 3 V 1 (G) R, G G V 2 >V 3 Arcs to examine V 2 < V 3 , V 2 > V 1 • Delete unmentioned tail values IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue. 19 Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R, B V 1 – V 2 none V 2 V 3 V 1 - V 3 V 1 (G) R, G G V 2 >V 3 V 2 ( G ) Arcs to examine V 2 < V 3 , V 2 > V 1 • Delete unmentioned tail values IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue. 20

  11. Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R, B V 1 – V 2 none V 2 V 3 V 1 - V 3 V 1 (G) R, G G V 2 >V 3 V 2 ( G ) Arcs to examine V 2 < V 3 , V 2 > V 1 , V 1 >V 2 • Delete unmentioned tail values IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue. 21 Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R, B V 1 – V 2 none V 2 V 3 V 1 - V 3 V 1 (G) R G V 2 >V 3 V 2 (G) V 3 > V 2 Arcs to examine V 2 >V 1 , V 1 >V 2 • Delete unmentioned tail values IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue. 22

  12. Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R, B V 1 – V 2 none V 2 V 3 V 1 - V 3 V 1 (G) R G V 2 >V 3 V 2 (G) V 3 > V 2 none Arcs to examine V 2 >V 1 , V 1 >V 2 • Delete unmentioned tail values IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue. 23 Constraint Propagation Example V 1 R,G,B Different-color constraint Graph Coloring V 2 Initial Domains V 3 R, G G V 1 Arc examined Value deleted R, B V 1 – V 2 none V 2 V 3 V 1 - V 3 V 1 (G) R G V 2 -V 3 V 2 (G) V 2 >V 1 Arcs to examine V 1 >V 2 • Delete unmentioned tail values IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue. 24

Recommend


More recommend