57
The Vehicle Routing Problem Using CP in the real world

The Vehicle Routing Problem Using CP in the real world

Embed Size (px)

Citation preview

Page 1: The Vehicle Routing Problem Using CP in the real world

The Vehicle Routing Problem

Using CP in the real world

Page 2: The Vehicle Routing Problem Using CP in the real world

2/58NICTA Copyright 2011 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 Using CP in the real world

3/58NICTA Copyright 2011 From imagination to impact

What is the Vehicle Routing Problem

Given a set of customers,

and

a fleet of vehicles to make deliveries,

find

a set of routes that services all customers at minimum cost

Page 4: The Vehicle Routing Problem Using CP in the real world

4/58NICTA Copyright 2011 From imagination to impact

Vehicle Routing Problem

Page 5: The Vehicle Routing Problem Using CP in the real world

5/58NICTA Copyright 2011 From imagination to impact

Vehicle Routing Problem

Page 6: The Vehicle Routing Problem Using CP in the real world

6/58NICTA Copyright 2011 From imagination to impact

Why study the VRP?

• The logistics task is 9% of economic activity in Australia

• Logistics accounts for 10% of the selling price of goods

Page 7: The Vehicle Routing Problem Using CP in the real world

7/58NICTA Copyright 2011 From imagination to impact

Vehicle Routing Problem

For each customer, we know

Quantity required

The cost to travel to every other customer

For the vehicle fleet, we know

The number of vehicles

The capacity

We must determine which customers each vehicle serves, and in what order, to minimise cost

Page 8: The Vehicle Routing Problem Using CP in the real world

8/58NICTA Copyright 2011 From imagination to impact

Vehicle Routing Problem

Objective function

In academic studies, usually a combination:

First, minimise number of routes

Then minimise total distance or total time

In real world

A combination of time and distance

Must include vehicle- and staff-dependent costs

Usually vehicle numbers are fixed

Page 9: The Vehicle Routing Problem Using CP in the real world

9/58NICTA Copyright 2011 From imagination to impact

Vehicle Routing Problem

• Might be more than one ‘capacity’

– e.g. limited weight and volume

• Might be more than one type of vehicle

– Different capacities and costs

– ‘Heterogeneous Vehicles’

Page 10: The Vehicle Routing Problem Using CP in the real world

10/58NICTA Copyright 2011 From imagination to impact

MIP formulation

}1,0{

}x{

xq

,0xx

1x

1x

subject to

c:minimise

ijk

jijki

j k j khjkihk

j kijk

i kijk

,ij

ijk

ki

ji kijk

x

S

kQ

hk

i

j

x

Datacij: Cost of travel from i to j

qi: Demand at i

Decision var:

xijk: Travel direct from i to j on vehicle k

Depot

Page 11: The Vehicle Routing Problem Using CP in the real world

11/58NICTA Copyright 2011 From imagination to impact

Vehicle Routing Problem

In a classic 2-echelon routing problem:

Stage 1: Production/warehouse to distribution depots

Stage 2: Distribution depots to end customer

VRP is primarily concerned with Stage 2

• Strategic decision

• Also study dynamic version

Page 12: The Vehicle Routing Problem Using CP in the real world

12/58NICTA Copyright 2011 From imagination to impact

History: Travelling Salesman Problem

• A travelling salesman has to visit a number of cities. He knows the cost of travel between each pair.What order does he visit the cities to minimise cost?

• Long and well-studied problem (since the 60’s)• A sub-problem in many others• Used in chip fabrication and many other real-world

problems

• TSP = VRP with 1 vehicle of infinite capacity

• In vehicle routing - having decided which vehicle will visit which customers, each vehicle route is a travelling salesman problem

Page 13: The Vehicle Routing Problem Using CP in the real world

13/58NICTA Copyright 2011 From imagination to impact

Travelling Salesman Problem

• Exact solution are found regularly for problems with 200-300 cities, and occasionally for problems with 1000 nodes.

• Some larger problems solved(24,798 cities, towns and villages in Sweden)

• But – no constraints on the solution

• Even one constraint, and the whole method is unusable

Page 14: The Vehicle Routing Problem Using CP in the real world

14/58NICTA Copyright 2011 From imagination to impact

Routing with constraints

• Each new twist (business rule, practice, limitation) changes which solutions are good, and which are even acceptable

• The types of constraints that must be observed may impact on the way the problem is solved

• Many types of constraint studied – but usually in isolation

• We will look at a few that have been studied in the literature

Page 15: The Vehicle Routing Problem Using CP in the real world

15/58NICTA Copyright 2011 From imagination to impact

Time window constraints

Vehicle routing with Constraints • Time Window constraints

– A window during which service can start– E.g. only accept delivery 7:30am to 11:00am

– Additional input data required• Duration of each customer visit• Time between each pair of customers

• (Travel time can be vehicle-dependent or time-dependent)

– Makes the route harder to visualise

Page 16: The Vehicle Routing Problem Using CP in the real world

16/58NICTA Copyright 2011 From imagination to impact

Time Window constraints

Page 17: The Vehicle Routing Problem Using CP in the real world

17/58NICTA Copyright 2011 From imagination to impact

Pickup and Delivery problems

• Most routing considers delivery to/from a depot (depots)

• Pickup and Delivery problems consider FedEx style

problem:

pickup at location A, deliver to location B

Load profile:

Page 18: The Vehicle Routing Problem Using CP in the real world

18/58NICTA Copyright 2011 From imagination to impact

Pickup and Delivery problems

• PDPs have two implied constraints:

– pickup is before delivery

– pickup and delivery are on the same vehicle

• Usually, completely different methods used to solve this sort of problem

• Can be quite difficult

• Standard VRP is in effect a PDP with all stuff picked up at (delivered to) a depot. Not usually solved that way

Page 19: The Vehicle Routing Problem Using CP in the real world

19/58NICTA Copyright 2011 From imagination to impact

Pickup and Delivery problem

Interesting variants

• Dial-a-ride problem:

– Passenger transport

– Like a multi-hire taxi

– Pickup passenger A, pickup passenger B, drop off B, pickup up C, drop off A, ….

– Ride-time constraints (e.g. max 1.4 x direct travel time)

• PDP can be used to model cross-docking

– Pick up at Factory, Deliver to DC; Pickup at DC, Deliver to customer

– Constraint: “Deliver to DC” before “Pickup at DC”

Page 20: The Vehicle Routing Problem Using CP in the real world

20/58NICTA Copyright 2011 From imagination to impact

Fleet size and mix

• Heterogonous vehicles

– Vehicles of different capacities, costs, speeds etc

• Fleet size and mix problem

– Decide the correct number of each type of vehicle

– Strategic decision

• Can be the most important part of optimization

Page 21: The Vehicle Routing Problem Using CP in the real world

22/58NICTA Copyright 2011 From imagination to impact

Other variants

Profitable tour problem

• Not all visits need to be completed

• Known profit for each visit

• Choose a subset that gives maximum return(profit from visits – routing cost)

Page 22: The Vehicle Routing Problem Using CP in the real world

24/58NICTA Copyright 2011 From imagination to impact

Other variants

Period Routing

• Routing with periodical deliveries

• Same routes every week / fortnight

• Deliver to different customers with different frequencies: patterns

• 3-part problem

– Choose pattern for each cust

– Choose qty for each delivery

– Design route for each day

M T W T F

? ?

? ?

? ? ?

? ? ? ? ?

Page 23: The Vehicle Routing Problem Using CP in the real world

25/58NICTA Copyright 2011 From imagination to impact

VRP meets the real world

Many groups now looking at real-world constraints

Rich Vehicle Routing Problem

• Attempt to model constraints common to many real-life enterprises

– Multiple Time windows

– Multiple Commodities

– Heterogeneous vehicles

– Compatibility constraints • Goods for customer A can’t travel with goods from

customer B• Goods for customer A can’t travel on vehicle C

Page 24: The Vehicle Routing Problem Using CP in the real world

26/58NICTA Copyright 2011 From imagination to impact

VRP meets the real world

Other real-world considerations

• Fatigue rules and driver breaks

• Vehicle re-use

• Ability to change vehicle characteristics (composition)

– Add trailer, or move compartment divider

• Use of limited resources

– e.g limited docks for loading, hence need to stagger dispatch times

• Variable loading / unloading times

Page 25: The Vehicle Routing Problem Using CP in the real world

27/58NICTA Copyright 2011 From imagination to impact

VRP meets the real world

Yet more constraints

• Only two types of product on each vehicle

• ‘Grand tour’ constraint

– Customers visited in ‘patterns’ (Period Routing)

– Grand tour includes all visits

– Skip visit if not required that day

– Each day must be feasible (incl. time windows)

• Meet ferry

• Blood transport (dynamic time window)

• Promiscuous driver constraint

Page 26: The Vehicle Routing Problem Using CP in the real world

28/58NICTA Copyright 2011 From imagination to impact

VRP meets the real world

New data sources

• Routing with time-of-day dependent travel times

– Uses historical data to forecast travel time at different times of day

• Routing with dynamic travel times

– Uses live traffic information feed to update expected travel time dynamically

Page 27: The Vehicle Routing Problem Using CP in the real world

29/58NICTA Copyright 2011 From imagination to impact

VRP meets the real world

Stochastic Routing

What if things don’t go according to plan?

• Sources of uncertainty

– Uncertainty in existence (do I even need to visit)

– Uncertainty in quantity (how much is actually required)

– Uncertainty in travel times (traffic)

– Uncertainty in duration (maintenance engineer)

• Optimal solution can be brittle

– If something is not quite right, whole solution falls apart

Page 28: The Vehicle Routing Problem Using CP in the real world

30/58NICTA Copyright 2011 From imagination to impact

VRP meets the real world

E.g. garbage collection

• Wet rubbish is heavy

• On rainy days, trucks may have more load than usual(uncertainty in quantity)

• Need stops near dump in case they have to double back

• = Recourse.

Page 29: The Vehicle Routing Problem Using CP in the real world

31/58NICTA Copyright 2011 From imagination to impact

Solution Methods

Page 30: The Vehicle Routing Problem Using CP in the real world

32/58NICTA Copyright 2011 From imagination to impact

Solving VRPs

VRP is hard

• NP Hard in the strong sense

• Exact solutions only for small problems (20-50 customers)

• Most solution methods are heuristic

• Most operate as

– Construct

– Improve

Page 31: The Vehicle Routing Problem Using CP in the real world

33/58NICTA Copyright 2011 From imagination to impact

ILP

Advantages

• Can find optimal solution

Disadvantages

• Only works for small problems

• One extra constraint back to the drawing board

}1,0{

}x{

xq

,0xx

1x

1x

subject to

c:minimise

ijk

jijki

j k j khjkihk

j kijk

i kijk

,ij

ijk

ki

ji kijk

x

S

kQ

hk

i

j

x

Page 32: The Vehicle Routing Problem Using CP in the real world

34/58NICTA Copyright 2011 From imagination to impact

ILP – Column Generation

89 76 99 45 32

1 1 1 1 0 0 …

2 0 1 1 0 1 …

3 0 0 0 0 0 …

4 1 0 1 1 0 …

5 1 0 0 0 0 …

Columns represent routes

Rows represent customers

Column/route cost ck

Array entry aik = 1 iff customer i is covered by route k

Page 33: The Vehicle Routing Problem Using CP in the real world

35/58NICTA Copyright 2011 From imagination to impact

Column Generation

• Decision var xk: Use column k?

• Column only appears if feasible ordering is possible

• Cost of best ordering is ck

• Best order stored separately

• Master problem at right

}1,0{

1

subject to

min

k

kik

kk

x

ia

xc

i

Page 34: The Vehicle Routing Problem Using CP in the real world

36/58NICTA Copyright 2011 From imagination to impact

Column Generation

Subproblem

• i.e. shortest path with side constraints

• If min is –ve add to master problem

• CP!

sconstraint Route

1

1 s.t.

)(min,

iij

jij

jijji

ij

jx

ix

cx

Page 35: The Vehicle Routing Problem Using CP in the real world

37/58NICTA Copyright 2011 From imagination to impact

Heuristic methods - Construction

Insert methods

Insert1.dig

Order is important:

Insert2.dig

Compare.dig

Page 36: The Vehicle Routing Problem Using CP in the real world

38/58NICTA Copyright 2011 From imagination to impact

Heuristic methods - Construction

Savings method (Clarke & Wright 1964)

• Calculate Sij for all i, j

• Consider cheapest Sij

• If j can be appended to i

– merge them to new i

– update all Sij

• else

– delete Sij

• Repeat

ij

Page 37: The Vehicle Routing Problem Using CP in the real world

39/58NICTA Copyright 2011 From imagination to impact

Improvement Methods

2-opt (3-opt, 4-opt…)

• Remove 2 arcs

• Replace with 2 others

Page 38: The Vehicle Routing Problem Using CP in the real world

40/58NICTA Copyright 2011 From imagination to impact

Improvement methods

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 39: The Vehicle Routing Problem Using CP in the real world

41/58NICTA Copyright 2011 From imagination to impact

Improvement methods

Variable Neighbourhood Search

• Consider multiple neighbourhoods

– 1-move (move 1 visit to another position)

– 1-1 swap (swap visits in 2 routes)

– 2-2 swap (swap 2 visits between 2 routes)

– 2-opt

– 3-opt

– Or-opt size 2 (move chain of length 2 anywhere)

– Or-opt size 3 (chain length 3)

– Tail exchange (swap final portion of routes

Page 40: The Vehicle Routing Problem Using CP in the real world

42/58NICTA Copyright 2011 From imagination to impact

Improvement methods

Variable Neighbourhood Search

• Consider multiple neighbourhoods

• Find local minimum in smallest neighbourhood

• Advance to next-largest neighbourhood

• Search current neighbourhood

– If a change is found, return to smallest neighbourhood

– Otherwise, advance to next-largest

Page 41: The Vehicle Routing Problem Using CP in the real world

43/58NICTA Copyright 2011 From imagination to impact

Improvement methods

Path Relinking

• Applies where-ever a population of solutions is available

• Take one (good) solution A

• Take another (good) reference solution B

• Gradually transform solution A into solution B

– pass through new solutions “between” A and B

– new solutions contain traits of both A and B

– should be good!

Page 42: The Vehicle Routing Problem Using CP in the real world

44/58NICTA Copyright 2011 From imagination to impact

Improvement methods

Genetic Programming

• Simulated Natural Selection

Page 43: The Vehicle Routing Problem Using CP in the real world

45/58NICTA Copyright 2011 From imagination to impact

Genetic Programming

• Generate a population of solutions (construct methods)

• Evaluate fitness (objective)• Create next generation:

– Choose two solutions from population– Combine the two (two ways)– (Mutate)– Produce offspring (calculate fitness)– (Improve)– Repeat until population doubles

• Apply selection:– Bottom half “dies”

• Repeat

Page 44: The Vehicle Routing Problem Using CP in the real world

46/58NICTA Copyright 2011 From imagination to impact

Genetic Programming

1 4 6 2 3 8 9 5 10 7

1 10 8 2 5 4 9 3 6 7

125

132

6 1 9 7 3 2 10 4 8 5

1 9 7 10 8 6 4 3 2 5

160

198

Page 45: The Vehicle Routing Problem Using CP in the real world

47/58NICTA Copyright 2011 From imagination to impact

Genetic Programming

1 4 6 2 3 8 9 5 10 7

1 10 8 2 5 4 9 3 6 7

125

132

6 1 9 7 3 2 10 4 8 5

1 9 7 10 8 6 4 3 2 5

160

198

1 10 8 2 3 9 5 10 7 4 128

Page 46: The Vehicle Routing Problem Using CP in the real world

48/58NICTA Copyright 2011 From imagination to impact

Genetic Programming

1 4 6 2 3 8 9 5 10 7

1 10 8 2 5 4 9 3 6 7

125

132

6 1 9 7 3 2 10 4 8 5

1 9 7 10 8 6 4 3 2 5

160

198

1 10 8 2 5 9 5 10 7 4

1 4 6 2 3 9 3 7 8 10

128

206

Page 47: The Vehicle Routing Problem Using CP in the real world

49/58NICTA Copyright 2011 From imagination to impact

Genetic Programming

1 4 6 2 3 8 9 5 10 7

1 10 8 2 5 4 9 3 6 7

125

132

6 1 9 7 3 2 10 4 8 5160

1 10 8 2 5 9 5 10 7 4 128

Page 48: The Vehicle Routing Problem Using CP in the real world

50/58NICTA Copyright 2011 From imagination to impact

Genetic Programming

Split

• Solution representation does not include route delimiters

• Routes are determined using “Split” routine

– Solves shortest path problem on an auxiliary graph

– O(mn2)

• Allows freer movement in solution space

Page 49: The Vehicle Routing Problem Using CP in the real world

51/58NICTA Copyright 2011 From imagination to impact

Scaling

Solving problems with tens of thousands of nodes

• Decompose problem

– Split into smaller problems

• Limit search

– Only consider inserting next to nearby nodes

– Only consdier inserting into nearby routes

Page 50: The Vehicle Routing Problem Using CP in the real world

52/58NICTA Copyright 2011 From imagination to impact

Solution Methods

.. and the whole bag of tricks

• Tabu Search

• Simulated Annealing

• Ants

• Bees

• ….

Page 51: The Vehicle Routing Problem Using CP in the real world

53/58NICTA Copyright 2011 From imagination to impact

A CP Model for the TSP

Page 52: The Vehicle Routing Problem Using CP in the real world

54/58NICTA Copyright 2011 From imagination to impact

Model

Classic TSP

• n customers (fixed in this model)

• fixed locations

– where things happen

– one for each customer + one for the depot

• Know distance/cost C(i,j) between each location pair

– Obeys triangle inequality

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

• Customers are ‘named’ in CP by their index

Page 53: The Vehicle Routing Problem Using CP in the real world

55/58NICTA Copyright 2011 From imagination to impact

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 N

Page 54: The Vehicle Routing Problem Using CP in the real world

56/58NICTA Copyright 2011 From imagination to impact

Constraints

• AllDifferent ( s )

2

4

1

5

3

6

i si

1 4

2 1

3 6

4 2

5 3

6 5

Page 55: The Vehicle Routing Problem Using CP in the real world

57/58NICTA Copyright 2011 From imagination to impact

1

Constraints

• AllDifferent ( s )

• Circuit ( s )

2

45

3

6

i si

1 4

2 3

3 6

4 2

5 1

6 5

Page 56: The Vehicle Routing Problem Using CP in the real world

58/58NICTA Copyright 2011 From imagination to impact

Objective

Objective is

• minimise( sumi in N ( C( i, si) ) )

Page 57: The Vehicle Routing Problem Using CP in the real world

59/58NICTA Copyright 2011 From imagination to impact

Playtime

Now you have a try…