chapter 6 r n
play

Chapter 6 R&N ICS 271 Fall 2016 Kalev Kask ICS-271:Notes 5: 1 - PowerPoint PPT Presentation

Set 5: Constraint Satisfaction Problems Chapter 6 R&N ICS 271 Fall 2016 Kalev Kask ICS-271:Notes 5: 1 Outline The constraint network model Variables, domains, constraints, constraint graph, solutions Examples:


  1. Set 5: Constraint Satisfaction Problems Chapter 6 R&N ICS 271 Fall 2016 Kalev Kask ICS-271:Notes 5: 1

  2. Outline • The constraint network model – Variables, domains, constraints, constraint graph, solutions • Examples: – graph-coloring, 8-queen, cryptarithmetic, crossword puzzles, vision problems,scheduling, design • The search space and naive backtracking, • The constraint graph • Consistency enforcing algorithms – arc-consistency, AC-1,AC-3 • Backtracking strategies – Forward-checking, dynamic variable orderings • Special case: solving tree problems • Local search for CSPs ICS-271:Notes 5: 2

  3. ICS-271:Notes 5: 3

  4. Constraint Satisfaction Example: map coloring Variables - countries (A,B,C,etc.) Values - colors (e.g., red, green, yellow)    A B, A D, D E , etc. Constraints: E A B A red green D red yellow green red B green yellow F yellow green G yellow red C ICS-271:Notes 5: 4

  5. ICS-271:Notes 5: 5

  6. ICS-271:Notes 5: 6

  7. ICS-271:Notes 5: 7

  8. ICS-271:Notes 5: 8

  9. Varieties of constraints • Unary constraints involve a single variable, – e.g., SA ≠ green • Binary constraints involve pairs of variables, – e.g., SA ≠ WA • Higher-order constraints involve 3 or more variables, – Clauses in boolean (propositional) logic – e.g., cryptoarithmetic column constraints ICS-271:Notes 5: 9

  10. Hard vs Soft Constraints • Hard constraints : must be satisfied – Satisfaction problem • Soft constraints : capture preferences – Optimization problem ICS-271:Notes 5: 10

  11. Sudoku Each row, column and major block must be all different “Well posed” if it has unique solution: 27 constraints ICS-271:Notes 5: 11

  12. Sudoku • Variables: 81 slots • Domains = {1,2,3,4,5,6,7,8,9} • Constraints: • 27 not-equal Constraint propagation 2 3 2 4 6 Each row, column and major block must be all different “Well posed” if it has unique solution: 27 constraints ICS-271:Notes 5: 12

  13. ICS-271:Notes 5: 13

  14. ICS-271:Notes 5: 15

  15. A network of constraints X 1 • Variables X – X X 1 ,....,X 5 2 n • Domains X – D ,....,D of discrete values: X 4 3 1 n • Binary constraints: – R ij which represent the list of allowed pairs of values, R ij is a subset D i xD of the Cartesian product: . j • Constraint graph: – A node for each variable and an edge for each constraint • Solution: – An assignment of a value from its domain to each variable such that no constraint is violated. • A network of constraints represents the relation of all solutions.     {( 1 ) | ( , ) , , } sol x ,....,x x x R x D x D n i j ij i i j j ICS-271:Notes 5: 16

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

  17. Class scheduling/Timetabling ICS-271:Notes 5: 19

  18. Search vs. Inference • Search : – In the space of partial variable-value assignments – Key idea : conditioning • Inference : – Derive new information implied by values/constraints – Key idea : local consistency ICS-271:Notes 5: 20

  19. But only d n unique assignments ICS-271:Notes 5: 21

  20. ICS-271:Notes 5: 22

  21. The search space • X 1 ,....,X Definition: given an ordering of the variables n – a state: • is an assignment to a subset of variables that is consistent. – Operators: • add an assignment to the next variable that does not violate any constraint. How to choose next variable? – Goal state : • a consistent assignment to all the variables. ICS-271:Notes 5: 23

  22. ICS-271:Notes 5: 24

  23. ICS-271:Notes 5: 25

  24. ICS-271:Notes 5: 26

  25. ICS-271:Notes 5: 27

  26. Backtracking • Complexity of extending a partial solution: – Complexity of consistent: O(e log t), t bounds #tuples, e bounds #constraints – Complexity of selectvalue: O(e k log t), k bounds domain size ICS-271:Notes 5: 28

  27. The effect of variable ordering z divides x, y and t ICS-271:Notes 5: 30

  28. A coloring problem ICS-271:Notes 5: 31

  29. Backtracking Search for a Solution ICS-271:Notes 5: 32

  30. Backtracking Search for a Solution ICS-271:Notes 5: 33

  31. Backtracking Search for All Solutions ICS-271:Notes 5: 34

  32. Summary so far • Constraint Satisfaction Problems – variables, domains, constraints – solution = assignment to all variables such that all constraints are satisfied – constraint graph • Search vs Inference: – conditioning vs local consistency . • Search – Backtracking search : • In the space of partial assignments; • add consistent var=value assignment at each search space node. • If not possible, backtrack – Effect on search space size on var/val order : • Variable order – most constrained variable first • Value order – least constraining value first ICS-271:Notes 5: 35

  33. The Minimal network: Example: the 4-queen problem ICS-271:Notes 5: 36

  34. Inference (Approximation) algorithms • Arc-consistency (Waltz, 1972) • Path-consistency (Montanari 1974, Mackworth 1977) • k-consistency (Freuder 1982) • Key Idea : – Transform the network into smaller and smaller (but equivalent) networks by tightening the domains/constraints. ICS-271:Notes 5: 37

  35. Arc-consistency X Y  1, 2, 3 1, 2, 3 1  X, Y, Z, T  3 X  Y  = Y = Z T  Z X  T 1, 2, 3 1, 2, 3  T Z ICS-271:Notes 5: 38

  36. Arc-consistency X Y  1 3 1  X, Y, Z, T  3 X  Y  = Y = Z T  Z X  T 2 3  T Z • Incorporated into backtracking search • Constraint programming languages powerful approach for modeling and solving combinatorial optimization problems. ICS-271:Notes 5: 39

  37. Arc-consistency algorithm domain of X domain of Y Arc is arc-consistent if for any value of there exist a matching value of ( ) X i ,X X X j i i Algorithm Revise makes an arc consistent ( ) X i ,X j Begin 1. For each a in D i if there is no value b in D j that is consistent with a then delete a from the D i . End. O(k 2 ) Revise is , k is the number of values in each domain. ICS-271:Notes 5: 40

  38. Algorithm AC-3 • Begin – 1. Q <--- put all arcs in the queue in both directions – 2. While Q is not empty do, – 3. Select and delete an arc from the queue Q ( ) X i ,X j • 4. Revise ( ) X i ,X j • 5. If Revise changes (reduces) the domain of X i then add to the queue all arcs that go to X i (( X l ,X i for all l except i ). – 6. end-while • End • Complexity: – Processing an arc requires O(k^2) steps – There is edges e – The number of times each arc can be processed is 2·k O(ek 3 – Total complexity is ) ICS-271:Notes 5: 41

  39. Sudoku • Variables: 81 slots • Domains = {1,2,3,4,5,6,7,8,9} • Constraints: • 27 not-equal Constraint propagation 2 3 2 4 6 Each row, column and major block must be all different “Well posed” if it has unique solution: 27 constraints ICS-271:Notes 5: 42

  40. Sudoku Path-consistency or 3-consistency 4-consistency and i-consistency in geeral Each row, column and major block must be all different “Well posed” if it has unique solution ICS-271:Notes 5: 43

  41. The Effect of Consistency Level • After arc(2)-consistency z=5 and l=5 are removed • After path(3)-consistency – R’_ zx – R’_ zy – R’_ zl – R’_ xy – R’_xl – R’_ yl Tighter networks yield smaller search spaces ICS-271:Notes 5: 44

  42. Improving Backtracking O(exp(n)) • Before search: (reducing the search space) – Arc-consistency, path-consistency, k-consistency – Variable ordering (fixed) • During search : – Look-ahead schemes : • Variable ordering ( Choose the most constraining variable) • Value ordering ( Choose the least restricting value ) – Look-back schemes : • Backjumping • Constraint recording • Dependency-directed backtracking ICS-271:Notes 5: 45

  43. ICS-271:Notes 5: 46

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