Professional Documents
Culture Documents
Research Project
Mathematical modelling & graph theory
Subject :
Realized by :
Abstract—After introducing the general classes of Vehicle Routing Problem and some related solutions, this report
focuses on the Vehicle Routing Problem with Stochastic Demands (VRPSD) within the safety stocks approach that
deals with uncertainty in the customer demands by considering safety stocks, i.e. when designing the routes, part of the
vehicle capacity is reserved to deal with potential emergency situations caused by unexpected demands. We will
discuss the methodology used by Juan and al. and we will see how the parallelization of this methodology can be
employed to efficiently solve the VRPSD.
Thus, for a given VRPSD instance, our algorithm considers different levels of safety stocks. For each of these levels, a
different scenario is defined.
Index Terms—Vehicle Routing Problems, Stochastic demands, Stochastic optimisation, Stochastic Planning, Safety
Stocks, Parallel Metaheuristic, Parallel and distributed computing.
ports, stations, warehouses and depots). length (or time) constraint instead of ca-
Nevertheless, in other applications, the net- pacity constraint.
work is not always materialized by a physical ∗ Multi-Depot VRP (MDVRP) : company
structure, and arcs are used to describe the may have several depots from which it
allowed movements. can serve its customers. If the customers
Note that the graph can be direct, particu- are clustered around depots, then the
larly when they can be traversed in only one distribution problem should be modeled
direction because of the presence of one-way as a set of independent VRPs. However,
courses. if the customers and the depots are in-
Each arc is weighted by a cost, which generally termingled, then a MDVRP should be
represents its length and/or travel time. solved. A MDVRP requires the assign-
ment of customers to depots. A fleet of
1.2 Objective vehicles is based at each depot.
The main objective of VRP is the customers’ ∗ VRP with Pick-Up and Delivering
demands satisfaction with the minimization of (VRPPD) : is a VRP in which the pos-
total costs. sibility that customers return some com-
modities is contemplated. So in VRPPD,
it should be taken into account that
1.3 Variants of VRP’s
the goods returned by customers to the
The variations of components with the appear- delivery vehicle must fit into it. These
ance of constraints give the emergence to many restrictions make the planning problem
types of VRP’s. more difficult and can lead to bad uti-
∗ Capacitated VRP (CVRP) : is a Vehicle lization of the vehicles capacities, in-
RoutingProblem (VRP) in which a fixed creased travel distances or a need for
fleet of delivery vehicles ofuniform ca- more vehicles. Hence, it is usual to con-
pacity must provide service to known sider restricted situations where all de-
customerdemands for a single commod- livery demands start from the depot and
ity from a common depot atminimum all pick-up demands shall be brought
transit cost. That is, CVRP is like VRP back to the depot, so there are no in-
with theadditional constraint that every terchanges of goods between the cus-
vehicle must have uniformcapacity of a tomers.
single commodity. ∗ Split Delivery VRP (SDVRP) : a relax-
∗ VRP with Time Windows (VRPTW) : ation of the VRP wherein it is allowed
is a VRP with the additional restriction that the same customer can be served
that each customer ci should be served by different vehicles if it reduces overall
in a time interval [ei , li ] (time window), costs. This relaxation is very important
where ei and li represents the early and if the sizes of the customer orders are as
late time. big as the capacity of a vehicle.
∗ VRP with Backhauls (VRPB) : The ∗ Periodic VRP (PVRP) : In classical
VRPB is the extension ofthe VRP in VRPs, typically the planning period is a
which the customer set is partitioned single day. In the case of the Period Vehi-
into two subsets. One contains cus- cle Routing Problem (PVRP), the classi-
tomers that require a given quantity of cal VRP is generalized by extending the
product to be delivered and the second planning period to a specified number of
contains customers where a given quan- days.
tity of inbound products must be picked
up.
∗ Distance-Constrained VRP (DCVRP) :
In DCVRP, each route has a maximum
PROJECT OF MATHEMATICAL MODELLING & GRAPH THEORY. 4
X X
min cij · xkij (1)
k∈K (i,j)∈V
X X
xkij = 1 ∀i ∈ V \ {0} (2)
j∈V\{i} k∈K
Fig. 1. Types of VRP’s X X
xkij = xkji ∀i ∈ V \ {0}∀k ∈ K (3)
j∈V\{i} j∈V\{i}
X X
qi · xkij ≤ Q ∀k ∈ K (4)
i∈V\{0} j∈V\{i}
In this paper we will give a detailled de- As such, on one hand, the vehicle routes are
scription of the Vehicle Routing Problems with designed in advance by applying a particular
Stochastic Demands. algorithm but on the other hand, due to the
uncertainty of the customers demands, at some
point along a route the capacity of the vehicle
3.2 VRPSD basic charcteristics and exam- may be depleted before all demands on the
ples route have been satisfied.
VRPSD have received attention only recently,
the first detailed study of VRPSD was given in The main goal here consists of determin-
a paper by D.J.Bertsimas proposed in 1992, in ing the optimal solution (set of routes) that
wich the author try to configure the problem minimizes those tangible costs subject to the
of money collection/distribution over a central following constraints:
Bank, in this case the demands was stochastic,
1) All routes begin and end at the depot.
following some specific probability law of
2) Each vehicle has a maximum load ca-
distribution. Hence if a bank has to collect
pacity, which is considered to be the
money on a daily basis from several but not all
same for all vehicles.
of its branches. The capacity Q of the vehicle
3) All (stochastic) customer demands
used may not correspond to any physical
must be satisfied.
constraints but to an upper bound on the
4) Each customer is supplied by a single
amount of money that a vehicle is permitted
vehicle.
to carry for safety reasons established by
5) A vehicle cannot stop twice at the
insurance companies. In the same way, there
same customer without incurring in a
is a similar study where the bank decides to
penalty cost.
deliver money to Automated Teller Machines
(ATM) that are geographically dispersed over
several areas. 3.3 Dealing with demands uncertainty
Similarly, the collection of recyclable material Two major techniques are used to deal with
can be considered as a VRSPD, where the stochasticity in VRP’s : a priori optimization and
probability of visiting an assembly point is re-optimization .
given, and the capacity Q corresponds to the
physical constraint that a truck can carry only 3.3.1 A priori optimization
a fixed weight or volume, we talk about Green
In priori-optimization a solution must be deter-
VRPSD (GVRPSD).
mined beforehand, this solution is ”confronted”
Moreover, the VRPSD is related to many
with the realization of the stochastic parameters
practical situations. Psaraftis (1995) and
in a second step.
Chepuri and Homem de Mello (2005)
We can distinguish tree main approaches :
investigated the delivery of petroleum
products, industrial gases, and home heating • Chance-constrained programming :
oil. Shen et al. (2009) presented an example Probabilistic constraints are sometimes
regarding the delivering of supplies to cities transformed into deterministic ones by
under a state of emergency. Markovic et al. the formulation of an optimization
(2005) suggested that the VRPSD could be used problem that ensures that the
to model the delivery and pickup processes probability of meeting a demand is
of mail, packages, and recycled material from above a certain level (for example :
offices and industrial plants. P (Di ≤ capacity) ≤ 1 − α where Di total
demand assigned to a route. In other
The basic characteristic of the VRPSD is that words, it restricts the feasible region so
the actual demand of each customer is revealed that the confidence level of the solution
only when the vehicle reaches the customer. is high. The chance-constrained method
PROJECT OF MATHEMATICAL MODELLING & GRAPH THEORY. 8
is a relatively robust approach, however, programming with recourse. In the first stage,
it is often difficult to solve. an a priori solution (i.e. a complete set of routes
• Stochastic programming with recourse as in a deterministic VRP) is planned. Then,
In this approach we must take a recourse in the second stage, this first-stage solution is
which is an action must be done to ”ad- executed; that is, each route is followed, and
just” the a priori solution to accommo- the actual values of the stochastic parameters
date the revealed information. (the customer demands in the case of VRPSD)
are gradually revealed.
3.3.2 Re-optimization In the second stage of the problem, failures may
Re-opitmization technique is based on the be observed when a route is executed. Such
implicit assumption that information (in failures occur when the vehicle performing
VRPSD’s information means demands) is the route arrives at a customers location
revealed over time as the vehicles perform without sufficient residual capacity to service
their assigned routes, routes are created piece the observed demand. These occurrences are
by piece based on the currently available simply referred to as route failures.
information. To recover route feasibility, recourse actions
For example Victor Pillac and al. proposed must be taken. As presented in Gendreau,
an appraoch based on dynamic programming Jabali, and Walter (2014), various studies have
known as Multiple Scenario Approach (MSA) as been conducted to formulate and assess the
if a pool of scenarios is continuously optimized efficiency of the possible recourse actions that
and updated to capture the uncertainties. can be applied to the VRPSD.
Even if internally each scenario in the pool
contains acomplete routing for the customers, In the jargon of transport sciences, the first
the only information visible to the user is the stage is named tactical plannig, and the second
next customerto visit. This study proposes an is operational planning.
adaptation of this framework to the VRPSD,
by maintaining a pool of scenarios containing 3.4.2 recourse policy
possible realizations of the customer demands. Recourse actions that can be implemented
Scenarios are optimized with and Adaptive independently by the vehicles performing the
Variable Neighborhood Search and the next routes determined in the first stage of the
client to visit is selected with a Consensus problem. These recourse actions can either
algorithm. be reactive (i.e., implemented only after a
This technique offer greater flexibility over route failure occurs) or proactive (i.e., made
the recourse optimization action, however, it in anticipation of possible failures that could
have to be run every time a decision has to be take place along the route). A reactive recourse
taken, which can be time consuming for large action takes the form of a back-and-forth (BF),
instances. trip to the depot, where the vehicle is able to
restock and then serve the remaining demand
In the following we’ll try to give a two ex- at the customer location where the failure
amples of both frames of work re-optimization occurred.
and a-priori optimization, in the aim to see how After a BF trip, the vehicle simply proceeds
that affect the formulation of the problem. to the next scheduled customer on the route.
In the case of an exact stockout, whereby the
revealed demand matches exactly the residual
3.4 A priori optimization example : re-
capacity of the vehicle, a restocking trip is
course action
performed, entailing that the vehicle visits the
3.4.1 Recourse action depot before proceeding to the next customer
In this approach, the problem is decomposed along the route, see Gendreau, Laporte, and
into two stages, as in two-stage stochastic Sguin (1995) and Hjorring and Holt (1999). In
PROJECT OF MATHEMATICAL MODELLING & GRAPH THEORY. 9
c(i, j); ∀i, j ∈ V and the following assumptions use of Genetic Algorithms, Tabu Search,
hold true: Simulated Annealing or Ant Colony Op-
timization.
1) c(i, j) = c(j, i) (i.e., costs are symmetric)
2) c(i, i) = 0
Thus, one key idea behind our approach is to
3) The triangle inequality is satisfied :
transform the issue of solving a given VRPSD
c(i, j) ≤ c(i, k) + c(k, j)
instance into a new issue which consists of
These costs are usually expressed in terms of solving several ”conservative” CVRP instances,
traveled distances, traveling plus service time each characterized by a specific probability of
or a combination of both. suffering route failures.
Let Vehicle Maximum Capacity : The term conservative refers here to the fact
V M C > M ax{Di }, where Di ≥ 0 ∀i ∈ V ∗ rep- that only a certain percentage of the vehi-
resent the independent random variables that cle total capacity will be considered as avail-
describe customer demand. able during the routing design phase. In other
For each customer, the exact value of its de- words, part of the total vehicle capacity will be
mand is not known before- hand but it is only reserved for attending possible ”emergencies”
revealed once the vehicle visits. No further as- caused by under-estimated random demands
sumptions are made on these random variables during the actual distribution (routing execu-
other than that they follow a well-known theo- tion) phase. This part can be considered as a
retical or empirical distribution either discrete safety stock since it reflects the level of extra
or continuous with existing mean denoted by stock that is maintained to buffer against pos-
E[Di ]. sible route failures. In fact, in the point of view
In this context, the aim is to find a feasible solu- of Juan and al. the safety stcoks methodology is
tion (set of routes) that minimizes the expected described by the following specific steps :
delivery costs while satisfying all customer de-
mands and vehicle capacity constraints. 1) Consider a VRPSD instance defined by
a set of n customers with stochastic
4.2 Fundamentals of the safety stocks demands : Di ≥ 0 and (1 ≤ Di ≤ n)
methodology where each Di follow a predefined
statistical distribution either theoretical
A safety stock is a certain amount of the vehicle
or empirical as long as its mean exists.
capacity that is not considered while designing
Let the vehicle maximum capacity be
the routes. Then, if the final routes demands
VMC.
surpass their expected values, this stock can
be employed to try to satisfy them. Thus, the
2) Determine a set K of percentages,
aim of considering safety stocks is to reduce the
where each element k is the percentage
probability of a route failure. The safety stocks
of the vehicle capacity W that can be
approach is inspired by the two following ma-
used during the route design phase,
jor facts:
in other words, 1k represents a fixed
• The VRPSD can be seen as a generaliza- level of safety stock. For each of these
tion of the CVRP or, to be more specific, elements, follow the steps 3 to 9.
the CVRP is just a VRPSD with constant
demands -random demands with zero 3) Consider the capacitated CVRP(k ) with
variance-. a total vehicle capacity of W ∗ = kW
• While the VRPSD is yet an emerging with the deterministic demands
research area, extremely efficient meta- d∗i = E[Di ]. Where E[Di ] symbolizes
heuristics do already exists for solving the mean or expected value of each
the CVRP, specially a powerful state- random demand.
of-the-art metaheuristics based on the
PROJECT OF MATHEMATICAL MODELLING & GRAPH THEORY. 11
4) Generate an initial solution for the is lower than the fixed cost of the cur-
CVRP(k ). This solution is also an apri- rent base solution, then the list of the
oristic solution for the CVRP-SD. It will best deterministic solutions is updated
be employed as it is as long as there (only if it is not full or if the worst
is no need of corrective actions (routes solution has a higher cost, then a swap
failures and re-stockings). Therefore, is performed) and the expected total
the cost associated to this solution, cost of the new solution is estimated
CCV RP (k) , can be considered as a base with a short simulation. If this cost is
or fixed cost of the CVRP-SD solution. lower than the expected total cost of the
In the case of the stochastic problem, base solution, the latter is replaced and
there is also a variable cost CCA (k) the list of the best stochastic solutions
that depends on the corrective actions is updated. Otherwise, an acceptance
undertaken. Consequently, for a given criterion is used to decide whether the
value of k , the total cost of the ”stochas- base solution is deteriorated to the new
tic” solution (the one associated with one. Before that, if the fixed cost of
the CVRP-SD) is the sum of the fixed the new solution is higher, then that
cost corresponding to the ”determinis- solution is discarded. This iterative pro-
tic” solution (the one associated with cess will provide, after analyzing many
the CVRP) and the variable cost due to possible solutions, a list of promising
corrective actions, therefore : solutions for the CVRP-SD.
8) Try to improve all promising solutions
CCV RP SD (k) = CCV RP (k) + CCA (k) with an intensive routing algorithm.
5) Use Monte Carlo Simulation (MCS) to es- 9) Use a long simulation to generate a
timate the expected cost due to correc- sample of total costs for each promising
tive actions for each route j of the apri- solution. Large samples are required to
j
oristic solution, E[CCA (k)] (1 ≤ j ≤ m), obtain estimates with small confidence
Then aggregate the expected total cost intervals.
for all routes, 10) Finally, return the top best stochas-
m
tic solutions (considering all solutions
found with the different values in K ),
X j
E[CCA (k)] = E[CCA (k)]
j=1
and the corresponding samples (they
will be used for completing a risk anal-
In this phase, a short simulation is used ysis).
to quickly get that estimate. Then, the
expected total cost of the solution is The following flowchart represent a sum-
calculated as follows: mary of this methodology :
nlter←1 3
Compute a biased-randomized
Consider the cap,MDVRP instance with di=E[Di] and W*=(1-
priority list of customers for each
K)W,where K is the element of K in the niter position
depot based on marginal savings
Is newSol better N
than baseSol for Y
the stochastic
and cap .MDVRP N
Update bestSochSol Y
N baseSol←newSol
Is stopping criteria
Y met ?
8
Improve all routing
sols(bestDetSol and bestStochSol)
Is nlter<size(K) ? Y
10
Retuen bestDetSol and bestStochSol with
sample observations for risk analysis N
PROJECT OF MATHEMATICAL MODELLING & GRAPH THEORY. 13
4.3 Advantages of safety stocks approach the current remaining stock. The cost of this
• The methodology is valid for any statis- strategy incorporates the costs on the edges that
tical distribution with a known mean, link a customer with the depot and the depot
either theoretical e.g., Normal, Log- with the next customer minus the cost of the
Normal, Weibull, Gamma, etc. or even edge linking both customers.
experimental.
• In some sense, the methodology is ”re- 4.5 Computational experiments
ducing” a complex VRPSD -where no
efficient metaheuristics have been de- The algorithm has been implemented as a
veloped yet- to a limited set of more Python application and tested on 23 MDVRP
tractable CVRPs where excellent, fast benchmark instances: the first seven were pro-
and extensively tested metaheuristics ex- posed by Christofides and Eilon (1969), the fol-
ists. This adds credibility to the quality lowing four were created by Gillett and Johnson
of the final solution or solutions pro- (1976) and the remaining are described in Chao
vided to the decision-maker. et al. (1993). Vidal et al. (2012), Escobar et al.
• Thus, the methodology exposed here can (2014), and Juan et al. (2015) are some recent
be applied to CVRPSD instances of vir- works using them. These instances have been
tually any size (e.g., problems with hun- adapted as described next. The demand of each
dreds or even thousands of nodes) since customer (di ) has been considered as a random
complexity due to size can be managed variable Di following a log-normal distribution
by efficient CVRP metaheuristics and with mean d i and variance vdi . Three different
Monte Carlo simulation. scenarios have been considered, each one with
a respectively different variance : 0.1 · E[Di ],
0.5 · E[Di ] and 1 · E[Di ].
4.4 Further considerations The first column identifies the instance and the
The algorithm used to get the initial solution for second shows the best known solution (BKS) for
the CVRP is the one proposed in Juan et al. Ini- the MDVRP. The next five columns are associ-
tially, a customer-depot assignment map is set, ated with the solution with the lowest fixed cost:
and then the CWS heuristic is applied to obtain the first, the best deterministic solution - fixed
a fast routing plan. Regarding safety stocks, it cost (BDS-FC), represents the fixed cost; the
is expected that lower values of k will provide second calculates the gap between the BKS and
more reliable routes, as a high percentage of the BDS-FC, which reveals the performance of
the vehicle capacity will be reserved as safety the algorithm for the deterministic version of
stock. However, a high fixed cost will result too, the problem; the third, the best deterministic
since more vehicles will be needed to cover all solution - total expected cost (BDS-TEC), is the
the customers demands. On the other hand, a expected total cost; the fourth, the best deter-
high value of k is related to a lower fixed cost ministic solution - reliability (BDS-R), has been
but a higher variable cost due to the elevated computed as one minus the number of route
risk of having to return to the depot to reload. failures divided by the number of routes; and
Considering the trade-off between these two the fifth, best deterministic solution - k (BDS-
costs, different values are tested as indicated K), provides the percentage of the vehicle total
in step 2. The cost due to corrective actions is capacity chosen. The following column repre-
computed as follows. In case of route failure, sents the gap between the BDS-TEC and the
it includes the cost of returning to the depot BDS-FC. The next three columns are associated
first and then to the customer being served. with the solution with the lowest expected total
It is assumed that the vehicle delivers all the cost: the best stochastic solution - total expected
remaining stock before going back to reload. A cost (BSS-TEC) contains the expected total cost;
re-stocking is carried out when the expected the following two columns, the best stochas-
demand of the next customer is higher than tic solution - reliability (BSS-R) and the best
PROJECT OF MATHEMATICAL MODELLING & GRAPH THEORY. 14
[6] Juan, A., Faulin, J., Grasman, S., Riera, D., Marull, J.,
On common operating systems, each program Mendes, C. Transportation Research Part C 19 (2011)
runs in its own process. Usually, we start a 751-65 in Using safety stocks and simulation to solve the vehicle
routing problem with stochastic demands, 2010 ELSEVIER Ltd.
program by double-clicking on the icon’s pro-
gram or selecting it from a menu. In this recipe, [7] Juan, AA., Jorba, J., Faulin, J., Caceres, J., Marqus, JM.,
we simply demonstrate how to start a single Using parallel & distributed computing for real-time solving
of vehicle routing problems with stochastic demands, Springer
new program from inside a Python program. A Science+Business Media, LLC 2011 Published online, 23
process has its own space address, data stack, June 2011.
and other auxiliary data to keep track of the
[8] Marinaki, M., Marinakis, Y., Expert Systems With
execution; the OS manages the execution of all Application 46 (2016) 145-163. A Glowworm Swarm
processes, managing the access to the computa- Optimization algorithm for the Vehicle Routing Problem with
tional resources of the system via a scheduling Stochastic Demands. 2015 ELSEVIER Ltd.
B.3 Working with threads in Python [10] Salavati-Khoshghalb, M., Gendreau, M., Jabali, O., Rei, W.
(2019) A Rule Based Recourse for the Vehicle Routing Problem
Thread-based parallelism is the standard way with Stochastic Demands. Transportation Science. Published
Online in Articles in Advance 25 June 2019
of writing parallel programs. However, the
Python interpreter is not fully thread-safe. In
order to support multithreaded Python pro-
grams, a global lock called the Global Inter-
preter Lock (GIL) is used. This means that only
one thread can execute the Python code at the
same time; Python automatically switches to
the next thread after a short period of time or
when a thread does something that may take a
while. The GIL is not enough to avoid problems
in your own programs. Although, if multiple
threads attempt to access the same data object,
it may end up in an inconsistent state.