B.Y. Choueiry ✫ ✬ Title : Constraint Satisfaction Problems AIMA: Chapter 6 Required reading: Recommended reading: — Introduction to CSPs (Bartak’s on-line guide) — “Algorithms for Constraints Satisfaction problems: A Survey” by Vipin Kumar. AI Magazine, Vol 13, No 1, 32-44, 1992. — Constraint Programming: In Pursuit of the Holy Grail. Bartak 1 Introduction to Artificial Intelligence CSCE 476-876, Fall 2018 Instructor’s notes #19 URL: cse.unl.edu/˜cse476 URL: cse.unl.edu/˜choueiry/F18-476-876 October 5, 2018 Berthe Y. Choueiry (Shu-we-ri) ✪ ✩
B.Y. Choueiry ✫ ✬ Constraint Processing • Constraint Satisfaction: – Modeling and problem definition (Constraint Satisfaction Problem, CSP) – Algorithms for constraint propagation 2 – Algorithms for search • Constraint Programming: Languages and tools – logic-based Instructor’s notes #19 – object-oriented October 5, 2018 – functional ✪ ✩
B.Y. Choueiry ✫ ✬ Courses on Constraint Processing http://cse.unl.edu/˜choueiry/Constraint-Courses.html 3 • CSCE 421/821 Foundations of Constraint Processing • CSCE 921 Advanced Constraint Processing Instructor’s notes #19 October 5, 2018 ✪ ✩
B.Y. Choueiry ✫ ✬ Outline • Problem definition and examples • Solution techniques: search and constraint propagation 4 • Exploiting the structure • Research directions Instructor’s notes #19 October 5, 2018 ✪ ✩
B.Y. Choueiry ✫ ✬ What is this about? Context: Solving a Kendoku Puzzle Problem: You need to assign numbers to unmarked cells Possibilities: You can choose any number between 1 and 5 Constraints: restrict the choices you can make Unary: You have to respect predefined cells Binary: No two cells in same row or column have the same value 5 Global: All the cells in each area must summ up to a given value. Instructor’s notes #19 You have choices, but are restricted by constraints October 5, 2018 − → Make the right decisions ✪ ✩
B.Y. Choueiry ✫ ✬ Constraint Satisfaction Given • A set of variables: 25 cells • For each variable, a set of choices {1,2,3,4,5} • A set of constraints that restrict the combinations of values the variables can take at the same time 6 Questions • Does a solution exist? classical decision problem • How two or more solutions differ? How to change specific choices without perturbing the solution? Instructor’s notes #19 • If there is no solution, what are the sources of conflicts? October 5, 2018 Which constraints should be retracted? • etc. ✪ ✩
B.Y. Choueiry ✫ ✬ Constraint Processing is about • solving a decision problem • while allowing the user to state arbitrary constraints in an expressive way and • providing concise and high-level feedback about alternatives and conflicts 7 Power of Constraints Processing • flexibility & expressiveness of representations relax Instructor’s notes #19 • interactivity, users can constraints reinforce October 5, 2018 Related areas: AI, OR, Algorithmic, DB, Prog. Languages, etc. ✪ ✩
B.Y. Choueiry ✫ ✬ Definition Given P = ( V , D , C ) : • V a set of variables V = { V 1 , V 2 , . . . , V n } • D a set of variable domains (domain values) 8 D = { D V 1 , D V 2 , . . . , D V n } • C a set of constraints C V a ,V b ,...,V i = { ( x, y, . . . , z ) } ⊆ D V a × D V b × . . . × D V i Query: can we find one value for each variable Instructor’s notes #19 such that all constraints are satisfied? October 5, 2018 In general, NP-complete ✪ ✩
B.Y. Choueiry ✫ ✬ Terminology • Instantiating a variable: V i ← a where a ∈ D V i • Variable-value pair (vvp) • Partial assignment 9 • No good • Constraint checking • Consistent assignment Instructor’s notes #19 • Constrained optimization problem: Objective function October 5, 2018 ✪ ✩
B.Y. Choueiry ✫ ✬ Representation : Constraint graph V = { V 1 , V 2 , . . . , V n } Given P = ( V , D , C ) D = { D V 1 , D V 2 , . . . , D V n } C set of constraints C V i ,V j = { ( x, y ) } ⊆ D V i × D V j 10 Constraint graph v1 < v2 V1 { 1, 2, 3, 4 } { 3, 6, 7 } V2 Instructor’s notes #19 v1+v3 < 9 v2 < v3 v2 > v4 October 5, 2018 { 3, 4, 9 } { 3, 5, 7 } V3 V4 ✪ ✩
B.Y. Choueiry ✫ ✬ Example I : Temporal reasoning B A < B [ 5.... 18] A 11 [ 1.... 10 ] B < C 2 < C - A < 5 [ 4.... 15] C Instructor’s notes #19 − → C-A ∈ [2, 5] is a constraint of bounded differences October 5, 2018 ✪ ✩
B.Y. Choueiry ✫ ✬ Example II : Map coloring Using 3 colors (R, G, & B), color the US map such that no two adjacent states do have the same color NE WY KS 12 { red, green, blue } CO AR { red, green, blue } { red, green, blue } { red, green, blue } UT { red, green, blue } AZ OK NM LA TX Instructor’s notes #19 Variables? Domains? Constraints? October 5, 2018 ✪ ✩
B.Y. Choueiry ✫ ✬ Domain types V = { V 1 , V 2 , . . . , V n } Given P = ( V , D , C ) D = { D V 1 , D V 2 , . . . , D V n } C set of constraints 13 C V i ,V j = { ( x, y ) } ⊆ D V i × D V j Domains: − → restricted to {0, 1}: Boolean CSPs Instructor’s notes #19 − → Finite (discrete): enumeration techniques works − → Continuous: sophisticated algebraic techniques are needed October 5, 2018 consistency techniques on domain bounds ✪ ✩
B.Y. Choueiry ✫ ✬ Constraint arity V = { V 1 , V 2 , . . . , V n } Given P = ( V , D , C ) D = { D V 1 , D V 2 , . . . , D V n } C set of constraints C V k ,V l ,V m = { ( x, y, z ) } ⊆ D V k × D V l × D V m 14 Constraints: universal, unary, binary, ternary, . . . , global Representation: Constraint network V2 V1 v1 < v2 Instructor’s notes #19 { 3, 6, 7 } { 1, 2, 3, 4 } v1+v3 < 9 v2 > v4 October 5, 2018 v2 < v3 { 3, 4, 9 } { 3, 5, 7 } V4 v1+v2+V4 < 10 V3 ✪ ✩
B.Y. Choueiry ✫ ✬ Constraint definition Constraints can be defined • Extensionally: all allowed tuples are listed practical for defining arbitrary constraints C V 1 ,V 2 = { ( r, g ) , ( r, b ) , ( g, r ) , ( g, b ) , ( b, r ) , ( b, g ) } 15 • Intensionally: when it is not practical (or even possible) to list all tuples, define allowed tuples in intension. C V 1 ,V 2 = { ( x, y ) | x ∈ D V 1 , y ∈ D V 2 , x � = y } → Define types of common constraints, to be used repeatedly Examples: Alldiff (a.k.a. mutex), Atmost, Cumulative, Instructor’s notes #19 Balance, etc. October 5, 2018 Other types of constraints: linear constraints, nonlinear constraints, constraints of bounded differences (e.g., in temporal reasoning), etc. ✪ ✩
B.Y. Choueiry ✫ ✬ Example III : Cryptarithmetic puzzles D X 1 = D X 2 = D X 3 = { 0 , 1 } D F = D T = D U = D V = D R = D O = [0 , 9] F T U W R O T W O + T W O F O U R 16 X 3 X 2 X 1 (a) (b) O + O = R + 10 X1 Instructor’s notes #19 X1 + W + W = U + 10 X2 X2 + T +T = O + 10 X3 October 5, 2018 X3 = F Alldiff({F, D, U, V, R, O}) ✪ ✩
B.Y. Choueiry ✫ ✬ How to solve a CSP ? 17 Search! 1. Constructive, systematic search 2. Local search Instructor’s notes #19 October 5, 2018 ✪ ✩
B.Y. Choueiry ✫ ✬ Incremental formulation: as a search problem Initial state: empty assignment, all variables are unassigned Successor function: a value is assigned to any unassigned variable, provided that it does not conflict with previously assigned variables (back-checking) Goal test: The current assignment is complete (and consistent) 18 Path cost: a constant cost (e.g., 1) for every step, can be zero — A solution is a complete, consistent assignment. Instructor’s notes #19 — Search tree has constant depth n (# of variables) → DFS!! October 5, 2018 — However, path for reaching a solution is irrelevant - Complete-state formulation is OK - Solved with local search (ref. SAT) ✪ ✩
B.Y. Choueiry ✫ ✬ Systematic search → Starting from a root node → Consider all values for a variable V 1 → For every value for V 1 , consider all values for V 2 → etc.. S 19 Var 1 v4 v1 v2 v3 Var 2 Instructor’s notes #19 October 5, 2018 For n variables, each of domain size d : - Maximum depth? fixed! - Maximum number of paths? size of search space, size of CSP ✪ ✩
B.Y. Choueiry ✫ ✬ Back-checking Systematic search generates d n possibilities Are all possible combinations acceptable? S S 20 Var 1 Var 1 v4 v4 v1 v2 v3 v1 v2 v3 Var 2 Var 2 Instructor’s notes #19 → Expand a partial solution only when consistent October 5, 2018 − → early pruning ✪ ✩
B.Y. Choueiry ✫ ✬ Before looking at search.. Consider 21 1. Importance of modeling/formulating to control the size of the search space 2. Preprocessing: consistency filtering to reduce size of search space Instructor’s notes #19 October 5, 2018 ✪ ✩
✬ ✩ Importance of modeling N -queens : formulation 1 Variables? Domains? Size of CSP? N -queens : formulation 2 variables? domains? ✫ size of csp? ✪ 22 B.Y. Choueiry Instructor’s notes #19 October 5, 2018
Recommend
More recommend