constraint satisf action
play

Constraint Satisf action CS 486/ 686 May 17, 2005 Universit y of - PowerPoint PPT Presentation

Constraint Satisf action CS 486/ 686 May 17, 2005 Universit y of Wat erloo 1 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart Outline What are CSPs? St andard search and CSPs I mprovement s Backt r acking


  1. Constraint Satisf action CS 486/ 686 May 17, 2005 Universit y of Wat erloo 1 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  2. Outline • What are CSPs? • St andard search and CSPs • I mprovement s – Backt r acking – Backt r acking + heurist ics – Forward checking 2 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  3. I ntroduction • I n t he last couple of lect ures we have been solving problems by searching in a space of st at es – Treat ing st at es as black boxes, ignoring any st ruct ure inside t hem – Using pr oblem-specif ic rout ines • Today we st udy problems where t he st at e st ruct ure is import ant 3 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  4. • States: all arrangement s of 0,1,… , or 8 queens on t he board • I nitial state: 0 queens on t he boar d • Successor f unction: Add a queen t o t he board • Goal test: 8 queens on t he board wit h no t wo of t hem at t acking each ot her 57 ≈ 3x10 14 st at es 64x63x… 4 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  5. • States: all arrangement s k queens (0 ≤ k ≤ 8), one per column in t he lef t most k columns, wit h no queen at t acking anot her • I nitial state: 0 queens on t he boar d • Successor f unction : Add a queen t o t he lef t most empt y column such t hat it is not at t acked • Goal test: 8 queens on t he board 2057 St at es 5 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  6. I ntroduction • Earlier search met hods st udied of t en make choices in an arbit rary order • I n many problems t he same st at e can be reached independent of t he order in which t he moves are chosen (commut at ive act ions) • Can we solve problems ef f icient ly by being smart in t he order in which we t ake act ions? 6 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  7. 4- queens Constraint Propagation Place a queen in a squar e Remove conf lict ing squares f rom consider at ion 7 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  8. 4- queens Constraint Propagation Place a queen in a squar e Remove conf lict ing squares f rom consider at ion 8 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  9. 4- queens Constraint Propagation Place a queen in a squar e Remove conf lict ing squares f rom consider at ion 9 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  10. 4- queens Constraint Propagation Place a queen in a squar e Remove conf lict ing squares f rom consider at ion 10 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  11. CSP Def inition • A const raint sat isf act ion problem (CSP) is def ined by {V,D,C} where – V ={V 1 ,V 2 ,… ,V n } is a set of variables – D={D 1 ,… ,D n } is t he set of domains, D i is t he domain of possible values f or variable V i – C={C 1 ,… ,C m } is t he set of const raint s • Each const raint involves some subset of t he variables and specif ies t he allowable combinat ions of values f or t hat subset 11 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  12. CSP Def inition • A st at e is an assignment of values t o some or all of t he variables – {V i =x i , V j =x j ,… } • An assignment is consist ent if it does not violat e any const r aint s • A solut ion is a complet e, consist ent assignment (“hard const raint s”) – Some CSPs also require an obj ect ive f unct ion t o be opt imized (“sof t const raint s”) 12 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  13. Example 1: 8- Queens • 64 variables V ij , i=1 t o 8, j =1 t o 8 • Domain of each variable is {0,1} • Const raint s – V ij =1 � V ik =0 f or all k ≠ j – V ij =1 � V kj =0 f or all k ≠ i – Similar const raint f or diagonals – ∑ i,j V ij =8 Binary const raint s relat e t wo variables 13 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  14. Example 2 – 8 queens • 8 variables V i , i=1 t o 8 • Domain of each variable is {1,2,… ,8} • Const raint s – V i =k � V j ≠ k f or all j ≠ i – Similar const raint s f or diagonals Binary const raint s relat e t wo variables 14 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  15. Example 3 - Map Coloring NT NT NT Q Q Q WA WA WA T SA SA NSW NSW NSW SA V V V Const raint graph T T � 7 var iables {WA,NT,SA,Q,NSW,V,T} � Each variable has t he same domain: {red, green, blue} � No t wo adj acent variables have t he same value: WA ≠ ≠ ≠ ≠ NT, WA ≠ ≠ ≠ ≠ SA, NT ≠ ≠ ≠ SA, NT ≠ ≠ ≠ ≠ ≠ Q, SA ≠ ≠ ≠ ≠ Q, SA ≠ ≠ NSW, SA ≠ ≠ V,Q ≠ ≠ NSW, NSW ≠ ≠ V ≠ ≠ ≠ ≠ ≠ ≠ ≠ ≠ 15 CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  16. Example from R and N, Annotations from Stanford CS 1 2 1 Example 4 - St reet Puzzle 2 1 3 4 5 N i = {English, Spaniard, Japanese, I talian, Norwegian} C i = {Red, Green, White, Yellow, Blue} D i = {Tea, Cof f ee, Milk, Fruit- juice, Water} J i = {Painter, Sculptor, Diplomat, Violinist, Doctor} A i = {Dog, Snails, Fox, Horse, Zebra} The Englishman lives in the Red house Who owns t he Zebra? Who owns t he Zebra? The Spaniard has a Dog Who drinks Wat er? Who drinks Wat er? The Japanese is a Painter The I talian drinks Tea The Norwegian lives in the f irst house on the lef t The owner of the Green house drinks Cof f ee The Green house is on the right of the White house The Sculptor breeds Snails The Diplomat lives in the Yellow house The owner of the middle house drinks Milk The Norwegian lives next door to the Blue house The Violinist drinks Fruit juice The Fox is in the house next to the Doctor’s 16 The Horse is next to the Diplomat’s CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  17. Example from R and N, Annotations from Stanford CS 1 2 1 St reet Puzzle 2 1 3 4 5 N i = {English, Spaniard, Japanese, I talian, Norwegian} C i = {Red, Green, White, Yellow, Blue} D i = {Tea, Cof f ee, Milk, Fruit- juice, Water} J i = {Painter, Sculptor, Diplomat, Violinist, Doctor} A i = {Dog, Snails, Fox, Horse, Zebra} (N i = English) ⇔ (C i = Red) The Englishman lives in the Red house The Spaniard has a Dog (N i = J apanese) ⇔ (J i = Paint er) The Japanese is a Painter The I talian drinks Tea (N 1 = Norwegian) The Norwegian lives in the f irst house on the lef t The owner of the Green house drinks Cof f ee The Green house is on the right of the White house The Sculptor breeds Snails i = Whit e) ⇔ (C (C i+1 = Green) The Diplomat lives in the Yellow house 5 ≠ Whit e) (C The owner of the middle house drinks Milk 1 ≠ Green) The Norwegian lives next door to the Blue house (C The Violinist drinks Fruit juice The Fox is in the house next to the Doctor’s lef t as an exercise 17 The Horse is next to the Diplomat’s CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  18. Example from R and N, Annotations from Stanford CS 1 2 1 St reet Puzzle 2 1 3 4 5 N i = {English, Spaniard, Japanese, I talian, Norwegian} C i = {Red, Green, White, Yellow, Blue} D i = {Tea, Cof f ee, Milk, Fruit- juice, Water} J i = {Painter, Sculptor, Diplomat, Violinist, Doctor} A i = {Dog, Snails, Fox, Horse, Zebra} (N i = English) ⇔ (C i = Red) The Englishman lives in the Red house The Spaniard has a Dog (N i = J apanese) ⇔ (J i = Paint er) The Japanese is a Painter The I talian drinks Tea (N 1 = Norwegian) The Norwegian lives in the f irst house on the lef t The owner of the Green house drinks Cof f ee The Green house is on the right of the White house The Sculptor breeds Snails i = Whit e) ⇔ (C (C i+1 = Green) The Diplomat lives in the Yellow house 5 ≠ Whit e) (C The owner of the middle house drinks Milk 1 ≠ Green) The Norwegian lives next door to the Blue house (C The Violinist drinks Fruit juice The Fox is in the house next to the Doctor’s unary const raint s 18 The Horse is next to the Diplomat’s CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

  19. Example from R and N, Annotations from Stanford CS 1 2 1 St reet Puzzle 2 1 3 4 5 N i = {English, Spaniard, Japanese, I talian, Norwegian} C i = {Red, Green, White, Yellow, Blue} D i = {Tea, Cof f ee, Milk, Fruit- juice, Water} J i = {Painter, Sculptor, Diplomat, Violinist, Doctor} A i = {Dog, Snails, Fox, Horse, Zebra} ∀ i,j ∈ [1,5], i ≠ j , N i ≠ N j ∀ ∀ ∀ The Englishman lives in the Red house ∀ i,j ∈ [1,5], i ≠ j , C ∀ ∀ ∀ i ≠ C The Spaniard has a Dog j ... The Japanese is a Painter The I talian drinks Tea The Norwegian lives in the f irst house on the lef t The owner of the Green house drinks Cof f ee The Green house is on the right of the White house The Sculptor breeds Snails The Diplomat lives in the Yellow house The owner of the middle house drinks Milk The Norwegian lives next door to the Blue house The Violinist drinks Fruit juice The Fox is in the house next to the Doctor’s 19 The Horse is next to the Diplomat’s CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend