Constraint Programming - PowerPoint PPT Presentation

1 / 41
About This Presentation
Title:

Constraint Programming

Description:

Constraint Programming. Michael Trick (actually 75% Pascal Van Hentenryck, 20 ... enum Country {Belgium,Denmark,France,Germany,Netherlands,Luxembourg} ... – PowerPoint PPT presentation

Number of Views:81
Avg rating:3.0/5.0
Slides: 42
Provided by: michae92
Category:

less

Transcript and Presenter's Notes

Title: Constraint Programming


1
Constraint Programming
  • Michael Trick
  • (actually 75 Pascal Van Hentenryck, 20 Irv
    Lustig, 5 Trick)
  • Carnegie Mellon

2
Outline
  • Motivation
  • An Overview of Constraint Programming
  • Constraint Programming at Work
  • Getting Started
  • Sports Scheduling
  • Manufacturing
  • Perspectives

3
Combinatorial Optimization
  • Many, many practical applications
  • Resource allocation, scheduling, routing
  • Properties
  • Computationally difficult
  • Technical and modeling expertise needed
  • Experimental in nature
  • Important () in practice
  • Many solution techniques
  • Integer programming
  • Specialized methods
  • Local search/metaheuristics
  • Constraint programming

4
Constraint programming
  • Began in 1980s from AI world
  • Prolog III (Marseilles, France)
  • CLP(R)
  • CHIP (ECRC, Germany)
  • Application areas
  • Scheduling, sequencing, resource and personnel
    allocation, etc. etc.
  • Active research area
  • Specialized conferences (CP, CP/AI-OR, )
  • Journal (Constraints)
  • Companies

5
Constraint Programming
  • Two main contributions
  • A new approach to combinatorial optimization
  • Orthogonal and complementary to standard OR
    methods
  • Combinatorial versus numerical
  • A new language for combinatorial optimization
  • Rich language for constraints
  • Language for search procedures
  • Vertical extensions

6
The Tutorial
  • Goal to provide an introduction
  • 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?

7
Constraint Programming
  • Constraint programming by example
  • Illustrate rich language
  • Contrast with integer programming
  • Illustrate some underlying technologies
  • Disclaimers
  • Cant cover all of CP
  • I want to make you curious
  • Language/system used
  • Could use many choose OPL

8
Modeling in Constraint Programming
  • A rich constraint language
  • Arithmetic, higher-order, logical constraints
  • Global constraints for natural substructures
  • Specification of a search procedure
  • Definition of search tree to explore
  • Specification of search strategy

9
Comparison of CP/IP
  • Branch and Prune
  • Prune eliminate infeasible configurations
  • Branch decompose into subproblems
  • Prune
  • Carefully examine constraints to reduce possible
    variable values
  • Branch
  • Use heuristics based on feasibility info
  • Main focusconstraints and feasibility
  • Branch and Bound
  • Bound eliminate suboptimal solutions
  • Branch decompose into subproblems
  • Bound
  • Use (linear) relaxation of problem ( cuts)
  • Branch
  • Use information from relaxation
  • Main focus objective function and optimality

10
Illustrative artificial example
  • Color a map of (part of) Europe Belgium,
    Denmark, France, Germany, Netherlands,
    Luxembourg
  • No two adjacent countries same color
  • Is four colors enough?

11
OPL example
  • enum Country Belgium,Denmark,France,Germany,Nethe
    rlands,Luxembourg
  • enum Colors blue,red,yellow,gray
  • var Colors colorCountry
  • solve
  • colorFrance colorBelgium
  • colorFrance colorLuxembourg
  • colorFrance colorGermany
  • colorLuxembourg colorGermany
  • colorLuxembourg colorBelgium
  • colorBelgium colorNetherlands
  • colorBelgium colorGermany
  • colorGermany colorNetherlands
  • colorGermany colorDenmark
  • Variables non-numeric
  • Constraints are non-linear
  • Looks nothing like IP!
  • Perfectly legal CP

12
Constraint Programming
  • Domain store
  • For each variable what is the set of possible
    values?
  • If empty for any variable, then infeasible
  • If singleton for any variable, then solution
  • Constraints
  • Capture interesting and well studied
    substructures
  • Need to
  • Determine if constraint is feasible WRT the
    domain store
  • Prune impossible values from the domains

13
Constraints
  • Can have differing techniques to handle a
    constraint type
  • 3x10y2z 4w 4
  • x in 0,1, y in 0,1,2, z in 0,1,2, w in
    0,1
  • 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

14
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

15
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 xdi to problem and solve

16
Show OPL solving coloring problem
17
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.

18
Examples of formulation abilities
  • Facility location want a constraint that
    customer j can be assigned to warehouse i only if
    warehouse open. (yi1 if warehouse i open)
  • IP xi,j is 1 if cust j assigned to i
  • xi,j
  • CPxj is the warehouse cust j assigned to (not
    a 0,1 variable)
  • yxj 1

19
Similar example
  • Routing type constraints.
  • Let xi be the ith customer visited and di,j
    be distance from i to j
  • sum (i in 1..n) dxi,xi1
  • gives total distance traveled

20
Formulation strengths
  • Logical requirements if A1 and Beither C3 or D1.
  • Really painful in IP. Straightforward in CP
  • ((A1) (B ((C3)\/(D1))

21
Global Constraints
  • Recognize that some types of constraints come up
    often
  • Create specialized routines to handle
  • Strong pruning
  • Efficient handling
  • Extend system to include these

22
Global constraint alldifferent
  • Most well known and studied constraint.
  • alldifferent(x,y,z)
  • states that x, y, and z take on different values.
    So x2, y1, z3 would be ok, but not x1, y3,
    z1.
  • Clear uses in routing (xi is ith customer
    visited, alldifferentx says each customer
    visited at most once), very useful in many other
    situations.

23
Alldifferent feasibility and pruning
  • Feasibility? Given domains, create
    domain/variable bipartite graph

x1
1
x2
2
3
x3
4
x4
5
x5
24
Alldifferent feasibility and pruning
  • Pruning? Which edges are in no matching?

x1
1
Domain is sharply reduced
x2
2
3
x3
4
x4
5
x5
25
Global constraints
  • Many different types of constraints have
    specialized routines
  • distribute(card,value,base) the number of times
    valuei appears in base is cardi
  • circuit(succ) the values in succ form a
    hamiltonian circuit (so if you follow the
    sequence 1, succ1, succsucc1 etc, you will
    get a loop through 1..n.

26
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

27
Vertical language extensions
  • 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

28
Scheduling
  • Want concepts of jobs, machines, before,
    after, jobs requiring machines, and so on.
  • Easy to extend

29
Example of scheduling
forall(j in Jobs) forall(t in 1..nbTasks-1
) taskj,t precedes taskj,t1
forall(j in Jobs) forall(t in Tasks)
taskj,t requires toolresourcej,t
30
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
  • Specify tree to search
  • Specify how to explore the tree

31
Example of Search Strategies
  • forall(s in Stores ordered by increasing
    regretdmax(costs))
  • tryall(w in Warehouses ordered by increasing
    supplyCosts,w) suppliers w
  • implements a maximum regret ordering (find a
    store with maximum regret then order the
    warehouses by increasing cost)

32
Example Problem
  • Painting cars (from Magnanti and Sokel).
  • Sequence cars to minimize paint changeover
  • Cars cannot be sequenced too far out of order

33
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.
  •  

34
Constraint Program
  • int n
  • int rnge
  • int ncolor
  • range Slots 1..n
  • var Slots slot1..n
  • var Slots revslot1..n
  • int color1..n
  • minimize
  • sum (j in 1..n-1) (colorrevslotj
    colorrevslotj1)
  • subject to
  • forall (i in Slots)
  • i-rngerange /
  • alldifferent(slot) /must choose different
    slots /
  • forall (i in Slots)
  • revslotsloti i

35
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

36
Result
  • Formulation is much easier than IP formulation
  • Gets good solutions much faster than IP
  • Is competitive in proving optimality

37
Finding optimal solutions
  • 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

38
Perspectives
  • Many solution techniques
  • Integer programming
  • Constraint programming
  • Local search
  • Combinations
  • Which to use?

39
Comparing IP and CP
  • Complementary technologies
  • Integer programming
  • Objective function relaxations
  • Constraint programming
  • Feasibility domain reductions
  • Might need to experiment with both
  • CP particularly useful when IP formulation is
    hard or relaxation does not give much information

40
Combining Methods
  • Local and Global Search
  • Use CP/IP for very large neighborhood search
    (take a solution, remove large subset, find
    optimal completion)
  • Combining CP and IP
  • Use LP as constraint handler
  • Use CP as subproblem solver in branch and price

41
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.pp
    t
Write a Comment
User Comments (0)
About PowerShow.com