Constraint Satisfaction Problems
Total Page:16
File Type:pdf, Size:1020Kb
Constraint Satisfaction Problems Nebel, Hu´e and W¨olfl Constraint Satisfaction Problems Introduction Organization Introduction Bernhard Nebel, Julien Hu´e, and Stefan W¨olfl Albert-Ludwigs-Universit¨atFreiburg April 23, 2012 Constraint Satisfaction Problems Nebel, Hu´e and W¨olfl Introduction Constraint Satisfaction Problems Real World Applications Introduction Solving Constraints Contents of the lecture Organization Constraints Constraint What is a constraint? Satisfaction Problems 1 a: the act of constraining b: the state of being checked, Nebel, Hu´e restricted, or compelled to avoid or perform some action . and W¨olfl c: a constraining condition, agency, or force . Introduction Constraint 2 a: repression of one's own feelings, behavior, or actions Satisfaction Problems b: a sense of being constrained . Real World Applications Solving (from Merriam-Webster's Online Dictionary) Constraints Contents of the lecture Usage Organization In programming languages, constraints are often used to restrict the domains of variables. In databases, constraints can be used to specify integrity conditions. In mathematics, a constraint is a requirement on solutions of optimization problems. Examples Constraint Satisfaction Problems Nebel, Hu´e and W¨olfl Examples: Introduction Constraint Satisfaction Latin squares Problems Real World Applications Eight queens problem Solving Constraints Contents of the Sudoku lecture Map coloring problem Organization Boolean satisfiability Latin Square Constraint Satisfaction Problems Problem: Nebel, Hu´e How can one fill an n × n table with n different symbols and W¨olfl . such that each symbol occurs exactly once in each row Introduction Constraint Satisfaction and and each column? Problems Real World Applications Solving 2 3 Constraints 1 2 4 3 Contents of the 21 2 33 lecture 1 2 2 3 1 4 1 2 3 1 6 7 Organization 2 1 4 5 63 4 2 17 3 1 2 4 5 4 1 3 2 There are essentially 56 different Latin squares of size 5, 9408 squares of size 6, 16.942.080 squares of size 7, 535.281.401.856 squares of size 8, . Latin Square Constraint Satisfaction Problems Problem: Nebel, Hu´e How can one fill an n × n table with n different symbols and W¨olfl . such that each symbol occurs exactly once in each row Introduction Constraint Satisfaction and and each column? Problems Real World Applications Solving 2 3 Constraints 1 2 3 4 Contents of the 21 2 33 lecture 1 2 2 3 4 1 1 2 3 1 6 7 Organization 2 1 4 5 63 4 1 27 3 1 2 4 5 4 1 2 3 There are essentially 56 different Latin squares of size 5, 9408 squares of size 6, 16.942.080 squares of size 7, 535.281.401.856 squares of size 8, . Eight Queens Puzzle Constraint Satisfaction Problem: Problems How can one put 8 queens on a standard chess board Nebel, Hu´e (8 × 8-board) and W¨olfl Introduction . such that no queen can attack any other queen? Constraint Satisfaction Problems Real World Applications Solutions: Solving Constraints Contents of the The puzzle has 12 unique solutions (up to rotations and lecture reflections) Organization Old problem proposed in 1848. Various variants knights (instead of queens) 3D n queens on an n × n-board A Solution . Constraint Satisfaction Problems Nebel, Hu´e and W¨olfl 8 0Z0Z0Z0Z Introduction 7 Constraint Z0Z0Z0Z0 Satisfaction Problems 6 Real World 0Z0Z0Z0Z Applications 5 Solving Z0Z0Z0Z0 Constraints Contents of the 4 0Z0Z0Z0Z lecture Organization 3 Z0Z0Z0Z0 2 qZ0Z0Z0Z 1 Z0Z0Z0Z0 a b c d e f g h Figure: A solution of the 8-queens problem A Solution . Constraint Satisfaction Problems Nebel, Hu´e and W¨olfl 8 0Z0Z0Z0Z Introduction 7 Constraint Z0Z0Z0Z0 Satisfaction Problems 6 Real World 0Z0Z0Z0Z Applications 5 Solving Z0Z0Z0Z0 Constraints Contents of the 4 0l0Z0Z0Z lecture Organization 3 Z0Z0Z0Z0 2 qZ0Z0Z0Z 1 Z0Z0Z0Z0 a b c d e f g h Figure: A solution of the 8-queens problem A Solution . Constraint Satisfaction Problems Nebel, Hu´e and W¨olfl 8 0Z0Z0Z0Z Introduction 7 Constraint Z0Z0Z0Z0 Satisfaction Problems 6 Real World 0ZqZ0Z0Z Applications 5 Solving Z0Z0Z0Z0 Constraints Contents of the 4 0l0Z0Z0Z lecture Organization 3 Z0Z0Z0Z0 2 qZ0Z0Z0Z 1 Z0Z0Z0Z0 a b c d e f g h Figure: A solution of the 8-queens problem A Solution . Constraint Satisfaction Problems Nebel, Hu´e and W¨olfl 8 0Z0l0Z0Z Introduction 7 Constraint Z0Z0Z0Z0 Satisfaction Problems 6 Real World 0ZqZ0Z0Z Applications 5 Solving Z0Z0Z0Z0 Constraints Contents of the 4 0l0Z0Z0Z lecture Organization 3 Z0Z0Z0Z0 2 qZ0Z0Z0Z 1 Z0Z0Z0Z0 a b c d e f g h Figure: A solution of the 8-queens problem A Solution . Constraint Satisfaction Problems Nebel, Hu´e and W¨olfl 8 0Z0l0Z0Z Introduction 7 Constraint Z0Z0Z0Z0 Satisfaction Problems 6 Real World 0ZqZ0Z0Z Applications 5 Solving Z0Z0Z0Z0 Constraints Contents of the 4 0l0Z0Z0Z lecture Organization 3 Z0Z0l0Z0 2 qZ0Z0Z0Z 1 Z0Z0Z0Z0 a b c d e f g h Figure: A solution of the 8-queens problem A Solution . Constraint Satisfaction Problems Nebel, Hu´e and W¨olfl 8 0Z0l0Z0Z Introduction 7 Constraint Z0Z0Z0Z0 Satisfaction Problems 6 Real World 0ZqZ0Z0Z Applications 5 Solving Z0Z0Z0Z0 Constraints Contents of the 4 0l0Z0Z0Z lecture Organization 3 Z0Z0l0Z0 2 qZ0Z0Z0Z 1 Z0Z0ZqZ0 a b c d e f g h Figure: A solution of the 8-queens problem A Solution . Constraint Satisfaction Problems Nebel, Hu´e and W¨olfl 8 0Z0l0Z0Z Introduction 7 Constraint Z0Z0Z0l0 Satisfaction Problems 6 Real World 0ZqZ0Z0Z Applications 5 Solving Z0Z0Z0Z0 Constraints Contents of the 4 0l0Z0Z0Z lecture Organization 3 Z0Z0l0Z0 2 qZ0Z0Z0Z 1 Z0Z0ZqZ0 a b c d e f g h Figure: A solution of the 8-queens problem A Solution . Constraint Satisfaction Problems Nebel, Hu´e and W¨olfl 8 0Z0l0Z0Z Introduction 7 Constraint Z0Z0Z0l0 Satisfaction Problems 6 Real World 0ZqZ0Z0Z Applications 5 Solving Z0Z0Z0Zq Constraints Contents of the 4 0l0Z0Z0Z lecture Organization 3 Z0Z0l0Z0 2 qZ0Z0Z0Z 1 Z0Z0ZqZ0 a b c d e f g h Figure: A solution of the 8-queens problem Sudoku Constraint Problem: Satisfaction Problems Fill a partially completed 9 × 9 grid such that Nebel, Hu´e . each row, each column, and each of the nine 3 × 3 and W¨olfl boxes contains the numbers from 1 to 9. Introduction Constraint Satisfaction Problems 2 5 3 9 1 Real World Applications Solving 1 4 Constraints Contents of the 4 7 2 8 lecture Organization 5 2 9 8 1 4 3 3 6 7 2 7 3 9 3 6 4 Sudoku Constraint Problem: Satisfaction Problems Fill a partially completed 9 × 9 grid such that Nebel, Hu´e . each row, each column, and each of the nine 3 × 3 and W¨olfl boxes contains the numbers from 1 to 9. Introduction Constraint Satisfaction Problems 2 5 8 7 3 6 9 4 1 Real World Applications Solving 6 1 9 8 2 4 3 5 7 Constraints Contents of the 4 3 7 9 1 5 2 6 8 lecture Organization 3 9 5 2 7 1 4 8 6 7 6 2 4 9 8 1 3 5 8 4 1 6 5 3 7 2 9 1 8 4 3 6 9 5 7 2 5 7 6 1 4 2 8 9 3 9 2 3 5 8 7 6 1 4 Constraint Satisfaction Problem Constraint Satisfaction Problems Nebel, Hu´e Definition and W¨olfl A constraint network is defined by: Introduction Constraint a finite set of variables Satisfaction Problems Real World a (finite) domain of values for each variable Applications Solving Constraints a finite set of constraints (i.e., binary, ternary, . relations Contents of the defined between the variables) lecture Organization Problem Is there a solution of the network, i.e., an assignment of values to the variables such that all constraints are satisfied? k-Colorability Constraint Satisfaction Problem: Problems Nebel, Hu´e Can one color the nodes of a given graph with k colors and W¨olfl . such that all nodes connected by an edge have Introduction different colors? Constraint Satisfaction Problems Real World Applications Reformulated as a constraint network: Solving Constraints Contents of the Variables: the nodes of the graph lecture Domains: \colors" f1; : : : ; kg for each variable Organization Constraints: nodes connected by an edge must have different values This constraint network has a particular restricted form: only binary constraints domains are finite k-Colorability Constraint Satisfaction Problem: Problems Nebel, Hu´e Can one color the nodes of a given graph with k colors and W¨olfl . such that all nodes connected by an edge have Introduction different colors? Constraint Satisfaction Problems Real World Applications Reformulated as a constraint network: Solving Constraints Contents of the Variables: the nodes of the graph lecture Domains: \colors" f1; : : : ; kg for each variable Organization Constraints: nodes connected by an edge must have different values This constraint network has a particular restricted form: only binary constraints domains are finite k-Colorability Constraint Satisfaction Problem: Problems Nebel, Hu´e Can one color the nodes of a given graph with k colors and W¨olfl . such that all nodes connected by an edge have Introduction different colors? Constraint Satisfaction Problems Real World Applications Reformulated as a constraint network: Solving Constraints Contents of the Variables: the nodes of the graph lecture Domains: \colors" f1; : : : ; kg for each variable Organization Constraints: nodes connected by an edge must have different values This constraint network has a particular restricted form: only binary constraints domains are finite Crossword Puzzle Constraint Problem instance: Satisfaction Problems Variables: empty squares in a crossword puzzle; Nebel, Hu´e Domains: letters fA; B; C; : : : ; Zg for each variable; and W¨olfl Introduction Constraints: relations defined by a given set of words that Constraint Satisfaction need (or are allowed) to occur in the completed puzzle.