constraint satisfaction
play

Constraint Satisfaction Search techniques make choices in an often - PDF document

What we will try to do ... Constraint Satisfaction Search techniques make choices in an often Problems (CSP) arbitrary order. Often little information is available to make each of them (Where we postpone making difficult decisions until


  1. What we will try to do ... Constraint Satisfaction � Search techniques make choices in an often Problems (CSP) arbitrary order. Often little information is available to make each of them (Where we postpone making difficult decisions until they become easy to make) decisions until they become easy to make) � In many problems, the same states can be y p , reached independent of the order in which choices are made (“commutative” actions) R&N: Chap. 5 � Can we solve such problems more efficiently by picking the order appropriately? Can we even avoid making any choice? 1 2 Constraint Propagation Constraint Propagation 5 5 5 5 5 6 7 6 6 5 5 5 5 6 � Place a queen in a square � Count the number of non-attacked squares in every row and column � Remove the attacked squares from future consideration � Place a queen in a row or column with minimum number � Remove the attacked squares from future consideration 3 4 Constraint Propagation Constraint Propagation 4 3 3 3 4 5 3 3 3 4 3 3 4 4 4 3 3 2 3 3 5 4 � Repeat 5 6 1

  2. Constraint Propagation Constraint Propagation 3 3 3 1 2 2 1 4 2 2 2 2 1 3 1 7 8 Constraint Propagation Constraint Propagation 1 2 1 2 1 1 9 10 Constraint Propagation What do we need? � More than just a successor function and a goal test � We also need: • A means to propagate the constraints imposed by • A means to propagate the constraints imposed by one queen’s position on the positions of the other queens • An early failure test � Explicit representation of constraints � Constraint propagation algorithms 11 12 2

  3. Constraint Satisfaction Problem (CSP) Map Coloring � Set of variables {X 1 , X 2 , …, X n } NT NT Q Q � Each variable X i has a domain D i of WA WA possible values. Usually, D i is finite SA SA NSW NSW V V � Set of constraints {C 1 C 2 Set of constraints {C 1 , C 2 , …, C p } C p } T T � Each constraint relates a subset of � 7 variables {WA,NT,SA,Q,NSW,V,T} variables by specifying the valid � Each variable has the same domain: combinations of their values {red, green, blue} � Goal: Assign a value to every variable such � No two adjacent variables have the same value: that all constraints are satisfied WA ≠ NT, WA ≠ SA, NT ≠ SA, NT ≠ Q, SA ≠ Q, SA ≠ NSW, SA ≠ V, Q ≠ NSW, NSW ≠ V 13 14 8-Queen Problem Street Puzzle 1 2 3 4 5 � 8 variables X i , i = 1 to 8 N i = {English, Spaniard, Japanese, Italian, Norwegian} C i = {Red, Green, White, Yellow, Blue} � The domain of each variable is: {1,2,…,8} D i = {Tea, Coffee, Milk, Fruit-juice, Water} J i = {Painter, Sculptor, Diplomat, Violinist, Doctor} � Constraints are of the forms: A i = {Dog, Snails, Fox, Horse, Zebra} Who owns the Zebra? Who owns the Zebra? The Englishman lives in the Red house • X i = k � X j ≠ k for all j = 1 to 8, j ≠ i The Spaniard has a Dog Who drinks Water? The Japanese is a Painter The Italian drinks Tea • Similar constraints for diagonals The Norwegian lives in the first house on the left The owner of the Green house drinks Coffee The Green house is on the right of the White house All constraints are binary 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 The Horse is next to the Diplomat’s 15 16 Street Puzzle Street Puzzle 1 2 3 4 5 1 2 3 4 5 N i = {English, Spaniard, Japanese, Italian, Norwegian} N i = {English, Spaniard, Japanese, Italian, Norwegian} C i = {Red, Green, White, Yellow, Blue} C i = {Red, Green, White, Yellow, Blue} D i = {Tea, Coffee, Milk, Fruit-juice, Water} D i = {Tea, Coffee, Milk, Fruit-juice, Water} J i = {Painter, Sculptor, Diplomat, Violinist, Doctor} J i = {Painter, Sculptor, Diplomat, Violinist, Doctor} A i = {Dog, Snails, Fox, Horse, Zebra} A i = {Dog, Snails, Fox, Horse, Zebra} ∀ i,j ∈ [1,5], i ≠ j, N i ≠ N j (N i = English) ⇔ (C i = Red) The Englishman lives in the Red house The Englishman lives in the Red house ∀ i j ∈ [1 5] i ≠ j C ≠ C ∀ i,j ∈ [1,5], i ≠ j, C i ≠ C j The Spaniard has a Dog The Spaniard has a Dog ... (N i = Japanese) ⇔ (J i = Painter) The Japanese is a Painter The Japanese is a Painter The Italian drinks Tea The Italian drinks Tea (N 1 = Norwegian) The Norwegian lives in the first house on the left The Norwegian lives in the first house on the left The owner of the Green house drinks Coffee The owner of the Green house drinks Coffee The Green house is on the right of the White house The Green house is on the right of the White house The Sculptor breeds Snails The Sculptor breeds Snails (C i = White) ⇔ (C i+1 = Green) The Diplomat lives in the Yellow house The Diplomat lives in the Yellow house The owner of the middle house drinks Milk The owner of the middle house drinks Milk (C 5 ≠ White) The Norwegian lives next door to the Blue house The Norwegian lives next door to the Blue house (C 1 ≠ Green) The Violinist drinks Fruit juice The Violinist drinks Fruit juice The Fox is in the house next to the Doctor’s The Fox is in the house next to the Doctor’s left as an exercise The Horse is next to the Diplomat’s 17 The Horse is next to the Diplomat’s 18 3

  4. Street Puzzle Street Puzzle 2 2 1 3 4 5 1 3 4 5 N i = {English, Spaniard, Japanese, Italian, Norwegian} N i = {English, Spaniard, Japanese, Italian, Norwegian} C i = {Red, Green, White, Yellow, Blue} C i = {Red, Green, White, Yellow, Blue} D i = {Tea, Coffee, Milk, Fruit-juice, Water} D i = {Tea, Coffee, Milk, Fruit-juice, Water} J i = {Painter, Sculptor, Diplomat, Violinist, Doctor} J i = {Painter, Sculptor, Diplomat, Violinist, Doctor} A i = {Dog, Snails, Fox, Horse, Zebra} A i = {Dog, Snails, Fox, Horse, Zebra} (N i = English) ⇔ (C i = Red) The Englishman lives in the Red house The Englishman lives in the Red house The Spaniard has a Dog The Spaniard has a Dog (N i = Japanese) ⇔ (J i = Painter) The Japanese is a Painter The Japanese is a Painter The Italian drinks Tea The Italian drinks Tea (N 1 = Norwegian) The Norwegian lives in the first house on the left The Norwegian lives in the first house on the left � N 1 = Norwegian The owner of the Green house drinks Coffee The owner of the Green house drinks Coffee The Green house is on the right of the White house The Green house is on the right of the White house The Sculptor breeds Snails The Sculptor breeds Snails (C i = White) ⇔ (C i+1 = Green) The Diplomat lives in the Yellow house The Diplomat lives in the Yellow house (C 5 ≠ White) The owner of the middle house drinks Milk The owner of the middle house drinks Milk � D 3 = Milk The Norwegian lives next door to the Blue house The Norwegian lives next door to the Blue house (C 1 ≠ Green) The Violinist drinks Fruit juice The Violinist drinks Fruit juice The Fox is in the house next to the Doctor’s The Fox is in the house next to the Doctor’s unary constraints The Horse is next to the Diplomat’s The Horse is next to the Diplomat’s 19 20 Street Puzzle Task Scheduling T 1 1 2 3 4 5 N i = {English, Spaniard, Japanese, Italian, Norwegian} T 2 T 4 C i = {Red, Green, White, Yellow, Blue} D i = {Tea, Coffee, Milk, Fruit-juice, Water} J i = {Painter, Sculptor, Diplomat, Violinist, Doctor} T 3 A i = {Dog, Snails, Fox, Horse, Zebra} Four tasks T 1 , T 2 , T 3 , and T 4 are related by time constraints: The Englishman lives in the Red house � C 1 ≠ Red • T 1 must be done during T 3 T st b d d i T The Spaniard has a Dog � A 1 ≠ Dog The Japanese is a Painter • T 2 must be achieved before T 1 starts The Italian drinks Tea • T 2 must overlap with T 3 The Norwegian lives in the first house on the left � N 1 = Norwegian The owner of the Green house drinks Coffee • T 4 must start after T 1 is complete The Green house is on the right of the White house The Sculptor breeds Snails � Are the constraints compatible? The Diplomat lives in the Yellow house � What are the possible time relations between two tasks? The owner of the middle house drinks Milk � D 3 = Milk The Norwegian lives next door to the Blue house � What if the tasks use resources in limited supply? The Violinist drinks Fruit juice � J 3 ≠ Violinist The Fox is in the house next to the Doctor’s How to formulate this problem as a CSP? The Horse is next to the Diplomat’s 21 22 3-SAT Finite vs. Infinite CSP � n Boolean variables u 1 , ..., u n � Finite CSP: each variable has a finite domain of values � p constraints of the form � Infinite CSP: some or all variables have u i ∨ u j ∨ u k = 1 u * ∨ u * ∨ u k *= 1 an infinite domain an infinite domain where u* stands for either u or ¬ u E.g., linear programming problems over the reals: � Known to be NP-complete for i = 1, 2, ..., p : a x +a x +...+a x = a i,n n i,1 1 i,2 2 i,0 for j = 1, 2, ..., q : b x +b x +...+b x b ≤ j,1 1 j,2 2 j,n n j,0 � We will only consider finite CSP 23 24 4

Recommend


More recommend