You are on page 1of 13

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/220209250

A Dynamic Programming Algorithm for the Shortest Path Problem with Time
Windows and Linear Node Costs

Article  in  Networks · May 1998


DOI: 10.1002/(SICI)1097-0037(199805)31:33.0.CO;2-A · Source: DBLP

CITATIONS READS

107 1,353

4 authors, including:

François Soumis Jacques Desrosiers


Polytechnique Montréal HEC Montréal - École des Hautes Études commerciales
171 PUBLICATIONS   8,720 CITATIONS    129 PUBLICATIONS   11,418 CITATIONS   

SEE PROFILE SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Optimization of aircraft trajectories View project

Primal Integer Optimizer View project

All content following this page was uploaded by Jacques Desrosiers on 29 June 2018.

The user has requested enhancement of the downloaded file.


A Dynamic Programming Algorithm for the
Shortest Path Problem with Time Windows
and Linear Node Costs

Irina Ioachim, 1 Sylvie Gélinas, 1 François Soumis, 1 Jacques Desrosiers 2


1
GERAD and École Polytechnique, P.O. Box 6079, Station ‘‘Centre-Ville,’’
Montréal (Québec), Canada H3C 3A7
2
GERAD and École des Hautes Études Commerciales, 3000, chemin de la
Côte-Sainte-Catherine, Montréal, Canada H3T 2A7

Received July 1994; accepted 17 June 1997

Abstract: This paper presents an optimal dynamic programming algorithm, the first such algorithm in
the literature to solve the shortest path problem with time windows and additional linear costs on the
node service start times. To optimally solve this problem, we propose a new dynamic programming
algorithm which takes into account the linear node costs. This problem has numerous applications: Two
examples are job-shop scheduling and aircraft routing and scheduling. To underline the efficiency of the
proposed method, we compare it with an approach based on partial discretization of the time windows.
It clearly outperformed the discretization approach on test problems with wide time windows and many
nodes with negative costs. q 1998 John Wiley & Sons, Inc. Networks 31: 193–204, 1998

Keywords: shortest path; time windows; dynamic programming

1. INTRODUCTION tional node costs on the service start times. Because of


the time windows, only feasible paths need to be consid-
ered. The shortest path in this context is the path with
Consider a connected network G Å (V, A), where V is
minimum cost, with respect to both the arc costs and node
the set of nodes and A is the set of arcs. With each arc
costs.
(i, j) √ A is associated a real number cost and a nonnega-
When all node costs are zero, this problem reduces to
tive integer duration. For each node, a time window
a shortest path problem with time windows. If negative
within which the node may be visited and a node cost as
cost cycles are present in the network, the presence of
a function of the service start time are specified. Waiting
time windows prohibits unbounded solutions. Since find-
time is allowed at no cost before the beginning of a time
ing an elementary shortest path with time windows is a
window. This paper proposes the first algorithm to solve
strongly NP-hard problem [8], the literature has focused
the shortest path problem with time windows and addi-
on the relaxed version, denoted SPPTW, which allows
for multiple visits to the same node. SPPTW is NP-hard,
Correspondence to: J. Desrosiers but several pseudopolynomial algorithms to solve it are
Contract grant sponsors: Quebec Government; Natural Sciences and available [3, 4, 7]. Numerous practical applications of
Engineering Research Council of Canada SPPTW in vehicle routing and crew scheduling are found

q 1998 John Wiley & Sons, Inc. CCC 0028-3045/98/030193-12

193

/ 8U1F$$0810 03-25-98 12:16:05 netwal W: Networks 810


194 IOACHIM ET AL.

in survey papers [2, 7, 18]. For example, in models using [14] to be a transportation problem with n / 1 nodes and
time-constrained multicommodity network flow formula- 3n 0 1 arcs; in [9], the number of arcs was reduced to
tions, the SPPTW appears as a subproblem in decomposi- 2n 0 1. The complexity of these three algorithms is O(n).
tion approaches such as the Dantzig–Wolfe decomposi- Convex functions of the time variables are also handled
tion and Lagrangian relaxation. in [9]; the complexity of the proposed algorithm is O(n)
The motivation for solving the new version of the in the number of unidimensional minimizations of the
SPPTW which includes linear node costs arises from its convex functions. These papers, with the literature on
practical applications. As mentioned above, decomposi- SPPTW [3, 4, 7], serve as a departure point for designing
tion approaches use SPPTW to generate feasible paths an optimal algorithm for the shortest path problem with
(or schedules) for vehicles and crews. SPPTW retains time windows and linear node costs.
local time window constraints, i.e., on a single path at a A mathematical formulation of the problem is given in
time. Any coupling constraints that link time variables Section 2. To solve it, we present a dynamic programming
simultaneously on several paths cannot be incorporated algorithm which can solve the new version of SPPTW
into the SPPTW. However, when these coupling con- involving linear time costs. This algorithm is presented
straints are relaxed in a Lagrangian relaxation approach, in two stages: First, in Section 3, we analyze the cost
e.g., the time variables appear in the objective function function with respect to the schedule of a given path with
together with dual multipliers, and this introduces linear linear node costs. Second, in Section 4, we describe a
node costs in the SPPTW. As an application, consider a new dynamic programming algorithm resulting from this
weekly aircraft assignment problem where some subsets analysis. In Section 5, numerical tests illustrate the rela-
of flights have to depart at the same time within time tive efficiency of the proposed algorithm when compared
windows, but on different days. These flights are not nec- to an alternative approach based on discretizing the time
essarily covered by the same aircraft and, hence, the same intervals.
departure time restrictions corresponding to each subset
must be defined on the time variables [13]. A second
application is for aircraft routing and scheduling problems
2. PROBLEM FORMULATION
including headway constraints, such as a requirement to
provide at least 1 hour or at most 2 hours between flights
with the same origin and destination [13]. A third applica- As for the SPPTW, we solve the nonelementary version
tion is for periodic aircraft scheduling problems over a of our constrained shortest path problem. Any network
day or a week [13]. In this case, linear costs on the containing positive time cycles can be transformed into
sink node are introduced to produce a periodic schedule. an acyclic time-oriented network by creating copies of
Another application is in job-shop scheduling, where all the original nodes with disjoint time intervals for each
jobs have to be processed on several machines within copy. Hence, a path in the new network may visit several
time windows defined by ready and due dates, while pre- copies of an original node at different times. However,
cedence constraints are specified between jobs [12]. Ad- this acyclic network may be very large. For the rest of
ditional applications include vehicle routing [6, 10] and the paper, we assume that the network G Å (V, A) is
automated guided vehicles [19]; heuristic approaches acyclic. To describe the problem, we use the following
were used to solve these problems previously. This paper notation:
provides the first optimization algorithm for this extended
version of the SPPTW; consequently, the number of ap- • V Å N < {o, d}: the node set, where N Å {1, 2, . . . ,
plications should grow in the near future. n}, o is the source node and d is the sink node;
Relevant literature is as follows. De Palma et al. [1] • [ai , bi ]: the time window at node i √ N (ao Å bo at
solved the problem of finding the best path for a commuter the source node);
leaving at a given time and willing to arrive within a • li : the linear cost at node i √ V, a real number un-
given soft time interval, when the travel time along an restricted in sign;
arc is a function of the service start time at the origin
• tij : the duration of arc (i, j) √ A, a nonnegative integer;
node of this arc. This problem is defined on an acyclic
time-oriented network. The authors presented a pseudo- • cij : the cost of arc (i, j) √ A, a real number unrestricted
polynomial algorithm for this NP-hard problem, which in sign.
has some polynomial subcases. In addition, several au-
thors studied the optimization of a schedule along a given Each arc (i, j) √ A satisfies the relation ai / tij ° bj .
path with linear and convex node costs. Sexton and Bodin The assumption ao Å bo is not restrictive. If ao x bo , a
[14], Sexton and Choi [15], and Dumas et al. [9] gave new node o * is defined with ao = Å bo = Å ao , together with
polynomial algorithms to find the optimal schedule in an arc (o *, o) with zero cost and duration. The following
presence of linear cost functions of the time variables. variables are necessary for a complete mathematical for-
Given an n-node path problem, the dual was shown in mulation of the problem:

/ 8U1F$$0810 03-25-98 12:16:05 netwal W: Networks 810


SHORTEST PATH PROBLEM WITH TIME WINDOWS 195

• Xij , (i, j) √ A: a binary flow variable which is equal i √ N. The service start time synchronization constraints
to 1 if the arc (i, j) is in the shortest path and to 0 may be formulated as
otherwise;
• Ti , i √ V: a time variable which represents the service Ti 0 Tmi Å ai , i √ N, (9)
start time at node i.
where Tmi is a time variable which represents the slack
The shortest path problem with time windows and linear between the service start time and the beginning of a
node costs can be formulated as the following nonlinear time window for all flights in group mi . Obviously, two
integer program: different flights with the same departure time have identi-
cal daily time windows. Since they use the same time
Minimize ∑ cij Xij / ∑ li Ti (1) slack variable, all flights in set mi will necessarily have
(i ,j ) √A i√V the same departure time.
When these same departure time constraints are re-
subject to: laxed in a Lagrangian relaxation approach, the time vari-
ables appear in the objective function together with dual
∑ Xo j Å 1, (2) multipliers. Let li denote the dual multiplier associated
j: (o ,j ) √A
with same departure time constraint i. With this notation,
∑ Xid Å 1, (3) the problem of constructing a minimal cost aircraft itiner-
i : (i ,d ) √A ary can be formulated as (1)–(8) above.
∑ Xij 0 ∑ Xj i Å 0, ∀i √ N (4)
j: (i ,j ) √A j: (j,i ) √A

Xij (Ti / tij 0 Tj ) ° 0, ∀ (i, j) √ A (5) 3. OPTIMAL SCHEDULE OF A PATH

ai ° Ti ° bi , ∀i √ {o, d} (6) The process described in Section 4 to solve SPPTWTC


ai ( ∑ Xij ) ° Ti ° bi ( ∑ Xij ), iteratively constructs paths from the origin node o to
j: (i ,j ) √A j: (i ,j ) √A
nodes in N < {d}. Given that the node sequence is al-
(7) ready known in such a path, the arc cost component is
∀i √ N fixed, while values of the time variables in an optimal
Xij binary, ∀ (i, j) √ A. (8) schedule determine the node cost component. As linear
costs are a special case of convex costs, the polynomial
The objective function (1) minimizes the sum of the arc algorithm of Dumas et al. [9] can be applied to find the
and node costs. Constraints (2) – (4) define the classical optimal schedule of a path. In this section, we pursue a
network flow constraints for a path originating at node o different research direction: For a given partial path, we
and ending at node d. A feasible path in the network define and analyze the node cost function at the last node
respects both the nonlinear compatibility requirements be- of the path. This function provides the time cost compo-
tween flow and time variables (5) as well as the time nent at each point in the time window. Moreover, the
window constraints (6) and (7). Note that constraints function can be constructed iteratively, i.e., as a path is
(7) impose Ti Å 0, ∀i √ N whenever (j: (i ,j ) √A Xij Å 0, extended from node i to node j, we show that the node
i.e., only node costs associated with nodes in the shortest cost function at node j is obtained using the node cost
path contribute to the cost function. Finally, constraints function at node i.
(8) impose binary values for the flow variables. Let P Å {y0 , y1 , y2 , . . . , yq }, P , V be a path originat-
We denote the shortest path problem with time win- ing at node y0 Å o, ending at node yq , and satisfying the
dows and time costs by SPPTWTC. A special case with time window constraints at each node. The cost of path
li Å 0, i √ V is the SPPTW itself. An obvious complexity P is
result is the following: q0 1 q

∑ cyl,yl/1 / ∑ lylTyl . (10)


Proposition. SPPTWTC is an NP-hard problem. lÅ0 lÅ0

For an example of an application which requires solv- The first term in (10) is constant for a given path, while
ing an SPPTWTC, we derive next the objective function To is fixed at To Å ao Å bo . An optimal schedule computa-
of the SPPTWTC in the context of the above-mentioned tion for path P amounts to finding the values of the time
weekly aircraft assignment problem where some subsets variables Tyl , 1 ° l ° q, within the time windows that
of flights have to depart at the same time within time minimize the total node cost while respecting the given
windows, but on different days [13]. Let mi denote the node visiting order. As mentioned previously, this can be
set of flights that have the same departure time as flight done with algorithms of linear complexity [9, 14, 15].

/ 8U1F$$0810 03-25-98 12:16:05 netwal W: Networks 810


196 IOACHIM ET AL.

Another characteristic of path P is that time window re- It follows from this definition that the function takes real
gions where path P is not feasible can be eliminated [9]. values. Moreover, the time window reduction ensures that
The reduced time windows [a ryl , b ryl ], 0 ° l ° q are the function is well defined, since the linear program that
obtained recursively, as follows: defines the value of the function is always feasible. This
function definition also permits one to prove piecewise
a ry0 Å ay0 , a ryl/1 Å max(ayl/1 , a ryl / tyl,yl/1 ), linearity and convexity. Consider the parametric right-
hand side problem obtained by setting T Å a ryq / u in
l Å 0, 1, . . . , q 0 1, (11) constraint (18), where u is a real parameter taking values
r r r in [0, b ryq 0 a ryq ]. As u moves within this range, the
b Å by q , b Å min(byl , b 0 tyl,yl/1 ),
yq yl yl/1
function f P (a ryq / u ) is piecewise linear and convex, as
l Å q 0 1, q 0 2, . . . , 0. (12) it represents the optimal value of a minimization linear
program (this result is found in [16]). Since each piece
With this notation and the above comments, the schedule of the function corresponds to the simplex basis for the
optimization problem for path P is written as the following current optimal solution, the function contains a finite
linear program: number of linear pieces. These results are summarized in
the following theorem and illustrated in Figure 1(top).
q
Minimize ∑ lylTyl (13)
Theorem 1. The node cost function f P of path P is
lÅ0
piecewise linear and convex over [a ryq , b ryq ] and contains
subject to: a finite number of linear pieces.

P
Tyl / tyl,yl/1 ° Tyl/1 , 0°l°q01 (14) yq be the smallest time value at which f (T )
Let t*
reaches its minimum. Let
a ryl ° Tyl ° b ryl , 0 ° l ° q. (15)
{argminT √ [ a ry ,b ry ] f P (T )} (20)
This formulation, while found in [9], can also be derived q q

from the previous formulation (1) – (8) of problem


SPPTWTC by fixing the flow variables on the arcs of be the set points that minimize function f P and let t* yq be
path P at 1, fixing all the other flow variables at 0, and the smallest value in this set. Obviously, the point at
ending the path at node d Å yq . which a convex piecewise linear function reaches its mini-
Note that when the linear node costs are positive for mum value is not unique if and only if the function con-
all nodes in a path, it is optimal to visit nodes as early tains a segment of zero slope. For T õ t* yq function f is
as possible. By the same token, when the linear node strictly decreasing, while it is nondecreasing for T
costs are negative for all nodes in a path, it is optimal to ú t* yq . It follows that starting the service at node yq at
visit nodes as late as possible. Thus, when nodes with time T ú t* yq costs more than starting it at time t*yq (and
negative costs precede nodes with positive costs in a path, waiting eventually up to T ). Since the objective is to find
a compromise must be made between service start times. the minimum-cost path, the nonnegative slope segments
are useless. Therefore, they can be replaced by a single
Definition. The node cost function, f P , for path P, for T zero slope piece, as depicted in Figure 1(bottom). This
√ [a ryq , b ryq ], is given by gives rise to a new node cost function definition:
q
f P (T ) Å Minimize ∑ lylTyl Definition.

H
(16)
lÅ0 f P (T ), a ryq ° T õ t*
yq
P
g (T ) Å (21)
subject to: f P (t*
yq ), t* r
yq ° T ° b y q .

Tyl / tyl,yl/1 ° Tyl/1 ,


(17) As illustrated in Figure 1, point t* yq defined by (20) is
0°l°q01 the absolute minimum of the cost functions f P and g P at
node yq . We give next some properties of function g P .
Tyq Å T (18) By definition, the function inherits some of the properties
given in Theorem 1 for function f P . Therefore, function
a ryl ° Tyl ° b ryl , g P (T ) is piecewise linear, convex, and nonincreasing on
(19) [a ryq , b ryq ]. To describe the function, we need the coordi-
0 ° l ° q 0 1. nates of its breakpoints. For p / 1 such points, g P is

/ 8U1F$$0810 03-25-98 12:16:05 netwal W: Networks 810


SHORTEST PATH PROBLEM WITH TIME WINDOWS 197

Fig. 1. Representation of the cost functions f P and g P .

described by the set {(t ykq , g P (t ykq ))É1 ° k ° p / 1}, To gain a better understanding of the nature of the cost
where p represents the number of pieces of function g P . function, we consider a brief example of a path that visits
According to the properties of function g P , we have three nodes. For this particular path, the example proposes
a simple method to obtain the node cost function. Figure
2 illustrates the process.
p /1
a ryq Å t 1yq õ t 2yq õ rrr õ t pyq Å t*
yq ° t y q Å b ryq , (22)

Example 1. We analyze the cost function for the path


g P (t 1yq ) ú g P (t 2yq ) ú rrr ú g P (t pyq ) {o, 1, 2}. Let a1 Å 4, b1 Å 15, a2 Å 12, b2 Å 24 and t12
(23) Å 5, l1 Å 03, l2 Å 1. Also, let lo Å to ,1 Å co ,1 Å c12
Å f P (t* P p/ 1
yq ) Å g (t yq ). Å ao Å bo Å 0. Note that the time windows are already
reduced at node 1. Following the definition of function
g, we compute g { o ,1} (T ) Å l1T Å 03T for 4 ° T ° 15,
These p / 1 points define p linear pieces of the cost which reaches its minimum value at t 1* Å 15. We next
function. The associated slopes are given by shift this function to the right by t12 Å 5 units and add a
zero slope segment of value g { o ,1} (t *
1 ) between times
t*
1 / t12 and max(b1 / t12 , b2 ). Let g̃
{ o ,1,2 }
denote the
m 1yq õ m 2yq õ rrr õ m p0
yq
1
õ m pyq Å 0. (24)
shifted function:

r P
yq Å b yq , then function g has in fact only p 0 1 pieces,
If t*
since the last two breakpoints in the function description g { o ,1} (T 0 t12 ) Å 03T / 15,
are identical and the last piece, with slope m pyq Å 0, is a 9 ° T õ 20,
single point. Otherwise, for t* r
yq õ b yq , the cost function
gI { o ,1,2 } (T ) Å (25)
has p linear pieces, the last one of which has slope m pyq g { o ,1} (15) Å 045,
Å 0. 20 ° T ° 24.

/ 8U1F$$0810 03-25-98 12:16:05 netwal W: Networks 810


198 IOACHIM ET AL.

Fig. 2. Representation of the cost functions in Example 1.

Next, we add the linear node cost l2T for node 2 and
compute g { o ,1,2 } (T ) Å H 02T / 15, 12 ° T õ 20,
025, 20 ° T ° 24.
(27)

02T / 15,
The function g { o ,1,2 } thus obtained has two linear pieces.
9 ° T õ 20,
gI { o ,1,2 } (T ) / l2T Å gI { o ,1,2 } (T ) / T Å
T 0 45, By Theorem 1, the minimum-cost service start time at
a node along the path can easily be found when the func-
20 ° T ° 24. tion’s description is known.
(26) We next give a second theorem summarizing the im-
portant properties of the node function g P . The proof of
To obtain the cost function g { o ,1,2 } , we now have to find the theorem also provides a method to construct this
the value tH 2* Å 20 at which the function g̃ {o ,1,2} (T ) / l2T node cost function when a path is extended from node
reaches its minimum. Then, following the definition of i to node j .
function g, all pieces beyond tH 2* are replaced by a single
zero slope piece; finally, the resulting function is re- Theorem 2. The node cost function g P (T ), for a ryq ° T
stricted to the reduced time window at node 2. This gives ° b ryq , of a path P visiting q nodes is piecewise linear,

/ 8U1F$$0810 03-25-98 12:16:05 netwal W: Networks 810


SHORTEST PATH PROBLEM WITH TIME WINDOWS 199

convex, and nonincreasing and contains at most q linear be the set of time values that minimize the above function.
pieces, ∀q ¢ 1. Next, define tH *
j to be the smallest of these values. Since

Proof. The piecewise linear, convex, and nonincreas- this latter function is also piecewise linear, it follows that
ing properties of the function are a direct consequence of all pieces starting after time tH j* have nonnegative slopes.
the definition of the function. We prove the last part by From the definition of function g P , all pieces with a non-
mathematical induction on q, the number of nodes in the negative slope are replaced by a single piece with a zero
path (excluding the source node o). We first verify the slope. Therefore, several pieces may be deleted at node
result for q Å 1. The node cost function then has only j because of new positive slopes, thus reducing the num-
one linear piece of zero slope if ly1 ¢ 0 (in which case ber of pieces of the new cost function. At the third step,
r the domain of function g P is restricted to [a rj , b rj ], where
y1 Å a y1 ) or one linear piece of negative slope if ly1
t*
r r
a rj Å max(a ri / tij , aj ), b rj Å bj , thus providing the final
õ 0 (in which case t* y1 Å b y1 ). Indeed, for a y1 ° T description of function g P . We obtain
r
° b y1 ,

g P (T ) Å H
r
ly1a , if ly1 ¢ 0,
y1
(28)
P
g (T ) Å H gI P (T ) / lj T, a rj ° T ° t*
gI P (t*
j ),
j ,

r
j ° T ° bj ,
t*
(31)

ly1T, if ly1 õ 0.

and
Since the theorem holds for q Å 1, assume that the result
true for a path with q 0 1 nodes. To simplify the notation,
let i Å yq01 and j Å yq . By the induction hypothesis, a rj , if a rj ú tH *
j ,

function g P " { j } has at most q 0 1 linear pieces. The con- tH j* , if a rj ° tH j* ° b rj ,


j Å
t* (32)
struction of g P is next given in three steps: shifting g P " { j }
by tij units to the right; adding the linear node cost lj T b rj , if b rj õ tH *
j .
and computing the new nonpositive slopes; and restricting
the resulting function to the interval [a rj , b rj ]. Thus, the restriction of the function to the feasibility range
Note that when extending the path from node i to node at node j can only further reduce the number of pieces in
j we can only assume that the time windows are reduced the node cost function. Therefore, the result is proven for
according to (11) and (12) with respect to path P " { j}, paths with q nodes, ∀q ¢ 1. j
up to node i. At the first step, the function is shifted as
follows: Step 2 of the proof gives a method to compute the new
slope for pieces at node j, after the node cost lj T is added
to the shifted cost function. Indeed, since all pieces with
g P " { j } (T 0 tij ), t 1i / tij ° T
a nonnegative slope are replaced by one segment with
õ t*
i / tij ,
zero slope, we have
gI P (T ) Å P" { j }
(29)
g (t* i / tij ° T
i ), t* m jk Å min(m ik / lj , 0), 1 ° k ° p. (33)
° max(b ri / tij , bj ).
Using the notation of the proof, note that m jk Å 0 for all
k satisfying t ik / tij ¢ tH *
j . A second consequence of this
The shifted function g̃ P is defined at node j for t 1i / tij
theorem is an additional property for the node cost func-
° T ° max(b ri / tij , bj ). Since t* r
i ° b i , it has the same
tion f P , which was studied in Theorem 1. For path P,
P" { j } r
number of pieces as g i õ b i , while one more
if t*
r
function f P also has at most q linear pieces. Indeed, note
piece of zero slope is added if t* i Å b i and t* i / tij õ bj . that steps 1 and 3 of the proof of Theorem 2 also apply
Hence, the number of linear pieces of g̃ P is at most q. for function f P . However, step 2 does not apply, since
To complete the proof, note that the next two steps in pieces with a nonnegative slope are retained in this func-
the construction of the node cost function g P can only tion’s representation. Hence, Theorem 2 gives a stronger
reduce the current number of pieces of g̃ P . At the second result, since the number of pieces of function g P is even
step, the new slopes of function g P are computed by add- smaller than the number of pieces of f P . Since the dy-
ing the node cost lj T to g̃ P (T ) and by retaining only those namic programming algorithm uses function g P , we chose
pieces with a nonpositive slope. The addition of the linear to formulate the theorem for this function.
node cost gives the function g̃ P (T ) / lj T, for t 1i / tij Let i Å yq01 and j Å yq denote the second-last and last
° T ° max(b ri / tij , bj ). Let nodes of path P. We next discuss situations leading to an
increase or decrease in the number of pieces in the cost
{argminT √ [ t 1i /tij,max (b ri/tij,bj ) ] (gI P (T ) / lj T )} (30) function when path P " { j} and its associated cost function

/ 8U1F$$0810 03-25-98 12:16:05 netwal W: Networks 810


200 IOACHIM ET AL.

g P " { j } are extended to node j. The proof of Theorem 2 rem 2 gives the complexity of the proposed node cost
suggests three situations which decrease the number of function construction method, which is of O(n 2 ), for a
pieces. First, pieces can be eliminated at the beginning path visiting n nodes. Recall that Dumas et al. [9] pro-
of g P , because of aj . Second, pieces can be eliminated at posed an O(n) complexity algorithm to find the optimal
the end of the function because of new positive slopes. path schedule. Our method is more complex because the
Finally, pieces can also be eliminated at the end of the node cost function is fully described at each node of the
function because of the value of bj . These three cases are path. This information is essential in the path construction
formally described next. process used in the dynamic programming algorithm,
which is described in the next section.
CASES 1–3. Let i and j denote the last two nodes of path
P, with i Å yq01 and j Å yq . The extension of this path
from node i to node j eliminates at least one piece if
4. A DYNAMIC PROGRAMMING
1. ∃k √ [2, p] such as t ik / tij ° aj . ALGORITHM FOR SPPTWTC
i Å bi , ∃k √ [1, p 0 2] such as m i / lj ¢ 0;
2. If t* k

An integer optimal solution for the SPPTW can be found


i õ bi , ∃k √ [1, p 0 1] such as m i / lj ¢ 0.
k
if t*
by dynamic programming [3, 4, 7]. These algorithms
i Å bi , ∃k √ [1, p 0 1] such as t i / tij ¢ bj ;
3. If t* k
iteratively construct paths starting at node o until node d
i õ bi , ∃k √ [1, p] such as t i / tij ¢ bj .
k
if t* is reached. Throughout these algorithms, each path is la-
beled with its service start time at the last visited node
Alternatively, the extension can increase the number and its cost, i.e., the sum of the arc costs. Dominance
of pieces by at most one, and the new piece is added as among paths arriving at the same node is determined by
a last piece of function g P . defining a partial order relation between labels of the form
(time, cost). Only the minimal elements of the label set
CASE 4. Let i and j denote the last two nodes of path P,
are kept following this determination, as only they may
with i Å yq01 and j Å yq . The extension of this path
be retrieved among the labels of the optimal path. This
from node i to node j adds one piece at the end if t*
i
dominance process reduces the number of labels kept
Å b ri , t*
i / tij õ bj and t*
j √ {t*
i / tij , bj }.
during the iterations of the algorithm, so that problems
of large size can be solved. Recall that SPPTW is equiva-
Next, Theorem 3 shows how to use the node cost func-
lent to the particular case of our shortest path problem
tions to obtain the optimal path schedule. Let t oyl , 1 ° l
with time windows and linear costs on the service start
° q, denote the time values of the optimal path schedule, times when li Å 0, ∀i √ V.
i.e., an optimal solution of (13) – (15). We show that if In our problem, new labels and a new dominance pro-
ai , bi , and tij are integer ∀i, j √ V, then the linear program cedure must be defined to account for nonzero values of
(13) – (15) has the integrality property. the linear node costs li , i √ N. Before formally describing
the dynamic programming algorithm, we discuss the im-
Theorem 3. If ai , bi , and tij are integer, ∀i, j √ V, then pact of the node cost function on the path construction
the time values t oyl , 1 ° l ° q, of the optimal path schedule process. We showed that, in the presence of linear node
are integer. costs, the cost of a path P ending with node i is given by
Proof. Note that the cost function construction method the cost function g P . The case of three paths ending at
shows that the time components of the breakpoints are the same node i is depicted in Figure 3(top). The associ-
integer if ai , bi , and tij are integer, ∀i √ V. As a result, ated cost functions are g P1 , g P2 , and g P3 . Performing dom-
inance at node i involves keeping only the best paths. As
yl , 1 ° l ° q are integer. The optimal schedule is obtained
t*
depicted in Figure 3(bottom), each path dominates the
recursively as follows:
others on certain intervals in the time window, and the
resulting dominance function contains pieces of all three
t oyq Å t*
yq (34) cost functions.
Let P1 , P2 , . . . , Ps denote s paths ending at node i and
t oyl Å min(t* o
yl , t yl/1 0 tl ,l/1 ),
let t 1i ( Pl ) denote the time component value of the first
(35)
for l Å q 0 1, q 0 2, . . . , 0. breakpoint of path Pl , 1 ° l ° s. We have to determine
dominance relations among all these paths. Doing so
It follows that the time values t oyl , 1 ° l ° q are also means finding a new function Gi defined by
integer. j
Gi Å min(g P1 , g P2 , . . . , g Ps ), (36)
Therefore, the optimal schedule is a byproduct of the
node cost function construction method for a path. Theo- where Gi : [min(t 1i ( Pl )É1 ° l ° s), bi ] r R, that is the

/ 8U1F$$0810 03-25-98 12:16:05 netwal W: Networks 810


SHORTEST PATH PROBLEM WITH TIME WINDOWS 201

Fig. 3. Dominance between several paths.

time interval between the earliest path start time at node not be all integers, even when ai , bi , and tij are integers
i and the end of the time window, bi . The function Gi ∀i √ V. These noninteger breakpoints cannot be found
thus defined is the minimum of all cost functions of paths in the optimal schedule of the shortest path, according to
arriving at node i and is called the dominance function. Theorem 3. Thus, in the representation of function Gi , i
As the function is a minimum of piecewise linear and √ V, each noninteger time value of a breakpoint is going
nonincreasing functions, it has these two properties as to be replaced by the next integer in the time window.
well. Nevertheless, Gi is not necessarily convex nor con- By its definition, the dominance function Gi , i √ V,
tinuous, while functions g Pl , 1 ° l ° s are both convex can be described by a list of breakpoints and the associ-
and continuous. These properties are summarized in the ated slopes {(t ik , Gi (t ik ), m ik )É1 ° k ° ri }, where ri
next proposition: denotes the number of linear pieces of function Gi . The
worst-case value of ri is equal to bi 0 ai / 1. Each
Proposition. Function Gi is piecewise linear and nonin- breakpoint of function Gi defines a label in our dynamic
creasing, but not necessarily convex or continuous, ∀i √ V. programming algorithm.
A basic operation in dynamic programming shortest
We study next the breakpoints of function Gi . As path algorithms is the treatment of a label. Let G 01 ( j)
shown in Figure 3, the breakpoints of function Gi may denote the set of predecessors of node j, and for i

/ 8U1F$$0810 03-25-98 12:16:05 netwal W: Networks 810


202 IOACHIM ET AL.

√ G 01 ( j), let wij denote the label extension function. A 5. COMPUTATIONAL RESULTS
label (t ik , Gi (t ik ), m ik ) is extended at node j into a new
label given by To evaluate our algorithm, we performed two types of
tests: First, we solved several test problems with the pro-
posed dynamic programming algorithm. Second, we com-
wij (t ik , Gi (t ik ), m ik ) pared it with a shortest path algorithm based on discretiza-
tion. We implemented both our algorithm and the discreti-
zation-based algorithm in the C programming language;
(max(aj , t ik / tij ), Gi (t ik ) / lj max(aj , t ik / tij )
tests were run on a SUN SPARC station 2 (28.5 Mips,
Å / cij , min(0, m ik / lj )), if t ik / tij ° bj , 4.2 Mflops).
f, otherwise.
5.1. Results of the Proposed Dynamic
Programming Algorithm
When extending a label, we compute the new label time
value and check the feasibility, the new cost, and the new To test our algorithm, we used 15 test problems, involving
slope at node j. acyclic networks with time windows and positive arc
Since the network is acyclic, we assume that the nodes costs. These were selected from the bench-mark problem
are numbered in topological order. Let node d be num- sets developed in [17]. The original data was transformed
bered as n / 1. Let EFF denote an operator on a label into acyclic networks before solving. Our test problems
set that finds the minimum of several piecewise linear are available upon request. The node costs were randomly
functions. generated using an uniform distribution U[ 05, 5]. Sev-
eral characteristics of the test problems such as the node
number, the arc number, the average time window length,
A Dynamic Programming Algorithm for SPPTWTC and the average arc duration are provided in the first four
columns of Table I. Note that the problem size increases
up to problems with 700 nodes and 80,000 arcs.
Initialization: (t 1o , Go (t 1o ), m 1o ) Å (ao , loao , 0); r0 Å 1. The results of the dynamic programming shortest path
Main step: For j Å 1 to n / 1 do problem with node costs are given in Table I. To analyze
Treatment of node j: the results, several statistics on the sink node were calcu-
Gj Å EFF( < < wij (t ik , Gi (t ik ), m ik )); lated. Thus, the next three columns of the table present
01
i√G (j ) 1°k°ri
Compute r j . the time window width at this node, the number of non-
End of algorithm. dominated labels, and the average number of nodes for
the paths corresponding to these labels. Note that the time
window width at the sink node is much larger than the
We initialize the label of node o. Then, all nodes are average time window width. This shows that a potentially
treated in topological order until we reach node d (num- large number of nondominated labels may be present at
bered n / 1) and each node is treated only once. The this node. Note also that the number of labels increases
treatment of node j is made in two stages: First, the labels with the number of arcs. To compute the number of nodes
of its predecessors are extended to node j. Second, the in the path corresponding to a given label, we backtrack
dominance function Gj at node j is obtained by taking the from the nondominated labels at the sink node. The last
minimum of the extended labels. The number of pieces column of Table I contains the running CPU times. All
in function Gj is computed at the same time to obtain the execution times are less than 8 seconds, except for the
value of r j . The algorithm terminates when all nodes are largest problem, which takes 21 seconds.
treated. The cost of the shortest path is given by the
minimum value of function Gn/1 .
5.2. Comparison with a Partial Discretization
To compute the complexity of this algorithm, note first
Approach
that each node is treated only once since the network is
acyclic. The number of operations to perform during the In a second test, we compared our dynamic programming
treatment of each node depends on the worst-case value algorithm with an alternative algorithm, consisting of a
of ri , for i √ V. Consider the acyclic discretized network discretization of the time windows. This can be done by
obtained by creating bi 0 ai / 1 copies of each node i, creating bi 0 ai / 1 copies of each node i, i √ V and
i √ V and by retaining all the feasible resulting arcs. In by keeping all the feasible resulting arcs. Each node in
the worst case, our algorithm does as many operations this new network has a fixed schedule and the node cost
as an acyclic shortest path algorithm on the discretized becomes a constant which can be added to the arc costs.
network. Thus, the worst-case complexity of the algo- To find the shortest path in this new network, one can
rithm is O(( Si √ V (bi 0 ai / 1)) 2 ). use the algorithm of Fulkerson [11] for acyclic networks.

/ 8U1F$$0810 03-25-98 12:16:05 netwal W: Networks 810


SHORTEST PATH PROBLEM WITH TIME WINDOWS 203

TABLE I. Results of the proposed dynamic programming algorithm

Statistics on the sink node


Average Average arc
No. No. TW width duration TW width No. Average no. CPU
nodes arcs (min) (min) (min) labels nodes/path (s)

27 224 105.8 386.9 1609 5 3.0 0.00


33 373 264.5 397.1 1749 37 3.9 0.02
52 812 101.2 399.1 1735 49 4.7 0.03
60 923 259.1 379.7 1900 63 6.0 0.07
77 1636 199.6 410.6 1875 17 5.4 0.08
88 1909 282.1 407.8 1900 64 6.1 0.20
102 3241 100.7 387.2 1832 59 4.3 0.13
116 2991 271.5 405.6 1978 59 6.2 0.37
131 3686 213.3 388.4 1978 93 7.5 0.37
176 7563 173.7 393.0 1875 62 6.4 0.63
206 8403 227.4 412.3 2074 86 6.9 1.03
307 18344 172.8 367.0 1978 221 9.4 3.90
308 17950 227.9 420.6 2100 128 6.9 2.70
489 42625 188.8 391.6 2074 164 9.3 7.98
693 79426 188.6 406.9 2100 303 8.7 20.98

However, the huge size of the resulting networks prohibits and 10% of negative linear node costs were created. Then,
the application of this method for our test problems. This the 15 groups were obtained by reducing the time values
method creates, for the largest test problem, a 15 million by a factor of 1, 3, 5, 10, and 15. The first column lists
arc network. Instead, the solution process of the classical the values of the scaling factor, while the second column
SPPTW was only partially discretized. In fact, if lj is gives the average resulting time window width. The
nonnegative, only the first label must be kept, since it header of the next three columns gives the percentage of
dominates the following ones. Therefore, this partial dis- negative node costs in the respective problem groups. For
cretization is performed only for nodes with negative each of the 10 problems, we computed the ratio between
costs. Furthermore, we reduced the memory requirements the CPU times for the dynamic programming algorithm
with an implementation using the initial networks, a list and of the partial discretization approach and then com-
of labels (time, cost) with integer time values, and a puted the average CPU time ratio of a group. The resulting
modified path extension procedure. When extending a value is indicated in the last three columns of Table II.
path from node i to node j, which incurs a negative node Take, e.g., the first problem group in the second row of
cost, we create one label of type (time, cost) for each Table II, which contains 10 test problems with 50% nodes
integer time value in [aj , bj ] for which the path is feasible. with negative costs and a scaling factor of 3. The average
The dominance is next performed as for the classical CPU time ratio of 0.16 indicates that our dynamic pro-
SPPTW, i.e., on two-dimensional labels. gramming algorithm outperforms the discretization-based
To compare the two approaches, we generated differ- algorithm and is six times faster.
ent percentages of negative node costs and varied the For problems with the original time windows, the new
time values in the problem data. To better analyze the
performance of the two algorithms, we divided the time
values in the initial problem data by a scaling factor. As TABLE II. Ratio of the CPU times
the scaling factor increases, there are fewer discrete points of the dynamic programming algorithm
to consider in the time window of nodes with negative over an approach based on discretization
costs. Note that when dividing by the scaling factor, the
% of negative
resulting time values for the time windows are rounded
linear node costs
to keep the same number of feasible arcs as in the initial Scaling Average
problems. The scaling factor is used to reduce the values factor TW width 50% 25% 10%
of the time-related problem data without changing the
structure of the corresponding networks. 1 204.7 0.02 0.04 0.08
The results are presented in Table II. We used the 10 3 68.9 0.16 0.23 0.34
5 41.5 0.33 0.46 0.76
largest problems in Table I to create 15 groups of 10
10 21.1 0.81 0.90 1.21
problems each. Different groups were obtained first by 15 14.5 1.20 1.28 1.59
changing the node costs, so that problems with 50, 25,

/ 8U1F$$0810 03-25-98 12:16:05 netwal W: Networks 810


204 IOACHIM ET AL.

dynamic programming algorithm strongly outperforms labeling algorithm for the shortest path problem with
the discretization-based approach. As expected, for large time windows. INFOR 26 (1988) 191–212.
values of the scaling factor when the time windows are [4] M. Desrochers and F. Soumis, A reoptimization algo-
narrow, the partial discretization algorithm is faster than rithm for the shortest path problem with time windows.
the dynamic programming approach, since the label struc- Eur. J. Oper. Res. 35 (1988) 242–254.
ture is simpler and the dominance process is faster. How- [5] J. Desrosiers, Y. Dumas, M. Solomon, and F. Soumis,
ever, this only occurs for four groups of problems among Time constrained routing and scheduling. Handbooks in
Operations Research and Management Science, Vol. 8
the 15 considered. Nevertheless, the proposed dynamic
Network Routing, (M. O. Ball et al., Eds.). Elsevier
programming algorithm proves better for wide time win- Science, Amsterdam (1995) 35–139.
dows, even when the number of negative node costs is
[6] J. Desrosiers, J.-A. Ferland, J.-M. Rousseau, and L.
small. Chapleau, TRANSCOL: A multi-period school bus rout-
ing and scheduling system. TIMS Stud. Mgmt. Sci. 22
(1986) 47–71.
6. CONCLUSIONS [7] J. Desrosiers, P. Pelletier, and F. Soumis, Plus court
chemin avec contraintes d’horaire. RAIRO 17 (1983)
This paper proposed an algorithm to solve the shortest 357–377.
path problem with time windows and additional linear [8] M. Dror, Note on the complexity of the shortest path
costs on the node service start times, denoted SPPTWTC. models for column generation in VRPTW. Oper. Res.
42 (1994) 977–978.
This problem has numerous applications: e.g., aircraft
[9] Y. Dumas, J. Desrosiers, and F. Soumis, Optimizing the
routing and scheduling and job-shop scheduling. To opti-
schedule for a fixed vehicle path with convex inconve-
mally solve SPPTWTC, we developed a dynamic pro- nience costs. Trans. Sci. 24 (1990) 145–151.
gramming algorithm based on a deep analysis of the cost
[10] J.-A. Ferland and L. Fortin, Vehicle routing with sliding
structure. To prove the efficiency of the proposed method, time-windows. Eur. J. Oper. Res. 38 (1989) 359–378.
we compared it with an approach based on partial discreti- [11] D. R. Fulkerson, Flow networks and combinatorial oper-
zation of the time windows. The new algorithm clearly ations research. Perspective on Optimization (A. M.
outperformed the discretization approach on test problem Geoffrion, Ed.). Addison-Wesley, Reading, MA (1972)
groups with wide time windows and many nodes with 139–171.
negative costs. This first optimal algorithm for SPPTWTC [12] S. Gélinas, Problèmes d’ordonnancement. PhD Disserta-
should, consequently, increase the number of applications tion, École Polytechnique de Montréal, Canada (1996).
in the near future. [13] I. Ioachim, Algorithmes pour la planification d’itinér-
aires d’avions. PhD Dissertation, École Polytechnique
This research was supported by the Quebec Government de Montréal, Canada (1995).
(Fonds pour la Formation de Chercheurs et l’Aide à la Recher- [14] T. Sexton and L. Bodin, Optimizing single vehicle many-
che, and the SYNERGIE program of Fonds de Développement to-many operations with desired delivery times: I. Sched-
Technologique) and by the Natural Sciences and Engineering uling. Trans. Sci. 19 (1985) 378–410.
Research Council of Canada. [15] T. Sexton and Y. Choi, Pickup and delivery of partial
loads with time windows. Am. J. Math. Mgmt. Sci. 6
(1986) 369–398.
[16] M. Simonnard. Programmation linéaire. Tome 1, Du-
REFERENCES nod, Paris (1972).
[17] M. M. Solomon, Algorithms for the vehicle routing and
[1] A. De Palma, P. Hansen, and M. Labbé, Commuters’ scheduling problem with time window constraints. Oper.
paths with penalties for early or late arrival time. Trans. Res. 35 (1987) 254–265.
Sci. 24 (1990) 276–286. [18] M. M. Solomon and J. Desrosiers, Time window con-
[2] M. Desrochers, J. K. Lenstra, M. W. P. Savelsbergh, and strained routing and scheduling problems. Trans. Sci. 22
F. Soumis, Vehicle routing with time windows: Optimi- (1988) 1–13.
zation and approximation. Vehicle Routing: Methods [19] G. Ulusoy and U. Bilge, A time window approach to
and Studies (B. Golden and A. A. Assad, Eds.). North- simultaneous scheduling of machines and material han-
Holland, Amsterdam (1988) 65–84. dling system in an FMS. Oper. Res. 43 (1995) 1058–
[3] M. Desrochers and F. Soumis, A generalized permanent 1070.

/ 8U1F$$0810 03-25-98 12:16:05 netwal W: Networks 810


View publication stats

You might also like