constraint t networks
play

Constraint t Networks ( slides courtesy o ( y of Natalia - PowerPoint PPT Presentation

Constraint t Networks ( slides courtesy o ( y of Natalia Flerova, based on slides court tesy of Rina Dechter) Read ding Russell and Norvig Chapter 6 (3 rd ed.); Cha 6 (3 rd d ) Ch apter 5 (2 nd ed.) 5 (2 nd d ) Ch t t For next week:


  1. Constraint t Networks ( slides courtesy o ( y of Natalia Flerova, based on slides court tesy of Rina Dechter)

  2. Read ding Russell and Norvig Chapter 6 (3 rd ed.); Cha 6 (3 rd d ) Ch apter 5 (2 nd ed.) 5 (2 nd d ) Ch t t For next week: Ch Chapter 7 (for Tuesday) t 7 (f T d ) ) Chapter 8 (for Thursday y)

  3. Good source Good source e of advanced e of advanced inform mation Rina Dechter, Constraint Processing , g , Morgan Kaufmann 3

  4. Out tline  Constraint Satisfaction Pro oblems (CSPs): Definition and simple mod Definition, and simple mod deling examples deling examples   Representing constraints  Consistency algorithms (ar C i l i h ( rc-, path- and i-consistency) h d i i )  General search strategy Look-ahead meth hods  4

  5. Constra aint Satisfaction Example : map coloring Variables - countries (A A,B,C,etc.) Values - colors (e.g., r red, green, black) Constraints: A ≠ B, A ≠ D, D ≠ E , etc. E A B A red green D D red black green red B green black F bl black k green black red G C

  6. Constraint Netw work; Definition A constraint network is: R = (X,D,C C)  X = { X { X X 1 , ... ,X n } X } X X 1  X variables  D domains D = { D D 1 , ... , D n } , D i = { v 1 , ... v k }  C constraints  C constraints C = { C 1 , ... C t } ,,, C i = � S i ,R i �  R expresses allowed tuples over scopes s A solution is an assignment to all vari ables that satisfies all constraints (join of  all relations). Tasks: consistency?, one or all solutio i t ? ll l ti ons, counting, optimization ti ti i ti T k  6

  7. Example: The N-queens problem The network has four variables, all w with domains Di = {1, 2, 3, 4}. (a) The labeled chess board. (b) The c constraints between variables. Sp ring 2009 7

  8. Example The 4 p 4-queen problem q p Standard CSP formulation of the problem: Place 4 Queens on a chess board of 4x4 • Variables : each row is a variable. such that no two queens reside in the same row, column or diagonal. 1 2 3 4 1 2 3 4 Q Q Q X 1 Q Q Q Q Q Q X 2 2 Q Q Q X 3 Q Q Q X 4 D i = { 1,2,3,4 } . { 1 2 3 4 } D • Domains : 4 ( ) • Constraints : There are = 6 constr raints involved: 2 2 • Constraint Graph : R 12 = {� 1,3 � � 1,4 � � 2,4 � � 3,1 � � 4,1 � � 4,2 � } X 1 R 13 = {� 1,2 � � 1,4 � � 2,1 � � 2,3 � � 3,2 � � 3,4 � � 4,1 � � 4,3 � 4 } X 3 R 14 = {� R = {� 1 2 � 1,2 � � � 1 3 � 1,3 � � � 2,1 � 2 1 � � � 2,3 � 2 3 � � � 2 4 � 2,4 � � � 3,1 � 3 1 � � � 3 2 � 3,2 � � � � � 3 3 4 � 3,4 � 3 � � 4 2 � 4,2 � � � 4,3 � 4 3 � } } R 23 = {� 1,3 � � 1,4 � � 2,4 � � 3,1 � � 4,1 � � 4,2 � } X 2 X 4 R 24 = {� 1,2 � � 1,4 � � 2,1 � � 2,3 � � 3,2 � � 3,4 � � 4,1 � � � 4,3 � 4 } R 34 = {� {� 1 3 � 1,3 � � � 1 4 � 1,4 � � � 2 4 � 2,4 � � � 3,1 � 3 1 � � � 4 1 � 4,1 � � � 4 2 � 4,2 � } } R

  9. A solution and a p A solution and a p partial consistent partial consistent tup ple Not all consistent instantiations are part o of a solution: (a)A consistent instantiation that is not pa art of a solution. (b) Th (b) The placement of the queens correspon l t f th nding to the di t th solution (2, 4, 1,3). c) The placement of the queens correspon nding to the solution (3, 1, 4, 2). Sp ring 2009 9

  10. Example: configu uration and design Sp ring 2009 10

  11. Configuratio on and design Want to build: recreation area, apartm ments, houses, cemetery,  dump  Recreation area near lake  Steep slopes avoided except for recreation a area  Poor soil avoided for developments P il id d f d l t  Highway far from apartments, houses and r recreation  Dump not visible from apartments, houses and lake  Lots 3 and 4 have poor soil  Lots 3 and 4 have poor soil  Lots 3, 4, 7, 8 are on steep slopes  Lots 2, 3, 4 are near lake  Lots 1, 2 are near highway g y Sp ring 2009 11

  12. Out tline  CSP: Definition, and simp ple modeling examples  Representing constraints Representing constraints  Consistency algorithms (ar rc-, path- and i-consistency)  General search strategy Look-ahead meth hods  12

  13. Constraint’s re epresentations X Y Z 1 3 2  Relation: allowed tuples p 2 1 3  Algebraic expression: X � Y 2 ≤ 10 , X ≠ Y Y 2 10 X ≠ Y X X X  Propositional formula: � � b � � a � b � � ¬ c � Sp ring 2009 13

  14. Operations w with relations  Intersection  Union U i  Difference  Selection  Projection j  Join  Composition Composition 14

  15. Figure 1.8: Example of set operation ns intersection, union, and difference applied to o relations. Sp ring 2009 15

  16. selection, projection, and jo oin operations on relations. Sp ring 2009 16

  17. Constrain nt Graphs: Primal, Dual an nd Hypergraphs A (primal) constraint graph: a node per variable  arcs connect constrained variables. t t i d i bl  A dual constraint graph: a node per constraint’s sc cope, an  arc connect nodes sharing variables =hypergraph 2 1 4 3 12 12,13 1,2,3,4,5 3,6,9,12 3 5 6 5 9 13 7 11 9 5,7,11 8,9,10,11 12 11 10 10,13 8 10 13 (b) Sp ring 2009 17 (a)

  18. Out tline  CSP: Definition, and simp ple modeling examples  Representing constraints Representing constraints  Consistency algorithms (ar rc-, path- and i-consistency)  General search strategy Look-ahead meth hods  18

  19. Consistenc cy methods  Constraint propagation n – inferring new constraints constraints  Can get such an explic it network that the search will find the solution w ill fi d th l ti without dead-ends. ith t d d d  Approximation of infer rence:  Arc, path and i-consiste ency  Methods that transform m the original network into a tighter and tighte er representations 19

  20. Arc-cons Arc-cons sistency sistency - infer constraints based on p pairs of variables X Y  1, 2, 3 1, 2, 3 1  X, Y, Z, T  3 1  X Y Z T  3 X  Y  Y = Z = T  Z T  Z X  T 1, , 2, , 3 1, , 2, , 3   T Z Insures that every legal value in the dom main of a single variable has a legal match In the domain of any othe er selected variable 20

  21. Arc-con nsistency i t X Y  1 3 1  X, Y, Z, T  3 1  X Y Z T  3 X  Y  Y = Z = T  Z T  Z X  T 2 3   T Z 21

  22. 22 nsistency Arc-con i t

  23. Revise for arc c-consistency 23 D � D ∩ D i � D i ∩ π i � � R R R � D � R ij � D j �

  24. AC AC C-1 C-1 Complexity ( Mackworth and Freuder, 1986 ): enk 3 � O �  e = number of arcs, n variables, k values s  (ek^2, each loop, nk number of loops), best t-case = ek,  Arc-consistency is: ek 2 �  � � 24

  25. AC AC C-3 C-3 ek 3 � O � Complexity:  25 Best case O(ek), since each arc may Best case O(ek) since each arc may be processed in O(2k) be processed in O(2k)   e = number of arcs, n variables, k valu ues 

  26. Distributed ar Distributed ar rc-consistency rc-consistency (Constraint p propagation) Implement AC-1 distributedly.  D i � D i ∩ π i � R ij � D j � Node x j sends the message to node _j g  x_i j � π i � R ij � D j � h i Node x_i updates its domain:  D i � D i ∩ π i � R ij � D j � = D ∩ h j j D i � D i ∩ h i D Messages can be sent  asynchronously or scheduled in a topological order 26

  27. Distributed Ar rc-Consistency  Arc-consistency can be A i b formulated as a distributed f l d di ib d algorithm: A B C D F G 27 a Constraint network a Constraint network

  28. Relational Ar rc-consistency R 1 A A B 1 1 2 R 2 R 3 2 1 3 3 3 A A 2 1 A C The message that R2 sends to R1 is 2 3 1 2 B C 3 2 3 1 3 3 2 2 R1 updates its relation and domains and send ds R 5 messages to neighbors B C B C F F D D F F R 4 1 2 3 A B D 3 2 1 G 1 2 3 1 1 3 3 2 2 R 6 2 1 3 D F G 2 3 1 1 2 3 3 1 2 28 2 2 1 1 3 3 3 2 1

  29. R 1 1 the dual join-graph DRAC on A A 1 2 R 2 3 A B R R 3 1 1 2 2 1 1 1 3 A C A 2 1 1 2 A A 3 2 2 3 3 2 3 1 AB AC 3 2 B A C B R 5 R 4 4 5 5 4 4 B C F A B D ABD BCF 1 2 3 1 2 3 6 3 2 1 1 3 2 F D 2 2 1 1 3 3 DFG DFG 2 3 1 R 6 3 1 2 D F G 3 2 1 29 1 1 2 2 3 3 2 1 3

  30. Sud doku – Constraint t Satisfaction f • Variables: empty slots • Constraint • Domains = • Propagation P ti { 1,2,3,4,5,6,7,8,9} • Constraints: • I nference 27 all-different  2 3 2 4 6 Each row, column and major blo ock must be alldifferent 30 “Well posed” if it has unique solu ution: 27 constraints

  31. 31 Path-consistency

  32. 32 Path-consistency

  33. Revi Revi ise-3 ise-3  Complexity: O(k^3)  Best-case: O(t)  Worst-case O(tk) e = number of arcs, n variables, k valu e number of arcs, n variables, k valu ues, t = tightness: number of tuples in the ues, t tightness: number of tuples in the 33  constraint relation

Recommend


More recommend