Presentation is loading. Please wait.

Presentation is loading. Please wait.

Constraint Satisfaction Basics strongly influenced by Rina Dechter, “Constraint Processing”, 2003.

Similar presentations


Presentation on theme: "Constraint Satisfaction Basics strongly influenced by Rina Dechter, “Constraint Processing”, 2003."— Presentation transcript:

1 Constraint Satisfaction Basics strongly influenced by Rina Dechter, “Constraint Processing”, 2003

2 complete search space of a problem  variables V = {v 1, v 2, …., v n }  domains D = {D 1, D 2, …., D n }, v i  D i  search space T = D 1 X D 2 X…. X D n  size of search space |D 1 |. |D 2 |. ….. |D n | if there are no constraints, any solution in T is feasible

3 constraint satisfaction problems  variables V = {v 1, v 2, …., v n }  domains D = {D 1, D 2, …., D n }, v i  D i  constraints C = {C 1, C 2, …., C k } C i is a relation on scope S i  V C i puts constraints on some variables in the problem  search space T = D 1 X D 2 X…. X D n a solution in the search space T whose values violate a constraint is infeasible a constraint satisfaction problem is often called a constraint network

4 example: Sudoku puzzle  variables V = {v 11, v 12, v 13,..., v 99 }  domains D 1 = D 2 = D 3 =... = D 99 = {1,2,3,4,5,6,7,8,9}  constraints: “no repeated values in row, columns or squares; pre-assigned values” C = {C 1, C 2, …., C 810 } C i is a relation on scope S i = {v i1, v i2 } algebraic: { (v i1,v i2 ) | v i1 ≠ v i2 } C j on S j = {v j1 }: { v j1 | v j1 = k } for particular puzzle:

5 example: Sudoku puzzle 4825 534 7●8 59 271 26 89 976 8174 81 variables V i D i = {1,2,3,4,5,6,7,8,9} ∀ i each square is subject to 20 binary constraints of form V i ≠ V j total = 81 * 20 / 2 = 810 a particular game also has ~ 25 constraints of form V i = k

6 describing constraints  scope S i :the set of variables on which a constraint C i is defined  scheme S = {S 1, S 2, …, S k } set of all scopes on which constraints are defined  arity of a constraint C i is size of its scope |S i | unary constraint on one variable binary constraint on two variables n-ary constraint on n variables* *n-ary constraints can be rewritten as (many) binaries

7 simple scheduling problem five tasks to schedule, T1, T2, T3, T4, T5  each lasts one hour  each may start at 1PM, 2PM, 3PM  tasks can be executed simultaneously except: T1 starts after T3 T3 starts before T4 and after T5 T2 cannot be concurrent with T1 or T4 T4 cannot start at 2PM

8 simple scheduling problem five tasks to schedule, T1, T2, T3, T4, T5  variables? domains?  constraints? scopes? arity?

9 constraint graphs  vertices: variables  edges: (binary) variable scopes TSPscheduling problem v1v1 v1v1 v2v2 v2v2 v4v4 v4v4 v3v3 v3v3 T1 T2 T3 T4 T5

10 crossword puzzle (after Dechter) HOSESLASERSHEETSNAIL STEERALSOEARNHIKE IRONSAMEEATLET RUNSUNTENYES MEITNOUS 1 1 2 2 3 3 4 4 5 5 7 7 6 6 8 8 9 9 12 10 11 13

11 crossword puzzle HOSESLASERSHEETSNAIL STEERALSOEARNHIKE IRONSAMEEATLET RUNSUNTENYES MEITNOUS 1 1 2 2 3 3 4 4 5 5 7 7 6 6 8 8 9 9 12 10 11 13 variables: 13 (letters) domains: alphabet constraints: S 1 {1,2,3,4,5} C1 {(H,O,S,E,S), (L,A,S,E,R), (S,H,E,E,T), (S,N,A,I,L), (S,T,E,E,R)}

12 crossword puzzle HOSESLASERSHEETSNAIL STEERALSOEARNHIKE IRONSAMEEATLET RUNSUNTENYES MEITNOUS 1 1 2 2 3 3 4 4 5 5 7 7 6 6 8 8 9 9 12 10 11 13 S 1 {1,2,3,4,5} arity 5 S 2 {3,6,9,12} S 3 {5,7,11} S 4 {8,9,10,11} S 5 {10,13} S 6 {12,13}

13 crossword puzzle HOSESLASERSHEETSNAIL STEERALSOEARNHIKE IRONSAMEEATLET RUNSUNTENYES MEITNOUS 1 1 2 2 3 3 4 4 5 5 7 7 6 6 8 8 9 9 12 10 11 13 partial solution satisfying C 4 and C 5 over S 4  S 5 {8,9,10,11,13} {(S,A,M,E,E)}

14 graphs for arity > 2  hypergraph multiple nodes per “hyperedge” 1 1 2 2 3 3 4 4 5 5 7 7 6 6 8 8 9 9 12 10 11 13

15 graphs for arity > 2  hypergraph 1 1 2 2 3 3 4 4 5 5 7 7 6 6 8 8 9 9 12 10 11 13 1 1 2 2 3 3 4 4 5 5 7 7 6 6 8 8 9 9 12 10 11 13

16 graphs for arity > 2  dual of hypergraph nodes are constraints edges are common variables 1 1 2 2 3 3 4 4 5 5 7 7 6 6 8 8 9 9 12 10 11 13 1,2,3,4,5 5,7,11 3,6,9,12 8,9,10,11 12,13 10,13 3 11 12 10 59 13

17 crossword puzzle another formulation HOSESLASERSHEETSNAIL STEERALSOEARNHIKE IRONSAMEEATLET RUNSUNTENYES MEITNOUS 1 1 2 2 3 3 4 4 5 5 7 7 6 6 8 8 9 9 12 10 11 13 variables: 6: 1 3 5 8 10 12 domains: words by length constraints: crossings S 1 {1,3}S 2 {1,5}S 3 {10,12} S 4 {3,8}S 5 {3,12}S 6 {5,8} S 7 {10,8} all binary constraints

18 binary constraint networks only unary and binary constraints  constraint deduction inferring new constraints from initial set 1.constraints between unconstrained variables 2.tightening of existing constraints

19 constraint deduction example: V = { v 1,v 2,v 3 } D 1 = D 2 = D 3 = { red, green} C 1 : {(v 2,v 1 )|v 2 ≠v 1 } = {(red, green),(green, red)} C 2 : {(v 1,v 3 )|v 1 ≠v 3 } = {(red, green),(green, red)} solutions: {(red, green, green), (green, red, red)} red green red green red green v1v1 v2v2 v3v3

20 constraint deduction example: new constraint network with same solutions --> better for partial solutions (more later) red green red green red green v1v1 v2v2 v3v3 red green red green red green v1v1 v2v2 v3v3 inferred constraint: v 2 = v 3

21 constraint composition given two binary* constraints C 1, C 2 on scopes S 1 = {x,y} and S 2 = {y,z} then the composition C 3 =C 1. C 2 is defined on S 3 = {x,z} C 3 = {(a,b)| a  D x, b  D z,  c  D y such that (a,c)  C 1 and (c,b)  C 2 } e.g.,C 1 = {(red, green),(green, red)} C 2 = {(red, green),(green, red)} C 3 =C 1. C 2 = {(red, red), (green, green)} *also works for a unary and a binary

22 inferring with constraints Who owns the zebra? p.225 variables domains constraints constraint graph

23 Who owns the zebra?  variables

24 Who owns the zebra?  variables and domains 25 variables  5 cars  5 pets  5 house colours  5 drinks  5 nationalities the houses?? they are the elements of the domains

25 Who owns the zebra?  variables and domains 25 variables, D = {1, 2, 3, 4, 5} for each variable  5 cars  5 pets  5 house colours  5 drinks  5 nationalities

26 Who owns the zebra?  constraints explicit implicit assuming all binary, how many?

27 Who owns the zebra?  constraints explicit14 implicit50 assuming all unary or binary, how many?64

28 Who owns the zebra?  binary constraint graph a 5-permutation as 10 binary constraints milk o.j.water cocoaeggnog

29 Who owns the zebra?  binary constraint graph 5 permutations drinks colours cars pets nationalities

30 Who owns the zebra?  binary constraint graph 14 explicit constraints drinks colours cars pets nationalities

31 Who owns the zebra? drinks colours cars pets nationalities 12345 horse snail dog fox zebra


Download ppt "Constraint Satisfaction Basics strongly influenced by Rina Dechter, “Constraint Processing”, 2003."

Similar presentations


Ads by Google