Intelligence Artificial Intelligence Ian Gent Constraint Programming 1.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Artificial Intelligence 15. Constraint Satisfaction Problems
Non-Binary Constraint Satisfaction Toby Walsh Cork Constraint Computation Center.
Constraint Programming Peter van Beek University of Waterloo.
Constraint Satisfaction Patrick Prosser. An Example, Exam Timetabling Someone timetables the exams We have a number of courses to examine how many? Dept.
Intelligence Artificial Intelligence Ian Gent Search: 2.
Constraint Satisfaction Problems Russell and Norvig: Chapter
Intelligence Artificial Intelligence Ian Gent Search: 1.
Intelligence Artificial Intelligence Ian Gent Constraint Programming 3: The Party.
Local Search Jim Little UBC CS 322 – CSP October 3, 2014 Textbook §4.8
Constraint Satisfaction Problems
Distributed Constraint Satisfaction Problems M OHSEN A FSHARCHI.
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 CMSC 471 Fall 2002 Class #6 – Wednesday, September 18.
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
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 (CSP)
Intelligence Artificial Intelligence Ian Gent Constraint Programming 2.
Constraint Processing and Programming Introductory Exemple Javier Larrosa.
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Constraint Satisfaction Problems
Artificial Intelligence Constraint satisfaction Chapter 5, AIMA.
Constraint Satisfaction Problems
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.
Constraint Satisfaction Problems
Constraint Satisfaction Problem Solving Chapter 5.
Chapter 5 Outline Formal definition of CSP CSP Examples
Constraint Satisfaction Problems
Constraint Satisfaction Problems
1 Constraint Satisfaction Problems Slides by Prof WELLING.
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
Constraint Satisfaction Problems Chapter 6. Review Agent, Environment, State Agent as search problem Uninformed search strategies Informed (heuristic.
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.
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,
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.
CSC 8520 Spring Paula Matuszek CS 8520: Artificial Intelligence Search 3: Constraint Satisfaction Problems Paula Matuszek Spring, 2013.
Chapter 5 Constraint Satisfaction Problems
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.
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.
Constraint Satisfaction Problems (CSPs)
Constraint Satisfaction
Constraint Satisfaction Problem
Lecture 7 Constraint Satisfaction Problems
Chapter 3: Finite Constraint Domains
Constraint Satisfaction Problems
Artificial Intelligence
Constraint Satisfaction Problems. A Quick Overview
Constraint Satisfaction Problems
CS 8520: Artificial Intelligence
Constraint Satisfaction Problems
Constraint Satisfaction Problems (CSP)
Presentation transcript:

Intelligence Artificial Intelligence Ian Gent Constraint Programming 1

Intelligence Artificial Intelligence Part I :Constraint Satisfaction Problems Constraint Programming 1

3 Constraint Satisfaction Problems zCSP = Constraint Satisfaction Problems yAI exams, CSP =/= Communicating Sequential Processes zA CSP consists of: ya set of variables, X yfor each variable x i in X, a domain D i xD i is a finite set of possible values ya set of constraints restricting tuples of values xif only pairs of values, it’s a binary CSP zA solution is an assignment of a value in D i to each variable x i such that every constraint satisfied

4 Who Cares? zMany problems can be represented as CSP’s ye.g. scheduling, timetabling, graph coloring, puzzles, supply chain management, parcel routing, party arranging … zMany Constraint Programming toolkits available yCHIP yILOG Solver [expensive commercially] yEclipse [free academically] yMozart [available as rpm for Linux]

5 Colouring as CSP zCan we colour all 4 nodes with 3 colours so that no two connected nodes the same colour? zVariable for each node yAll D i = { red, green, blue} zConstraint for each edge yall constraints of the form xx i  x j zSolution gives a colouring zIt’s a binary CSP

6 SAT as a CSP zVariable in CSP for each variable/letter in SAT zEach domain D i = {true, false} zConstraint corresponds to each clause ydisallows unique tuple which falsifies clause ye.g. (not A) or (B) or (not C) x  not zNot binary CSP unless all clauses 2-clauses

7 N-Queens as a CSP zChessboard puzzle ze.g. when n = 8… yplace 8 queens on a 8x8 chessboard so that no two attack each other zVariable x i for each row i of the board zDomain = {1, 2, 3 …, n} for position in row zConstraints are: yx i  x j queens not in same column yx i - x j  i-jqueens not in same SE diagonal yx j - x i  i - jqueens not in SW diagonal

8 Constraint Satisfaction Problems zCSP = Constraint Satisfaction Problems yAI exams, CSP =/= Communicating Sequential Processes zA CSP consists of: ya set of variables, X yfor each variable x i in X, a domain D i xD i is a finite set of possible values ya set of constraints restricting tuples of values xif only pairs of values, it’s a binary CSP zA solution is an assignment of a value in D i to each variable x i such that every constraint satisfied

9 Formal Definition of Constraints zA constraint C ijk… involving variables x i, x j, x k … yis any subset of combinations of values from D i, D j, D k … yI.e. C ijk...  D i x D j x D k … yindicating the allowed set of values zMost constraint programming languages/toolkits allow a number of ways to write constraints: ye.g. if D 1 = D 2 = {1,2,3} … x{ (1,2), (1,3), (2,1), (2,3), (3,1), (3,2) } xx 1  x 2 xCtNeq(x1,x2) zI’ll use whatever notation seems right at the time

10 More Complex Constraints zConstraints don’t need to be simple x DONALD x+GERALD x= ROBERT zCryptarithmetic: all letters different and sum correct zVariables are D, O, N, A, L, G, E, R, B, T zDomains: y{0,1,2,3, …, 9} for O, N, A L,E,R,B,T y{1,2,3, …, 9} for D, G zHow do we express it?

11 Donald + Gerald = Robert zWe can write one long constraint for the sum: y100000*D *O *N + 100*A+ 10*L + D *G *E *R + 100*A+ 10*L + D = *R *O *B + 100*E+ 10*R + T zBut what about the difference between variables? yCould write D =/= O, D=/=N, … B =/= T yOr express it as a single constraint on all variables yAllDifferent(D,O,N,A,L,G,E,R,B,T) zThese two constraints yexpress the problem precisely yboth involve all the 10 variables in the problem

12 Search in Constraints zThe basics of search are (guess what) the same as usual zDepth first search is the most commonly used zWhat toolkits (Solver, Mozart … ) add is ypropagation during search done automatically zIn particular they offer efficient implementations of propagation algorithms like yForward checking yMaintaining Arc consistency

13 Forward Checking zThe simplest good propagation is Forward Checking zThe idea is very simple yIf you set a variable and it is inconsistent with some other variable, backtrack! zTo do this we need to keep up to date the current state of each variable yAdd a data structure to do this, the current domain CD yInitially, CD i = D i yWhen we set variable x j = v xremove x i = u from CD i if some constraint is not consistent with both x j = v, x i = u

14 Forward Checking zFor implementation, we have to cope with undoing the effects of forward checking after backtracking yOne way is to store CD i on the stack at each depth in search, so it can be restored xexpensive on space xvery easy in languages which make copies automatically, e.g. Lisp, Prolog yAnother is to store only the changes to CD i xthen undo destructive changes to data structures on backtracking xusually faster but can be more fiddly to implement

15 Forward Checking, example zVariables x, y zDx = Dy = {1,2,3,4,5} zConstraint x < y - 1 zInitially CDx = CDy = {1,2,3,4,5} zIf we set x = 2, then: ythe only possible values are y = 4, y = 5 xso set CDy = {4,5} zIf we set x = 4, then yno possible values of y remain, I.e. CDy = { } yretract choice of x = 4 and backtrack

16 Heuristics zAs usual we need efficient variable ordering heuristics zOne is very important, like unit propagation in SAT: yIf any CD is of size 1 xwe must set that variable to the remaining value zMore generally, a common heuristic is “minimum remaining value” yI.e. choose variable with smallest size CD ymotivated by most constrained first, or also some theoretical considerations.

17 Next time zArc Consistency zSpecial kinds of constraints, like all different zFormulation of constraint problems zHow to organise a party