1 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 CSC384: Intro to Artificial Intelligence Backtracking Search I ● Announcements.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Constraint Satisfaction Patrick Prosser. An Example, Exam Timetabling Someone timetables the exams We have a number of courses to examine how many? Dept.
Local Search Jim Little UBC CS 322 – CSP October 3, 2014 Textbook §4.8
Constraint Satisfaction Introduction to Artificial Intelligence COS302 Michael L. Littman Fall 2001.
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
ICS-271:Notes 5: 1 Lecture 5: Constraint Satisfaction Problems ICS 271 Fall 2008.
Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni.
Constraint Satisfaction Problems. Constraint satisfaction problems (CSPs) Standard search problem: – State is a “black box” – any data structure that.
CPSC 322, Lecture 11Slide 1 Constraint Satisfaction Problems (CSPs) Introduction Computer Science cpsc322, Lecture 11 (Textbook Chpt 4.0 – 4.2) January,
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Artificial Intelligence Constraint satisfaction Chapter 5, AIMA.
CS420 lecture ten BACKTRACK. Solution vectors In optimization problems, or more general in search problems, a set of choices are to be made to arrive.
Constraint Satisfaction Problems
Constraint Satisfaction
Chapter 5 Outline Formal definition of CSP CSP Examples
Constraint Satisfaction Problems
Constraint Satisfaction Problems
Slide 1 Constraint Satisfaction Problems (CSPs) Introduction Jim Little UBC CS 322 – CSP 1 September 27, 2014 Textbook §
Local Search CPSC 322 – CSP 5 Textbook §4.8 February 7, 2011.
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
HISTORY The problem was originally proposed in 1848 by the chess player Max Bezzel, and over the years, many mathematicians, including Gauss have worked.
CS 484 – Artificial Intelligence1 Announcements Homework 2 due today Lab 1 due Thursday, 9/20 Homework 3 has been posted Autumn – Current Event Tuesday.
Constraint Satisfaction Problems Chapter 6. Review Agent, Environment, State Agent as search problem Uninformed search strategies Informed (heuristic.
Contents of Chapter 7 Chapter 7 Backtracking 7.1 The General method
Chapter 5 Section 1 – 3 1.  Constraint Satisfaction Problems (CSP)  Backtracking search for CSPs  Local search for CSPs 2.
Data Structures Using C++ 2E1 Recursion and Backtracking: DFS Depth first search (a way to traverse a tree or graph) Backtracking can be regarded as a.
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Searching by Constraint CMSC Artificial Intelligence January 24, 2008.
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,
Chapter 5: Constraint Satisfaction ICS 171 Fall 2006.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Fall 2006 Jim Martin.
CSC 8520 Spring Paula Matuszek CS 8520: Artificial Intelligence Search 3: Constraint Satisfaction Problems Paula Matuszek Spring, 2013.
CSPs Tamara Berg CS Artificial Intelligence Many slides throughout the course adapted from Svetlana Lazebnik, Dan Klein, Stuart Russell, Andrew.
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.
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.
Backtracking & Brute Force Optimization Intro2CS – weeks
Chapter 13 Backtracking Introduction The 3-coloring problem
Fahiem Bacchus, University of Toronto CSC384: Intro to Artificial Intelligence  Backtracking Search (CSPs)  Chapter 5  5.3 talks about local search.
N-queens problem Original problem: How to place 8 queens on an 8x8 chessboard so that no two queens attack each other N-queen problem: Generalization for.
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.
1 CSC 384 Lecture Slides (c) , C. Boutilier and P. Poupart CSC384: Lecture 16  Last time Searching a Graphplan for a plan, and relaxed plan heuristics.
1 Constraint Satisfaction Problems (CSP). Announcements Second Test Wednesday, April 27.
Constraint Satisfaction Problems
Cse 150, Fall 2012Gary Cottrell: Many slides borrowed from David Kriegman! Constraint Satisfaction Problems Introduction to Artificial Intelligence CSE.
CS 561, Session 8 1 This time: constraint satisfaction - Constraint Satisfaction Problems (CSP) - Backtracking search for CSPs - Local search for CSPs.
CSG3F3/ Desain dan Analisis Algoritma
Constraint Satisfaction Problems (CSPs)
Instructor: Vincent Conitzer
Constraint Satisfaction Problem
Lecture 7 Constraint Satisfaction Problems
CS 188: Artificial Intelligence
Computer Science cpsc322, Lecture 14
Computer Science cpsc322, Lecture 13
Back Tracking.
Analysis and design of algorithm
Chapter 3: Finite Constraint Domains
Artificial Intelligence
Constraint satisfaction problems
CS 8520: Artificial Intelligence
Constraint Satisfaction Problems
Constraint satisfaction problems
Constraint Satisfaction Problems (CSP)
Presentation transcript:

1 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 CSC384: Intro to Artificial Intelligence Backtracking Search I ● Announcements ■ Readings: Chapter 5. ■ A2 is out today (check the website this afternoon). Due Oct 25

2 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Constraint Satisfaction Problems ● The search algorithms we discussed so far had no knowledge of the states representation (black box). So, we could not take advantage of domain-specific information. ● CSP are a special class of search problems with a uniform and simple state representation. ● This allows to design more efficient algorithms.

3 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Constraint Satisfaction Problems ● Many problems can be represented as a search for a vector of feature values. ■ k-features: variables. ■ Each feature has a value. Domain of values for the variables. ■ e.g., height = {short, average, tall}, weight = {light, average, heavy}. ● In these problems the problem is to search for a set of values for the features (variables) so that the values satisfy some conditions (constraints).

4 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Constraint Satisfaction Problems ● Sudoku: ■ 81 variables, the value in each cell. ■ Values: a fixed value for those cells that are already filled in, the values {1-9} for those cells that are empty. ■ Solution: a value for each cell satisfying the constraints: ● no cell in the same column can have the same value. ● no cell in the same row can have the same value. ● no cell in the same sub-square can have the same value.

5 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Constraint Satisfaction Problems ● Scheduling ■ Want to schedule a time and a space for each final exam so that ● No student is scheduled to take more than one final at the same time. ● The space allocated has to be available at the time set. ● The space has to be large enough to accommodate all of the students taking the exam.

6 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Constraint Satisfaction Problems ● Variables: ■ T1, …, Tm: Ti is a variable representing the scheduled time for the i-th final. ● Assume domains are fixed to {MonAm, MonPm, …, FriAm, FriPm}. ■ S1, …, Sm: Si is the space variable for the i-th final. ● Domain of Si are all rooms big enough to hold the i-th final.

7 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Constraint Satisfaction Problems ● Want to find an assignment of values to each variable (times, rooms for each final), subject to the constraints: ■ For all pairs of finals i, j such that there is a student taking both: ● Ti ≠ Tj ■ For all pairs of finals i, j ● Ti ≠ Tj or Si ≠ Sj ■ either i and j are not scheduled at the same time, or if they are they are not in the same space.

8 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Constraint Satisfaction Problems (CSP) ● More formally. ● A CSP consists of ■ a set of variables V1, …, Vn ■ for each variable a domain of possible values Dom[Vi]. ■ A set of constraints C1,…, Cm.

9 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Constraint Satisfaction Problems ● Each variable be assigned any value from its domain. ● Vi = d where d ∈ Dom[Vi] ● Each constraint C has ■ A set of variables it is over, called its scope: e.g., C(V1,V2,V4). ■ Is a boolean function that maps assignments to these variables to true/false. ● e.g. C(V1=a,V2=b,V4=c) = True ● this set of assignments satisfies the constraint. ● e.g. C(V1=b,V2=c,V4=c) = False ● this set of assignments falsifies the constraint.

10 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Constraint Satisfaction Problems ● A solution to a CSP is ■ an assignment of a value to all of the variables such that ● every constraint is satisfied.

11 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Constraint Satisfaction Problems ● Sudoku: ■ V 11, V 12, …, V 21, V 22, …, V 91, …, V 99 ● Dom[V ij ] = {1-9} for empty cells ● Dom[V ij ] = {k} a fixed value k for filled cells. ■ Row constraints: ● CR1(V 11, V 12, V 13, …, V 19 ) ● CR2(V 21, V 22, V 23, …, V 29 ) ●...., CR9(V 91, V 92, …, V 99 ) ■ Column Constraints: ● CC1(V 11, V 21, V 31, …, V 91 ) ● CC2(V 21, V 22, V 13, …, V 92 ) ●...., CC9(V 19, V 29, …, V 99 ) ■ Sub-Square Constraints: ● CSS1(V 11, V 12, V 13, V 21, V 22, V 23, V 31, V 32, V 33 ) ● CSS1(V 14, V 15, V 16,…, V 34, V 35, V 36 )

12 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Constraint Satisfaction Problems ● Sudoku: ■ Each of these constraints is over 9 variables, and they are all the same constraint: ● Any assignment to these 9 variables such that each variable has a unique value satisfies the constraint. ● Any assignment where two or more variables have the same value falsifies the constraint. ■ Such constraints are often called ALL-DIFF constraints.

13 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Constraint Satisfaction Problems ● Sudoku: ■ Thus Sudoku has 3x9 ALL-Diff constraints, one over each set of variables in the same row, one over each set of variables in the same column, and one over each set of variables in the same sub-square. ■ Note also that an ALL-Diff constraint over k variables can be equivalently represented by k choose 2 not- equal constraints over each pair of these variables. ● e.g. CSS1(V 11, V 12, V 13, V 21, V 22, V 23, V 31, V 32, V 33 ) = NEQ(V 11,V 12 ), NEQ(V 11,V 13 ), NEQ(V 11,V 21 ) …, NEQ(V 32,V 33 ) ■ NEQ is a not-equal constraint.

14 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Constraint Satisfaction Problems ● Exam Scheduling ■ constraints: ■ For all pairs of finals i, j such that there is a student taking both: ● NEQ(Ti,Tj) ■ For all pairs of finals i, j ● C(Ti,Tj,Si,Sj) ■ This constraint is satisfied ● by any set of assignments in which Ti ≠ Tj. ● any set of assignments in which Si ≠ Sj. ■ Falsified by any set of assignments in which Ti=Tj as well as Sj=Sj.

15 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Solving CSPs ● CSPs can be solved by a specialized version of depth first search. ● Key intuitions: ■ We can build up to a solution by searching through the space of partial assignments. ■ Order in which we assign the variables does not matter---eventually they all have to be assigned. ■ If during the process of building up a solution we falsify a constraint, we can immediately reject all possible ways of extending the current partial assignment.

16 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Backtracking Search ● These ideas lead to the backtracking search algorithm Algorithm BT (Backtracking) BT(Level) If all variables assigned PRINT Value of each Variable RETURN or EXIT (RETURN for more solutions) (EXIT for only one solution) V := PickUnassignedVariable() Variable[Level] := V Assigned[V] := TRUE for d := each member of Domain(V) Value[V] := d OK := TRUE for each constraint C such that V is a variable of C and all other variables of C are assigned. if C is not satisfied by the current set of assignments OK := FALSE if(OK) BT(Level+1) return

17 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Solving CSPs ● The algorithm searches a tree of partial assignments. Root {} Vi=aVi=bVi=c Vj=1Vj=2 The root has the empty set of assignments Children of a node are all possible values of some (any) unassigned variable Subtree Search stops descending if the assignments on path to the node violate a constraint

18 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Backtracking Search ● Heuristics are used to determine which variable to assign next “ PickUnassignedVariable ”. ● The choice can vary from branch to branch, e.g., ■ under the assignment V1=a we might choose to assign V4 next, while under V1=b we might choose to assign V5 next. ● This “dynamically” chosen variable ordering has a tremendous impact on performance.

19 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Example. ● N-Queens. Place N Queens on an N X N chess board so that no Queen can attack any other Queen. ■ Variables, one per row. ● Value of Qi is the column the Queen in row i is place. ■ Constrants. ● Vi ≠ Vj for all i ≠ j (can put two Queens in same column) ● |Vi-Vj| ≠ i-j (Diagonal constraint) ■ (i.e., the difference in the values assigned to Vi and Vj can’t be equal to the difference between i and j.

20 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Example. ● 4X4 Queens

21 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Example. ● 4X4 Queens

22 Hojjat Ghaderi [Courtesy of Fahiem Bacchus], University of Toronto, Fall 2006 Example. ● 4X4 Queens Solution!