VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing...

60
SCHOOL OF SCIENCE AND ENGINEERING VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Capstone Project Final Report Zaineb El Qaissoumi Supervised by Dr. Ilham Kissani Spring 2017

Transcript of VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing...

Page 1: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

SCHOOL OF SCIENCE AND ENGINEERING

VEHICLE ROUTING OPTIMIZATION USING TIME

WINDOW CONSTRAINT

Capstone Project Final Report

Zaineb El Qaissoumi

Supervised by

Dr. Ilham Kissani

Spring 2017

Page 2: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

2

VEHICLE ROUTING OPTIMIZATION USING TIME

WINDOW CONSTRAINT

Capstone Project Final Report

APPROVED BY SUPERVISOR

Page 3: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

3

Contents LIST OF ABBREVIATIONS .................................................................................................................... 4

LIST OF FIGURES .................................................................................................................................... 5

ACKNOWLEDGEMENTS ....................................................................................................................... 6

ABSTRACT ................................................................................................................................................. 7

I. INTRODUCTION ............................................................................................................................... 8

II. Overview of the Problem .............................................................................................................. 10

1. Definition ....................................................................................................................................... 10

2. STEEPLE Analysis ....................................................................................................................... 13

3. Solutions to the VRP ..................................................................................................................... 15

3.1 Heuristics and Metaheuristics Approaches ............................................................................ 15

3.2 Exact Approach ....................................................................................................................... 19

III. Methodology .................................................................................................................................. 23

IV. Solution using Heuristic Algorithm. ............................................................................................ 25

1. Map Generation ............................................................................................................................ 25

2. Clustering the Data ....................................................................................................................... 27

3. TSP with a Time Constraint ........................................................................................................ 28

1.1 Manual Representation of the TSP ......................................................................................... 29

1.2 Solving TSP using Matlab ....................................................................................................... 31

4. Solving VRPTW ............................................................................................................................ 40

5. Using Virmousil’s Data ................................................................................................................. 41

V. Solution using Tabu Search ............................................................................................................. 43

1. Trial using Ifrane’s Data Set ........................................................................................................ 43

2. Solving the Tangier Case .............................................................................................................. 47

VI. Results & Future work ................................................................................................................. 51

REFERENCES .......................................................................................................................................... 54

APPENDICES ........................................................................................................................................... 55

Appendix A: A Matrix .......................................................................................................................... 55

Appendix B: b Matrix ........................................................................................................................... 57

Appendix C: Snippets of Code ............................................................................................................. 58

Page 4: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

4

LIST OF ABBREVIATIONS

OR …………………………………………… Operations Research

VRP …………………………………………… Vehicle Routing Problem

CVRP …………………………………………… Capacitated VRP

DVRP …………………………………………… VRP with a Distance Constraint

VRPTW …………………………………………… VRP with a Time Window Constraint

TSP …………………………………………… Traveling Salesman Problem

TSPTW …………………………………………… TSP with a Time Window Constraint

CF-RS …………………………………………… Cluster First – Route Second

LS …………………………………………… Local Search

TS …………………………………………… Tabu Search

PFIH …………………………………………… Push First Insertion Heuristic

Page 5: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

5

LIST OF FIGURES

Figure 1: Visualization of a Vehicle Routing Problem

Figure 2: Types of solutions to the VRP

Figure 3: 2-Interchange method with move operator (2,1)

Figure 4: Fisher and Jaikumar’s Algorithm

Figure 5: Produced map with chosen stops

Figure 6: Travel time matrix obtained

Figure 7: Clustering map

Figure 8: Visualization of a Traveling Salesman Problem

Figure 9: Minimum Spanning Tree Problem

Figure 10: Dijkstra’s Algorithm with Directed Edges

Figure 11: Initial Aeq matrix

Figure 12: New Aeq matrix after merging it with initial Aeq

Figure 13: Final Aeq matrix

Figure 14: Final beq matrix

Figure 15: Fisher Algorthim’s Time Window Constraints and Bounds

Figure 16: First row from A matrix

Figure 17: Code for lowerbound and upperbound

Figure 18: Generated map for TSPTW

Figure 19: Generated map for VRPTW

Figure 20: Tangier map generated using CF-RS

Figure 21: Distance matrix for Tabu Search

Figure 22: Resulting map using TS

Figure 23: Tangier map using TS

Page 6: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

6

ACKNOWLEDGEMENTS

I would like to express my utmost gratitude to my parents for their never-ending support, for all

their sacrifices, for never sparing any of my needs, and for their continuous belief in me through

all the ups and downs, all the personality crises, and the dilemmas. I would also like to thank the

rest of my family and my friends who always had confidence in me, who are always there to offer

moral support, and who always show me that there is nothing I can’t do if I have the will for it.

Special thanks are directed towards Maximilian Dietrich and Ayoub Makroz for their support

throughout this project.

Furthermore, I offer my deep gratitude to Dr. Ilham Kissani for her continuous help, assistance,

and guidance through every step of this project. Thankfulness is in place for Dr. Boukili

Abderrazak as well for assisting with the progress of this work.

Page 7: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

7

ABSTRACT

The Vehicle Routing Problem handles the optimization of the transportation routes in a way that

ensures the finding of the optimal lowest cost route from one vertex to another. It goes through a

several constraints that vary depending on the type of problem that’s being handled. This report

mentions the different methods and techniques that are used to solve the VRP, with a specific

attention to the vehicle routing problem with a time window constraint or VRPTW. It will be

solved, first, using a heuristic method called Cluster First-Route Second by means of Fisher and

Jaikumar’s algorithm. Then, by the meta-heuristic method of Tabu Search. After testing and

implementation, the case of a company in Tangier called Virmousil will be solved. The software

used to conduct this project is Matlab.

Keywords: vehicle routing problem, time window, VRPTW, traveling salesman problem, TSPTW,

Matlab, Cluster First- Route Second, tabu search.

Page 8: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

8

I. INTRODUCTION

Transportation can be considered an every-day task for everyone in society, but it is a very critical

concept for companies that aim for high productivity. Be it internal transportation of staff, or

transportation of merchandise to clients, efficiency is always a company’s main goal. This is why

the practice of operations research (OR) is widespread internationally. OR refers to applying

scientific and/or mathematical approaches in order to efficiently analyze composite problems, such

as ones that involve very complex systems [9]. A very clear example of this type of problems

would be the vehicle routing problem.

The vehicle routing problem, or VRP for short, is a non-polynomial problem that appeared in 1959

as a truck dispatching problem [5], and that is used in order to detect the most optimal route that

can be used, so as to travel from one point to another using a specific number of vehicles. In this

report, this latter problem is tackled using the time window constraint, in addition to the vehicle

routing problem’s usual constraints and side conditions. From the different types of algorithms

and techniques that are used to solve the VRP, and that will be explained later on throughout this

report, the problem at hand is first solved using integer linear programing following Fisher’s

algorithm, which is an exact approach. For such a complex problem to be solved using that specific

algorithm, it will be simplified into sets of smaller simpler problems; which are later on clustered

to form a VRP. Then, the solution will be obtained using this method will be compared with one

from using a meta-heuristic algorithm called Tabu Search.

Throughout this report, the Vehicle Routing Problem will be further explained, both in a general

way and with a focus on Vehicle Routing Problem with a Time Window constraint, the general

approaches used to solve this problem will be demonstrated, and the procedure that was followed

Page 9: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

9

to unravel the specific problem at hand will be presented in detail. These methods will, then, be

used to solve the case of a company in Tangier called Virmousil that wants to optimize its

employees’ transportation routes. The results obtained from the methods mentioned before will be

compared to identify which one is the most efficient.

Page 10: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

10

II. Overview of the Problem

As mentioned earlier, the vehicle routing problem is a complex one involving many constraints

and side constraints that must be respected. In this part, this problem will be defined, a STEEPLE

analysis will be performed, and the main solutions used to solve the VRP will be presented.

1. Definition

The vehicle routing problem is one that comprises the design of a set of routes that have the lowest

cost possible for each vehicle that is traveling from one stop to another; these stops are also referred

to as vertices, from and back to a starting point called the depot [3]. These routes need to respect

some criteria, which are:

(i) Every single vertex needs to be visited exactly once by exactly one specific vehicle.

(ii) All the generated routes need to start and end at the depot.

(iii) Some- or- all the common side constraints need to be satisfied. These will be discussed in

detail later on.

Page 11: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

11

Figure 1: Visualization of a Vehicle Routing Problem

In figure 1, each color represents a different route that a distinct vehicle takes to a certain number

of vertices. We can notice that each route starts and ends at the depot which - in this case - is the

vertex (0). For example, in one of the routes, the vehicles follow the path 0 → 5 → 6 → 7 → 0.

In order to express this problem in a more mathematical form, it can be described as a graph 𝐺 =

(𝑉, 𝐴), wherein V and A are sets of vertices and arcs, respectively. V includes the n number of

vertices that will be traveled to, such that 𝑉 = {1, 2, … , 𝑛} , and A consists of all arcs (𝑖, 𝑗) where

every arc has vertex (i) as a starting point and vertex (j) as the arrival vertex (𝑖 ≠ 𝑗), For each arc,

a specific function 𝑐𝑖𝑗 needs to be minimized. An example of this function is the traveled distance,

which would make the goal to be minimizing the traveled distance between certain vertices (i) and

(j). The common side limitations that need to be respected are:

Distance restricted vehicle routing problem: otherwise known as DVRP. This is the base case

of the VRP. It states that each route length must not exceed a maximum route length L that

Page 12: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

12

includes the distance between the nodes, and that takes into consideration the travel time

between the two vertices (i) and (j), and the stopping time 𝛿𝑖 that is required at each vertex

visit.

Capacity restricted vehicle routing problem: also known as the CVRP. In this type of problem,

each stop (i) is considered to be a customer with a specific known undividable non-negative

weight 𝑑𝑖, which is assigned to it in advance [16]. The sum of all the weights 𝑑𝑖 should not

exceed the maximum capacity of the vehicle traveling through the route. In the ‘The Vehicle

Routing Problem: An overview of exact and approximate algorithms’ paper by Laporte, a

special case of this type of problem is mentioned, which states that the number of cities,

represented by 𝑞, should be equal to the total capacity D of the vehicles, for 𝑑𝑖 = 1 (𝑓𝑜𝑟 𝑖 >

1) .

Time restricted vehicle routing problem: also referred to as VRPTW. In this type of VRP, the

vertex (i) should be visited within an interval [𝑎𝑖 , 𝑏𝑖], where 𝑎𝑖 represents the earliest arrival

time at vertex (i), and 𝑏𝑖 the latest departure time from the same vertex. There are two types of

time windows. Soft windows allow a slight violation of this constraint with the condition of a

cost to be paid. For example, if a vehicle arrives at vertex (i) after the specified time window

assigned to it, a penalty will be added to the cost that is being minimized. The second type is

hard time windows. This does not allow a later arrival at a stop than the latest arrival time,

and/or requires a waiting time when the arrival time at a certain vertex is before 𝑎𝑖.

In addition to this constraint, this type of problem also states that the service time at each stop

cannot start before a specific set time window [4]; that is, if we have 𝑚 representing the number

of vehicles available, such that 𝑣𝑒ℎ𝑖𝑐𝑙𝑒𝑠 = {1,2, … , 𝑘, … , 𝑚}, if the vehicle k traveling through

Page 13: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

13

the routes arrives before the start of the service time, it must wait at that stop until the start of

the service time.

As was mentioned earlier, the VRPTW will be the focus of this project.

2. STEEPLE Analysis

After fully understanding what the VRP represents, let us perform a STEEPLE Analysis on this

project. A STEEPLE analysis allows the gain of a fuller understanding of the problem by

identifying the societal, technological, environmental, economic, political, legal, and ethical

impacts of this project. These parts will be depicted in details below.

Societal Impact

The VRPTW is an optimization problem. Reducing the time that it takes to get from one stop to

another, or trying to optimize the available time in order to get the lowest possible cost does not

only benefit the company, but also the employees, the customers, and society in general. Therefore,

implementing it in other domains will encourage efficiency, not just in the working world but also

in everyday life

Technological Impact

The main technological or technical impact of the VRP presents itself as the efficient use of the

technology that we have at hand in order to maximize the optimization results. That is, using

everything the company has and implement it towards an optimized solution.

Environmental Impact

Page 14: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

14

Since the distance and time that it takes the vehicles to go from a vertex (i) to another will be

optimized, less fuel/gas will be consumed after the optimization. Thus, reducing air pollution that

resulting from the emissions from burning fossil fuels in the vehicles’ engines. This is an important

indirect benefit of the VRP, since this concerns the entire planet that is already suffering from the

detriments of global warming.

Economic Impact

As was mentioned in the environmental impact section, optimizing the route means lower fuel

consumption, and therefore, less money spent on fuel or gasoline on each of the vehicles, saving

the operator a considerable amount of money in the long run. Another important positive economic

impact is customer satisfaction. The faster the customers get their deliveries, the more satisfied

they are with the company and the more likely they are to become returning customers. This means

that the revenue is going to grow due to the efficiency of the work.

Political & Legal Impact

Since the vehicle routing problem is only used by each company or entity individually to optimize

the transportation of their products and/or services to their customers, it does not interfere with

any laws or political party’s work. Therefore, it has no direct political or legal impact.

Ethical Impact

There is no exact ethical impact of this project, but there is a small indirect one. It is working

towards preserving the privacy of the customers while the route is being optimized, because some

personal information is needed so as to design the solution to a VRP. For example, the capacity

and type of deliverable to each customer could be enclosed to organize the vehicles by type of

deliverables.

Page 15: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

15

3. Solutions to the VRP

There are different types of techniques to find the solutions to the vehicle routing problem with

different types of approaches. All of which were developed thoroughly in the past, and are grouped

into Heuristics, Meta-Heuristics, and exact solutions. These are classified as shown in the graph

below:

Figure 2: Types of solutions to the VRP

3.1 Heuristics and Metaheuristics Approaches

These methods do not guarantee absolute optimization or exact solutions to the vehicle routing

problem, but they are, by far, most widely used as tools to find enhanced solutions. The reason for

their popularity lies in the fact that, in a relatively short period, they find the most optimized route

with a low cost, which is not necessarily the optimal route [6]. Some examples of the heuristic

SOLUTIONS TO THE VRP

Exact Algorithms

Dynamic Programming

Branch-and-Bound

Fisher Algorithm

Branch-and-Cut

Heuristics

SimpleHeuristics

Savings

Sweep

Cluster First, Route Second

Route First, Cluster Second

Improvements Methods

Meta-Heuristics

Local Search

Simulated Annealing

Tabu Search

Population Search

Genetic Search

Adaptive Memory Search

Learning Mechanims

Ant Colony

Neutral Network

Page 16: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

16

method include the nearest neighbor algorithm and the Clarke and Wright algorithm which find

approximate solutions to the problem [12]. The latter algorithm solves the VRP by only taking into

consideration two nodes at a time, finding the lower cost route between them, and then going forth.

A heuristic approach that will be tackled in this report is the Cluster First- Route Second method.

As its name suggests, it relies on clustering or bundling the vertices closest to each other into small

groups that will each be visited by one vehicle through a distinct route. This project combines the

use of CF-RS with the Fisher and Jaikumar Algorithm, which will be explained in detail in the

next section, and a simplified form of the Sweep algorithm [3].

For a better definition of meta-heuristics, Michel Gendreau’s paper ‘An Introduction to Tabu

Search’ can be used as a reference. Gendreau mentions in his paper, that this method refers to

utilizing heuristics in a way that allows the guidance and controlling of these heuristics’ inner

components so as to mold them to the specific problem we have. Examples of the metaheuristics

method include the ant colony system, where constraints are handled as colonies that aim to

maximize the optimization of the objective function [1], and the simulated annealing, a relaxation

method where the best solution is stored until the next best one is found; then this result overwrites

the already existing solution. This latter method was inspired by the biochemical Metropolis

annealing algorithm, where a metal is heated and then cooled slowly to enable its efficient re-

crystallization by allowing the energy to decrease, leading to lower possibility of crystal re-

arrangement, while thermal equilibrium is achieved. It was later applied to optimization processes

by using analogies such as referring to the states that the physical system is in as the solutions, and

to the energy as the cost function [13].

The meta-heuristic approach that will be used later in this report is Tabu Search. This method is

based on the local search algorithm, LS for short, which starts by finding an initial solution, and

Page 17: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

17

then keeps searching to find a better solution which replaces the initially set solution. This

continues as a form of iteration until the search gets terminated due to reaching a local optimum.

Meanwhile, Tabu Search could be seen as an improved local search combined with short term

memories that will be referred to as Tabu Lists [7]. These lists include, for a short period of time,

a number of moves that are not to be made again; called Tabu moves. This is done to avoid

repetition of non-improving moves and to escape the local optimum. This algorithm includes

different parameters, which are:

- Initial solution: this will be the first current saved solution. This could either be an input by the

user or generated using Push Forward Insertion Heuristic (PFIH), or greedy algorithm. PFIH

consists of the insertion of one vertex within the edges in the route, and selecting the one that,

both, meets the time criteria and has the lowest cost, that way only achievable solutions are

accepted [15]. This happens when the closest possible vertex to the depot is chosen along with

its solution, and then the closest vertex to that one is added to the list. This continues until a

solution that respects the constraints set is found, which will be stored as the current best

solution.

- Neighborhood Structure: this is a very important component of TS, as it is the basis of the

search. Each neighborhood is a solution that was acquired by the application of one

transformation to the current best solution. This could be achieved by exchanging one node or

more between routes to achieve diverse neighborhoods.

- Local Search: the LS structure stays the same as described above. A method that can be used

to achieve a local search is the λ-Interchange concept. For example, if 2-Interchange is used,

it means that no more than two nodes can be exchanged from one route to the other, all the

while respecting the time window assigned. Nodes keep being interchanged between feasible

Page 18: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

18

routes until the best one is achieved or a local optimum is reached, then this new solution gets

stored as the best solution. The moves completed by this method are denoted as the move

operator (u,v), where u refers to the node moved or exchanged from the first route, and v

denotes that from the second route. It is to be noted that, if two vertices are moved together

from one route to the other, they will both be inserted in the same position respecting their

position from the first route. The figure below illustrates a case where two nodes are moved

from the first route and only one is moved from the second one; making it a (2,1) move

operator.

Figure 3: 2-Interchange method with move operator (2,1)[8]

- Tabu or Tabu Moves: these are one of the elements that further distinguishes between LS and

TS [7]. They represent the moves or solutions that cannot be visited by the local search and

that are stored in a Tabu List. The only way for these moves to be used or visited again would

be if they meet the aspiration criterion (see below).

- Tabu Lists: these stand for the short term memory of the search in which Tabus are stored.

Once a move or solution is stored in the Tabu List, it becomes forbidden or taboo. This is done

to avoid revisiting already visited vertices or solutions, so as to enable the algorithm to find

different solutions with different costs at each iteration, and then choosing the one with the

Page 19: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

19

lower cost as the new best cost. Once the iterations start to produce the same solution, the local

search ends.

- Aspiration Criterion: this criterion is responsible for making Tabu Search so effective. In the

case where a Tabu Move offers a better solution with a lower cost than the actual solution or

than the non-Tabu Moves, the Tabu status on that specific move is eliminated.

- Stopping Criterion: to stop the local search, a stopping criterion needs to be set. This could be

a limited number of algorithm repetition or iteration, a pre-set specific cost that needs to be

met, or when the algorithm cannot generate any better solution. For example, if a certain

number of iteration only produces the same optimized cost, the Tabu Search is terminated [7].

The Tabu Search algorithm can then be phrased as follows:

a. Choose the initial solution, and set it as the current best solution. Set up the Tabu List.

b. Find the set of neighborhood solutions that do not belong to the Tabu List.

c. Extract the best solution from step b, according to the time window and capacity constraints.

d. If the best solution from neighborhood is better than the current best solution, store new

solution as best current solution. Otherwise, add to the Tabu List and delete from set of

solution.

e. If the stopping criterion is met, the search is to be terminated. Otherwise, the algorithm goes

back to step b.

This algorithm will be developed using Matlab later in this report.

3.2 Exact Approach

Page 20: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

20

In the first part of the report, the exact approach will play an essential role. It aims to calculate and

determine all the possible solutions until the best one is established. This approach can be mainly

divided into three big categories according to Laporte.

- Direct Tree Search methods: such as the Branch-and-Bound, in which the strategy is to divide

the solution set into different subsets, and then use optimization to solve each of them. This is

done by observing the entire solution set, and then relaxing the problem in order to determine

the solutions that are not viable [2].

- Dynamic Programming: in which the number of the most optimized routes in terms of cost is

to be minimized, by assigning the constraint of only accepting the vertices that appear on the

specified route. This is done this by assigning a binary coefficient 𝑎𝑖𝑗 such that:

𝑎𝑖𝑗 = 1 𝑖𝑓𝑓 𝑣𝑒𝑟𝑡𝑒𝑥 𝑖 𝑎𝑝𝑝𝑒𝑎𝑟𝑠 𝑜𝑛 𝑡ℎ𝑒 𝑟𝑜𝑢𝑡𝑒 𝑗 (𝑖 > 1)

And multiplying it by another binary coefficient 𝑥𝑗, such that:

𝑥𝑗 = 1 𝑖𝑓𝑓 𝑟𝑜𝑢𝑡𝑒 𝑗 𝑖𝑠 𝑢𝑠𝑒𝑑 𝑖𝑛 𝑡ℎ𝑒 𝑜𝑝𝑡𝑖𝑚𝑎𝑙 𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛

- Linear Integer Programming: this category enforces that the problem has, on top of the other

existing VRP constraints, the one that states that either one or more variable have to be binary;

meaning that it either has a value of one if it applies or zero otherwise [11]. The main method

from this technique that will be mainly focused on is the three-index vehicle flow formulation

by Fisher and Jaikumar. Assuming no stopping time, we can represent the VRP using this

algorithm knowing that:

- 𝑥𝑖𝑗𝑘 is the binary variable specifying whether the vehicle k traverses the arc (i,j) or not.

- 𝑦𝑘 is the binary variable specifying whether the vertex (i) is served by vehicle k.

- Dk is the maximum capacity of the vehicle k used.

Page 21: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

21

- [𝑎𝑖, 𝑏𝑖]where 𝑎 𝑖represents the earliest arrival time at the vertex (i), and 𝑏𝑖 the latest departure

from (i).

- ti is the arrival time.

Figure 4: Fisher and Jaikumar’s Algorithm

The figure above lists the constraints that the Fisher and Jaikumar algorithm require. The first

constraint (1) represents the objective function. The goal of this algorithm is to minimize the cost

of the route from vertex (i) to vertex (j) traveled by vehicle k. The second constraint states that for

all the vehicles that are available at the depot, the sum of the non-negative weights di assigned to

each vehicle k, should not exceed the maximum capacity D of vehicle k. Constraint (3) conditions

that the number of vehicles serving vertices i=2,…, n, n being the number of stops, should be equal

Page 22: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

22

to one meaning that each stop is served only once. The variable yik=m only at the depot or at i=1,

this means that the only stop that could be served by more than one vehicle is the depot since it is

the starting and finish vertex for all the routes. The fourth and fifth constraints state that for all

available vehicles k, the arc (i,j) is traversed by m if the vertex (j) is served by the same vehicle k

for all arrival and departure vertices. The sixth constraint aims to delete any sub tours from the

optimal solution. The seventh constraint states that the arrival time at vertex (j) should be equal to

the sum of the departure time from (i) and the travel time from (i) to (j), if these arcs appear on the

optimal solution. Constraint (8) situates the arrival time at a certain vertex (i) to be within a specific

time window, which is between an earliest arrival time ai and a latest departure time bi. And the

final two constraints state that xij and yik are the binary variables.

Page 23: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

23

III. Methodology

After defining the problem and its known solutions, the methodology that was followed to solve

the problem at hand is to be presented. As mentioned before, the solution is supposed to be found

using two methods: the heuristic approach, and the meta-heuristic approach. A set of data about

the city of Ifrane will be used, and the stops will be as follows: the AUI bus shelter, the downtown

center, the market place, the American School of Ifrane, Best Western, and the bus station.

The heuristic approach used is Cluster First- Route Second. The first step that will be taken is the

clustering, which stands for simplify the VRP into smaller problems where only one vehicle will

be traversing each route. This means that the problem will change from one large VRP into smaller

sets of traveling salesman problems, or TSPs for short. This will be done using the k-search

approach where the vertices are bundled depending on the distance to each other and to the depot.

Each TSP will be solved using integer linear programming following the Fisher and Jaikumar

algorithm, which is presented in figure 4. The software package Matlab will be used to develop

the algorithm, specifically a function called intlinprog. After developing the exact solution code

for the TSP, the time constraints will be applied in order to establish a traveling salesman problem

with a time window constraint. This will, then, be used in a cluster system that originates from the

depot, which will change the smaller TSPs back into one large VRP. The VRP will therefore

consist of small TSPs that are solved using intlinprog. Despite the fact that the Fisher and Jaikumar

algorithm, an exact one, is the one used, this solution will be a heuristic one due to the introduction

of clusters, which might lead to the loss of the actual exact solution to the problem.

The next step is applying the meta-heuristic algorithm to compare the results acquired from both

this and the heuristics algorithm. The Tabu Search was chosen for this project and the algorithm

Page 24: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

24

that was listed earlier will be followed to generate the optimal route with the lowest cost possible.

Simulated Annealing will be used to define the Aspiration Criterion following its temperature

reasoning. Again, this will be done using the Matlab software.

The final step will be comparing the results acquired from both algorithms to determine the

efficiency of each approach on a small data scale. A different set of larger data will then be used

to confirm the correct behavior of the code or find necessary modifications. The small and large

data sets are from Ifrane and Tangier respectively.

Page 25: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

25

IV. Solution using Heuristic Algorithm.

1. Map Generation

For the heuristics CF-RS approach, the first step is, of course, the clustering of the vertices that

form the problem. The exact algorithm will, then, be applied to the entire problem set as a TSP

before being clustered into a VRP. Before the generation of any solutions, the map of Ifrane has

to be generated through Matlab to identify the stops.

That is why the first lines of code, attached in the appendix, serve to display the map of Ifrane that

will be used as a basis to show the locations of the stops, and the route the algorithm will choose

for the set of data at hand. In order to set the points that the algorithm will be basing its calculations

on, the map was first opened in Matlab, and the specific location of each stop was selected so as

to determine its latitude and longitude. This information was compiled into an Excel file that is

called in Malab to circle the stops on the map. For the Ifrane case, the coordinates are shown in

Table 1 and the resulting visual representation is shown in the figure below.

Table 1: Coordinates of Ifrane data set

Stops Stop Index Longitude Latitude

AUI Bus Shelter 1 1486 292

Downtown Center 2 1409 680

Market Place 3 1103 813

ASI 4 454 1266

Best Western 5 435 784

Bus Station 6 805 953

Page 26: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

26

Figure 5: Produced map with chosen stops

The identification of the coordinates allows the generation of the travel time matrix using the

Pythagorean algorithm to estimate the distance between each stop. Each of the obtained value is

then divided by a number acquired from assuming that the time it will take the vehicle to travel in

Ifrane is 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 𝑓𝑟𝑜𝑚 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒𝑑 𝑚𝑎𝑡𝑟𝑖𝑥

50, 50 being a weight used to discount the distance matrix and

generate the travel time. The floors of the values we got from the divisions were used to generate

the following travel time matrix:

Figure 6: Travel time matrix obtained

Page 27: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

27

2. Clustering the Data

As previously stated, the VRP will be solved by clustering the TSP. The k-means clustering will

be used. This system was originally suggested by Lloyd, and refers to an algorithm that assigns a

specific number n vertices to a k number of cluster. This is done by, first, assigning the same

number of centroids as the number of clusters we wish to acquire, in our case the number of clusters

k is equal to the number of vehicles m. A distance is, then, generated from each of the stops to the

centroids, and thus the stops that are closest to the centroids are assigned to different clusters. The

same steps are repeated until the clusters do not change [10]. This part of the project was made

simpler by the existence of a cluster function in Matlab that allows the input of the coordinates set

of the stops, gathers them into one big matrix that is called X, and that displays the different clusters

along with the clusters’ centroids.

What was done in this case was to choosed the depot first to exclude it from the set of data, and

cluster the remaining stops. This is done to identify the depot, and cluster surrounding it.

Consequently, using n=6, the point with the coordinates Longitude= 805 and Latitude=953 will

be set as our depot, let it be and include the other five stops in the k-means clustering function.

The depot is shown in the figure below as a red circle, and the other stops are shown as blue dots.

The clustering sets are shown as the green and blue circles. The map that will be created is as

follows.

Page 28: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

28

Figure 7: Clustering map

The remaining step consists of turning this TSP into a VRP. This is done by storing the coordinates

for each of the clusters, and runing the TSP code, described in the following section, for each of

them. Meaning that the TSP code will run for the first time with the coordinates of the first cluster

and the depot. And then will run once more with the coordinates of the second cluster along with

the depot.

3. TSP with a Time Constraint

The traveling salesman problem includes only one vehicle that travels through the set of vertices

representing the stops or the clients. The main purpose of the TSP is to visit each vertex exactly

once while using the route with the lowest cost (distance and/or travel time). In a similar manner

Page 29: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

29

to the VRP, the TSP includes many different types such as the capacitated traveling salesman

problem, the distance restricted TSP, and the traveling salesman problem with a time constraint,

which will be the main focus, and that will be referred to as TSPTW. This problem will be solved

using the Fisher and Jaikumar algorithm featured in figure 4. Using the vertices given in figure

(1), the Traveling Salesman Problem can be represented in a way so that instead of having different

vehicles travel through different sets of vertices, only one vehicle will go through all of them,

starting and ending at the depot.

Figure 8: Visualization of a Traveling Salesman Problem

1.1 Manual Representation of the TSP

The first concept that we can directly relate to the TSP is the Hamiltonian cycle, since both allow

only one visit to each vertex. However, the Hamiltonian cycle concept does not permit the return

to the starting point, and thus, we cannot use it to represent the TSP that does not allow nodes to

be visited again. The second concept that comes to mind is the Minimum Spanning Tree Problem,

where a first node is selected and marked as solved, the edge relating the solved nodes to the

Page 30: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

30

unsolved nodes are selected and the shortest one is chosen, leading to marking the unsolved node

attached to that edge as solved, and so on and so forth.

Figure 9: Minimum Spanning Tree Problem

Again, this cannot be related to the TSP due to the fact that the Spanning Tree does not necessitate

coming back to the starting point but rather just aims at going through all the nodes.

Another concept that could be thought of to represent this type of problem is the Dijkstra

Algorithm. Its aim is to find the shortest path between nodes starting at a specific point, which in

this case is the depot. A simple example with directed edges helps to get a clearer vision of this.

Figure 10: Dijkstra’s Algorithm with Directed Edges

Page 31: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

31

In the case depicted in Figure 10, the node (0) is considered to be the depot, so the route could

either visit node (1) directly for a cost of ten or to node (3) for a cost of five. Since we are the goal

is to find the route with the lowest cost, the choice to go through node (3) first seems obvious.

Then, from this latter node, the choice should be made to either go to the fourth node, the second

one, or the first one. This goes on until the following path is found:

𝑛𝑜𝑑𝑒 (0) → 𝑛𝑜𝑑𝑒 (3) → 𝑛𝑜𝑑𝑒 (1) → 𝑛𝑜𝑑𝑒 (2) → 𝑛𝑜𝑑𝑒 (4) → 𝑛𝑜𝑑𝑒 (0)

This path has a total cost of 21. Assuming that the costs represent the number of hours from node

to node, it will take 21 hours to go through all the nodes. This illustration is far from being an exact

visualization of the TSP but is rather a simplification to show the logic behind trying to find the

shortest path.

1.2 Solving TSP using Matlab

Before coding the time window constraints for the TSP, a full understanding of the equality and

the inequality constraint when it comes to the TSP with a time constraint is necessary. The

difference between the equality constraints and the inequality constraints, is that the matrices that

characterize them, Aeq and beq for equality, and A and b for inequality, are presented in this fashion:

𝐴𝑒𝑞 ∗ 𝑥𝑖𝑗 = 𝑏𝑒𝑞

𝐴 ∗ 𝑥𝑖𝑗 ≤ 𝑏

The equality constraints are almost identical for all types of TSP, so they will be discussed first.

There are two kinds of equality constraints.

(i) For n number of vertices or stops, there must be n trips in total.

Page 32: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

32

(ii) There could only be two trips attached to each vertex, one arriving to it and one departing

from it.

Going back to the Ifrane model, the permutation of pairs of trips to the six stops is generated 𝑃26 =

30, and the first equality constraint (i) is presented, first, as an equation, i.e.

𝑥12 + 𝑥13 + 𝑥14 + 𝑥15 + 𝑥16 + 𝑥21 + 𝑥23 + 𝑥24 + 𝑥25 + 𝑥26

+ 𝑥31 + 𝑥32 + 𝑥34 + 𝑥35 + 𝑥36 + 𝑥41 + 𝑥42 + 𝑥43 + 𝑥45 + 𝑥46

+ 𝑥51 + 𝑥52 + 𝑥53 + 𝑥54 + 𝑥56 + 𝑥61 + 𝑥62 + 𝑥63 + 𝑥64 + 𝑥65 = 6

.

Knowing that xij is binary, and that it only equals one when the trip (i,j) is a part of the solution,

(i) is enforced by making the sum of all the possible trips equal to 6, which is the number of stops.

To represent this in code, the initial sparse matrix Aeq is generated and filled with ones in order to

account for the number of trips xij. This matrix has the sparsity of the permutation mentioned

before. That is, since n=6, the matrix will be [1x30], and each column represent a possible trip,

resulting in a matrix like shown in Figure 11

Figure 11: Initial Aeq matrix

At the same time, the first row of the beq matrix will be set to the number of trips, to enforce that

the sum of all the trips be equal to the number of vertices.

Page 33: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

33

Now, the additional equality constraint (ii) needs to be added to the Aeq matrix. This is done by

either allocating more sparse space in the original Aeq matrix, which must have n number of rows,

while the number of columns remains equal to the number of permutations of n, or creating a new

matrix that will be merged with the initial one. This new matrix stores one for the trips leaving a

specific vertex (i) towards all the possible vertices (j). Using the vertex (1) as an example, it is

known that it is possible to travel towards all the other vertices departing from that vertex, but as

seen in constraint (ii) there could only be one trip departing from each node, so to indicate that,

the following equation is transcribed, 𝑥12 + 𝑥13 + 𝑥14 + 𝑥15 + 𝑥16 = 1

This is presented in the Aeq matrix by assigning one to each column representing said trips, and

assigning one in the adjacent beq row. This is done for each vertex (i) headed towards all other

vertices (j). This new matrix is then merged with the initial Aeq matrix that features in figure 12.

In addition to only having one trip departing from each vertex, constraint (ii) also states that there

could only be one trip arriving at each stop. This is included by assigning all the trips that include

each vertex to be equal to two. Still using vertex (1) as a reference, all the trips that include (1)

will be set equal to two to enforce that the constraint cannot be broken. The following equation is

acquired

𝑥12 + 𝑥13 + 𝑥14 + 𝑥15 + 𝑥16 + 𝑥21 + 𝑥31 + 𝑥41 + 𝑥51 + 𝑥61 = 2

Again, this is assigned to the Aeq and beq matrices, resulting in the Aeq matrix shown in figure 12.

Page 34: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

34

Figure 12: New Aeq matrix after merging it with initial Aeq

So far, the equality constraints are equal for all types of TSP, but since the TSPTW is the one

tackled in this project, there is another unknown in addition to the binary variable, i.e. the time of

arrival at each stop. Because no equality constraints apply to the that unknown variable t, their

value will be set in the Aeq matrix to be all zeros except for the value of the first vertex, since that

is known. Thus, the final Aeq matrix should look similar to the one shown in figure 13 with the

final beq matrix similar to that in figure 14.

Page 35: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

35

Figure 13: Final Aeq matrix

Figure 14: Final beq matrix

After applying the equality constraints, the inequality constraints that are represented as 𝐴 ∗ 𝑥 ≤

𝑏 can now be implemented. Since a time constraint is of interest here, the seventh and eighth

constraints from figure (2) are relevant and are shown again in figure 15.

Page 36: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

36

Figure 15: Fisher Algorthim’s Time Window Constraints and Bounds

T is a very large number, ti the arrival time at stop (i), tij represents the traveling time between the

two nodes (i) and (j), and ai and bi the earliest arrival time and latest departure time from vertex

(i), respectively.

To formulate the constraint (7) as 𝐴 ∗ 𝑥 ≤ 𝑏, it needs to be rearranged in a way that all the variables

are on one side, and the constants on the other. . The resulting equations are:

{𝑡𝑖 − 𝑡𝑗 + 𝑥𝑖𝑗𝑘𝑇 ≤ −𝑡𝑖𝑗 + 𝑇

𝑡𝑗 − 𝑡𝑖 + 𝑥𝑖𝑗𝑘𝑇 ≤ 𝑡𝑖𝑗 + 𝑇

Referring to the example of vertex (1) still, and only taking into consideration the trip (1,2), these

equation should become (𝑘 = 1 since this is a TSP and only one vehicle is used):

{𝑡1 − 𝑡2 + 𝑥12𝑇 ≤ −𝑡12 + 𝑇𝑡2 − 𝑡1 + 𝑥12𝑇 ≤ 𝑡12 + 𝑇

To represent this in the inequality matrix A, the same formatting that was used for the Aeq matrix

needs to be respected, that is the first 30 columns represent the trips xij and the last 7 columns

characterize ti (i=1,2,…, n+1). Seven arrival times are used to signify arrival times at different

vertices during the vehicle’s trip through the stops, including the arrival time back at the depot tn+1.

Thus, T will be assigned to each of the respective x12 in the first and second rows of the matrix

accordingly, and in the first row, one will be assigned to the time of arrival at (1) and -1 to the time

of arrival at (2), and vice versa for the following row for each respective node. This could be

visualized by referring to the figure below.

Page 37: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

37

Figure 16: First row from A matrix

The number of overall rows in the A has to be equal to the number of permutation multiplied by

two, plus the allowed trips between nodes. Therefore, the sum of the trips from vertex (1) to vertex

(2) must be one to avoid any sub tours. So, using the Ifrane example, the number of rows should

be 30*2+15=75 row. The resulting A matrix can be found in the Appendix.

In order to program the second matrix b, the aforementioned travel time matrix will be used to

represent tij which will either be added to or subtracted from the large number T in accordance with

the values assigned in the rows in the A matrix. That is, utilizing the trip (1,2), the value of the

time it takes to travel from (1) to (2) t12 recorded in the travel time matrix is called t12=-7,

subtracted from T and recorded in the first row of b, then added to T and recorded in the second

Page 38: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

38

row of b. Thus, the first row of b, will be -7+T= 99,993. The full resulting b matrix will also figure

in the Appendix.

Moving on toconstraint (8) from Fisher and Jaikumar’s algorithm, ai and bi will be used to represent

the upper and lower bounds of the problem at hand. So, for the binary variable xij, which can only

be equal to one or zero, the upper bound will be one and lower bound will be zero. These conditions

were implemented in Matlab using the functions ones(M,N) and zeros(M,N) which insert ones and

zeros respectively, for M number of rows and N number of columns. As for the arrival times ti, the

upper bound will represent the latest departure time bi from that vertex i, and the lower bound will

represent the earliest arrival time ai. The input that was chosen for the Ifrane case is shows in figure

17.

Figure 17: Code for lowerbound and upperbound

The final step before finding the solution is to set the cost and the upper and lower bound so as to

include the 8th constraint from the Fisher algorithm. The cost will simply be a matrix that includes

the distance matrix that was generated using the Pythagorean algorithm, and n+1 rows that are

filled with zeros. This latter signifies that the cost of the arrival times is yet to be determined. As

for the upper and lower bounds, they will be represented by matrices with a number of rows that

is equal to the number of permutation, the upper bound for this must be one and the lower bound

must be zero due to the fact that xij is a binary variable, and shouldn’t be anything but ones or zeros.

In addition to those rows, we should also include arrival times. The lower and upper bounds for

those should be an input from the user, and must refer to the earliest arrival time at the node and

the latest departure time, respectively.

Page 39: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

39

For the optimization part, the function used; intlinprog, is already built in Matlab. It requires the

following input: the cost, the number of variables which are the trips and the arrival times, the

equality matrices (Aeq and beq), the inequality matrices (A and b), the lower and upper bounds, and

the variable ‘opts’ that could be generated using the optimoptions function, which creates the

display parameters using the intlinprog function’s output. The return is the xij referring to the

feasible optimal trips, the optimized cost, the exit flag that displays whether or not an optimal

solution was found, and output. This latter includes a character message with details of what

happened within the function. The message that should be displayed if the function worked would

announce that the optimal solution was found and include why the intlinprog function stopped.

Ultimately the optimal route is displayed on the map that was generated in the beginning of this

process. The resulting map is shown in figure 18.

Figure 18: Generated map for TSPTW

Page 40: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

40

The cost of the optimal solution is 3.1716e+03, and it took 0.794910 seconds for the code to run.

Now that the TSPTW is solved, the clustering can be effectuated to return to the VRPTW.

4. Solving VRPTW

Time has come for the results gotten from the clustering function to be applied to the Ifrane data

set. The clustering coordinates are as follows:

Table 2: First clustering’s coordinates

Stops Stop Index Longitude Latitude

Bus Station 1 805 953

AUI Bus Shelter 2 1486 292

Downtown Center 3 1409 680

Market Place 4 1103 813

Table 3: Second clustering’s coordinates

Stops Stop Index Longitude Latitude

Bus Station 1 805 953

ASI 2 454 1266

Best Western 3 435 784

These coordinates are then used for two distinct TSPs that meet at the same depot. The optimized

cost of the first clustering’s TSP is 2.0075e+03 and that of the second one is 1.3594e+03. The

optimal cost of this VRP problem therefore amounts to 3.3669e+03. The total time it took for the

code to compile the routes and generate the cost is 0.928476 seconds.

The map generated is displayed in figure 19, where the blue circles represent the stops from the

first cluster, and the red ones represent those from the second cluster.

Page 41: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

41

Figure 19: Generated map for VRPTW

The cost has noticeably increase. This is because the first solution using Fisher’s algorithm gives

the optimal exact solution, while using clustering overlooks multiple ideal solutions since instead

of using the entire set of data, it is limited to just the cluster of the data given. This is why the

Cluster First, Route Second method is classified as heuristic despite making use of an exact

algorithm to solve the TSPs (see Figure 2).

5. Using Virmousil’s Data

Now, the code can be applied to solve the company’s employees’ transportation case. In order to

simplify the problem, the Tangier region was divided into four parts. This report will be tackling

the case of the west region for the 6AM shift, where the stops are Boukhalef, Al Irfan, Ziaten and

Mesnana, and the depot is Virmousil. The company’s main time constraint is for the vehicles to

Page 42: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

42

leave Virmousil at 5AM and arrive back at the depot at or before 5:45AM. This enabled us to

obtain the following map.

Figure 20: Tangier map generated using CF-RS

The first cluster includes Boukhalef, Al Irfan and the depot as shown with the blue circle, and the

second one contains Mesnana, Ziaten and the depot as illustrated with the red circles. The total

cost of this trip is 2.7007e+03, while the elapsed running time is 0.650950s. This result however

does not take into consideration the capacity or the number of employees that need to be picked

up at each stop.

Page 43: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

43

V. Solution using Tabu Search

1. Trial using Ifrane’s Data Set

For the Tabu Search, a lot of new information about the vehicles and stops is included to ensure

the feasibility of the solution in a real-life situation. The load capacity for each stop is taken into

consideration. For the Ifrane example, the traveling vehicles have a specific capacity that cannot

be exceeded and each of the stops has its own load that needs to fit into the vehicle when it is

visited. The load then accumulates along the route. Another piece of necessary information is the

unloading time at each stop. The vehicle is only allowed to be idle at each vertex for a specific

period.

Following the algorithm listed in chapter II.3, the first step is to find the initial solution. Before

doing so, a matrix containing information about all the stops needs to be assembled. This matrix

includes the longitude and latitude of each stop, the capacity, and the earliest arrival time and latest

departure time for each vertex along with the unloading or serving time. A distance matrix is

produced based on the first information matrix relying on the Eucledian Distance d(m,n) for the 2-

dimensional space. Following this, the distance between two points m and n can be calculated

using the following equation:

𝑑(𝑚, 𝑛) = √(𝑚𝑥 − 𝑛𝑥)2 − (𝑚𝑦 − 𝑛𝑦)²

The generated distance matrix for application in Ifrane is shown in figure 20.

Page 44: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

44

Figure 21: Distance matrix for Tabu Search

The initial solution can now be produced using Push First Insertion Heuristic. The first step is to

pinpoint the first visited node, which will be done by generating the cost matrix that contains the

cost between each stop and the depot. The cost matrix is of dimension [2 x n], where the first row

contains the cost between the stops and the second one includes the stop indices. The cost is

calculated using the following equation

𝐶𝑖 = − 𝛼 ∗ 𝑑𝑑𝑒𝑝𝑜𝑡,𝑖 + 𝛽 ∗ 𝑏𝑖 + 𝛾 ∗ (𝜋

360) ∗ 𝑎

Where 𝑎 = 𝑡𝑎𝑛−1 (𝑖𝑥

𝑖𝑦) , 𝑑𝑑𝑒𝑝𝑜𝑡,𝑖 represents the distance from the depot to the vertex (i) and is

extracted from the first row of the distance matrix, and 𝑏𝑖 denotes the latest departure time from

node (i). The weights α, β, and γ were calculated by Soloman [14] and their equivalences are α=

0.7, β= 0.1, and γ= 0.2. This cost matrix is then sorted from smallest distance to largest, and the

indices corresponding to this sort are stored in their own matrix. The overall route capacity is set

to be the vehicles’ total capacity, and the local search starts looking for the initially visited node,

bearing the following conditions:

- The distance from the depot to the vertex (i) will take less time than its latest arrival time.

- The node’s capacity is lower than the overall vehicle capacity.

Page 45: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

45

If this applies, node (i) is stored as the initial vertex, its cost is kept as the route’s initial cost, and

it is deleted from the matrix containing the indices. This is done to avoid visiting this particular

node more than once. The vertex’s capacity is now subtracted from the overall route capacity that

is used as a parameter to avoid exceeding the vehicle’s capacity.

The local search will be applied to all the remaining nodes taking into consideration that the node’s

capacity should not exceed the overall route capacity, and whether the addition of this vertex to

the route in that specific position will forbid the feasibility of the succeeding nodes. This is done

to make sure that the time window is being respected.

Earlier, with the heuristic method, both the upper and lower bounds were used as input in the

intlinprog function to respect the assigned time window. In this method, only the latest departure

time from a vertex (i) will be taken into consideration. This will be done by continuously checking

if the addition of a node in a route will lead to the breaching of the next vertex’s time window. If

so, it will not be added to the route in that specific position. The matrix containing the indices will

be flipped or switched to choose a new vertex, and the local search will continue until a complete

route is formed.

It is to be noted that if the selected node allows the feasibility of the time window, it will be added

to the route, the new cost of the route will be the initial cost plus the cost of this vertex, and the

route capacity will be minimized by the vertex’s capacity.

The route acquired from the local search is stored as the best route while its cost is stored as the

best possible cost.

The 2-Interchange process takes place then to get new routes that will be compared to each other

and that will determine the neighborhood structure. Each neighborhood will be structured after the

consideration of 𝑘∗(𝑘−1)

2 routes; k being the vehicle used. This process takes into consideration two

Page 46: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

46

routes from which pairs are compared during each iteration. The best cost generated by each pair

of nodes will be recorded, and the pair with the lowest cost is selected to be exchanged or to make

up the neighborhood. To make this process even more efficient, the costs between pairs are

recorded in a matrix, that way whenever they are being evaluated or assessed during different

iteration, the neighborhood structure remains stable and intact.

To avoid finding the same route over and over again, the Tabu List is created and its size is set to

be ten since the Ifrane model is so small. And the aspiration criterion is inspired by the Simulated

Annealing’s concept of heating up the material to ensure efficient energy spread, making the

probability of a move meeting the aspiration criterion and being allowed to leave the Tabu List to

follow the equation 𝑃(𝐴𝐶) = exp(𝐶𝑖−𝐶𝑗

𝑇) knowing that Ci is the cost of the Tabu Move and Cj is

the cost of the actual solution, and T is the temperature. In the analogy, the probability of a vertex

meeting the aspiration criterion will be correlated to the temperature (the higher the temperature,

the bigger the probability). This temperature is “lowered” throughout the running of this algorithm

to limit the escape Tabu List. This procedure is repeated to ensure the production of the best

possible route with the lowest cost.

As for the stopping criterion, the number of maximum iterations was set to 50 for this data set.

This maximum ensures the generation of the best solution for a small size data.

The route resulting from this method is displayed in figure 22.

Page 47: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

47

Figure 22: Resulting map using TS

The cost of this route is 4.4221e+03 and the elapsed calculation time is 1.034689 seconds.

2. Solving the Tangier Case

Now that the code was tested, the Tangier case can be solved using Tabu Search. Since this

algorithm takes into consideration the capacity of both the vehicles and the stops, the number of

employees that need to be picked up at each stop is listed in Table 4.

Table 4: Tangier stops with capacity

Stop Total Capacity

Virmousil 0

Boukhalef 28

Ziaten 2

Page 48: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

48

Al irfan 43

Mesnana 23

Taking into consideration the fact that the vehicles that the company uses have a total capacity of

nineteen, these stops were divided to enable the automobiles to travel through them. The resulting

distributed capacities will be as shown in table 5, while the travel time between all the stops which

was calculated using Google Maps is presented in table 6.

Table 5: Stops with distributed capacity

Stops Distributed Capacity

Virmousil 0

Boukhalef 13

Boukhalef 15

Ziaten 2

Al irfan 6

Al irfan 18

Al irfan 19

Mesnana 7

Mesnana 16

Table 6: Travel time

Travel Time (min) From/To Virmousil Boukhalef Ziaten Al Irfan Mesnana Virmousil 0 11 13 12 16 Boukhalef 11 0 6 4 10

Ziaten 13 6 0 5 7 Al irfan 12 4 5 0 8

Mesnana 16 10 7 8 0

By inputting this information and taking into consideration a service time of four minutes in each

stop, the map displayed in figure 23 is generated.

Page 49: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

49

Figure 23: Tangier map using TS

Since this map is a bit unclear, the actual routes generated are listed in Table 7. And the total

traveling time was calculated for each of the routes to ensure the respect of the time window that

the company provided, all the while respecting the total capacity of the vehicle.

It should be noted that due to the limited capacity of the vehicles, each row represents a routes

traveled by a vehicle and the total time it took.

Table 7: Routes generated using TS

Trips Employees picked up Travel Time Total Service

Time Total Route Time

Time Window

Respected? Capacity

Respected? Virmousil→Boukhalef→Virmousil 15 11+11=22min 4 min 26 min YES YES Virmousil→ Irfane→ Boukhalef→

Virmousil 6+13= 19 12+4+11= 27min 8 min 35 min YES YES

Virmousil→ Mesnana→Ziaten→Virmousil

7+2=9 16+7+13=36 8 min 44 min YES YES 16+2=18 16+7+13=36 8 min 44 min YES YES

Virmousil→ Irfane→ Virmousil 18 12+12=24 4 min 28 min YES YES 19 12+12=24 4 min 28 min YES YES

Page 50: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

50

The travel time column includes the sum of travel time from each stop to the other in the route.

For example, in the Virmousil→ Irfane→ Boukhalef→ Virmousil route, the travel time is the time

it takes to go from Virmousil to Irfane (12 minutes), plus the duration of the drive from Irfane to

Boukhalef (4 minutes), in addition to the travel time from Boukhalef back to Virmousil (11

minutes). Since the service time in each stop is four minutes and the route goes through two nodes

in this route, then the total service time in this trip is eight minutes. Adding up the travel time and

the total service time gives us the total route time, which must be less than or equal to 45 minutes.

As is shown in the table, all the routes respect the time and capacity windows.

This code generates a cost of 3.0630e+03 and takes 1.910532s to run.

Page 51: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

51

VI. Results & Future work

As can be noticed from the previous two chapters, the heuristics and meta-heuristic methods both

result in the generation of the same route that needs to be followed for the Ifrane data set. This is

due to the fact that this set does not include a specific capacity to be respected. As for the Tangier

data set, Tabu Search offers a more in-depth solution that takes into consideration the time window

set by the company and the capacity of the vehicles. This is the reason behind the higher costs that

the TS code generates and the slightly higher running time. These observations lead to the

conclusion that the meta-heuristic method is more adaptable to different situations and data sets.

The heuristics method is more specific to certain problems, and despite the fact that it generates

optimized routes, most times than not, these routes are not the most optimal ones.

The Tangier data set was tested once more using a vehicle capacity of thirty and the TS method.

The same routes were generated, but the cost that the company has to pay is way less than if it only

uses vehicles with a capacity of nineteen because instead of using 6 vehicles to go through these

stops, it will only need to use four as can be seen in table 8.

Table 8: Using a vehicle capacity of 30

Trips Employees picked up Travel Time Total Service

Time Total Route Time

Time Window

Respected? Capacity

Respected? Virmousil→Boukhalef→Virmousil 28 11+11=22min 4 min 26 min YES YES

Virmousil→ Mesnana→Ziaten→Virmousil 23+2=25 16+7+13=36 8 min 44 min YES YES

Virmousil→ Irfane→ Virmousil 24 12+12=24 4 min 28 min YES YES 19 12+12=24 4 min 28 min YES YES

This lowers its expenses in terms of vehicles needed; a lower number of vehicles means lower

fuel/gas spending and less drivers needed, and in terms of the efficiency of the trips. i.e. instead of

Page 52: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

52

visiting the same stops using multiple vehicles to meet the demand, only vehicle will be used for

most of these stops.

In the future, the code for the clustering could be more user-friendly by using it as a function for

which the user only inputs the coordinates of the stops making it return the coordinates of each

cluster. These coordinates could then be used in a TSP solving function that simply returns the

best route and the map corresponding to it. Additionally, the codes should be tested with a larger

scale data set to ensure its efficiency, and a relationship could be created between the code and

Google Maps so as to generate the real travel times faster and the Tabu Search code could compare

between the maximum travel time and total route time, instead of doing it manually.

Page 53: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

53

VII. Conclusion

The vehicle routing problem was defined along with its most common solutions. A special focus

was given to the VRP with a time window constraint which was solved using a Cluster First- Route

Second algorithm that relied on K-means clustering and the Fisher and Jaikumar linear integer

programming algorithm as well as using Tabu Search, which relied on the Simulated Annealing

concept to create its aspiration criterion. The results from both methods were presented using two

data sets; the Ifrane set and the Tangier one. Results and comparisons between the two methods

were presented and future work that can be beneficial when it comes to this topic was listed.

Page 54: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

54

REFERENCES [1] Ant Algorithm, Networking and Emerging Optimization, 2013.

[2] Branch and Bound, Networking and Emerging Optimization, 2013.

[3] Cluster-First Route-Second Method, Networking and Emerging Optimization, 2013.

[4] Cordeau, J.F et al, The VRP with Time Window, Les Cahiers du GERAD, 2000.

[5] Dantzig, G. B. and Ramser, J. H., The Truck Dispatching Problem, INFORMS, 2008.

[6] El-Sherbeny, Nasser A., Vehicle routing with time windows: An overview of exact, heuristic

and metaheuristic methods, Journal of King Saud University – Science, 2010.

[7] Gendreau, Michel, AN INTRODUCTION TO TABU SEARCH, Centre de recherche sur les

transports et Département d´informatique et de recherche opérationnelle, 2002.

[8] Ghoseiri, K. and Ghannadpour, S. F., Hybrid Genetic Algorithm for Vehicle Routing and

Scheduling Problem, ASCI, 2012.

[9] https://www.informs.org/Explore/Operations-Research-Analytics

[10] https://www.mathworks.com/help/stats/kmeans.html#bueq7aj-5

[11] INTEGER LINEAR PROGRAMMING (IP), 2003

[12] Laporte, Gilbert, The Vehicle Routing Problem: An overview of exact and approximate

algorithms, European Journal of Operational Research, 1991.

[13] Righini, Giovanni, Hill climbing: Simulated annealing and Tabu search, University of

Milan.

[14] Solomon, Marius M, Algorithms for the Vehicle Routing and Scheduling Problems with

Time Window Constraints, Operations Research, 1987.

[15] Tan K.C. et al., Heuristics Methods for vehicle routing problem with time window, Artificial

Intelligence in Engineering, 2001.

[16] Toth, Paolo and Vigo, Daniele, Models, relaxations and exact approaches for the capacitated

vehicle routing problem, ELSEVIER, 2002.

Page 55: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

55

APPENDICES

Appendix A: A Matrix 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0

100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 0 0 0 0 0

0 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 -1 0 0 0 0

0 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 1 0 0 0 0

0 0 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 -1 0 0 0

0 0 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 1 0 0 0

0 0 0 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 -1 0 0

0 0 0 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 1 0 0

0 0 0 0 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0

Page 56: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

56

100000 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0

Page 57: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

57

Appendix B: b Matrix 99993

100007

99988

100012

99972

100028

99977

100023

99982

100018

99993

100007

99994

100006

99978

100022

99981

100019

99987

100013

99988

100012

99994

100006

99985

100015

99987

100013

99994

100006

99972

100028

99978

100022

99985

100015

99991

100009

99991

100009

99977

100023

99981

100019

99987

100013

99991

100009

99992

100008

99982

100018

99987

100013

99994

100006

99991

100009

99992

100008

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

Page 58: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

58

Appendix C: Snippets of Code

Generating the map:

Generating distance matrix for Fisher’s algorithm:

Page 59: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

59

Generating the distance matrix for Tabu Search:

Cost calculations in PFIH for Tabu Search

Code for Equality Constraints

Page 60: VEHICLE ROUTING OPTIMIZATION USING TIME WINDOW CONSTRAINT Routing... · vehicle routing optimization using time window constraint ... spring 2017 . 2 vehicle routing optimization

60

Optimization using intlinprog: