Solving CSPs: Binary Constraints, Constraint Propagation, and Arc Consistency

lecture notes for principles of artificial n.w
1 / 14
Embed
Share

Learn about solving Constraint Satisfaction Problems (CSPs) through binary constraints, constraint propagation techniques, and ensuring arc consistency. Explore unary, binary, and global constraints, as well as the transformation to binary constraints. Enhance your understanding of CSPs with examples like cryptarithmetic puzzles and hypergraphs.

  • CSPs
  • Binary Constraints
  • Constraint Propagation
  • Arc Consistency
  • Constraint Satisfaction

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Lecture notes for Principles of Artificial Intelligence (COMS 4720/5720) Yan-Bin Jia, Iowa State University Solving CSPs Outline I. Binary CSPs II. Constraint Propagation * Figures are from the textbook site (or drawn by the instructor) unless the source is specifically cited.

  2. I. Binary CSP A unary constraint restricts the value of a single variable. SA ,SA ????? A binary constraint relates two variables. SA WA A higher order constraint relate more variables. Ternary constraint example: ?,?,? ,? < ? < ? or ? > ? > ? A global constraint involves an arbitrary number of variables (but not necessarily all the variables). Alldiff(?1, ,??): variables ?1, ,??must have different values. e.g., Sudoku (all variables in a row, column, or 3 3 box).

  3. Cryptarithmetic Puzzle Addition constraints on the four columns: carry-overs into the tens, hundreds, and thousands, Respectively. ? + ? = ? + 10 ?1 ?1+ ? + ? = ? + 10 ?2 ?2+ ? + ? = ? + 10 ?3 ?3= ? A hypergraph generalizes a graph in that an edge (called an hyperedge) can connect more than two vertices. Alldiff constraint hyperedge Constraint hypergraph

  4. Transformation to Binary Constraints Any ?-ary constraint can be reduced to a set of binary constraints by introducing auxiliary variables. Any CSP can be transformed into a binary CSP. Advantages of a global constraint such as Alldiff: Easier and less error-prone to write. Allowing efficient special-purpose inference algorithms.

  5. II. Constraint Propagation Use constraints to reduce the number of legal values for a variable, which in turn reduces those for another variable, and so on. Enforcement of local consistency can cause inconsistent values to be eliminated throughout the constraint graph. Node consistency Suppose South Australians dislike green. Domain for SA: {red, blue} Eliminate all the unary constraints by reducing the domains of the involved variables at the start. A variable is node-consistent if all the values in its domain satisfy its unary constraints.

  6. Arc Consistency A variable ??is arc-consistent with respect to (w.r.t.) another variable ??if for every value in ?? there exists a value in ?? that satisfies the binary constraint on the arc (i.e., edge (??,??)). ? + ? < 5 ? ? ?? ?? ??= {1,3,5} ??= {1,2,3} Non-commutative ? is arc-consistent w.r.t. ?, but not vice versa. The variable is arc-consistent if it is so w.r.t every other variable that it shares a binary constraint with. The constraint graph is arc-consistent if every variable is arc consistent with every other variable.

  7. Application of Arc Consistency Example 1 ? = ?2 where ?,? {0,1, ,9} ? arc-consistent w.r.t. ? Reduced domain of ?:{0,1,2,3} ? arc-consistent w.r.t. ? Reduced domain of ?:{0,1,4,9} Example 2 Australia map-coloring SA WA No effect on the domain {red, green, blue} of each variable.

  8. Arc-Consistency Algorithm AC-3 ?? ?? ?? // domain of ?? has been reduced. // propagate to other variables // sharing a constraint with ?? Domain size ? & ? binary constraints. Each arc inserted into the queue ? times (?? has ? values to delete). Each checking takes ?(?2) time. ?(??3)

  9. Path Consistency Arc consistency reduces the domains. Path consistency checks implicit constraints inferable across triples of variables along a path. ??,?? is path-consistent w.r.t. ?? if for every assignment to ??,?? consistent with their constraint ??? (if exists), there exists an assignment to ?? that satisfies the constraints ??? and ??? between them and ??. No solution if using two colors even though every constraint can be satisfied individually. ??? ?? ?? ??? ??? ??

  10. Application of Path Consistency Make {WA, SA} path-consistent w.r.t. NT. Assume two colors only: red, blue. Only two possible assignments: {WA = red, SA = blue} {WA = blue, SA = red} No assignment for NT in either case! Eliminate both assignments to WA and SA. No solution to the problem.

  11. Bounds Propagation Two flights ?1 and ?2 have domains: ?1= [0,165] and ?2= [0,385] max capacity Constraint: the two flights together carry 420 people. domain reduction ?1= 420 385,165 = [35,165] ?2= 420 165,385 = [255,385] Bounds-consistent if for any two variables ?,?, whether ? takes on its lower- or upper-bound values, there exists some value of ? that satisfies the constraint between ? and ?. * By the above definition, for some value of ? between its lower and upper bounds, there may not exist a value of ? to meet the constraint (e.g., a nonlinear constraint). e.g., for ? 0,? ,? 0,1 not satisfied at ? = ?/2. 2 the constraint ? = sin? is

  12. Sudoku Fill the digits 1 to 9 in a 9 9 grid such that no digit appears twice in any row, column, or 3 3 box.

  13. Sudoku as a CSP Variables: ?1, ,?9,?1, ,?9 Domain: ? ={1,2, ,9} 27Alldiff constraints: Alldiff(?1,?2,?3,?4,?5,?6,?7,?8,?9) Alldiff(?1,?2,?3,?4,?5,?6,?7,?8,?9) Alldiff(?1,?1,?1,?1,?1,?1,?1,?1,?1) Alldiff(?9,?9,?9,?9,?9,?9,?9,?9,?9) Alldiff(?1,?2,?3,?1,?2,?3,?1,?2,?3) Alldiff(?7,?8,?9,?7,?8,?9,?7,?8,?9) A CSP solver can handle thousands of puzzles per second! Only the simplest ones can be solved by AC-3.

  14. Example of CSP Solution Consider E6: ??6 {1,2, ,9} 1 ? constraints in the box ??6 ??6 1,2,7,8 ={3,4,5,6,9} ? 4 constraints in the column ??6 ??6 2,3,5,6,8,9 ={4} ? 7 Consider A6: ??6 {1,2, ,9} constraints in the column Consider I6: ??6 {1,2, ,9} constraints in the column ??6 ??6 2,3,4,5,6,8,9 = {1,7} constraints in the box ??6 ??6 1,2,3,6,9 = {7} ??6 {1}

More Related Content