the vehicle routing problem

63
The Vehicle Routing Problem Part 2: A CP Approach

Upload: chiquita-kent

Post on 30-Dec-2015

375 views

Category:

Documents


15 download

DESCRIPTION

The Vehicle Routing Problem. Part 2: A CP Approach. Outline. Session 1 What is the vehicle routing problem (VRP)? ‘Traditional’ (Non-CP) solution methods A simple CP model Playtime Session 2 A CP model for the VRP Large Neighbourhood Search revisited Propagation More Playtime . - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The Vehicle Routing Problem

The Vehicle Routing Problem

Part 2: A CP Approach

Page 2: The Vehicle Routing Problem

2/64NICTA Copyright 2013 From imagination to impact

Outline

Session 1

• What is the vehicle routing problem (VRP)?

• ‘Traditional’ (Non-CP) solution methods

• A simple CP model

• Playtime

Session 2

• A CP model for the VRP

• Large Neighbourhood Search revisited

• Propagation

• More Playtime

Page 3: The Vehicle Routing Problem

3/64NICTA Copyright 2013 From imagination to impact

A CP Model for the VRP

Page 4: The Vehicle Routing Problem

4/64NICTA Copyright 2013 From imagination to impact

Model

A (rich) vehicle routing problem• n customers (fixed in this model)• m routes (fixed in this model)• fixed locations

– where things happen– one for each customer + one for (each?) depot

• c commodities (e.g. weight, volume, pallets)– Know demand from each customer for each

commodity• Know time between each location pair • Know cost between each location pair

– Both obey triangle inequality

Page 5: The Vehicle Routing Problem

5/64NICTA Copyright 2013 From imagination to impact

Vocabulary

• A solution is made up of routes (one for each vehicle)

• A route is made up of a sequence of visits

• Some visits serve a customer (customer visit)

(Some tricks)

• Each route has a “start visit” and an “end visit”

• Start visit is first visit on a route – location is depot

• End visit is last visit on a route – location is depot

• Also have an additional route – the unassigned route

– Where visits live that cannot be assigned

Page 6: The Vehicle Routing Problem

6/64NICTA Copyright 2013 From imagination to impact

Referencing

Customers

• Each customer has an index in N = {1..n}

• Customers are ‘named’ in CP by their index

Routes

• Each route has an index in M = {1..m}

• Unassigned route has index 0

• Routes are ‘named’ in CP by their index

Visits

• Customer visit index same as customer index

• Start visit for route k has index n + k ; aka startk

• End visit for route k has index n + m + k ; aka endk

Page 7: The Vehicle Routing Problem

7/64NICTA Copyright 2013 From imagination to impact

Referencing

Sets

• N = {1 .. n} – customers

• M = {1 .. m} – routes

• R = M {0} – includes ‘unassigned’ route

• V = {1 .. n + 2m} – all visits

• V0 = V {0} - includes a ‘spare’

• S = {n+1 .. n+m} – start visits

• E = {n+m+1 .. n+2m} – end visits

• VS= N S – visits that have a sensible successor

• VE= N E – visits that have a sensible predecessor

Page 8: The Vehicle Routing Problem

8/64NICTA Copyright 2013 From imagination to impact

Data

We know (note uppercase)

• Vi The ‘value’ of customer i

• Dik Demand by customer i for commodity k

• Ei Earliest time to start service at i

• Li Latest time to start service at i

• Qjk Capacity of vehicle j for commodity k

• Tij Travel time from visit i to visit j

• Cij Cost (w.r.t. objective) of travel from i to j

Page 9: The Vehicle Routing Problem

9/64NICTA Copyright 2013 From imagination to impact

Basic Variables

Successor variables: si

• si gives direct successor of i, i.e. the index of the next visit on the route that visits i

• si VE for i in VS si = 0 for i in E

Predecessor variables pi

• pi gives the index of the previous visit in the route

• pi VS for i in VE pi = 0 for i in S

• Redundant – but empirical evidence for its use

Route variables ri

• ri gives the index of the route (vehicle) that visits i

• ri R

Page 10: The Vehicle Routing Problem

10/64NICTA Copyright 2013 From imagination to impact

7

Example

2

9

4

3

5

1

8

6

Route 1

Route 2

Start visits

End visits

i si pi ri

1 4 2 2

2 1 7 2

3 8 5 1

4 9 1 2

5 3 6 1

6 5 0 1

7 7 0 2

8 0 3 1

9 0 4 2

Page 11: The Vehicle Routing Problem

11/64NICTA Copyright 2013 From imagination to impact

Other variables

Accumulation Variables

• qik Quantity of commodity k after visit i

• ci Objective cost getting to i

For problems with time constraints

• ai Arrival time at i

• ti Start time at i (time service starts)

• di Departure time at i

• Actually, only ti is required, but others allow for expressive constraints

Page 12: The Vehicle Routing Problem

12/64NICTA Copyright 2013 From imagination to impact

What can we model?

• Basic VRP• VRP with time windows• Multi-depot • Heterogeneous fleet• Open VRP (vehicle not required to return to base)

– Requires anywhere location– Route end visits located at anywhere– distance i anywhere = 0

• Compatibility– Customers on different / same vehicle– Customers on/not on given vehicle

• Pickup and Delivery problems

Page 13: The Vehicle Routing Problem

13/64NICTA Copyright 2013 From imagination to impact

What can we model?

• Variable load/unload times

– by changing departure time relative to start time

• Dispatch time constraints

– e.g. limited docks

– si for i in S is load-start time

• Depot close time

– Time window on end visits

• Fleet size and mix

– Add lots of vehicles

– Need to introduce a ‘fixed cost’ for a vehicle

– Cij is increased by fixed cost for all i S, all j N

Page 14: The Vehicle Routing Problem

14/64NICTA Copyright 2013 From imagination to impact

What can’t we model

• Can’t handle dynamic problems

– Fixed domain for s, p, r vars

• Can’t introduce new visits post-hoc

– E.g. optional driver break must be allowed at start

• Can’t handle multiple visits to same customer

– ‘Larger than truck-load’ problems

– If qty is fixed, can have multiple visits / cust

– Heterogeneous fleet is a pain

• Can’t handle time- or vehicle-dependent travel times/costs

• Soft Constraints

Page 15: The Vehicle Routing Problem

15/64NICTA Copyright 2013 From imagination to impact

Objective

Want to minimize

• sum of objective (cij) over used arcs, plus

• value of unassigned visits

minimize

0irii

Eii vc

Page 16: The Vehicle Routing Problem

16/64NICTA Copyright 2013 From imagination to impact

Basic constraints

Path ( S, E, { si | i V } )

AllDifferent ( { pi | i VE } )

Sit

ViEt

ViLt

Viat

ViTda

ViCcc

i

ii

ii

ii

Ssiis

Ssiis

ii

ii

0

,

,Accumulate obj.

Accumulate time

Time windows

Page 17: The Vehicle Routing Problem

17/64NICTA Copyright 2013 From imagination to impact

Constraints

Load

Consistency

Mkkr

Mkkr

Virr

Viip

Viis

CkSiq

CkViq

CkViQq

CkViQqq

kmn

kn

Ssi

Es

Sp

ik

ik

krik

Sksikks

i

i

i

i

ii

,0

,0

,

,

Page 18: The Vehicle Routing Problem

18/64NICTA Copyright 2013 From imagination to impact

Solving

Pure CP• Assign to ‘successor’ variables• Form chains of visits• Decision 1: Which visit to insert

(== variable choice)• Decision 2: Where to insert it

(== value choice) 2

4

3

5

1

s2= 1

s5= 3

s1= 4

7 9

8

6

s7= 2

• ‘Rooted chain’ starts at Start

• ‘Free chain’ otherwise

• Can reason about free chains but rooted chains easier

• “last(k)” is last visit in chain starting at k

Page 19: The Vehicle Routing Problem

19/64NICTA Copyright 2013 From imagination to impact

Propagation – Cycles

Subtour elimination

• Rooted chains are fine

• For free chains:

– for any chain starting at j,

• remove j from slast(j)

• Some CP libraries have built-ins

– Comet: ‘circuit’

– ILOG: Path constraint

Page 20: The Vehicle Routing Problem

20/64NICTA Copyright 2013 From imagination to impact

Propagation – Cycles

‘Path’ constraint

• Propagates subtour elimination

• Also propagates cost

• path (S, T, succ, P, z)

– succ array implies path

– ensures path from nodes in S to nodes in T through nodes in P

– variable z bounds cost of path

– cost propagated incrementally based on shortest / longest paths

Page 21: The Vehicle Routing Problem

21/64NICTA Copyright 2013 From imagination to impact

Propagation – Cost

‘Path’ constraint

Maintains sets• Path is consistent if it starts in S, ends in T, goes through P, and has bounds consistent with z

• Pos P U S U T : Possibly in the path– If no consistent paths use i, then i Pos

• Req Pos: Required to be in the path– If there is a consistent path that does not need i,

then i Req• Shortest path in Req lower bound on z• Longest path in Pos upper bound on z

== Shortest path with –ve costs • Updated incrementally (and efficiently)

Page 22: The Vehicle Routing Problem

22/64NICTA Copyright 2013 From imagination to impact

Simulated Annealing shortcut

• leverages cost estimate from Path constraint

• std SA:

– Generate sol

– test delta obj against uniform rand var

• improved SA

– generate random var first

– calc acceptable obj

– constrain obj

• Much more efficient

TeP

accept)(

*

)log(

zz

xT

Page 23: The Vehicle Routing Problem

23/64NICTA Copyright 2013 From imagination to impact

Propagation – Capacity (assume +ve qtys)

Rooted Chain

• For each visit i with pi not bound

– For each route k in domain of ri

• If spare space on route k won’t allow visit i– Remove k from ri

– Remove i from pend(k)

– Remove i from slast(start(k))

Free chains• As above (pretty much)• Before increasing chain to load L

– v = Count routes with free space ≥ L– c = Count free chains with load ≥ L– if c > v, can’t form chain

Assume +ve qtys

Page 24: The Vehicle Routing Problem

24/64NICTA Copyright 2013 From imagination to impact

Propagation – Time

Time Constraints:

Rooted chains:

• For each route k

– For each visit i in domain of slast(k)

• If vehicle can’t reach i before Ei

– Remove k from ri

– Remove i from slast(start(k))

Free chains:

• Form “implied time window” from chain

• Rest is as above

Page 25: The Vehicle Routing Problem

25/64NICTA Copyright 2013 From imagination to impact

Savings

Note:

• Clarke-Wright “Savings” method grows chains of visits

• Very successful early method

• Still used in many methods for an initial solution

• Very appropriate for CP

Page 26: The Vehicle Routing Problem

26/64NICTA Copyright 2013 From imagination to impact

Propagation – an alternative

• Alternative relies on knowledge of “incumbent” solution

• Use shared data structure

• Can use full insertion (insert into middle of ‘chain’)

Var/value choice

Propagators

CP System

Incumbent Solution

Page 27: The Vehicle Routing Problem

27/64NICTA Copyright 2013 From imagination to impact

Propagation

Insertion ‘in the middle’

• Propagators know incumbent solution

• Only propagate non-binding implications

• e.g. don’t “set” s1 s2 here:

• But 1 is removed from s4 , s6

• Can calculate earliest start, latest start to bound start time

• Can calculate feasible inserts, and update s vars appropriately

• Strong propagation for capacity, time constraints

2

4

1

3

7 9

8

6

Page 28: The Vehicle Routing Problem

28/64NICTA Copyright 2013 From imagination to impact

Insertion

• Allows for maximum propagation

• Allows constraints to influence solution progressively

• e.g. Blood delivery constraints

– Delivery within 20 minutes of pickup

– As soon as one is fixed implication flows to other

• e.g. Mutex (mutual exclusion) constraint

– Either this request XOR that one

– Used in line-haul – deliver direct xor use a cross-dock

– As soon as one is used, rother = { 0 }

Page 29: The Vehicle Routing Problem

29/64NICTA Copyright 2013 From imagination to impact

Insertion

Subtours – poor man’s AllDifferent

• Can use stronger subtour elimination (Pesant)

(i) (j)i j

ijii j

SjS ,

Page 30: The Vehicle Routing Problem

30/64NICTA Copyright 2013 From imagination to impact

Local Search

• Can apply std local search methods VRPs

– k-opt

– Or-opt

– exchange

– …

• Step from solution to solution, so

• CP is only used as rule-checker

– Little use of propagation

• But LNS is repeated insertion

– Makes maximum use of propagation

Page 31: The Vehicle Routing Problem

31/64NICTA Copyright 2013 From imagination to impact

Large Neighbourhood Search revisited

Page 32: The Vehicle Routing Problem

32/64NICTA Copyright 2013 From imagination to impact

Large Neighbourhood Search

Destroy & Re-create

• Destroy part of the solution

– Remove visits from the solution

• Re-create solution

– Use insert method to re-insert customers

– Different insert methods lead to new (better?) solutions

• If the solution is better, keep it

• Repeat

Page 33: The Vehicle Routing Problem

33/64NICTA Copyright 2013 From imagination to impact

Large Neighbourhood Search

Destroy part of the solution (Select method)

In CP terms, this means:

• Relax some variable assignments

In CP-VRP terms, this means

• Relax some successor assignments, i.e.

• ‘Unassign” some visits.

Page 34: The Vehicle Routing Problem

34/64NICTA Copyright 2013 From imagination to impact

Large Neighbourhood Search

Destroy part of the solution (Select method)

Examples

• Remove a sequence of visits

Page 35: The Vehicle Routing Problem

35/64NICTA Copyright 2013 From imagination to impact

Large Neighbourhood Search

Destroy part of the solution (Select method)

Examples

• Choose longest (worst) arc in solution

– Remove visits at each end

– Remove nearby visits

• Actually, choose rth worst

• r = n * (uniform(0,1))y

• y ~ 6

– 0.56 = 0.016

– 0.96 = 0.531

Page 36: The Vehicle Routing Problem

36/64NICTA Copyright 2013 From imagination to impact

Large Neighbourhood Search

Destroy part of the solution (Select method)

Examples

• Dump visits from k routes (k = 1, 2, 3)

– Prefer routes that are close,

– Better yet, overlapping

Page 37: The Vehicle Routing Problem

37/64NICTA Copyright 2013 From imagination to impact

Large Neighbourhood Search

Destroy part of the solution (Select method)

Examples

• Choose first visit randomly

• Then, remove “related” visits

– Based on distance, time compatibility, load

|)(|

)|(|

ji

ji

ijij

qq

aa

CR

Page 38: The Vehicle Routing Problem

38/64NICTA Copyright 2013 From imagination to impact

Large Neighbourhood Search

Destroy part of the solution (Select method)

Examples

• Dump visits from the smallest route

– Good if saving vehicles

– Sometimes fewer vehicles = reduced travel

Page 39: The Vehicle Routing Problem

39/64NICTA Copyright 2013 From imagination to impact

Large Neighbourhood Search

Destroy part of the solution (Select method)

• Parameter: Max to dump

– As a % of n?

– As a fixed number e.g. 100 for large problems

• Actual number is uniform rand (5, max)

Page 40: The Vehicle Routing Problem

41/64NICTA Copyright 2013 From imagination to impact

Large Neighbourhood Search

Re-create solution

• Use different insert methods

• Insert methods differ by choice of:

– Which visit to insert

– Where to insert it

• Where to insert: Usually in position that increases cost by least

• Which to insert: Examples:

– Random

• Choose visit to insert at random

– Minimum insert cost

• Choose visit that increasess cost by the least

– Regret, 3-Regret, 4-Regret

• Choose visit with maximum difference between first and next best insert position

Page 41: The Vehicle Routing Problem

42/64NICTA Copyright 2013 From imagination to impact

Regret

Page 42: The Vehicle Routing Problem

43/64NICTA Copyright 2013 From imagination to impact

Regret

Page 43: The Vehicle Routing Problem

44/64NICTA Copyright 2013 From imagination to impact

Regret

Page 44: The Vehicle Routing Problem

45/64NICTA Copyright 2013 From imagination to impact

Regret

Page 45: The Vehicle Routing Problem

46/64NICTA Copyright 2013 From imagination to impact

Regret

Page 46: The Vehicle Routing Problem

47/64NICTA Copyright 2013 From imagination to impact

Regret

Regret = C(insert in 2nd-best route) – C(insert in best route)

= f (2,i) – f (1,i)

K-Regret = ∑k=1,K (f (k,i) – f (1,i) )

Page 47: The Vehicle Routing Problem

48/64NICTA Copyright 2013 From imagination to impact

Large Neighbourhood Search

If the solution is better, keep it

• Can use Hill-climbing

• Can use Simulated Annealing

• Can use Threshold Annealing

• …

Repeat

• Can use fail limit (limit on number of infeasibilities found)

• Can use Restarts

• Can use limited number of iterations

Page 48: The Vehicle Routing Problem

49/64NICTA Copyright 2013 From imagination to impact

Large Neighbourhood Search

Big Advantage: We can tailor Select / Insert

e.g. Routing with Equipment• Some tasks need equipment• Pickup /drop-off equipment at sub-depots• Modelled as a PDP with special compatibility constraints

Special Destroy methods• Remove visits if equipment not used much• Destroy routes with equip needed by unassigned visits

Special Insert Methods• Add multiple equips if some tasks need them• Insert hardest to satisfy visits first

Page 49: The Vehicle Routing Problem

50/64NICTA Copyright 2013 From imagination to impact

Large Neighbourhood Search

Learning (Ropke & Pisinger)

• Learn which Select methods are performing well

• Learn which Insert methods are performing well

• Select according to “success”

• Success =

– New best solution

– New incumbent solutions

– Solution not previously seen

Page 50: The Vehicle Routing Problem

51/64NICTA Copyright 2013 From imagination to impact

Advanced techniques

Randomized Adaptive Decomposition

• Partition problem into subproblems

• Work on each subproblem in turn

• Decomposition ‘adapts’

– Changes in response to incumbent solution

1511712852181014203119641391617

Page 51: The Vehicle Routing Problem

52/64NICTA Copyright 2013 From imagination to impact

Advanced techniques – Re-create solution

Complete search

• If subproblem is small (e.g. selected < 10 visits), use complete search

• Good for highly constrained problems

Page 52: The Vehicle Routing Problem

53/64NICTA Copyright 2013 From imagination to impact

Advanced techniques – Re-create solution

Limited Discrepancy Search

Heuristic order

Page 53: The Vehicle Routing Problem

54/64NICTA Copyright 2013 From imagination to impact

Advanced techniques

Limited Discrepancy Search

Page 54: The Vehicle Routing Problem

55/64NICTA Copyright 2013 From imagination to impact

Advanced techniques

Limited Discrepancy Search

Page 55: The Vehicle Routing Problem

56/64NICTA Copyright 2013 From imagination to impact

Advanced techniques

Limited Discrepancy Search

Page 56: The Vehicle Routing Problem

57/64NICTA Copyright 2013 From imagination to impact

Advanced techniques

2-LDS

Page 57: The Vehicle Routing Problem

58/64NICTA Copyright 2013 From imagination to impact

Advanced techniques

2-LDS

Page 58: The Vehicle Routing Problem

59/64NICTA Copyright 2013 From imagination to impact

Advanced techniques

2-LDS

Page 59: The Vehicle Routing Problem

60/64NICTA Copyright 2013 From imagination to impact

Advanced techniques

2-LDS

Page 60: The Vehicle Routing Problem

61/64NICTA Copyright 2013 From imagination to impact

Advanced techniques

2-LDS

Page 61: The Vehicle Routing Problem

62/64NICTA Copyright 2013 From imagination to impact

Advanced techniques

Limited Discrepancy Search

• Structured incomplete search

• Budget of discrepancies

• ‘Spend’ a discrepancy by going against the heuristic

Page 62: The Vehicle Routing Problem

63/64NICTA Copyright 2013 From imagination to impact

Solving VRPs

• CP is “natural” for solving vehicle routing problems

– Real problems often have unique constraints

– Easy to change CP model to include new constraints

– New constraints don’t change core solve method

– Infrastructure for complete (completish) search in subproblems

• LNS is “natural” for CP

– Insertion leverages propagation

Page 63: The Vehicle Routing Problem

64/64NICTA Copyright 2013 From imagination to impact

Playtime 2

Solve some VRPs using Comet

Some differences between presentation and example: • Single commodity/capacity• Homogeneous fleet• ‘capacity’ in model == ‘q’ here• Capacity enforced by domain, not constraint• Only start time modelled explicitly

– arrival time implicit– duration fixed

• Successor of end visit for route k is start of route k+1– slast(k) = n + k + 1

• No ‘unassigned’ route