Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Michael Trick
(actually 75% Pascal Van Hentenryck, 20% Irv Lustig, 5% Trick)
Carnegie Mellon
Outline
Perspectives
Combinatorial Optimization
Resource allocation, scheduling, routing Computationally difficult Technical and modeling expertise needed Experimental in nature Important ($$$) in practice Integer programming Specialized methods Local search/metaheuristics Constraint programming
Properties
Constraint programming
Prolog III (Marseilles, France) CLP(R) CHIP (ECRC, Germany) Scheduling, sequencing, resource and personnel allocation, etc. etc.
Application areas
Constraint Programming
Orthogonal and complementary to standard OR methods Combinatorial versus numerical Rich language for constraints Language for search procedures Vertical extensions
The Tutorial
What is constraint programming? What is it good for? How does it compare to integer programming? How easy is it to use? What is the underlying technology?
Constraint Programming
Illustrate rich language Contrast with integer programming Illustrate some underlying technologies Cant cover all of CP I want to make you curious Could use many; choose OPL
Disclaimers
Language/system used
Arithmetic, higher-order, logical constraints Global constraints for natural substructures Definition of search tree to explore Specification of search strategy
Comparison of CP/IP
Prune
Bound
Branch
Branch
Color a map of (part of) Europe: Belgium, Denmark, France, Germany, Netherlands, Luxembourg No two adjacent countries same color Is four colors enough?
OPL example
enum Country {Belgium,Denmark,France,Germany,Netherlands,Luxem bourg}; enum Colors {blue,red,yellow,gray}; var Colors color[Country]; solve { color[France] <> color[Belgium]; color[France] <> color[Luxembourg]; color[France] <> color[Germany]; color[Luxembourg] <> color[Germany]; color[Luxembourg] <> color[Belgium]; color[Belgium] <> color[Netherlands]; color[Belgium] <> color[Germany]; color[Germany] <> color[Netherlands]; color[Germany] <> color[Denmark]; };
Variables nonnumeric Constraints are non-linear Looks nothing like IP! Perfectly legal CP
Constraint Programming
Domain store
Constraints
For each variable: what is the set of possible values? If empty for any variable, then infeasible If singleton for any variable, then solution
Determine if constraint is feasible WRT the domain store Prune impossible values from the domains
Constraints
Simple bound on sizes gives y in {0} More complicated handling gives x in {0}, y in {0}, z in {0,2}, w in {0,1}
Constraint Solving
General algorithm is
Repeat select a constraint c if c is infeasible wrt domain store return infeasible else apply pruning algorithm of c Until no value can be removed
Branching
Once the constraint solving is done, if the problem is not infeasible nor are the domains singletons, then apply the search method
Choose a variable x with non-singleton domain (d1, d2, di) Foreach d in (d1, d2, di) add constraint x=di to problem and solve
Strength of CP
Since there is no need for a linear relaxation, the language can represent much more directly (no need for big-M IP formulations.
Similar example
Routing type constraints. Let x[i] be the ith customer visited and d[i,j] be distance from i to j
Formulation strengths
Logical requirements: if A=1 and B<=2 then either C>=3 or D=1. Really painful in IP. Straightforward in CP:
Global Constraints
Clear uses in routing (x[i] is ith customer visited, alldifferent[x] says each customer visited at most once), very useful in many other situations.
1
2 3 4
1
2 3 4
Global constraints
distribute(card,value,base): the number of times value[i] appears in base is card[i] circuit(succ) : the values in succ form a hamiltonian circuit (so if you follow the sequence 1, succ[1], succ[succ[1]] etc, you will get a loop through 1..n.
Global constraints
Many others, and new ones being created all the time
Strengthen and expand the language Make modeling easier and more natural System is faster at finding solutions Details hidden to user
Can add constraints and definitions to make modeling even more natural Ideas remain the same: there are domains and constraints; constraints check for feasibility and prune domains; a search strategy guides the system in finding solutions
Scheduling
Want concepts of jobs, machines, before, after, jobs requiring machines, and so on. Easy to extend
Example of scheduling
forall(j in Jobs) forall(t in 1..nbTasks-1) task[j,t] precedes task[j,t+1]; forall(j in Jobs)
forall(t in Tasks)
task[j,t] requires tool[resource[j,t]];
Search Strategy
Combined with model, search strategies are integral to constraint systems. Allow choice of branching variables or more powerful search strategies Can be key in solving problems Two steps
implements a maximum regret ordering (find a store with maximum regret then order the warehouses by increasing cost)
Example Problem
Painting cars (from Magnanti and Sokel). Sequence cars to minimize paint changeover Cars cannot be sequenced too far out of order
Small example
Small Example: 10 cars in sequence. The order for assembly is 1, 2, ..., 10. A car must be painted within 3 positions of its assembly order. For instance, car 5 can be painted in positions 2 through 8 inclusive. Cars 1, 5, and 9 are red; 2, 6, and 10 are blue; 3 and 7 green; and 4 and 8 are yellow. Initial sequence 1, 2, ... 10 corresponds to color pattern RBGYRBGYRB and has 9 purgings. The sequence 2,1,5,3,7,4,8,6,10,9 corresponds to color pattern BRRGGYYBBR and has 5 purgings.
Constraint Program
int n=; int rnge=; int ncolor=; range Slots 1..n; var Slots slot[1..n]; var Slots revslot[1..n]; int color[1..n]= ; minimize sum (j in 1..n-1) (color[revslot[j]] <> color[revslot[j+1]]) subject to { forall (i in Slots) i-rnge<=slot[i] <= i+rnge; /*Must be in range */ alldifferent(slot); /*must choose different slots */ forall (i in Slots) revslot[slot[i]] = i; };
Personal use
Tremendous help in my work on sports scheduling: much easier to formulate idiosyncratic constraints Very fast to create prototypes Competitive (at least!) to IP approaches
Result
Formulation is much easier than IP formulation Gets good solutions much faster than IP Is competitive in proving optimality
Constraint programs can find optimal solutions. Typically works by finding a feasible solution and adding a constraint that future solutions must be better than it. Repeat until infeasible: the last solution found is optimal
Perspectives
Which to use?
Comparing IP and CP
Complementary technologies
Integer programming
Constraint programming
Might need to experiment with both CP particularly useful when IP formulation is hard or relaxation does not give much information
Combining Methods
Use CP/IP for very large neighborhood search (take a solution, remove large subset, find optimal completion) Use LP as constraint handler Use CP as subproblem solver in branch and price
Combining CP and IP
Conclusions
Constraint programming should become a part of every OR persons toolkit Combinations of CP and IP represent a big thing in future techniques Blurring of lines between optimization and heuristics This talk at http://mat.gsia.cmu.edu/INFORMS/cp.ppt