constraint satisfaction problems
play

Constraint Satisfaction Problems Chapter 5 Ch. 05 p.1/44 Outline - PowerPoint PPT Presentation

Constraint Satisfaction Problems Chapter 5 Ch. 05 p.1/44 Outline CSP examples Backtracking search for CSPs Problem structure and problem decomposition Local search for CSPs Ch. 05 p.2/44 Constraint satisfaction problems


  1. Constraint Satisfaction Problems Chapter 5 Ch. 05 – p.1/44

  2. Outline CSP examples Backtracking search for CSPs Problem structure and problem decomposition Local search for CSPs Ch. 05 – p.2/44

  3. ✄ ✁ Constraint satisfaction problems (CSPs) Standard search problem: state is a “black box”—any old data structure that supports goal test, eval, successor CSP: state is defined by variables �✂✁ with values from domain goal test is a set of constraints specifying allowable combinations of values for subsets of variables Simple example of a formal representation language Allows useful general-purpose algorithms with more power than standard search algorithms Ch. 05 – p.3/44

  4. ✍ ☞✍ ✚ ✏ ✛ ✓ ✍ ✍ ☞ ✒ ✣ ✚ ✣ ☛ ✘ ✄ ✂ ✏ ✁ � ✚ ✄ ☞✍ ✏✣ ✛ ✛ ✖ ✔✕ ✏ ✓ ✍ ☞✍ ✒ ✚ ✏ ✎ ✍ ✍ ☞ ✏ ✓ ✍ ☞✍ ✒ ✚ ✏ ✛ ✂ ✡ ✁✙ ✡ � ✁ ✂ ✄ ☎ ✂ ✆ � � ✆ ✁ ✄ ✝ ✘ ✍ ✍ ✏ ✒ ✓ ☞ ✍ Example: Map-Coloring Northern Territory Queensland Western South Australia New South Australia Wales Victoria Tasmania Variables , , , , , , Domains ☛✌☞✍ ✞✠✟ ✎✑✏ ✔✕✗✖ Constraints: adjacent regions must have different colors e.g., (if the language allows this), or ✛✢✜ ✎✑✏ ✎✑✏ ✔✕✗✖ Ch. 05 – p.4/44

  5. ✄ ☎ ✄☎ ☎ ☛ ✝ ☞ ✂ ✄☎ ✂ ✂ ✟ ✌ ✂ ✡ ✄☎ ☎ ☛ ✡ ✠ ✍ ✝ ✓ ☛ ☎ ✄☎ ✡ ✂ ✠ ☎ ✟ ✂ ✁ � ✁ ✂ ✄☎ ✌ ✝ Example: Map-Coloring (cont’d) Northern Territory Queensland Western South Australia New South Australia Wales Victoria Tasmania Solutions are assignments satisfying all constraints, e.g., ✆✞✝ ✆✞✝ ✆✞✝ ✎✏✒✑ Ch. 05 – p.5/44

  6. Constraint graph Binary CSP : each constraint relates at most two variables Constraint graph : nodes are variables, arcs show constraints NT Q WA SA NSW V T General-purpose CSP algorithms use the graph structure to speed up search. E.g., Tasmania is an independent subproblem! Ch. 05 – p.6/44

  7. ✄ ✟ ✌ ✍ ✎ ✌ ✆ ✝ ✄ ✆ ☎ ✆ ✄ ✆ ✂ ✁ � ✂ ✆ ✠ ✌ Varieties of CSPs Discrete variables finite domains; size complete assignments e.g., Boolean CSPs, incl. Boolean satisfiability (NP-complete) infinite domains (integers, strings, etc.) e.g., job scheduling, variables are start/end days for each job need a constraint language , e.g., ✎ ☞☛ ✎ ☞✏ ✟✡✠ ✆✞✝ linear constraints solvable, nonlinear undecidable Continuous variables e.g., start/end times for Hubble Telescope Ch. 05 – p.7/44 observations

  8. ✡ ✁ ☎ ☎ ✆ ☎ ✄ ☛ ✁ ✁ ✂ � ✌ ✄ ☛ ☎ ✄☎ ✡ ✂ � ✁ ✌ Varieties of constraints Unary constraints involve a single variable, e.g., Binary constraints involve pairs of variables, e.g., Higher-order constraints involve 3 or more variables, e.g., cryptarithmetic column constraints Preferences (soft constraints), e.g., is better than often representable by a cost for each variable assignment constrained optimization problems Ch. 05 – p.8/44

  9. ✝ ✝ � ☛ ✂ � ✏ ✓ � ✆ ✝ ✝ ✞ ✂ ✌ ✟ ✝ ✠ ✝ ✍ ✝ ✡ ✝ ☛ ✝ ✁ ✁ ✝ ✁ ☛ � ✍ ✆ ✝ ✌ ✂ ✂ ✁ ✌ ☎ ✠ ✁ ✝ ✂ ✝ ✝ ✁ ✝ ✠ ✝ � � ☞ Example: Cryptarithmetic F T U W R O T W O + T W O F O U R X 3 X 2 X 1 (a) (b) Variables: � ☎✄ Domains: Constraints alldiff , etc. Ch. 05 – p.9/44

  10. Real-world CSPs Assignment problems e.g., who teaches what class Timetabling problems e.g., which class is offered when and where? Hardware configuration Spreadsheets Transportation scheduling Factory scheduling Floorplanning Notice that many real-world problems involve real-valued variables Ch. 05 – p.10/44

  11. � ✂ � Standard search formulation (incremental) Let’s start with the straightforward, dumb approach, then fix it States are defined by the values assigned so far Initial state: the empty assignment, Successor function: assign a value to an unassigned variable that does not conflict with current assignment. fail if no legal assignments (not fixable!) Goal test: the current assignment is complete Ch. 05 – p.11/44

  12. ✂ ☛ ☛ ☎ ✂ ✎ ✆ ✁ � ✁ ✂ ✂ ☛ ✆ ☛ ✄ � Standard search formulation (incremental) This is the same for all CSPs! Every solution appears at depth with variables use depth-first search Path is irrelevant, so can also use complete-state formulation at depth , hence leaves!!!! Ch. 05 – p.12/44

  13. ✂ ✁ ✡ ✄ ☎ ☎ ☛ ☛ ✄ ✠ ✄ ☎ ✆ ✆ ✆ ✂ ✂ ✂ ✟ ✎ ✟ ✍ ✁ ✂ ✄ ☎ ✆ ✞ ✠ ☛ ✂ ✡ ✄ ☎ ☎ ☛ � � Backtracking search Variable assignments are commutative, i.e., [ then ] same as [ then ] Only need to consider assignments to a single variable at each node and there are leaves Depth-first search for CSPs with single-variable assignments is called backtracking search Backtracking search is the basic uninformed algorithm for CSPs Can solve -queens for Ch. 05 – p.13/44

  14. � ✙ ✡ � Backtracking search function B ACKTRACKING -S EARCH ( csp ) returns a solution, or failure return R ECURSIVE -B ACKTRACKING ({ }, csp ) function R ECURSIVE -B ACKTRACKING ( assignment, csp ) returns a solution, or failure if assignment is complete then return assignment var S ELECT -U NASSIGNED -V AR ( V ARIABLES [ csp ], assignment,csp ) for each value in O RDER -D OMAIN -V ARS ( var, assignment, csp ) do add { var = value } to assignment result R ECURSIVE -B ACKTRACKING ( assignment, csp ) if result failure then return result remove { var = value } from assignment return failure Ch. 05 – p.14/44

  15. Backtracking example Ch. 05 – p.15/44

  16. Backtracking example Ch. 05 – p.16/44

  17. Backtracking example Ch. 05 – p.17/44

  18. Backtracking example Ch. 05 – p.18/44

  19. Improving backtracking efficiency General-purpose methods can give huge gains in speed: 1. Which variable should be assigned next? 2. In what order should its values be tried? 3. Can we detect inevitable failure early? 4. Can we take advantage of problem structure? Ch. 05 – p.19/44

  20. Most constrained variable Most constrained variable: choose the variable with the fewest legal values Ch. 05 – p.20/44

  21. Most constraining variable Tie-breaker among most constrained variables Most constraining variable: choose the variable with the most constraints on remaining variables Ch. 05 – p.21/44

  22. Least constraining value Given a variable, choose the least constraining value: the one that rules out the fewest values in the remaining variables Allows 1 value for SA Allows 0 value for SA Combining these heuristics makes 1000 queens feasible Ch. 05 – p.22/44

  23. Forward checking Idea: Keep track of remaining legal values for unassigned variables Idea: Terminate search when any variable has no legal values WA NT Q NSW V SA T Ch. 05 – p.23/44

  24. Forward checking Idea: Keep track of remaining legal values for unassigned variables Idea: Terminate search when any variable has no legal values WA NT Q NSW V SA T Ch. 05 – p.24/44

  25. Forward checking Idea: Keep track of remaining legal values for unassigned variables Idea: Terminate search when any variable has no legal values WA NT Q NSW V SA T Ch. 05 – p.25/44

  26. Forward checking Idea: Keep track of remaining legal values for unassigned variables Idea: Terminate search when any variable has no legal values WA NT Q NSW V SA T Ch. 05 – p.26/44

  27. ✌ ✟ ✠ ✁ Constraint propagation Forward checking propagates information from assigned to unassigned variables, but doesn’t provide early detection for all failures: WA NT Q NSW V SA T and cannot both be blue! Constraint propagation repeatedly enforces constraints locally Ch. 05 – p.27/44

  28. ✂ � ✁ � ✁ � Arc consistency Simplest form of propagation makes each arc consistent is consistent iff for every value of there is some allowed WA NT Q NSW V SA T Ch. 05 – p.28/44

  29. ✂ � ✁ � ✁ � Arc consistency Simplest form of propagation makes each arc consistent is consistent iff for every value of there is some allowed WA NT Q NSW V SA T Ch. 05 – p.29/44

  30. � � ✁ � ✁ � ✂ � Arc consistency Simplest form of propagation makes each arc consistent is consistent iff for every value of there is some allowed WA NT Q NSW V SA T If loses a value, neighbors of need to be rechecked Ch. 05 – p.30/44

  31. � � ✁ � ✁ � ✂ � Arc consistency Simplest form of propagation makes each arc consistent is consistent iff for every value of there is some allowed WA NT Q NSW V SA T If loses a value, neighbors of need to be rechecked Arc consistency detects failure earlier than forward checking Can be run as a preprocessor or after each assignment Ch. 05 – p.31/44

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