ISN Workshop September 2003 Constraint Programming in Practice: Scheduling a Rehearsal Barbara Smith.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Solve Your Problem Faster - by changing the model
Non-Binary Constraint Satisfaction Toby Walsh Cork Constraint Computation Center.
Completeness and Expressiveness
The simplex algorithm The simplex algorithm is the classical method for solving linear programs. Its running time is not polynomial in the worst case.
Problems and Their Classes
Minimum Clique Partition Problem with Constrained Weight for Interval Graphs Jianping Li Department of Mathematics Yunnan University Jointed by M.X. Chen.
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.
Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License:
1 Chapter 8: Modelling with Finite Domain Constraints Where we examine how modelling and controlling search interact with finite domain constraints.
Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni.
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Review: Constraint Satisfaction Problems How is a CSP defined? How do we solve CSPs?
EE 553 Integer Programming
Bounds on Code Length Theorem: Let l ∗ 1, l ∗ 2,..., l ∗ m be optimal codeword lengths for a source distribution p and a D-ary alphabet, and let L ∗ be.
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.
Mathematics Substitution 1 When you have a certain number of valid equations for a problem, with the same number of unknown variables in them, it is often.
Constraint Satisfaction Problems
Jean-Charles REGIN Michel RUEHER ILOG Sophia Antipolis Université de Nice – Sophia Antipolis A global constraint combining.
Chapter 5 Outline Formal definition of CSP CSP Examples
Dr Eleni Mangina – COURSE: LOGIC PROGRAMMING (during a joint degree with Fudan University in Software Engineering) DEPT. OF COMPUTER SCIENCE UCD LOGIC.
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding ILPs with Branch & Bound ILP References: ‘Integer Programming’
PLANNING Partial order regression planning Temporal representation 1 Deductive planning in Logic Temporal representation 2.
Constraint Satisfaction Problems
1 Constraint Programming: An Introduction Adapted by Cristian OLIVA from Peter Stuckey (1998) Ho Chi Minh City.
Decision Procedures An Algorithmic Point of View
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
Building “ Problem Solving Engines ” for Combinatorial Optimization Toshi Ibaraki Kwansei Gakuin University (+ M. Yagiura, K. Nonobe and students, Kyoto.
CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.
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.
Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.
Constraint Satisfaction Problems Chapter 6. Review Agent, Environment, State Agent as search problem Uninformed search strategies Informed (heuristic.
Stocs – A Stochastic CSP Solver Bella Dubrov IBM Haifa Research Lab © Copyright IBM.
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.
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.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
A Logic of Partially Satisfied Constraints Nic Wilson Cork Constraint Computation Centre Computer Science, UCC.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
Chapter 5 Constraint Satisfaction Problems
Constraints and Search Toby Walsh Cork Constraint Computation Centre (4C) Logic & AR Summer School, 2002.
Chapter 2) CSP solving-An overview Overview of CSP solving techniques: problem reduction, search and solution synthesis Analyses of the characteristics.
Implicit Hitting Set Problems Richard M. Karp Erick Moreno Centeno DIMACS 20 th Anniversary.
CP Summer School Modelling for Constraint Programming Barbara Smith 3. Symmetry, Viewpoints.
CHAPTER 5 SECTION 1 – 3 4 Feb 2004 CS Constraint Satisfaction 1 Constraint Satisfaction Problems.
1. 2 Outline of Ch 4 Best-first search Greedy best-first search A * search Heuristics Functions Local search algorithms Hill-climbing search Simulated.
BIL 472 SADI EVREN SEKER Constraint Satisfaction.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
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.
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.
Automatic Test Generation
CSC Modeling with FD Constraints
Constraint Satisfaction
Constraint satisfaction problems
Constraint satisfaction problems
Presentation transcript:

ISN Workshop September 2003 Constraint Programming in Practice: Scheduling a Rehearsal Barbara Smith

ISN Workshop September 2003 Scheduling a Rehearsal The Rehearsal Problem Originated at Lancaster University ; see Adelson, Norman & Laporte, ORQ, 1976 Sequence an orchestral rehearsal of 9 pieces of music with 5 players Players arrive just before the first piece they play in & leave just after the last piece Minimize total waiting time i.e. time when players are present but not currently playing

ISN Workshop September 2003 Scheduling a Rehearsal Problem Data Piece Player Player Player Player Player Duration

ISN Workshop September 2003 Scheduling a Rehearsal Problem Data Piece Player Player Player Player Player Duration Total waiting time: 49 time units

ISN Workshop September 2003 Scheduling a Rehearsal The Main Question Can we solve the rehearsal problem efficiently using constraint programming?

ISN Workshop September 2003 Scheduling a Rehearsal Constraint Satisfaction Problems A CSP consists of: a set of variables, each with a set of possible values (its domain) and a set of constraints: a constraint on a subset of the variables specifies which values can be simultaneously assigned to these variables

ISN Workshop September 2003 Scheduling a Rehearsal Solutions to a CSP A solution to a CSP is an assignment of a value to every variable in such a way that the constraints are satisfied We might want just one solution (any solution).. or all solutions … or an optimal solution

ISN Workshop September 2003 Scheduling a Rehearsal Constraints A constraint affects a subset of the variables A constraint simply specifies the assignments to these variables that it allows Constraints are not limited e.g. to linear inequalities This generality allows CSPs to represent a wide range of problems

ISN Workshop September 2003 Scheduling a Rehearsal Examples x y = z where x, y, z are variables arithmetic expressions involving variables and constants x i = 1 x i+1 = 1 (i.e. if x i = 1 then x i+1 = 1) logical constraints can express the logic of the problem directly t = a i x i (t, a i, x i constants or variables) constraints on arrays of variables allDifferent(x 1, x 2, …, x n )

ISN Workshop September 2003 Scheduling a Rehearsal Constraint programming Constraint programming systems, e.g. ILOG Solver, Eclipse, Sicstus Prolog… allow the programmer to: define variables and their domains specify the constraints, using predefined constraint types define new constraints solve the resulting CSP

ISN Workshop September 2003 Scheduling a Rehearsal Solving CSPs Systematic search: choose a variable, var, that has not yet been assigned a value choose a value in the domain of var and assign it backtrack to try another choice if this fails Constraint propagation: derive new information from the constraints, including var=val i.e. every other value has been removed from the domain of this variable remove values from the domains of future variables that can no longer be used because of this assignment fail if any future variable has no values left

ISN Workshop September 2003 Scheduling a Rehearsal Termination Search terminates when either every variable has been assigned a value: a solution has been found and we only wanted one or there are no more choices to consider: there is no solution, or we have found them all Given long enough, the search will terminate in either case

ISN Workshop September 2003 Scheduling a Rehearsal Constraint Propagation Example Variables x 1, x 2, … x n, domains {0,1} Constraints x i = 1 x i +1 = 1, 1 i n Variable w defined by constraint w = i d i x i Domain of w is calculated as {0,.., i d i } If 1 is assigned to x 1 i.e. 0 is removed from its domain, then 0 is removed from the domain of x 2, then from x 3,… the lower bound on w is raised each time, until the only value left is i d i every variable only has one value left, so gets assigned

ISN Workshop September 2003 Scheduling a Rehearsal Rehearsal Problem: Decision Variables We have to decide the order of the pieces Define variables s 1, s 2, …, s n where s i = j if piece i is in the j th position Domain of s i is {1, 2,…,n} A valid sequence if allDifferent(s 1, s 2, …, s n ) is true What about minimizing waiting time?

ISN Workshop September 2003 Scheduling a Rehearsal Optimization Include a variable, say t, for the objective Include constraints (and maybe new variables) linking the decision variables and t Find a solution in which the value of t is (say) t 0 Add a constraint t < t 0 (if minimizing) Find a new solution Repeat last 2 steps When there is no solution, the last solution found has been proved optimal

ISN Workshop September 2003 Scheduling a Rehearsal Rehearsal Problem: Objective How do we link the sequence variables s 1, s 2, …, s n with t, the total waiting time? We need to know the waiting time for each player For each player and each piece (that they dont play) we need to know whether the player is waiting while this piece is played where this piece is in the sequence whether the player is there then i.e. if the player has arrived and has not yet left

ISN Workshop September 2003 Scheduling a Rehearsal New variables and constraints Where each piece is in the sequence d j is the position in the sequence of piece j d j = i iff s i = j For each slot in the sequence, which players are playing p kj = 1 iff player k plays the piece in slot j p kdj = kj where kj =1 iff player k plays piece j

ISN Workshop September 2003 Scheduling a Rehearsal More new variables & constraints When each player arrives and leaves a ki =1 iff player k has arrived by the start of slot i l ki =1 iff player k leaves at the end of slot i or later a k1 = p k1 a ki =1 iff a k,i-1 =1 or p ki = 1 similarly for l ki Whether a player is present during slot i r ki =1 iff player k has arrived and not yet left in slot i r ki = a ki l ki

ISN Workshop September 2003 Scheduling a Rehearsal And yet more… Whether a player is waiting while a piece is rehearsed w kj = 1 iff player k waits while piece j is played w kj = r k dj if kj =1, 0 otherwise Total waiting time t = k ( j w kj j )

ISN Workshop September 2003 Scheduling a Rehearsal Finally… When values have been assigned to s 1, s 2,…, s n a chain of constraint propagation through the new constraints will assign a value to t, as required Although we have a lot of new variables and constraints, we still only have n decision variables

ISN Workshop September 2003 Scheduling a Rehearsal Variable Ordering As soon as enough sequence variables have been assigned so that it is known when a player arrives and leaves, the waiting time for that player will be known But if we choose the variables in the order s 1, s 2,…, s n this wont happen until the sequence is nearly complete The search algorithm only says choose a variable that has not yet been assigned a value - it doesnt specify a choice A better order is s 1, s n, s 2, s n-1,…

ISN Workshop September 2003 Scheduling a Rehearsal Propagation in the Rehearsal Problem Suppose the first 4 assignments are s 1 = 3, s 9 = 9, s 2 = 8, s 8 = 4 Player 1 does not play in pieces 3 and 9, but does play in pieces 4 and 8 After these assignments, it is deduced that: player 1 arrives before the 2 nd piece & leaves after the 8 th player 1 is only waiting during piece 5 (even though it has not been decided when piece 5 will be played) the waiting time for player 1 is 3 (the duration of piece 5)

ISN Workshop September 2003 Scheduling a Rehearsal Results Number of backtracks is a good measure of search effort It takes nearly as many backtracks to prove optimality as to find the optimal solution, with first-to-last ordering Search orderBacktracks to find optimal Total backtracks Run time (sec.) First to last37,21365, Ends to middle1,1701,8281.4

ISN Workshop September 2003 Scheduling a Rehearsal Symmetry Reversing the sequence does not change waiting time Search finds an optimal sequence starting with 3 and ending with 9, then considers sequences starting with 9 and ending with 3 This is wasted effort Can be prevented by adding a constraint that is only true of one of a pair of mirror-image sequences, e.g. s 1 < s n

ISN Workshop September 2003 Scheduling a Rehearsal Results Search orderBacktracks to find optimal Total backtracks Run time (sec.) First to last37,21365, Ends to middle1,1701, First to last with s 1 < s n 35,67948, Ends to middle with s 1 < s n 1,1251,3651.0

ISN Workshop September 2003 Scheduling a Rehearsal A Talent Scheduling Problem In shooting a film, any actor not involved in the days scenes still gets paid Scheduling problem identical to the rehearsal problem - except that actors are paid at different rates Sample problem (for the film Mob Story) in Cheng et al. is much larger than the rehearsal problem (8 players, 20 pieces)

ISN Workshop September 2003 Scheduling a Rehearsal Improved Model The existing model cannot solve the talent scheduling problem in a reasonable time Waiting time for a player is only known when the first & last pieces he/she plays in are sequenced Constraints dont allow deductions about the sequence from a tighter constraint on the objective

ISN Workshop September 2003 Scheduling a Rehearsal Optimal Sequence Player Player Player Player Player Player Player Player

ISN Workshop September 2003 Scheduling a Rehearsal Implied Constraints Implied constraints are logically redundant – dont change the problem, just state part of it differently Good implied constraints reduce solution time by increasing constraint propagation The pieces the expensive players play in must be together Given a good solution (so a tight bound on the total waiting time) if we have placed one of these pieces in the sequence, the others must be very close to it This is not being recognised in the existing model

ISN Workshop September 2003 Scheduling a Rehearsal Constraint on Waiting time Waiting time for a player is at least the number of slots in the sequence between the time they arrive and the time they leave, less the number of pieces they play in This is a lower bound, because it just uses the fact that the duration of a piece is at least 1 time unit This is apparently a weak constraint, but in fact allows a bound on the waiting time to reduce the domains of the sequence variables

ISN Workshop September 2003 Scheduling a Rehearsal Results Adding these implied constraints improves solution time dramatically With other constraints, the talent scheduling problem can be solved: BacktracksRun time (sec.) Rehearsal problem Talent scheduling 576,579 1,120

ISN Workshop September 2003 Scheduling a Rehearsal Conclusions The model for the rehearsal problem is complex – but then describing the connection between the sequence of pieces and the waiting time, in words, is also complex This kind of sequencing problem is NP-hard, so its not surprising that solving a much larger problem requires a cleverer model Further improvements are possible – e.g. start with a better initial solution Improving the model needs an understanding of how constraints propagate – but mostly insight into the problem