CP Summer School 2008 1 Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Constraints and Search Toby Walsh Cork Constraint Computation Centre (4C) Logic & AR Summer School, 2002.
Non-Binary Constraint Satisfaction Toby Walsh Cork Constraint Computation Center.
ISN Workshop September 2003 Constraint Programming in Practice: Scheduling a Rehearsal Barbara Smith.
Constraint Satisfaction Problems Russell and Norvig: Chapter
Global Constraints Toby Walsh NICTA and University of New South Wales
Constraint Satisfaction Problems
Constraint Networks (cont.) Emma Rollón Postdoctoral researcher at UCI April 1st, 2009.
Constraint Satisfaction Introduction to Artificial Intelligence COS302 Michael L. Littman Fall 2001.
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
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.
Review: Constraint Satisfaction Problems How is a CSP defined? How do we solve CSPs?
Best-First Search: Agendas
Maths of Constraint Satisfaction, Oxford, March 2006 Constraint Programming Models for Graceful Graphs Barbara Smith.
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Constraint Satisfaction CSE 473 University of Washington.
Ryan Kinworthy 2/26/20031 Chapter 7- Local Search part 1 Ryan Kinworthy CSCE Advanced Constraint Processing.
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 Systems Laboratory March 26, 2007Reeson–Undergraduate Thesis1 Using Constraint Processing to Model, Solve, and Support Interactive Solving of.
Constraint Satisfaction Problem Solving Chapter 5.
Chapter 5 Outline Formal definition of CSP CSP Examples
Constraint Satisfaction Problems
Tractable Symmetry Breaking Using Restricted Search Trees Colva M. Roney-Dougal, Ian P. Gent, Tom Kelsey, Steve Linton Presented by: Shant Karakashian.
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
Modelling for Constraint Programming Barbara Smith CP 2010 Doctoral Programme.
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.
CP Summer School Modelling for Constraint Programming Barbara Smith 2. Implied Constraints, Optimization, Dominance Rules.
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
1 CS B551: Elements of Artificial Intelligence Instructor: Kris Hauser
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.
CP Summer School Modelling for Constraint Programming Barbara Smith 4. Combining Viewpoints, Modelling Advice.
Chapter 5 Constraint Satisfaction Problems
Constraints and Search Toby Walsh Cork Constraint Computation Centre (4C) Logic & AR Summer School, 2002.
Review Test1. Robotics & Future Technology Future of Intelligent Systems / Ray Kurzweil futurist Ray Kurzweil / A Long Bet A Long Bet / Robot Soccer.
Chapter 2) CSP solving-An overview Overview of CSP solving techniques: problem reduction, search and solution synthesis Analyses of the characteristics.
Constraint Satisfaction Problems (Chapter 6)
CP Summer School Modelling for Constraint Programming Barbara Smith 3. Symmetry, Viewpoints.
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
Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu Blind Searches - Introduction.
1. 2 Outline of Ch 4 Best-first search Greedy best-first search A * search Heuristics Functions Local search algorithms Hill-climbing search Simulated.
Eliminating non- binary constraints Toby Walsh Cork Constraint Computation Center.
Chapter 5 Team Teaching AI (created by Dewi Liliana) PTIIK Constraint Satisfaction Problems.
Constraint Satisfaction CSE 473 University of Washington.
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
CS 561, Session 8 1 This time: constraint satisfaction - Constraint Satisfaction Problems (CSP) - Backtracking search for CSPs - Local search for CSPs.
Scheduling with Constraint Programming
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
CS B551: Elements of Artificial Intelligence
Chapter 3: Finite Constraint Domains
Constraint Satisfaction Problems
Artificial Intelligence
Constraints and Search
Constraint satisfaction problems
CS 8520: Artificial Intelligence
Constraint Satisfaction Problems
Constraint satisfaction problems
Constraint Satisfaction Problems (CSP)
Presentation transcript:

CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization, Dominance Rules 3.Symmetry, Viewpoints 4.Combining Viewpoints, Modelling Advice

CP Summer School Modelling for Constraint Programming Barbara Smith 1. Definitions, Viewpoints, Constraints

CP Summer School Background Assumptions  A well-defined problem that can be represented as a finite domain constraint satisfaction or optimization problem  no uncertainty, preferences, etc.  A constraint solver providing:  a systematic search algorithm  combined with constraint propagation  a set of pre-defined constraints  e.g. ILOG Solver, Ecl i ps e, SICStus Prolog, …

CP Summer School Solving CSPs  Systematic search:  choose a variable x i that is not yet assigned  create a choice point, i.e. a set of mutually exclusive & exhaustive choices, e.g. x i = a v. x i ≠ a  try the first & backtrack to try the other if this fails  Constraint propagation:  add x i = a or x i ≠ a to the set of constraints  re-establish local consistency on each constraint   remove values from the domains of future variables that can no longer be used because of this choice  fail if any future variable has no values left

CP Summer School Representing a Problem  If a CSP M = represents a problem P, then every solution of M corresponds to a solution of P and every solution of P can be derived from at least one solution of M  More than one solution of M can represent the same solution of P, if modelling introduces symmetry  The variables and values of M represent entities in P  The constraints of M ensure the correspondence between solutions  The aim is to find a model M that can be solved as quickly as possible  NB shortest run-time might not mean least search

CP Summer School Interactions with Search Strategy  Whether M1 is better than M2 can depend on the search algorithm and search heuristics  I’m assuming the search algorithm is fixed  We could also assume that choice points are always x i = a v. x i ≠ a  Variable (and value) order still interact with the model a lot  Is variable & value ordering part of modelling?  I think it is, in practice  but here I will (mostly) pretend it isn’t

CP Summer School Viewpoints  A viewpoint is a pair, i.e. a set of variables and their domains  Given a viewpoint, the constraints have to restrict the solutions of M to solutions of P  So the constraints are (to some extent) decided by the viewpoint  Different viewpoints give very different models  We can combine viewpoints - more later  Good rule of thumb: choose a viewpoint that allows the constraints to be expressed easily and concisely  will propagate well, so problem can be solved efficiently

CP Summer School Example: Magic Square  Arrange the numbers 1 to 9 in a 3 x 3 square so that each row, column and diagonal has the same sum (15)  V1 : a variable for each cell, domain is the numbers that can go in the cell  V2 : a variable for each number, domain is the cells where that number can go x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8 x9x9

CP Summer School Magic Square Constraints  Constraints are easy to express in V1 :  x 1 + x 2 + x 3 = x 4 + x 5 + x 6 = x 1 + x 4 + x 7 = … = 15  but not in V2  e.g. one constraint says that the numbers 1, 2, 3 cannot all be in the same row, column or diagonal  And there are far more constraints in V2 than in V1 (78 v. 9) x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8 x9x9

CP Summer School Constraints  Given a viewpoint, the role of the constraints is:  To ensure that the solutions of the CSP match the solutions of the problem  To guide the search, i.e. to ensure that as far as possible, partial solutions that will not lead to a solution fail immediately

CP Summer School Expressing the Constraints  For efficient solving, we need to know:  the constraints provided by the constraint solver  the level of consistency enforced on each  the complexity of the constraint propagation algorithms  Not very declarative!  There is often a trade-off between time spent on propagation and time saved on search  which choice is best often depends on the problem

CP Summer School Auxiliary Variables  Often, the constraints can be expressed more easily/more efficiently if more variables are introduced  Example: car sequencing (Dincbas, Simonis and van Hentenryck, ECAI 1988)

CP Summer School Car Sequencing Problem  10 cars to be made on a production line, each requires some options  Stations installing options have lower capacity than rest of line e.g. at most 1 car out of 2 for option 1  Find a feasible production sequence classes123456Capacity Option /2 Option /3 Option /3 Option /5 Option /5 No. of cars

CP Summer School Car Sequencing - Model  A variable for each position in the sequence, s 1, s 2, …, s 10  Value of s i is the class of car in position i  Constraints:  Each class occurs the correct number of times  Option capacities are respected - ?

CP Summer School Car Sequencing – Auxiliary Variables  Introduce variables o ij :  o ij = 1 iff the car in the i th slot in the sequence requires option j  Option 1 capacity is one car in every two:  o i,1 + o i+1,1 ≤ 1 for 1 ≤ i < 10  Relate the auxiliary variables to the s i variables:  λ jk = 1 if car class k requires option j , 1 ≤ i ≤ 10, 1 ≤ j ≤ 5

CP Summer School Global Constraints  A range of global constraints is provided by any constraint solver  A global constraint replaces a set of simpler constraints on a number of variables  The solver provides an efficient propagation algorithm (often enforcing GAC, sometimes less)  A global constraint:  should reduce search  may reduce run-time (or may increase it)

CP Summer School The AllDifferent Constraint  Commonest global constraint?  allDifferent( x 1, x 2, …, x n ) replaces the binary ≠ constraints x i ≠ x j, i ≠ j  There are efficient GAC & BC algorithms for allDifferent  i.e. more efficient than GAC on a general n -ary constraint  Usually, using allDifferent gives less search than ≠ constraints  but is often slower  Advice:  use allDifferent when the constraint is tight  i.e. the number of possible values is n or not much more  try BC rather than GAC

CP Summer School Graceful Labelling of a Graph  A labelling f of the nodes of a graph with q edges is graceful if:  f assigns each node a unique label from { 0,1,..., q }  when each edge xy is labelled with | f (x) − f (y) |, the edge labels are all different

CP Summer School Graceful Labelling: Constraints  A possible CSP model has:  a variable for each node, x 1, x 2,..., x n each with domain { 0, 1,..., q }  auxiliary variables for each edge, d 1, d 2,..., d q each with domain { 1, 2,..., q }  d k = |x i − x j | if edge k joins nodes i and j  x 1, x 2,..., x n are all different  d 1, d 2,..., d q are all different  it is cost-effective to enforce GAC on the constraint allDifferent( d 1, d 2,..., d q )  but not on allDifferent( x 1, x 2,..., x n )  in the example, n = 9, q =16

CP Summer School One Constraint is Better than Several (maybe)  If there are several constraints all with the same scope, rewriting them as a single constraint will lead to more propagation…  if the same level of consistency is maintained on the new constraint  … more propagation means shorter run-time  if enforcing consistency on the new constraint can be done efficiently

CP Summer School Example: n-queens  A variable for each row, x 1, x 2, …, x n  Values represent the columns, 1 to n  The assignment (x i,c) means that the queen in row i is in column c  Constraints for each pair of rows i, j with i < j :  x i ≠x j  x i − x j ≠ i − j  x i − x j ≠ j − i

CP Summer School Propagating the Constraints  A queen in row 5, column 3 conflicts with both remaining values for x 3  But the constraints are consistent  constraint x i ≠x j thinks that (x 3,1) can support (x 5,3)  constraint x i − x j ≠ i − j thinks that (x 3,3) can support (x 5,3) ×  Enforcing AC on (x i ≠x j ) ٨ (x i − x j ≠ i − j ) ٨ (x i − x j ≠ j − i ) would remove 3 from the domain of x 5  but how would you do it?

CP Summer School Summary  The viewpoint (variables, values) largely determines what the model looks like  Choose a viewpoint that will allow the constraints to be expressed easily and concisely  Be aware of global constraints provided by the solver, and use them if they reduce run-time  Introduce auxiliary variables if necessary to help express the constraints