1 Chapter 5 Constraint Satisfaction Problems. 2 Outlines  Constraint Satisfaction Problems  Backtracking Search for CSPs  Local Search for CSP  The.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Constraint Satisfaction Problems Russell and Norvig: Chapter
Constraint Satisfaction Problems (Chapter 6). What is search for? Assumptions: single agent, deterministic, fully observable, discrete environment Search.
Constraint Satisfaction Problems
Lecture 11 Last Time: Local Search, Constraint Satisfaction Problems Today: More on CSPs.
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
This lecture topic (two lectures) Chapter 6.1 – 6.4, except 6.3.3
Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni.
Constraint Satisfaction problems (CSP)
Review: Constraint Satisfaction Problems How is a CSP defined? How do we solve CSPs?
Constraint Satisfaction Problems
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Constraint Satisfaction Problems
Constraint Satisfaction
Chapter 5 Outline Formal definition of CSP CSP Examples
Constraint Satisfaction Problems
Constraint Satisfaction Problems
Constraint Satisfaction Problems
ISC 4322/6300 – GAM 4322 Artificial Intelligence Lecture 4 Constraint Satisfaction Problems Instructor: Alireza Tavakkoli September 17, 2009 University.
1 Constraint Satisfaction Problems Slides by Prof WELLING.
Constraint Satisfaction Problems (CSPs) Chapter 6.1 – 6.4, except
CSPs Tamara Berg CS 560 Artificial Intelligence Many slides throughout the course adapted from Svetlana Lazebnik, Dan Klein, Stuart Russell, Andrew Moore,
CSPs Tamara Berg CS Artificial Intelligence Many slides throughout the course adapted from Svetlana Lazebnik, Dan Klein, Stuart Russell, Andrew.
Constraint Satisfaction Problems Chapter 6. Review Agent, Environment, State Agent as search problem Uninformed search strategies Informed (heuristic.
Chapter 5 Section 1 – 3 1.  Constraint Satisfaction Problems (CSP)  Backtracking search for CSPs  Local search for CSPs 2.
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
CSC 8520 Spring Paula Matuszek Based on Hwee Tou Ng, aima.eecs.berkeley.edu/slides-ppt, which are based on Russell, aima.eecs.berkeley.edu/slides-pdf.
Hande ÇAKIN IES 503 TERM PROJECT CONSTRAINT SATISFACTION PROBLEMS.
1 Constraint Satisfaction Problems Soup Total Cost < $30 Chicken Dish Vegetable RiceSeafood Pork Dish Appetizer Must be Hot&Sour No Peanuts No Peanuts.
Chapter 5: Constraint Satisfaction ICS 171 Fall 2006.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Fall 2006 Jim Martin.
CSC 423 ARTIFICIAL INTELLIGENCE Constraint Satisfaction Problems.
CSC 8520 Spring Paula Matuszek CS 8520: Artificial Intelligence Search 3: Constraint Satisfaction Problems Paula Matuszek Spring, 2013.
Lecture 5: Solving CSPs Fast! 1/30/2012 Robert Pless – Wash U. Multiple slides over the course adapted from Kilian Weinberger, Dan Klein (or Stuart Russell.
Chapter 5 Constraint Satisfaction Problems
CSE 473: Artificial Intelligence Constraint Satisfaction Daniel Weld Slides adapted from Dan Klein, Stuart Russell, Andrew Moore & Luke Zettlemoyer.
Constraint Satisfaction Problems (Chapter 6)
1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3 Grand Challenge:
CHAPTER 5 SECTION 1 – 3 4 Feb 2004 CS Constraint Satisfaction 1 Constraint Satisfaction Problems.
Constraint Satisfaction Problems University of Berkeley, USA
Constraint Satisfaction Problems Chapter 6. Outline CSP? Backtracking for CSP Local search for CSPs Problem structure and decomposition.
4/18/2005EE5621 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 5, 4/18/2005 University of Washington, Department of Electrical Engineering Spring.
1. 2 Outline of Ch 4 Best-first search Greedy best-first search A * search Heuristics Functions Local search algorithms Hill-climbing search Simulated.
Computing & Information Sciences Kansas State University Friday, 08 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 7 of 42 Friday, 08 September.
Chapter 5 Team Teaching AI (created by Dewi Liliana) PTIIK Constraint Satisfaction Problems.
EXAMPLE: MAP COLORING. Example: Map coloring Variables — WA, NT, Q, NSW, V, SA, T Domains — D i ={red,green,blue} Constraints — adjacent regions must.
1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Dr. Shazzad Hosain Department of EECS North South University Lecture 01 – Part C Constraint Satisfaction Problems.
1 Constraint Satisfaction Problems (CSP). Announcements Second Test Wednesday, April 27.
Constraint Satisfaction Problems
ARTIFICIAL INTELLIGENCE (CS 461D) Dr. Abeer Mahmoud Computer science Department Princess Nora University Faculty of Computer & Information Systems.
CS 561, Session 8 1 This time: constraint satisfaction - Constraint Satisfaction Problems (CSP) - Backtracking search for CSPs - Local search for CSPs.
Constraint Satisfaction Problems (Chapter 6)
ECE 448, Lecture 7: Constraint Satisfaction Problems
Constraint Satisfaction Problems Lecture # 14, 15 & 16
Advanced Artificial Intelligence
Constraint Satisfaction Problems
Constraint Satisfaction Problems
Constraint Satisfaction Problems
Artificial Intelligence
Constraint Satisfaction Problems
Constraint Satisfaction Problems
Constraint satisfaction problems
Constraint Satisfaction Problems. A Quick Overview
CS 8520: Artificial Intelligence
Constraint Satisfaction Problems
Constraint satisfaction problems
Constraint Satisfaction Problems (CSP)
Presentation transcript:

1 Chapter 5 Constraint Satisfaction Problems

2 Outlines  Constraint Satisfaction Problems  Backtracking Search for CSPs  Local Search for CSP  The structure of problems

3 Constraint Satisfaction Problems (CSP)  What is a CSP? –Finite set of variables X 1, X 2, …, X n –Domain of possible values for each variable Dx 1, D x2, … D xn –{C 1, C 2, …, C m } Set of constraint relations that limit the values the variables can take on, e.g., X 1 ≠ X 2  Solution: Assignment of value to each variable such that the constraints are all satisfied  Consistent, objective function.  Applications: Scheduling the time of observations on the Hubble Space Telescope, Floor planning, Map coloring, Cryptography

4 Search and CSPs  Search: –Each state is a black box with no internal structure –States support goal test, evaluation, successor function –Path to goal is important  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 –Solution is more important than path to goal

5 Constraints  Given a set of variables, each with a set of possible values (depends on domain), assign a value to each variable that: –satisfies some set of explicit constraints “hard constraints” –minimizes some cost function, where each variable assignment has a cost “soft constraints”

6 CSP Example: Map Coloring [From Russell and Norvig’s AIMA slides]

7 Solution to Map Coloring

8 Map Coloring represented as a Constraint Graph

9 Incremental Formulation of CSP  Initial state: {}  Successor function: a value can be assigned to any unassigned variable, subject to constraints  Goal test: current assignment is complete  Path cost: constant cost for every step

10 Complete-state formulation  State is a complete assignment  Might or might not satisfy the constraints  Local search method.

11 Domain  Discrete –Finite domain: Map coloring, 8-Queens problem: Q 1, Q 2, …, Q 8 –D i ={1, 2, …,8}, d=|D i | All possible assignment O(d m ) Exponential in the number of variables. Boolean CSP: 3SAT problem (NP-complete problem).

12 Domain  Discrete –Infinite domain: D=N, D=R –Constraint language StratJob1 + 5 < StartJob3 Linear Constraints Nonlinear constraint

13 Domain  Continuous –Operation research (OR) –AP: Hubble Space Telescope –Linear programming: –Integer Linear Programming –Quadratic programming

14 Types of Constraints  Hard Constraints: –Unary: single variable –Binary: pairs of variables –Higher-Order: 3 or more variables  Soft constraints: preferences represented by cost for each variable assignment

15 Example of Higher-Order CSP: Cryptarithmetic

16 Auxiliary variables  X 1, X 2, X 3  {0, 1}  Constraint hypergraph.  Every higher-order, finite-domain constraints can be reduced to a set of binary constraints if enough auxiliary variables are introduced.  Types of constraints –Absolute constraints: can not be violated. –Preference constraints: timetable scheduling, may be violated.

17 Turtle Puzzle What are your variables? What are the domains of possible values? What are the constraints?

18 Search Method to CSP  Apply BFS to CSP  Branch factors –Incremental state formulation. –First level: nd( d=|D|, n=# of variables) –Second level: (n-1)d( d=|D|, n=# of variables) –… –Size of Trees (n! d n )

19 Commutativity Property of CSPs  Commutativity: Order of application of actions has no effect on the outcome.  All CSP search algorithms consider a single variable assignment at a time  Example: We choose colors for Australian territories one at a time.  The number of leaves is d n.

20 Backtracking Search  DFS that chooses values for one variable at a time and backtracks when a variables has no legal values left to assign.

21 Backtracking Example: Map Coloring

22 Backtracking Example: Map Coloring

23 Backtracking Example: Map Coloring

24 Backtracking Search  Plain backtracking is uninformed search.

25 Improving Backtracking Efficiency  Which variable (or value) should be assigned next?  In what order should its values be tried?  Can we detect inevitable failure early (and avoid the same failure in subsequent paths)?

26 Most constrained variable  Most constrained variable: choose the variable with the fewest legal values  a.k.a. minimum remaining values (MRV) heuristic  If there is a variable X with zero legal values remaining, the MRV will select X and failure will be detected immediately (pruning the search tree)

27 Most constraining variable  Tie-breaker among most constrained variables –Degree heuristic  Most constraining variable: –choose the variable with the most constraints on remaining variables 5

28 Least constraining value  Given a variable, choose the least constraining value: –the one that rules out the fewest values in the remaining variables  Combining these heuristics makes 1000 queens feasible

29 Backtracking Search  Plain backtracking is uninformed search.

30 Forward Checking  Whenever a variable X is designed, the forward checking process looks at each unassigned variable Y that is connected to X by a constraint and deletes from Y’ domain any value that is inconsistent with the value chosen for X.

31 Forward checking  Idea: –Keep track of remaining legal values for unassigned variables –Terminate search when any variable has no legal values

32 Forward checking  Idea: –Keep track of remaining legal values for unassigned variables –Terminate search when any variable has no legal values

33 Forward checking  Idea: –Keep track of remaining legal values for unassigned variables –Terminate search when any variable has no legal values

34 Forward checking  Idea: –Keep track of remaining legal values for unassigned variables –Terminate search when any variable has no legal values inconsistent

35 Constraint propagation  Forward checking propagates information from assigned to unassigned variables, but doesn't provide early detection for all failures:  NT and SA cannot both be blue!  Constraint propagation repeatedly enforces constraints locally Undetected

36 Arc consistency  Simplest form of propagation makes each arc consistent  X  Y is consistent iff for every value x of X there is some allowed y

37 Arc consistency  Simplest form of propagation makes each arc consistent  X  Y is consistent iff for every value x of X there is some allowed y

38 Arc consistency  Simplest form of propagation makes each arc consistent  X  Y is consistent iff for every value x of X there is some allowed y  If X loses a value, neighbors of X need to be rechecked

39 Arc consistency  Simplest form of propagation makes each arc consistent  X  Y is consistent iff for every value x of X there is some allowed y  If X loses a value, neighbors of X need to be rechecked  Arc consistency detects failure earlier than forward checking  Can be run as a preprocessor or after each assignment

40 Arc Consistency  As a preprocessing Step.  As a propagation Step (forward checking) after every assignment during search (MAC algorithm, maintaining arc consistency).  Queue for storing arcs.

41 Arc consistency algorithm AC-3  Time complexity: O(n 2 d 3 )

42 Arc consistency  K-consistent  1-consistent=node consistency  2-consistent=arc consistency  3- consistency =path consistency  A graph is strongly consistency it is k- consistency and is also (k-1)-consistency, …

43 Local search for CSPs  Hill-climbing, simulated annealing typically work with "complete" states, i.e., all variables assigned –The initial state assigns a value to every one variables –Successor function works by changing the value of one variable at a time.  Example: 8-Queens problem –Successor function = swap rows  To apply to CSPs: –allow states with unsatisfied constraints –operators reassign variable values

44 Min-conflict  Variable selection: randomly select any conflicted variable  Value selection by min-conflicts heuristic: –choose value that violates the fewest constraints –i.e., hill-climb with h(n) = total number of violated constraints

45 Min-Conflicts algorithm

46 Example

47 Example: 4-Queens  States: 4 queens in 4 columns (4 4 = 256 states)  Actions: move queen in column  Goal test: no attacks  Evaluation: h(n) = number of attacks  Given random initial state, can solve n-queens in almost constant time for arbitrary n with high probability (e.g., n = 10,000,000)

48 Local search for CSP  Min-Conflicts is surprisingly effective for many CSPs.  Particular when given a reasonable initial state.  For n-Queens problem, (don’t count the initial state) the runtime of min-conflicts is roughly independent of problem size.  Million-queens problem in 50 steps.  Application: –Schedule –Plan schedule –Repair the schedule with a minimum number of changes.

49 Performance measure

50 The structure of Problem  The only that we can possibly hope to deal with the real world problem is decompose it into many small problem.  Decompose into independent subproblem.

51 Decompose  Each component CSP i.  If Si be the solution of SCP i, U i S i is a solution of U i CSP i.

52 Tree-structures CSP

53

54

55 Cycle Cutset

56 Worst case  C= (n-2)  Finding the smallest cycle cutset is NP-hard.  Approximation algorithm are known.  Cutset conditioning  Application: reasoning about probabilities.

57 Tree-Decomposition

58 Tree-decompose

59 Tree-decomposed  Solve each subproblem independently.  If any one has no solution, then entire problem has no solution.  If all subproblems have solutions, then construct a global solution as follows: –View each subproblem as a mega-variable whose domain is the set of all solutions for the subproblem. WA=red, SA=blue, NT=green –Solve the constraints connecting the subproblems using tree- algorithm. (for share variable) WA=red, SA=blue, NT=green consist with SA=blue. NT=green, Q=red.

60 Tree-width  The aim of tree-decomposed is to make the subproblem as small as possible.  Tree-width of a tree decomposition of a graph is one less than the size of the largest subproblems.  The tree-width of the graph is defined to be the minimum tree width among all its tree decompositions.  If a graph has tree-width with w, the problem can be solved in O(nd w+1 ) time. (polynominal time solvable)  Finding the decomposition with minimal tree width is NP-hard. (heuristic method).

61 Summary  CSPs are a special kind of problem: –states defined by values of a fixed set of variables –goal test defined by constraints on variable values  Backtracking = depth-first search with one variable assigned per node  Variable ordering and value selection heuristics help significantly  Forward checking prevents assignments that guarantee later failure  Constraint propagation (e.g., arc consistency) does additional work to constrain values and detect inconsistencies  Iterative min-conflicts is usually effective in practice

62 Another Forward Checking Example: 4-Queens Problem X1 {1,2,3,4} X3 {1,2,3,4} X4 {1,2,3,4} X2 {1,2,3,4} [4-Queens slides are adapted from Stanford’s CS 121, with major corrections]

63 Another Forward Checking Example: 4-Queens Problem X1 {1,2,3,4} X3 {1,2,3,4} X4 {1,2,3,4} X2 {1,2,3,4}

64 Another Forward Checking Example: 4-Queens Problem X1 {1,2,3,4} X3 {,2,,4} X4 {,2,3, } X2 {,,3,4}

65 Another Forward Checking Example: 4-Queens Problem X1 {1,2,3,4} X3 {,2,,4} X4 {,2,3, } X2 {,,3,4}

66 Another Forward Checking Example: 4-Queens Problem X1 {1,2,3,4} X3 {,,, } X4 {,2,3, } X2 {,,3,4}

67 Another Forward Checking Example: 4-Queens Problem X1 {,2,3,4} X3 {1,2,3,4} X4 {1,2,3,4} X2 {1,2,3,4}

68 Another Forward Checking Example: 4-Queens Problem X1 {,2,3,4} X3 {1,,3, } X4 {1,,3,4} X2 {,,,4}

69 Another Forward Checking Example: 4-Queens Problem X1 {,2,3,4} X3 {1,,3, } X4 {1,,3,4} X2 {,,,4}

70 Another Forward Checking Example: 4-Queens Problem X1 {,2,3,4} X3 {1,,, } X4 {1,,3, } X2 {,,,4}

71 Another Forward Checking Example: 4-Queens Problem X1 {,2,3,4} X3 {1,,, } X4 {1,,3, } X2 {,,,4}

72 Another Forward Checking Example: 4-Queens Problem X1 {,2,3,4} X3 {1,,, } X4 {,,3, } X2 {,,,4}

73 Another Forward Checking Example: 4-Queens Problem X1 {,2,3,4} X3 {1,,, } X4 {,,3, } X2 {,,,4}