Constraint Satisfaction Problems Russell and Norvig: Chapter 5.1-3.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Constraint Satisfaction Problems (Chapter 6). What is search for? Assumptions: single agent, deterministic, fully observable, discrete environment Search.
Constraint Satisfaction Problems
This lecture topic (two lectures) Chapter 6.1 – 6.4, except
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)
1 Constraint Satisfaction Problems. 2 Intro Example: 8-Queens Generate-and-test: 8 8 combinations.
This lecture topic (two lectures) Chapter 6.1 – 6.4, except 6.3.3
MBD and CSP Meir Kalech Partially based on slides of Jia You and Brian Williams.
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. Constraint satisfaction problems (CSPs) Standard search problem: – State is a “black box” – any data structure that.
Constraint Satisfaction Problems
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Artificial Intelligence Constraint satisfaction Chapter 5, AIMA.
Constraint Satisfaction Problems
Constraint Satisfaction
Constraint Satisfaction Problems Russell and Norvig: Chapter 3, Section 3.7 Chapter 4, Pages Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm.
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.
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.
1 Chapter 5 Constraint Satisfaction Problems. 2 Outlines  Constraint Satisfaction Problems  Backtracking Search for CSPs  Local Search for CSP  The.
Constraint Satisfaction Russell & Norvig Ch. 5. Overview Constraint satisfaction offers a powerful problem- solving paradigm –View a problem as a set.
CSC 8520 Spring Paula Matuszek CS 8520: Artificial Intelligence Search 3: Constraint Satisfaction Problems Paula Matuszek Spring, 2013.
Chapter 5 Constraint Satisfaction Problems
Constraint Satisfaction Problems (Chapter 6)
An Introduction to Artificial Intelligence Lecture 5: Constraint Satisfaction Problems Ramin Halavati In which we see how treating.
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
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.
Constraint Satisfaction Problems Rich and Knight: 3.5 Russell and Norvig: Chapter 3, Section 3.7 Chapter 4, Pages Slides adapted from: robotics.stanford.edu/~latombe/cs121/2003/home.htm.
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.
PSU CS 370 – Introduction to Artificial Intelligence 1 Constraint Satisfaction Problems.
1 Constraint Satisfaction Problems (CSP). Announcements Second Test Wednesday, April 27.
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
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:

Constraint Satisfaction Problems Russell and Norvig: Chapter 5.1-3

Intro Example: 8-Queens Generate-and-test, 8 8 combinations

Intro Example: 8-Queens

What is Needed? Not just a successor function and goal test But also a means to propagate the constraints imposed by one queen on the others and an early failure test  Explicit representation of constraints and constraint manipulation algorithms

Constraint Satisfaction Problem Set of variables {X 1, X 2, …, X n } Each variable X i has a domain D i of possible values Usually D i is discrete and finite Set of constraints {C 1, C 2, …, C p } Each constraint C k involves a subset of variables and specifies the allowable combinations of values of these variables Assign a value to every variable such that all constraints are satisfied

Example: 8-Queens Problem 8 variables X i, i = 1 to 8 Domain for each variable {1,2,…,8} Constraints are of the forms: X i = k  X j  k for all j = 1 to 8, j  i X i = k i, X j = k j  |i-j|  | k i - k j |  for all j = 1 to 8, j  i

Example: Map Coloring 7 variables {WA,NT,SA,Q,NSW,V,T} Each variable has the same domain {red, green, blue} No two adjacent variables have the same value: WA  NT, WA  SA, NT  SA, NT  Q, SA  Q, SA  NSW, SA  V,Q  NSW, NSW  V WA NT SA Q NSW V T WA NT SA Q NSW V T

Example: Task Scheduling T1 must be done during T3 T2 must be achieved before T1 starts T2 must overlap with T3 T4 must start after T1 is complete T1 T2 T3 T4

Constraint Graph Binary constraints T WA NT SA Q NSW V Two variables are adjacent or neighbors if they are connected by an edge or an arc T1 T2 T3 T4

CSP as a Search Problem Initial state: empty assignment Successor function: a value is assigned to any unassigned variable, which does not conflict with the currently assigned variables Goal test: the assignment is complete Path cost: irrelevant

Remark Finite CSP include 3SAT as a special case 3SAT is known to be NP-complete So, in the worst-case, we cannot expect to solve a finite CSP in less than exponential time

Backtracking example

Backtracking Algorithm CSP-BACKTRACKING(PartialAssignment a) If a is complete then return a X  select an unassigned variable D  select an ordering for the domain of X For each value v in D do  If v is consistent with a then Add (X= v) to a result  CSP-BACKTRACKING(a) If result  failure then return result Remove (X= v) from a Return failure Start with CSP-BACKTRACKING({})

Improving backtracking efficiency Which variable should be assigned next? In what order should its values be tried? Can we detect inevitable failure early?

Most constrained variable Most constrained variable: choose the variable with the fewest legal values a.k.a. minimum remaining values (MRV) heuristic

Most constraining variable Tie-breaker among most constrained variables Most constraining variable: choose the variable involved in largest # of constraints on remaining variables

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

Forward Checking After a variable X is assigned a value v, look at each unassigned variable Y that is connected to X by a constraint and deletes from Y’s domain any value that is inconsistent with v

Forward checking

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!

Definition (Arc consistency) A constraint C_xy is said to be arc consistent w.r.t. x if for each value v of x there is an allowed value of y. Similarly, we define that C_xy is arc consistent w.r.t. y. A binary CSP is arc consistent iff every constraint C_xy is arc consistent wrt x as well as wrt y.

When a CSP is not arc consistent, we can make it arc consistent, e.g. by using AC3. This is also called “enforcing arc consistency”.

Example Let domains be D_x = {1,2,3}, D_y = {3,4,5,6} A constaint C_xy = {(1,3),(1,5),(3,3),(3,6)} C_xy is not arc consistent w.r.t. x, neither w.r.t. y. By enforcing arc consistency, we get reduced domains D’_x = {1,3}, D’_y={3,5,6}

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

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

Arc consistency If X loses a value, neighbors of X need to be rechecked

Arc consistency Arc consistency detects failure earlier than forward checking Can be run as a preprocessor or after each assignment

Example: domain reduction Consider constraints: X > Y, Y > Z Domains: Dx = Dy = Dz = {1,2,3} - 1 in Dx is removed by maintaining arc consistency, w.r.t. the constraint X < Y. - You work out the rest. The resulting domains are D’x = {1}, D’y = {2}, D’z = {3} No search is needed

General CP for Binary Constraints Algorithm AC3 contradiction  false Q  stack of all variables while Q is not empty and not contradiction do X  UNSTACK(Q) For every variable Y adjacent to X do  If REMOVE-ARC-INCONSISTENCIES(X,Y) then If Y’s domain is non-empty then STACK(Y,Q) Else return false

Complexity Analysis of AC3 e = number of constraints (edges) (or n 2 where n is the # of variables) d = number of values per variable Each variable is inserted in Q up to d times REMOVE-ARC-INCONSISTENCY takes O(d 2 ) time AC3 takes O(ed 3 ) time to run

Solving a CSP Search: can find solutions, but must examine non- solutions along the way Constraint Propagation: can rule out non-solutions, but this is not the same as finding solutions: Interweave constraint propagation and search Perform constraint propagation at each search step.

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 Problem X1 {1,2,3,4} X3 {1,2,3,4} X4 {1,2,3,4} X2 {1,2,3,4}

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 Problem X1 {1,2,3,4} X3 {1,2,3,4} X4 {1,2,3,4} X2 {1,2,3,4}

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 Problem X1 {1,2,3,4} X3 {1,2,3,4} X4 {1,2,3,4} X2 {1,2,3,4}

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 Problem X1 {1,2,3,4} X3 {1,2,3,4} X4 {1,2,3,4} X2 {1,2,3,4}

4-Queens Problem X1 {1,2,3,4} X3 {1,2,3,4} X4 {1,2,3,4} X2 {1,2,3,4}

Local search for CSPs Hill-climbing, simulated annealing typically work with "complete" states, i.e., all variables assigned To apply to CSPs: allow states with unsatisfied constraints operators reassign variable values Variable selection: randomly select any conflicted variable Value selection by min-conflicts heuristic: choose value that violates the fewest constraints

Summary Constraint Satisfaction Problems (CSP) CSP as a search problem Backtracking algorithm General heuristics Forward checking Constraint propagation (Arc consistency) Interweaving CP and backtracking