Tutorial10 Multi Vehicle Routing With Time Windows PDF
Tutorial10 Multi Vehicle Routing With Time Windows PDF
www.data61.csiro.au
Outline
• Problem Description
• Solving the VRP
• Construction
• Local Search
• Meta-heuristics
• Variable Neighbourhood Search
• Including Large Neighbourhood Search
• CP101
• A CP model for the VRP
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
Travelling Salesman Problem
• Find the tour of minimum cost that visits
all cities
Why study the VRP?
• It’s hard: it exhibits all the difficulties of comb. opt.
• It’s useful:
o The logistics task is 9% of economic activity in Australia
o Logistics accounts for 10% of the selling price of goods
Why study the VRP in Robotics?
Appears as a sub-problem
• In real world
o A combination of time and distance
o Must include vehicle- and staff-dependent costs
o Usually vehicle numbers are fixed
o Includes “preferences” – like pretty routes
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
• Load profile:
Other variants
Orienteering Problem
• Maximum revenue in
limited time
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
– Multiple Depots
– Heterogeneous vehicles
– Compatibility constraints
• Goods for customer A {must | can’t} travel with goods from
customer B
• Goods for customer A {must | can’t} travel on vehicle C
VRP as an instance
Heuristic:
• Construct
• Improve
• Local Search
• Meta-heuristics
Exact Methods
VRP:
• MIP: Can only solve problems with 100-150 customers
• CP: Similar size
ILP
minimise : c ij xijk xijk = 1 if vehicle k travels
i, j k directly from i to j
subject to
x
i k
ijk 1 j Exactly one vehicle in
Capacity constraint
q x
i
i
j
ijk Qk k
x
j k
ihk x hjk
j k
0 k, h
q x
i
i
j
ijk Qk k
x ijk S 1 S P( N ),0 S
xijk {0,1}
Depot
ILP – Column Generation
Columns
represent routes
Column/route cost ck 89 76 99 45 32
1 1 1 1 0 0 …
Rows represent
customers 2 0 1 1 0 1 …
3 0 0 0 0 0 …
Array entry aik = 1 iff
customer i is 4 1 0 1 1 0 …
covered by route k
5 1 0 0 0 0 …
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 min c xk k
• Master problem at right
subject to
i a
k
ik xk 1 i
xk {0,1}
Heuristics for the VRP
Often variants of
• Construct
• Improve
E.g. (Greedy)
• Choose the customer that increases the cost by the least
• Insert it in the position that increases the cost by the least
Solving the VRP the easy way
Insert methods
Order is important:
Regret
Regret
Regret
Regret
Regret
Regret
Regret = C(insert in 2nd-best route) – C(insert in best route)
= f (2,i) – f (1,i)
Distance-based seeding
• Find the customer (s1) most distant from the depot
• Find the customer (s2) most distant from s1
• Find the customer (s3) mist distance from s1, s2
• …
• Continue until all vehicles have a seed
Implementation
• Heart of algorithm is deciding which customer to insert next, and
where
• Data structure of “Insert Positions”
o legal positions to insert a customer
o Must calculate cost of insert
o Must ensure feasibility of insert
• After each modification (customer insert)
o Add new insert positions
o Update cost of affected insert positions
o Check legality of all insert positions
o O(1) check important for efficiency
• Very effective
Local Search
• Local minima
Objective value
Current solution
Local Search
Escaping local minima
Meta-heuristics
• Heuristic way of combining heuristics
• Designed to escape local minima
Local Search
Escaping local minima
• Define more (larger) 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)
– Tail exchange (swap final portion of routes)
– 2-opt
– Or-opt (all sizes 2 .. n/2)
– 3-opt
Local Search
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
– Or-opt
– Tail exchange (swap final portion of routes
– 3-opt
– Explore one neighbourhood completely
– If no improvement found, advance to next neighbourhood
– When an improvement is found, return to level 1
Local Search
Variable Neighbourhood Search
1: S Ropke and D Pisinger, An Adaptive Large Neighborhood Search Heuristic for the Pickup and
Delivery Problem with Time Windows, Transportation Science 40(4), pp 455-472, 2006
Large Neighbourhood Search
Destroy part of the solution (Select method)
Rij Cij
(| ai a j | )
(| qi q j |)
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
Large Neighbourhood Search
Destroy part of the solution (Select method)
70/58
Large Neighbourhood Search
• If the solution is better, keep it
• Can use Hill-climbing
• Can use Simulated Annealing
• Can use Threshold Annealing
• …
Large Neighbourhood Search
T
P( accept increase ) e
Large Neighbourhood Search
Large Neighbourhood Search
Large Neighbourhood Search
Adaptive
– Ropke adapts choice based on prior performance
– “Good” methods are chosen more often
75/58
Large Neighbourhood Search
Adapting Select method
76/58
Large Neighbourhood Search
Ropke & Pisinger (with additions) can solve a variety of problems
• VRP
• VRP + Time Windows
• Pickup and Delivery
• Multiple Depots
• Multiple Commodities
• Heterogeneous Fleet
• Compatibility Constraints
Solution Methods
Summary so far:
An alternative:
Constraint Programming
Constraint Programming
CP offers a language for representing problems
• Decision variables
• Constraints on variables
% Vehicles constraint
int: NumVehicles; obj = sum (i in Visits)
int: NumRoutes = NumVehicles; (dist[Loc[i],Loc[succ[i]]]);
set of int: Vehicles =
1..NumVehicles; constraint
sum (i in Visits,j = routeOf[i])
% Location data (demand[i]) < j)
array[Locations] of float: locX; for j in Vehicles;
array[Locations] of float: locY;
array [Locations, Locations] of
int: dist;
Constraint Programming for the VRP
Constraint Programming
Advantages:
• Expressive language for formulating constraints
• Each constraint encapsulated
• Constraints interact naturally
• Constraints guide construction
Disadvantages:
• Can be slow
• No fine control of solving
• (unless you use a low-level library like gecode )
Constraint Programming
Two ways to use constraint programming
• Rule Checker
• Properly
Rule Checker:
• Use favourite method to create/improve a solution
• Check it with CP
– Very inefficient.
A CP Model for the VRP
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
Model
A (rich) vehicle routing problem
• n customers (fixed in this model)
• v vehicles (fixed in this model)
• m = v+1 one route per vehicle plus “unassigned” route
• 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
Referencing
Sets
• N = {1 .. n} – customers
• V = {1 .. v} – vehicles/real routes
• R = {1 .. m} - routes include ‘unassigned’ route
• S = {n+1 .. n+m} – start visits
• E = {n+m+1 .. n+2m} – end visits
• V = N S E – all visits
• VS= N S – visits that have a sensible successor
• VE= N E – visits that have a sensible predecessor
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 R = {1..m}
• Unassigned route has index m
• 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
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
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
Example
i si pi ri 1
1 4 2 2 Route 2
4
2 1 7 2
3 8 5 1 Route 1
2
4 9 1 2 End
3 visits
5 3 6 1
6 5 0 1
7 2 0 2 7 9
5
8
8 0 3 1
6
9 0 4 2 Start visits
Other variables
Accumulation Variables
• qik Quantity of commodity k after visit i
• ci Objective cost getting to i
Want to minimize
• sum of objective (cij) over used arcs, plus
• value of unassigned visits
minimize
c v
iE
i
i ri 0
i
Basic constraints
Path ( S, E, { si | i V } )
AllDifferent ( { pi | i VE } )
Decompose problem
• Only consider 2-3 routes
• Smaller problem is much easier to solve
Advanced techniques – Recreate
Adaptive Decomposition
Decompose problem
• Only consider 2-3 routes
• Smaller problem is much easier to solve
Adaptive
• Decompose in different ways
• Use problem features to determine decomposition
Conclusions
• Now you know
o How to construct a solution to a VRP by successive insertion
o How to improve the solution using
– Variable Neighbourhood Search
– Large Neighbourhood Search