Constraint Satisfaction Problems

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

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)
ICS-271:Notes 5: 1 Lecture 5: Constraint Satisfaction Problems ICS 271 Fall 2008.
MBD and CSP Meir Kalech Partially based on slides of Jia You and Brian Williams.
Constraint Satisfaction Problems. Constraint satisfaction problems (CSPs) Standard search problem: – State is a “black box” – any data structure that.
Constraint Satisfaction Problems
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.
Constraint Satisfaction CSE 473 University of Washington.
Constraint Satisfaction and the Davis-Putnam-Logeman-Loveland Procedure Henry Kautz.
Artificial Intelligence Constraint satisfaction Chapter 5, AIMA.
1 Constraint Satisfaction Problems Soup Total Cost < $30 Chicken Dish Vegetable RiceSeafood Pork Dish Appetizer Must be Hot&Sour No Peanuts No Peanuts.
Constraint Satisfaction Problems
Constraint Satisfaction
University College Cork (Ireland) Department of Civil and Environmental Engineering Course: Engineering Artificial Intelligence Dr. Radu Marinescu Lecture.
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.
Variables “To be is to be the value of a variable.” - William Quine.
1 Constraint Satisfaction Problems Slides by Prof WELLING.
Slide 1 Constraint Satisfaction Problems (CSPs) Introduction Jim Little UBC CS 322 – CSP 1 September 27, 2014 Textbook §
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.
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.
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.
CSPs Tamara Berg CS Artificial Intelligence Many slides throughout the course adapted from Svetlana Lazebnik, Dan Klein, Stuart Russell, Andrew.
CSE 473: Artificial Intelligence Constraint Satisfaction Daniel Weld Slides adapted from Dan Klein, Stuart Russell, Andrew Moore & Luke Zettlemoyer.
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.
Constraint Satisfaction CSE 473 University of Washington.
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
CMPT 463. What will be covered A* search Local search Game tree Constraint satisfaction problems (CSP)
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.
Constraint Satisfaction Problems (CSPs) Introduction
Constraint Satisfaction
Constraint Satisfaction
Advanced Artificial Intelligence
CS 188: Artificial Intelligence
Constraint Satisfaction Problems
Constraint Satisfaction Problems
Artificial Intelligence
Constraint satisfaction problems
Constraint Satisfaction Problems. A Quick Overview
Constraint Satisfaction Problems
CS 8520: Artificial Intelligence
Constraint Satisfaction Problems
Constraint satisfaction problems
Constraint Satisfaction Problems (CSP)
Presentation transcript:

Constraint Satisfaction Problems Introduction to AI

Real World Samples of CSP Assignment problems e.g., who teaches what class Timetabling problems e.g., which class is offered when and where? Transportation scheduling Factory scheduling

Map Colouring Given a map of “countries”: Assign a colour to each country such that IF two countries share a border THEN they are given different colours We can only use a limited number of colours Alternatively, we must use the minimal possible number of colours

Example: Map-Coloring Variables WA, NT, Q, NSW, V, SA, T Domains Di = {red,green,blue} Constraints: adjacent regions must have different colors e.g., WA ≠ NT, or (WA,NT) in {(red,green),(red,blue),(green,red), (green,blue),(blue,red),(blue,green)}

Example: Map-Coloring Solutions are complete and consistent assignments, e.g., WA = red, NT = green,Q = red,NSW = green,V = red,SA = blue,T = green

Constraint Graph

Map Colouring: Example Consider some “square” countries: How many colours are needed?

Example: 3 colours? Take the 3 colours to be red, green, blue How would you be sure that you have not missed out some possible 3 colouring? Need some complete search method! NO COLOUR LEFT!

WITH JUST ONE MORE COLOUR IT IS POSSIBLE Example: 4 colours? WITH JUST ONE MORE COLOUR IT IS POSSIBLE NO COLOUR LEFT!

Motivations Map Colouring is a specific problem so why care? Map Colouring is a typical “Constraint Satisfaction Problem (CSP)” CSPs have many uses scheduling timetabling window (task pane) manager in a GUI and many other common optimization problems with industrial applications

Constraint Satisfaction Problems Must be Hot&Sour Soup No Peanuts Chicken Dish Appetizer Total Cost < $30 No Peanuts Pork Dish Vegetable Unary, binary and N-ry constraints. Seafood Rice Not Both Spicy Not Chow Mein Constraint Network

Potential Follow-up “Constraint Programming” A different programming paradigm “you tell it what to solve, the system decides how to solve” a program to solve Sudoku can be only 20 lines of code! e.g. constraints on each row that all numbers in a row are different is just forall( j in 1..9 ) alldifferent( all(i in 1..9) pos[i,j] ); Very different from the usual paradigms: Procedural (Fortran, Pascal, C) Object-Oriented (C++, Java, C#) Functional (Lisp, ML, Haskell) Commercialised by ILOG, www.ilog.com, and others

From Maps to CSPs Will convert the map colouring into general idea of a CSP: Assign values such that the assigned values satisfy some constraints

Map Colouring Firstly add some labels A B C F E D

Map Colouring: Constraints Graphs are more common than maps – so convert to a graph Edge means “share a border” A B C F E D

Graph 3-Colouring A B C F E D Node, or “variable”, must be given a value from the set of colours { r, g , b } E.g. B := b Edge between two nodes  only allowed pairs of values from the set { (r,g), (r,b), (g, r), (g, b), (b, r), (b, g) } A B C F E D

Search Methods If want a complete search method then it is standard to use depth-first search with partial assignments Work with Partial Assignments Start with the empty assignment Generate children by adding a value for one more variable Analogy: path-finding – we started with the empty path, and then added one more segment at each time We already did this with the map colouring at the start of the lecture!

CSPs vs. Standard Search Problems state is a "black box“ – any data structure that supports successor function, heuristic function, and goal test CSP: state is defined by variables Xi with values from domain Di goal test is a set of constraints specifying allowable combinations of values for subsets of variables Simple example of a formal representation language Allows useful general-purpose algorithms with more power than standard search algorithms

Backtracking Example

Backtracking Example

Backtracking Example

Backtracking Example

Backtracking Search Animation Nodes are not created until they are ready to be used – to reduce memory usage A 2nd child of A is not created immediately, just remember that it is there B E D C

Can we 2-colour a Triangle? Can we assign values from { r , g } with the following variables and constraints? A C B Obviously not! But how can we see this using search?

Can we 2-colour a Triangle? Can we assign values from { r , g } to nodes A, B, and C “Generate-and-Test”: Colour nodes in the order, A, B, C A A=g A=r All the attempts to generate a satisfying assignment fail B B=r B=g Etc, etc C C name of node is just the branch variable C=r C=r C=g C=g Fail Fail Fail Fail

Early Failure Suppose a partial assignment fails i.e. violates a constraint Whatever values we eventually give to the so-far un-assigned variables the constraint will stay violated, and the solution will fail In the backtracking search: as soon as a constraint is violated by the current partial assignment then we can prune the search

Can we 2-colour a Triangle? Naive Backtracking Search: Backtracking with pruning of bad partial assignments A A=g A=r B B=r B=g C Fail C=r Did not have to try values for C C=g Fail Fail

Varieties of constraints Unary constraints involve a single variable, e.g., SA ≠ green Binary constraints involve pairs of variables, e.g., value(SA) ≠ value(WA) Higher-order constraints involve 3 or more variables, e.g., cryptarithmetic column constraints

Example: Latin Squares Puzzle X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 red RT RS RC RO green GT GS GC GO blue BT BS BC BO yellow YT YS YC YO Variables Values Constraints: In each row, each column, each major diagonal, there must be no two markers of the same color or same shape.

Real-world CSPs Assignment problems Timetabling problems e.g., who teaches what class Timetabling problems e.g., which class is offered when and where? Transportation scheduling Factory scheduling Notice that many real-world problems involve real-valued variables

Graph Matching Example Find a subgraph isomorphism from R to S. 1 2 (1,a) (1,b) (1,c) (1,d) (1,e) 3 4 (2,a) (2,b) (2,c) (2,d) (2,e) X X X S e (3,a) (3,b) (3,c) (3,d) (3,e) (3,a) (3,b) (3,c) (3,d) (3,e) X X X X X X X X X a c (4,a) (4,b) (4,c) (4,d) (4,e) X X X X b d How do we formalize this problem?

A Tiny Transportation problem How much should be shipped from several sources to several destinations Demand Qty Supply cpty Source Qty Shipped Destination a 1 x 11 1 b 1 1 x 12 x 1n x 21 a 2 2 2 b 2 x 22 x 2n : : : : a m n b m n

Constraint Satisfaction Problems Must be Hot&Sour Soup No Peanuts Chicken Dish Appetizer Total Cost < $30 No Peanuts Pork Dish Vegetable Unary, binary and N-ry constraints. Seafood Rice Not Both Spicy Not Chow Mein Constraint Network

Example: 4-Queens States: 4 queens in 4 columns (44 = 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)

The path cost is shown by the number on the links; the heuristic evaluation is shown by the number in the box. Assume that S is the start state and G is the goal state.   (a) What is the order that breadth-first search will expand the nodes? (b) What is the order that depth-first search will expand the nodes? (c) What is the order that hill climbing search will expand the nodes? (d) What is the order that A* search will expand the nodes?