Constraint Satisfaction Problems

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Constraint Satisfaction Problems Russell and Norvig: Chapter
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
Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni.
Constraint Satisfaction problems (CSP)
4/18/2005EE5621 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 6, 4/20/2005 University of Washington, Department of Electrical Engineering Spring.
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
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
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.
Artificial Intelligence CS482, CS682, MW 1 – 2:15, SEM 201, MS 227 Prerequisites: 302, 365 Instructor: Sushil Louis,
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.
Puzzle A Puzzle B. When asked about his birthday, a man said: "The day before yesterday I was only 25 and next year I will turn 28." This is true only.
Constraint Satisfaction Read Chapter 5. Model Finite set of variables: X1,…Xn Variable Xi has values in domain Di. Constraints C1…Cm. A constraint specifies.
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.
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.
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.
Dr. Shazzad Hosain Department of EECS North South University Lecture 01 – Part C Constraint Satisfaction Problems.
Constraint Satisfaction Problems Chapter 6.1 – 6.4 Derived from slides by S. Russell and P. Norvig, A. Moore, and R. Khoury.
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
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
ECE 448, Lecture 7: Constraint Satisfaction Problems
Constraint Satisfaction Problems (CSPs)
Constraint Satisfaction Problems Lecture # 14, 15 & 16
Clues 1 The Brit lives in the red house 2 The Swede keeps dogs as pets 3 The Dane drinks tea 4 As you look at the houses from across the street, the.
Solving the ‘Einstein” puzzle
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Constraint Satisfaction Problems
Artificial Intelligence
Constraints and Search
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 ECE457 Applied Artificial Intelligence Spring 2007 Lecture #4

Outline Defining constraint satisfaction problems (CSP) CSP search algorithms Russell & Norvig, chapter 5 ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 2

States What do we know about states? A state might be a goal (goal test) A state has a value (cost or payoff) An agent moves from state to state using actions The state space can be discreet or continuous Ties in with the problem definition Initial state, goal test, set of actions and their costs defined in problem ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 3

Definitions A constraint-satisfaction problem has A set of variables V = {X1, X2, …, Xn} Each variable has a domain of values Xi  Di = {di1, di2, …, din} A set of constraints on the values each variable can take C = {C1, C2, …, Cm} A state is a set of assignment of values S1 = {X1 = d12, X4 = d45} ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 4

Definitions Consistent (legal) state Complete state Goal state Does not violate any constraints Complete state All variables have a value Goal state Consistent and complete Might not exist Proof of inconsistency ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 5

Example: 8-queen Variables: 64 squares Values: Queen or no queen V = {X1,1, X1,2, …, X64,64} Values: Queen or no queen Xi,j  D = {queen, empty} States: All board configurations 1.8x1014 complete states Constraints: Attacks {Xi,j = queen  Xi,j+n = empty, Xi,j = queen  Xi+n,j = empty, Xi,j = queen  Xi+n,j+n = empty} 92 complete and consistent states ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 6

Example: 8-queen ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 7

Example: The Einstein Puzzle There are 5 houses in 5 different colours. In each house lives a person with a different nationality. These 5 owners drink a certain beverage, smoke a certain brand of cigar and keep a certain pet. No owners have the same pet, smoke the same brand of cigar or drink the same drink. Who keeps the fish? The English lives in a red house. The Swede keeps dogs as pets. The Dane drinks tea. The green house is on the left of the white house. The green house owner drinks coffee. The person who smokes Pall Mall rears birds. The owner of the yellow house smokes Dunhill. The man living in the house right in the centre drinks milk. The Norwegian lives in the first house. The man who smokes Blend lives next to the one who keeps cats. The man who keeps horses lives next to the man who smokes Dunhill. The owner who smokes Blue Master drinks beer. The German smokes Prince. The Norwegian lives next to the blue house. The man who smokes Blend has a neighbour who drinks water. ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 8

Example: The Einstein Puzzle 1 2 3 4 5 25 variables V = {N1, …, N5, C1, …, C5, D1, …, D5, S1, …, S5, P1, …, P5} Domains Ni  {English, Swede, Dane, Norwegian, German} Ci  {green, yellow, blue, red, white} Di  {tea, coffee, milk, beer, water} Si  {Pall Mall, Dunhill, Blend, Blue Master, Prince} Pi  {dog, cat, horse, fish, birds} ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 9

Example: The Einstein Puzzle The Norwegian lives in the first house. N1 = Norwegian The English lives in a red house. (Ni = English)  (Ci = Red) The green house is on the left of the white house. (Ci = green)  (Ci+1 = white) (C5 ≠ green) (C1 ≠ white) ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 10

Example: Map Colouring Colour map of the provinces of Australia 3 colours (red, green, blue) No adjacent provinces of the same colour Define CSP ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 11

Example: Map Colouring CSP Variables {WA, NT, SA, Q, NSW, V, T} Domain {R, G, B} Constrains {WA  NT, WA  SA, NT  SA, NT  Q, SA  Q, SA  NSW, SA  V, Q  NSW, NSW  V} ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 12

Solving CSP Iterative improvement methods Tree searching Start with random complete state, improve until consistent Tree searching Start with empty state, make consistent variable assignments until complete ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 13

Iterative Improvement Algorithm: Start with random complete state While not consistent Pick a variable (randomly or with a heuristic) Change its assignment to minimize number of violated constraints Not complete Might not search all state space Might not find a solution even if one exists We won’t do that in this course ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 14

Tree Search Formulate CSP as tree Root node: no variables are assigned a value Action: assign a value if it does not violate any constraints Solution node at depth n for n-variable problem ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 15

Backtracking Search Start with empty state While not complete Pick a variable (randomly or with heuristic) If it has a value that does not violate any constraints Assign that value Else Go back to previous variable Assign it another value ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 16

Backtracking Search Depth-first search algorithm Algorithm complete Goes down one variable at a time In a dead end, back up to last variable whose value can be changed without violating any constraints, and change it If you backed up to the root and tried all values, then there are no solutions Algorithm complete Will find a solution if one exists Will expand the entire (finite) search space if necessary Depth-limited search with limit = n ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 17

Example: Backtracking Search WA = G WA = R WA = B NT = G NT = B Q = B Q = R NSW = G NSW = G SWA = B NSW = R SA = B SA = ? SA = ? V = R T = G T = B T = R ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 18

Conflict-Directed Backjumping Suppose we colour Australia in this order: WA – R NSW – R T – B NT – B Q – G SA - ? Dead-end at SA No possible solution with WA = NSW Backtracking will try to change T on the way, even though it has nothing to do with the problem, before going to NSW ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 19

Conflict-Directed Backjumping Backtracking goes back one level in the search tree at a time Chronological backtrack Not rational in cases where the previous step is not involved to the conflict Conflict-directed backjumping (CBJ) Should go back to a variable involved in the conflict Skip several levels if needed to get there Non-chronological backtrack ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 20

Conflict-Directed Backjumping Maintain a conflict set for each variable List of previously-assigned variables that are related by constraints conf(WA) = {} conf(NSW) = {} conf(T) = {} conf(NT) = {WA} conf(Q) = {NSW,NT} conf(SA) = {WA,NSW,NT,Q} When we hit a dead-end, backjump to the deepest variable in the conflict set ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 21

Conflict-Directed Backjumping Learn from the conflict by updating the conflict set of the variable we jumped to Conflict at Xj, backjump to Xi conf(Xi)={X1,X2,X3} conf(Xj)={X3,X4,X5,Xi} conf(Xi) = conf(Xi)  conf(Xj) – {Xi} conf(Xi) = {X1,X2,X3,X4,X5} Xi absorbed the conflict set of Xj ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 22

Conflict-Directed Backjumping SA backjump to Q conf(Q) = {WA,NSW,NT} Meaning: “There is no consistent solution from Q onwards, given the preceding assignments of WA, NSW and NT together” Q backjump to NT conf(NT) = {WA,NSW} NT backjump over T to NSW conf(NSW) = {WA} conf(WA) = {} conf(NSW) = {} conf(T) = {} conf(NT) = {WA} conf(Q) = {NSW,NT} conf(SA) = {WA,NSW,NT,Q} ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 23

Heuristics Backtracking and CDJ searches are variations of depth-limited search Uninformed search technique Can we make it an informed search? Add some heuristics Which variable to assign next? In which order should the values be tried? How to detect dead-ends early? ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 24

Variable & Value Heuristics Most constrained variable Choose the variable with the fewest legal values remaining in its domain aka Minimum remaining values Most constraining variable Choose the variable that’s part of the most constraints Useful to pick first variable to assign aka Degree heuristic Least constraining variable Pick the variable that’s part of the fewest constrains Keeps maximum flexibility for future assignments ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 25

Variable & Value Heuristics Values: 2 Constraints: 2 Most constrained variable Values: 2 Constraints: 2 Values: 2 Constraints: 1 Values: 2 Constraints: 2 Most constrained & least constraining variable Most constrained variable Most constraining variable Most constraining variable Most constrained variable Values: 2 Constraints: 1 Least constraining variable ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 26

Forward Checking How to detect dead-ends early? Keep track of the domain of unassigned variables Use constraints to prune domain of unassigned variables Backtrack when a variable has an empty domain Do not waste time exploring further ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 27

Example: Forward Checking B NT G Q R NSW GB V RGB T SA WA B NT G Q RB NSW RGB V T SA R WA RGB NT Q NSW V T SA WA B NT RG Q RGB NSW V T SA ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 28

Problem with Forward Checking NT G Q NSW V T RGB SA R ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 29

Constraint Propagation Propagate the consequences of a variable’s constraints onto other variables Represent CSP as constraint graph Nodes are variables Arcs are constraints Check for consistency NT Q WA NSW SA V T ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 30

Checking for Consistency Node consistency Unary constraint (e.g. NT  G) A node is consistent if and only if all values in its domain satisfy all unary constraints Arc consistency Binary constraint (e.g. NT  Q) An arc Xi  Xj or (Xi, Xj) is consistent if and only if, for each value a in the domain of Xi, there is a value b in the domain of Xj that is permitted by the binary constraints between Xi and Xj. Path consistency Can be reduced to arc consistency ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 31

Checking for Consistency Node consistency Simply scan domain of values of each variable and remove those that are not valid Arc consistency Examine edges and delete values from domains to make arcs consistent ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 32

Checking for Consistency Remove inconsistent values from a variable’s domain Backtrack if empty domain Maintaining node and arc consistency reduces the size of the tree More computationally expensive than Forward Checking, but worth it ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 33

AC-3 Algorithm Keep queue of arcs (Xi, Xj) to be checked for consistency If checking an arc removes a value from the domain of Xi, then all arcs (Xk, Xi) are reinserted in the queue ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 34

AC-3 Algorithm Add all arcs to queue While queue not empty Get next arc from queue For each value di of Xi If there is no consistent value dj in Xj Delete di If a value di was deleted For each neighbour Xk of Xi Add arc (Xk, Xi) to queue ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 35

AC-3 Algorithm Advantages Disadvantage Prunes tree, reduces amount of searching For n-node CSP that’s n-consistent, solution is guaranteed with no backtracking Disadvantage Computationally expensive If pruning takes longer than searching, it’s not worth it ECE457 Applied Artificial Intelligence R. Khoury (2007) Page 36