Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni.

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
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
ICS-271:Notes 5: 1 Lecture 5: Constraint Satisfaction Problems ICS 271 Fall 2008.
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
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.
CAP 492 Course Dr. Souham Meshoul 1 CONSTRAINT SATISFACTION PROBLEMS Chapter 5.
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.
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.
Artificial Intelligence CS482, CS682, MW 1 – 2:15, SEM 201, MS 227 Prerequisites: 302, 365 Instructor: Sushil Louis,
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.
1 Chapter 5 Constraint Satisfaction Problems. 2 Outlines  Constraint Satisfaction Problems  Backtracking Search for CSPs  Local Search for CSP  The.
CSC 8520 Spring Paula Matuszek CS 8520: Artificial Intelligence Search 3: Constraint Satisfaction Problems Paula Matuszek Spring, 2013.
Chapter 5 Constraint Satisfaction Problems
Review Test1. Robotics & Future Technology Future of Intelligent Systems / Ray Kurzweil futurist Ray Kurzweil / A Long Bet A Long Bet / Robot Soccer.
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
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
CS 561, Session 8 1 This time: constraint satisfaction - Constraint Satisfaction Problems (CSP) - Backtracking search for CSPs - Local search for CSPs.
ECE 448, Lecture 7: Constraint Satisfaction Problems
Constraint Satisfaction Problems (CSPs)
Constraint Satisfaction Problems Lecture # 14, 15 & 16
Advanced Artificial Intelligence
CS 188: Artificial Intelligence
Constraint Satisfaction Problems
Constraint Satisfaction Problems
Artificial Intelligence
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:

Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni

Problem characterization A constraint satisfaction problem (or CSP) is a special kind of problem that satisfies some additional structural properties beyond the basic requirements for problems in general. In a CSP, the states are defined by the values of a set of variables and the goal test specifies a set of constraints that the values have to obey.

Problem characterization State components: –Variables –Domains (possible values for the variables) –(Binary) constraints between variables Goal: to find a state (a complete assignment of values to variables), which satisfies the constraints Examples: –map coloring –crossword puzzles –n-queens –resource assignment/distribution/location

Representation State = constraint graph –variables (n) = node tags –domains = node content –constraints = directed and tagged arcs between nodes Example: map coloring C1 C2C4 C3 C1 C2 C3 C4     blue, red, greenblue, green blue blue, red initial state

Representation In the search tree, a variable is assigned at each level. Solutions have to be complete assignment, therefore they appear at depth n, the number of variable and maximum depth of the tree. Depth-first search algorithms are popular in CSPs. The simplest class of CSP (map coloring, n- queens) are characterized by: –discrete variables –finite domains

Finite domains If the maximum size of the domain of any variable is d, then the number of possible complete assignments is O(d n ), exponential in the number of variables. CSPs with finite domain include Boolean CSPs, whose variables can only be true or false. In most practical applications, CSP algorithms can solve problems with domains orders of magnitude larger than the ones solvable by uninformed search algorithms.

Infinite domains With infinite domains (e.g., integers and strings), to describe constraints enumerating all legal combinations of values is not possible. A constraint language has to be used, for example: –job-start ≤ job-start 3 There exist algorithms for linear constraints over integer variables. No algorithm exists for general non-linear constraints over integer variables. In cases, infinite-domain problems can be reduced to a finite domain, just restricting the values of all variables (e.g., setting limits to the dates in which jobs can start).

Search-based algorithms Incremental formulation: –Initial state: empty assignment { }, with all unassigned variables –Successor function: assignment of a value to any variable not yet assigned, provided it does not conflict with assigned variables –Goal test: check if the current assignment is complete –Path cost: a constant cost (e.g., 1) for every step Complete formulation: –Each state is a complete assignment, which satisfies or not the constraints. –Local-search methods work well in this case. Constraint propagation: –Before the search –During the search

Constraints The simplest type is the unary constraint, which constraints the values of just one variable. A binary constraint relates two variables. Higher-order constraints involve three or more variables. Cryptarithmetic puzzles are an example:

Cryptarithmetic puzzles Variables: F, T, U, W, R, O, X 1, X 2, X 3 Domains: {0,1,2,3,4,5,6,7,8,9} Constraints: –Alldiff (F,T,U,W,R,O) –O + O = R + 10 · X 1 –X 1 + W + W = U + 10 · X 2 –X 2 + T + T = O + 10 · X 3 –X 3 = F, T ≠ 0, F ≠ 0

Depth-first search with backtracking Standard depth-first search on a CSP wastes time searching when constraints have already been violated. Because of the way that the operators have been defined, an operator can never redeem a constraint that has already been violated. A first improvement is: –To test constraints after each variable assignment –If all possible values violate some constraint, then the algorithm backtracks to the last valid assignment Variables are classified as: past, current, future.

Backtracking search algorithm

1.Set each variable as undefined. Empty stack. All variables are future variables. 2.Select a future variable as current variable. If it exists, delete it from FUTURE and stack it (top = current variable), if not, the assignment is a solution. 3.Select an unused value for the current variable. If it exists, mark the value as used, if not, set current variable as undefined, mark all its values as unused, unstack the variable and add it to FUTURE, if stack is empty, there is no solution, if not, go to 3. 4.Test constraints between past variables and the current one. If they are satisfied, go to 2, if not, go to 3. (It is possible to use heuristics to select variables (2.) and values (3.).

Backtracking search algorithm

Example: 4-queens Place 4 queens, one per row, so that they do not attack each others –Variables: R 1 … R 4 (queens) –Domains: [1 … 4] for each R i (columns) –Constraints: R i does not attack R j not attacking RiRi RjRj [1.. 4]

R1=1 R2=1 NO R2=2 NO R2=3 R3=1 NO R3=2 NO R3=3 NO R3=4 NO R2=4 R3=1 NO R3=2 R4=1 NO R4=2 NO R4=3 NO R4=4 NO R1=2 R2=1 NO R2=2 NO R2=3 NO R2=4 R3=1 R4=1 NO R4=2 NO R4=3 Backtracking R2 Backtracking R3, R2, R1

Propagating information through constraints So far the algorithm considers the constraints on a variable only at the time that the variable is chosen (e.g., by Select- Unassigned-Variable). By looking at some of the constraints earlier in the search, or even before the search has started, the search space can be drastically reduced.

Forward checking A way to make better use of constraints during search. Whenever a variable X is assigned: –the forward checking process looks 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 the value chosen for X.

Forward checking algorithm

Forward checking: example

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

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

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

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

R1=1? propagation: R2=3,4; R3=2,4; R4=2,3  R1=1 R2=3? propagation : R3=  R2=4? propagation : R3=2; R4=3  R2=4 R3=2? propagation : R4=  No other value for R3. Backtracking to R2 No other value for R2. Backtracking to R1 R1=2? propagation : R2=4; R3=1,3; R4=1,3,4  R1=2 R2=4? propagation : R3=1; R4=1,3  R2=4 R3=1? propagation : R4=3  R3=1 R4=3? No propagations  R4=3 Forward checking: 4-queens example

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

Constraint propagation Forward checking does not detect the “blue” inconsistency, because it does not look far enough ahead. Constraint propagation is the general term for propagating the implications of a constraint on one variable onto other variables. The idea of arc consistency provides a fast method of constraint propagation that is substantially stronger than forward checking.

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 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 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 preprocess or after each assignment

Algorithm for arc consistency

Algorithm for arc consistency: AC-3 It uses a queue to keep track of the arcs that need to be checked for inconsistency. Each arc (X i, X j ) in turn is removed from the agenda and checked. If any values need to be deleted from the domain of X i, then every arc (X k, X j ) pointing to X i must be reinserted on the queue for checking.

(C1,C2): eliminate AZUL (C2,C1): ok (C2,C3): ok (C3,C2): eliminate AZUL (C2,C4): ok (C4,C2): eliminate AZUL (C3,C4): eliminate VERDE add (C2,C3) (C4,C3): ok (C2,C3): ok C1 C2 C3 C4     AZUL, ROJO, VERDEAZUL, VERDE AZUL AZUL, ROJO Initial list: (C1,C2), (C2,C1), (C2,C3), (C3,C2), (C2,C4), (C4,C2), (C3,C4), (C4,C3) Algorithm for arc consistency: AC-3