Vehicle Routing Problem (VRP): models and algorithms

62
Agostino Nuzzolo nuzzolo@ing .uniroma2.it Antonio Polimeni [email protected] Logistica Territoriale Vehicle Routing Problem (VRP): models and algorithms 1

Transcript of Vehicle Routing Problem (VRP): models and algorithms

Page 1: Vehicle Routing Problem (VRP): models and algorithms

Agostino Nuzzolo [email protected]

Antonio Polimeni [email protected]

Logistica Territoriale

Vehicle Routing Problem (VRP):

models and algorithms

1

Page 2: Vehicle Routing Problem (VRP): models and algorithms

Contents:

Vehicle routing problem VRP definition

VRP formulation

Solution search approach

Example of search tools

2

Page 3: Vehicle Routing Problem (VRP): models and algorithms

Vehicle Routing Problem (VRP)

consists of designing optimal delivery or

collection routes from a central depot to a

set of geographically scattered customers

(e.g. retailers or travellers), subject to

various constraints, such as vehicle capacity,

route length, time windows, and so on

3

Page 4: Vehicle Routing Problem (VRP): models and algorithms

Vehicle Routing Problem (VRP)

http://www.jstor.org/stable/2627477

The Truck Dispatching Problem

G. B. Dantzig and J. H. Ramser

Management Science Vol. 6, No. 1 (Oct., 1959),

pp. 80-91

The paper is concerned with the optimum routing

of a fleet of gasoline delivery trucks between a

bulk terminal and a large number of service

stations supplied by the terminal.

4

Page 5: Vehicle Routing Problem (VRP): models and algorithms

Vehicle Routing Problem (VRP)

Veicoli merci

Transit on-demand services - Scuolabus

5

Page 6: Vehicle Routing Problem (VRP): models and algorithms

retailer 1

Depot

retailer nretailer i

retailer 3

retailer 2

Vehicle Routing Problem (VRP)

6

Page 7: Vehicle Routing Problem (VRP): models and algorithms

Vehicle Routing Problem (VRP): Example of routes

depot

7

Page 8: Vehicle Routing Problem (VRP): models and algorithms

Vehicle Routing Problem (VRP)

• Homogeneous (or not) vehicle fleet

• Different definition of vehicle capacity (weight, volume, …)

• Pickup or Delivery

• Mixed, both Pickup and Delivery.

• Multi-depot

• …

• Costs (costs for load/unload, empty journey…)

• Customers' priorities

(freight type, delivery time)

8

Page 9: Vehicle Routing Problem (VRP): models and algorithms

Vehicle Routing Problem (VRP)

• Compatibility

(vehicle-freight, vehicle-driver, …)

• Time windows for delivery/pick-up

(rigid or elastic)

• Route constraints

(maximum time, maximum length, …)

9

Page 10: Vehicle Routing Problem (VRP): models and algorithms

minimize SvVSiNSjN cij xijv

Vehicle Routing Problem (VRP): general formulation

N: set of clients, contains also the depot

V: set of homogeneous vehicles, |V| = m

cij : cost to move from i to j

xij : binary variable, equal to 1 if the travel

from i to j happens, 0 otherwise

Sv=1,..., m SjN xijv = 1 i N, i ≠ d, j ≠ d

Sv=1,..., m SjN xdjv = m

Sv=1,..., m SjN xjdv = m

SiNSjN rj xijv bv v V

xijv {0, 1} (i,j), v V

d is the depot;

ri freight demand on node i;

bv vehicle capacity, v = 1, 2, …, m;

a client must be reached only once

all vehicles star from depot and return to it

the delivered quantity not exceed the vehicle capacity

the problem variables are binary

10

Page 11: Vehicle Routing Problem (VRP): models and algorithms

Route

Path

Depot

Depot

Client

Network node

Vehicle Routing Problem (VRP): Example of routes

11

cij : cost to move from i to j

ji

In a road network, the travel cost is generally a

function of the flow vector: cij (f)

Page 12: Vehicle Routing Problem (VRP): models and algorithms

ESEMPIO (formulazione del problema)Definition of Combinatorial Optimization

Combinatorial optimization is the mathematical studyof finding an optimal arrangement, grouping, ordering,or selection of discrete objects usually finite in numbers.

- Lawler, 1976

Constraints can be hard (must be satisfied) or soft (is

desirable to satisfy).

12

Page 13: Vehicle Routing Problem (VRP): models and algorithms

Vehicle Routing Problem

Exact approaches

Heuristics approaches

Fisher (1993)Toth & Vigo (2002)Ropke et al. (2007)Baldacci et al. (2008)…

Jones et al. (2002)Montemanni et al. (2005)Bianchi et al. (2005)Hanshar & Ombuki-Berman (2007) Laporte (2007)…

Solution approaches

13

Page 14: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches

Saving methods

Branch and Bound: an exact approach to solve the VRP

Genetic Algorithm

14

Page 15: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: B&B steps

0. Initialization: Estimate a value for the Lower Bound

1. Solution tree: Select a node for the branch operation

2. Evaluation: Evaluate the objective function for the current

(partial) solution

3. Test: If the objective function is less than the lower bound, go to

step 1, else quit from the current branch and go to the step1

4. Stop: if all node are explored

15

Page 16: Vehicle Routing Problem (VRP): models and algorithms

4

12

3

17

1

13

0

135

2

1

1

1 8

Solution approaches: B&B

16

Number of solutions: n! n = number of nodes

CAVEAT: the number of solution is n! because no constraints are considered

Page 17: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: B&B0 [0]

1 [1] 2 [8] 4 [1]

1 8 1

2 [2]

1

3 [3]

1

4 [4]

1

Search Tree

3 [2]

0 [5]

1

2

lower bound = 5

Initial solution: an initial solution can be used to obtain a

value of the lower bound, in this case, the value is 5.

CAVEAT: the search of the lower bound is as important as finding the

solution

17

Page 18: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: B&B0 [0]

1 [1] 2 [8] 4 [1]

1 8 1

2 [2]

1

3 [3]

1

4 [4]

1

Search Tree

3 [2]

0 [5]

1

2

lower bound = 5

18

Page 19: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: B&B0 [0]

1 [1] 2 [8] 4 [1]

1 8 1

2 [2]

1

3 [3]

1

4 [4]

1

Search Tree

3 [2]

0 [5]

1

2

lower bound = 5

1 [19] 2 [3] 4 [3]

17 11

19

Page 20: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: B&B0 [0]

1 [1] 2 [8] 4 [1]

1 8 1

2 [2]

1

3 [3]

1

4 [4]

1

Search Tree

3 [2]

0 [5]

1

2

lower bound = 5

1 [19] 2 [3] 4 [3]

17 11

4 [16] 1 [4]

13 1

20

Page 21: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: B&B0 [0]

1 [1] 2 [8] 4 [1]

1 8 1

2 [2]

1

3 [3]

1

4 [4]

1

3 [2]

0 [5]

1

2

lower bound = 5

1 [19] 2 [3] 4 [3]

17 11

4 [16] 1 [4]

13 1

Search Tree

21

1 [38] 2 [16]

1335

Page 22: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: B&B0 [0]

1 [1] 2 [8] 4 [1]

1 8 1

2 [2]

1

3 [3]

1

4 [4]

1

3 [2]

0 [5]

1

2

lower bound = 5

1 [19] 2 [3] 4 [3]

17 11

4 [16] 1 [4]

13 1

1 [36] 2 [14] 3 [2]

35 131

Search Tree

22

Page 23: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: B&B0 [0]

1 [1] 2 [8] 4 [1]

1 8 1

2 [2]

1

3 [3]

1

4 [4]

1

3 [2]

0 [5]

1

2

lower bound = 5

1 [19] 2 [3] 4 [3]

17 11

4 [16] 1 [4]

13 1

1 [36] 2 [14] 3 [2]

35 131

4 [39]

35

Search Tree

23

Page 24: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: B&B0 [0]

1 [1] 2 [8] 4 [1]

1 8 1

2 [2]

1

3 [3]

1

4 [4]

1

3 [2]

0 [5]

1

2

lower bound = 5

1 [19] 2 [3] 4 [3]

17 11

4 [16] 1 [4]

13 1

1 [36] 2 [14] 3 [2]

35 131

2 [3] 1 [19]

1 17

4 [39]

35

Search Tree

24

Page 25: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: B&B0 [0]

1 [1] 2 [8] 4 [1]

1 8 1

2 [2]

1

3 [3]

1

4 [4]

1

3 [2]

0 [5]

1

2

lower bound = 5

1 [19] 2 [3] 4 [3]

17 11

4 [16] 1 [4]

13 1

1 [36] 2 [14] 3 [2]

35 131

2 [3] 1 [19]

1 17

1 [4]

1

0 [5]

4 [39]

35

Search Tree

25

Page 26: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: Meta-heuristics

• Meta-heuristics are iterative generation processes of solutions not

tied to any special problem type and are general methods that can

be altered to fit the specific problem.

• The inspiration from nature is (to name a few):

o Simulated Annealing (SA): molecule/crystal arrangement during cool

down

o Evolutionary Computation (EC): biological evolution

o Tabu Search (TS): long and short term memory

o Ant Colony and Swarms: individual and group behavior using

communication

26

Page 27: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches

Saving methods

Branch and Bound

Evolutionary algorithm: genetic algorithm

27

Page 28: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: genetic algorithm

Initial population

Selection

Crossover

Mutation

Population

Test End

Initial population (parameter: population size)

A set of feasible solutions. Examples of

population generation:

1) Random

2) Constructive methods

3) Constructive + improvement methods

28

Page 29: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: genetic algorithm

Initial population

Selection

Crossover

Mutation

Population

Test End

Selection

In the selection procedure the population is

evaluated in order to establish the parents

for the next step (crossover):

1) compute the Fitness Function value

2) compute the selection probability

3) extract the new solutions

29

Page 30: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: genetic algorithm

Initial population

Selection

Crossover

Mutation

Population

Test End

Crossover (parameter: crossover rate)

merging two parents to obtain two children,

example:

1) select the parents

2) for each parent, select a node interchange

set

3) append the interchange node set of a route

at the end of the other and eliminate the

repeated nodes

4) test the solution

5) update the solution cost

30

Page 31: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: genetic algorithm

Initial population

Selection

Crossover

Mutation

Population

Test End

Mutation (parameter: mutation rate)

Mutation allows variations to be introduced

into the solutions, extending the solution

space. Examples of mutation:

1) swapping two nodes in a route

2) reversing a route

31

Page 32: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: genetic algorithm

4 [5]

1 [40]2 [10]

3 [25]

17

28

13

0

20

35

13

15

36

33 23x: node id

[q]: quantity

32

Total number of solutions: Sk(n!/(n-k)!)

n = number of nodes k=1, 2, …n

Vehicle capacity = 40

Page 33: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: genetic algorithm

Initial population: generate a set of initial solutions

Constraint: capacity = 40

0-4-3-2-0 0-1-0

[86] [66]

0-2-4-3-0 0-1-0

[77] [66]

Soluzione 1

Soluzione 2

0-2-3-4-0

[86] [66]

Soluzione 3 0-1-0

33

Page 34: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: genetic algorithm

Selection: selecting the parents

0-4-3-2-0 0-1-0

[86] [66]

0-2-4-3-0 0-1-0

[77] [66]

Soluzione 1

Soluzione 2

0-2-3-4-0

[86] [66]

Soluzione 3 0-1-0

34

Page 35: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: genetic algorithm

Crossover: example of child generation

0-4-3-2-0 0-1-0

[86] [66]

0-2-4-3-0 0-1-0

[77] [66]

Soluzione 1

Soluzione 2

Select the nodes to cross

35

Page 36: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: genetic algorithm

Crossover: example of child generation

0-4-3-2-2-4-0 0-1-0

[-] [66]

0-2-4-3-3-2-0 0-1-0

[-] [66]

Soluzione 1

Soluzione 2

Crossing the solutions

36

Page 37: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: genetic algorithm

Crossover: example of child generation

0-3-2-4-0 0-1-0

[-] [66]

0-4-3-2-0 0-1-0

[-] [66]

Soluzione 1

Soluzione 2

Eliminate the duplicated nodes

37

Page 38: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: genetic algorithm

Crossover: example of child generation

0-3-2-4-0 0-1-0

[61] [66]

0-4-3-2-0 0-1-0

[86] [66]

Soluzione 1

Soluzione 2

Check the feasibility and evaluate objective function

38

Page 39: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: genetic algorithm

Mutation: example node swap

0-3-2-4-0 0-1-0

[61] [66]

0-4-3-2-0 0-1-0

[-] [66]

Soluzione 1

Soluzione 2

In solution 2, swap the node 3 with the node 2

39

Page 40: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: genetic algorithm

Mutation: example node swap

0-3-2-4-0 0-1-0

[61] [66]

0-4-2-3-0 0-1-0

[61] [66]

Soluzione 1

Soluzione 2

After the swap, evaluate the objective function

40

Page 41: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches

Saving Methods

Branch and Bound

Genetic Algorithm

41

Page 42: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: saving

Clarke-Wright Algorithm

The CW algorithm is a saving algorithm, an heuristic procedure thatallows to evaluate the ‘saving’ obtainable merging two tours.

0

1

0

2

+

0

21

=

42

Page 43: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: saving

Clarke-Wright algorithm

0. Construct a travel cost matrix

1. Assign one round-trip to each location

2. Calculate iteratively the savings for each pair of locations, and enterthem in a savings list

3. Order descending the savings list and merge the locations

43

Page 44: Vehicle Routing Problem (VRP): models and algorithms

Solution approaches: saving

0

1

0

2

+

0

21

=

Configuration A Configuration B

CA = d(0,1) + d(1,0) + d(0,2) + d(2,0) CB = d(0,1) + d(1,2) + d(2,0)

Saving = CA - CB = d(1,0) + d(2,0) - d(1,2)

44

Clarke-Wright Algorithm

The CW algorithm is a saving algorithm, an heuristic procedure thatallows to evaluate the ‘saving’ obtainable merging two tours.

Page 45: Vehicle Routing Problem (VRP): models and algorithms

i j di0 d0j dij sij

1 2 33 23 36 20

0

1

0

2

0

3

0

4

s(i,j) = d(i,0)+d(0,j) – d(i,j)

4

12

3

17

28

13

0

20

35

13

15

36

33 23

33 + 23 – 36

Solution approaches: saving

45

Page 46: Vehicle Routing Problem (VRP): models and algorithms

i j di0 d0j dij sij

1 2 33 23 36 20

s(i,j) = d(i,0)+d(0,j) – d(i,j)

4 [5]

1 [40]2 [10]

3 [25]

17

28

13

0

20

35

13

15

36

33 23

CAPACITY CONSTRAINT

0

1

0

2

+

0

21

= [q]: quantity

vehicle capacity= 40

Solution approaches: saving

33 + 23 – 36

46

Total number of solutions: Sk(n!/(n-k)!) k=1, 2, …n

Page 47: Vehicle Routing Problem (VRP): models and algorithms

i j qi qj qi+qj di0 d0j dij sij

1 2 40 10 50 33 23 36 -∞

4 [5]

1 [40]2 [10]

3 [25]

17

28

13

0

20

35

13

15

36

33 23

Check, considering the constraints, if two clients can be inserted in the same route

If the constraint is not satisfied, the saving value is -∞.

0

1

0

2

+

0

21

=

Solution approaches: saving

47

CAPACITY CONSTRAINT

[q]: quantity

vehicle capacity= 40

Page 48: Vehicle Routing Problem (VRP): models and algorithms

i j qi qj qi+qj di

0

d0j dij sij

1 3 40 25 65 33 13 17 -∞

3 1 25 40 65 13 33 17 -∞

2 4 10 5 15 23 15 13 25

4 2 5 10 15 15 23 13 25

1 2 40 10 50 33 23 36 -∞

2 1 10 40 50 23 33 36 -∞

3 2 25 10 35 13 23 20 16

1 4 40 5 45 33 15 35 -∞

2 3 10 25 35 23 13 20 16

4 1 5 40 45 15 33 35 -∞

3 4 25 5 30 13 25 28 0

4 3 5 25 30 15 23 28 0

4 [5]

1 [40]2 [10]

3 [25]

17

28

13

0

20

35

13

15

36

33 23

Solution approaches: saving

48

[q]: quantity

vehicle capacity= 40

Page 49: Vehicle Routing Problem (VRP): models and algorithms

4 [5]

1 [40]2 [10]

3 [25]

17

28

13

0

20

35

13

15

36

33 23

i j qi qj qi+qj di0 d0j dij sij

2 4 10 5 15 23 15 13 25

4 2 5 10 15 15 23 13 25

3 2 25 10 35 13 23 20 16

2 3 10 25 35 23 13 20 16

3 4 25 5 30 13 25 28 0

4 3 5 25 30 15 23 28 0

1 2 40 10 50 33 23 36 -∞

1 3 40 25 65 33 13 17 -∞

1 4 40 5 45 33 15 35 -∞

2 1 10 40 50 23 33 36 -∞

3 1 25 40 65 13 33 17 -∞

4 1 5 40 45 15 33 35 -∞

Table ordered by descending values

Solution approaches: saving

49

[q]: quantity

vehicle capacity= 40

Page 50: Vehicle Routing Problem (VRP): models and algorithms

4 [5]

1 [40]2 [10]

3 [25]

0

4 [5]

1 [40]2 [10]

3 [25]

033

23

13

28

13

0-2-4-3-0

Cost: 77 Cost: 66

0-1-0

Total cost: 77 + 66 = 143

Solution approaches: saving

50

Page 51: Vehicle Routing Problem (VRP): models and algorithms

4 [5]

1 [40]2 [10]

3 [25]

0

4 [5]

1 [40]2 [10]

3 [25]

033

1313

0-4-2-3-0

Cost: 61 Cost: 66

0-1-0

20

15

Total cost: 61 + 66 = 127

Solution approaches: saving

51

Page 52: Vehicle Routing Problem (VRP): models and algorithms

Agostino Nuzzolo [email protected]

Antonio Polimeni [email protected]

Logistica Territoriale

Vehicle Routing Problem (VRP):

models and algorithms

52

Page 53: Vehicle Routing Problem (VRP): models and algorithms

http://people.bath.ac.uk/ge277/index.php/vrp-spreadsheet-solver/

Vehicle Routing Problem (VRP): solver

53

Page 54: Vehicle Routing Problem (VRP): models and algorithms

Based on local search algorithm

EXCHANGE operator searches all possible pairs of customers in a given

solution and checks if exchanging them would result in a better objective function

value

1-OPT operator examines the possibility of removing every customer within a

given solution and re-inserting it to a different position within the routes to

improve the objective value

2-OPT operator attempts to take a route that crosses over itself and reorder it so

that it does not, and checks if the resulting solution has a better objective value

VEHICLE-EXCHANGE operator attempts to exchange all the customers in the

routes of two vehicles with different types, and is particularly useful for the case

of heterogeneous fleets

Vehicle Routing Problem (VRP): solver

54

G. Erdogan (2017). An open source Spreadsheet Solver for Vehicle Routing Problems. Computers & Operations Research,

84.

Page 55: Vehicle Routing Problem (VRP): models and algorithms

VRP Solver Console

Vehicle Routing Problem (VRP): solver

Initial configuration:

• Number of depots

• Number of customers

• Method for distance/time

evaluation

• Problem parameters

• Solver parameters

55

Page 56: Vehicle Routing Problem (VRP): models and algorithms

1. Locations

Vehicle Routing Problem (VRP): solver

User location:

• ID and name

• Address (optional, can be used for geocoding)

• Latitude and longitude

• Time windows and service time

• Pickup and delivery amount

• Profit

56

Page 57: Vehicle Routing Problem (VRP): models and algorithms

2. Distances

Vehicle Routing Problem (VRP): solver

Distance and time evaluation:

• Bird flight

• Euclidean

• On map

Route type

• Shortest

• Fastest

• Fastest with real time traffic

57

Page 58: Vehicle Routing Problem (VRP): models and algorithms

3.Vehicles

Vehicle Routing Problem (VRP): solver

Vehicle type and characteristics

58

Page 59: Vehicle Routing Problem (VRP): models and algorithms

4. Solution

Vehicle Routing Problem (VRP): solver

Output

59

Page 60: Vehicle Routing Problem (VRP): models and algorithms

5.Visualization

Vehicle Routing Problem (VRP): solver

0

12

3

4

5

6

78

9

10

V1 (T1)

V2 (T1)

V3 (T1)

V4 (T2)

V5 (T2)

V6 (T3)

60

Page 61: Vehicle Routing Problem (VRP): models and algorithms

5.Visualization

Vehicle Routing Problem (VRP): solver

0

12

3

4

5

6

78

9

10

V1 (T1)

V2 (T1)

V3 (T1)

V4 (T2)

V5 (T2)

V6 (T3)

61

Page 62: Vehicle Routing Problem (VRP): models and algorithms

Agostino Nuzzolo [email protected]

Antonio Polimeni [email protected]

Logistica territoriale

Vehicle Routing Problem (VRP):

models and algorithms

62