A generalized shortest path tour problem with time windows

This paper studies a generalization of the shortest path tour problem with time windows (GSPTPTW). The aim is to find a single-origin single-destination shortest path, which has to pass through an ordered sequence of not necessarily disjoint node-subsets. Each node has a time window for each node-subset to which it belongs. We investigate the theoretical properties of GSPTPTW and propose a dynamic programming approach to solve it. Numerical results collected on a large set of new benchmark instances highlight the effectiveness of the proposed solution approach.


Introduction
The Shortest Path Tour Problem (SPTP) is a constrained version of the Shortest Path Problem (SPP), and it was firstly introduced in [1]. Disjoint subsets of nodes T 1 , … , T N characterize SPTP, which aims at finding a shortest path from a source node s to a destination node d, where a solution path must visit the disjoint subsets the different best shooting hours. Moreover, a courier has to deliver parcels to several customers with different time availability in the same place (for example in a condominium). In this case, the subsets represent the possible availability of the customers to pick up the parcels, modeled as time windows, and the nodes represent the customers. Thus, a node can be included into several subsets, modeling the different time availability of the customer to pick up the parcels. One can also consider a courier that has to deliver parcels to several intermediate depots of the same company. Each depot can pick up the parcels in different time slots. Thus, we can model the different time slots as subsets T k and put into each subset the depots open in the associated time slot. The courier chooses the depot to deliver the parcels among all the open ones for each time slot.
The contribution of the paper is threefold. (1) We analyze the theoretical properties of GSPTPTW, proving that GSPTPTW has the same complexity as SPTPTW. It is a non-trivial result since relaxing the assumption on disjoint subsets the generalized problem maintains the same complexity of the more constrained variant. (2) We retrieve a polynomial procedure to transform any instance of GSPTPTW to an instance of SPTPTW. This result allows us to use solution approaches developed for SPTPTW to address GSPTPTW. (3) We define a solution strategy to directly solve GSPTPTW by exploiting a dynamic programming reformulation of GSPTPTW. The collected numerical results underline that solving GSPTPTW directly, by using the proposed dynamic programming approach, is more efficient than solving the corresponding SPTPTW, with the state-of-the-art algorithm proposed in [12].
Hence, the present work completes the theoretical study carried out for the SPT-PTW in [12]. Indeed, this paper and [12] represent together an overall overview on both theoretical and application aspects related to SPTP with time restrictions.
The paper is organized as follows. In Sect. 2, the problem is formally described. Section 3 presents the proposed solution approach based on dynamic programming. Section 4 shows the computational results carried out considering several network topologies. Finally, Sect. 5 concludes the paper providing some directions for future research.

The generalized shortest path tour problem with time windows
GSPTPTW is defined on a directed graph G(V, A), where V is the set of n nodes and A = {(i, j) ∈ V × V|i, j ∈ V ∧ i ≠ j} is the set of m arcs. Let s, d ∈ V be the source and the destination nodes, respectively. Subsets T k ⊆ V, k = 1, … , N are given. Let T = ⋃ N k=1 T k ⊆ V be the set of nodes included in at least one subset T k , k = 1, … , N . In SPTP and its variant with time windows, the subsets T k are disjoint, i.e., T h ∩ T l = �, ∀h, l = 1, … , N, h ≠ l . In GSPTPTW the disjunction constraint is relaxed, and this means that a node can belong to several subsets T k . Without loss of generality, we assume that T 1 = {s} and T N = {d}.
A non-negative cost c ij and a non-negative transit time t ij are associated with each arc (i, j) ∈ A . A service time s k i and a time window e k i , l k i is associated with each node i ∈ T k , where e k i and l k i are respectively the earliest and the latest feasible arrival time to node i when it is used to serve subset T k .
Given two distinct nodes i 1 and i v , a path i 1 i v = ⟨i 1 , … , i v ⟩ is an ordered sequence of nodes from i 1 to i v , such that i l , i l+1 ∈ A, l = 1, … , v − 1 . The cost c i 1 i v of the path i 1 i v is defined as the sum of the cost associated with its arcs, i.e., . GSPTPTW aims at finding a path * sd from the source node s ∈ V to the destination node d ∈ V in the directed graph G with the smallest cost. An optimal path * sd must visit sequentially the subsets T k , k = 1, … , N . We note that the subsets T k , k = 1, … , N , must be visited in exactly the same order in which they are defined.
Let i l be the arrival time at node i l , l = 1, … , v , a path sd is said to be a feasible solution for GSPTPTW if it satisfies the following requirements: Nodes i g k , k = 1, … , N , are called service nodes, since they are used to serve the subsets T k , k = 1, … , N , respectively. A subpath i g k i g k+1 , k = 1, … , N − 1 , is part of a feasible path sd and is used to connect service nodes i g k and i g k+1 . On the one hand, it can be composed of not-service nodes, i.e., i g k i g k+1 On the other hand, not-service nodes are not needed to connect i g k and i g k+1 , i.e., Equation (2) force each service node belonging to a path sd to be visited within the time window (waiting at a service node is allowed). In a feasible path, the nodes can be visited more than once. However, N nodes, including the source and the destination, must be service nodes, one for every subset T k , k = 1, … , N and the order imposed by the definition of the subsets must be guaranteed. Thus, a node i, belonging to some subset T k , can be present in a feasible path sd as either a service node or a not-service node. In addition, since a node can be part of several subsets T k , a feasible path can be composed of repeated service nodes. Indeed, a node can be used to serve any of the subsets to which it belongs.
Given a path si , let • k be the index of the first subset T k not served in si ; • i − be the node that precedes node i in si ; • Ψ(j, q) be a binary predicate indicating whether or not node j serves the subset T q in si .
Starting with s = 0 , the arrival time to a service node i g k ∈ si is defined as follows: whereas, the arrival time to a not-service node i is defined by the following equation: When a node i ∈ sd can be used to serve a subset T k , we have to mark i as either a service node or a not-service node. In the former case, we have to consider time window constraint and service time calculating i as Eq. (3). If node i is marked as not-service node, then Eq. (4) is used to determine the arrival time i . Note that when a node i ∈ T is used as not-service node, the time window is irrelevant. Moreover each node i ∈ V ⧵ T is always a not-service node since it does not belong to any subset T k , k = 1, … , N.
For the sake of clarity, Fig. 1 depicts a toy GSPTPTW instance with s = 1 and d = 8 . In this simple example, all transit times and all service times are set equal to 1. The costs are reported on the arcs. The path 1 18 = ⟨1, 2, 3, 4, 5, 8⟩ is a feasible path tour; the node 2 is the service node for T 2 and T 3 , and the node 3 is the service node for T 4 . The cost of 1 18 is c( 1 18 ) = 10 . The instance presents a second feasible path tour 2 18 = ⟨1, 2, 3, 4, 6, 7, 5, 8⟩ . This path is a feasible path tour, because the nodes 2, 6 and 5 are selected as service nodes for sets T 2 , T 3 and T 4 , respectively. The cost of 2 18 is c( 2 ) = 8 , and the solution is optimal. It is worth observing that node 2 belongs to two consecutive sets, i.e., T 2 and T 3 . Hence node 2 can be used as service node for both sets. It exists a feasible solution to GSPTPTW for the instance reported in Fig. 1 that is 3 18 = ⟨1, 2, 2, 3, 4, 6, 7, 5, 8⟩ where node 2 is a service node for both T 2 and T 3 and node 5 is the service node for set T 4 , with cost c( 3 ) = 8.
Since GSPTPTW is a generalization of SPTPTW, each SPTPTW instance is also a particular GSPTPTW instance, where each node belongs to at most one subset. By this consideration, it follows that the proof in [12] to assert the NP-hardness of SPT-PTW still remains valid for GSPTPTW. Therefore, the following result holds: Theorem 1 GSPTPTW is an NP-hard problem. (3)

Fig. 1 A toy example
In addition, we can prove that GSPTPTW is not harder than SPTPTW. ⟩ it is possible to define an instance ⟩ of SPTPTW. The following two properties are verified. Proof First, we describe the steps to construct an instance ⟩ . Let K(v) be the set of indices k such that v ∈ T k and let The following operations can be performed: It follows that the dimension of the instance I is greater than that of I G . In particular, we have It is worth observing that the new nodes v k are linked to the graph through arc (v, v k ) and (v k , v) . This means that to reach node v k , node v must be traversed. Property 1 follows. Indeed, each node v such that |K(v)| > 1 is not present in any T � k , k ∈ K(v) and the duplicated nodes v k of v are added to the associated T � k , ∀k ∈ K(v). Property 2 can be proved as follows.
⇒ Given a feasible path sd for GSPTPTW, it is possible to construct a path ′ sd in G � (V � , A � ) , such that c( � sd ) = c( sd ) . Let K s (v) be the set of indices k for which node v ∈ T k is a service node for the path sd . A feasible path ′ sd for the constructed instance of SPTPTW can be obtained by adding subpaths ⟨v, v k , v⟩ , for all k ∈ K s (v) . Node v is marked as not-service node, since v ∉ ⋃ N k=1 T � k , and the duplicated nodes v k , ∀k ∈ K s (v) are marked as service nodes for the subsets T � k , ∀k ∈ K s (v) . Since t vv k = t v k v = 0 , path ′ sd is feasible with respect to time window constraints. Thus, paths sd and ′ sd represent the same feasible solution. In addition, being c , and let v k be the service node for T ′ k in the path ′ sd .
For each k = 1, … , N , v k may or may not belong to T k in G. In the first case, v k is a service node also for T k . In the second case, v k ∉ T k because there exists in G a node v with |K(v) > 1| and v k has been created during the construction of the instance I. By construction, the path ′ sd must include the sub-path v k = ⟨v, v k , v⟩ , that has both cost and travel time equal to 0. Therefore, the path sd can be obtained replacing v k with the node v that is selected as service node for T k . The path sd remains feasible with respect to the edge traversal constrains, since we are traversing a subset of edges of ′ sd . Moreover, it remains feasible respect to the time windows, since the service time of v is equal to the service time of v k and the travel time ◻ Figure 2 reports the graph G ′ obtained by applying the construction procedure described in Theorem 2 to the toy instance of Fig. 1. Nodes 2 2 ( 6 2 ) and 2 3 ( 6 3 ) are the copies of node 2 (6) associated with subsets T ′ 2 and T ′ 3 , respectively. The dotted arcs are those included to connect node 2 (6) with its copies characterized by both cost and time equal to zero. The optimal solution is * 18 = ⟨1, 2, 2 2 , 2, 3, 4, 6, 6 3 , 6, 7, 5, 8⟩ , with service nodes {1, 2 2 , 6 3 , 5, 8} and cost c( * 18 ) = 8. From Theorems 1 and 2, the following result holds.

Theorem 3 GSPTPTW belongs to the same class of complexity of SPTPTW.
Theorem 3 is a strong result. Indeed, it claims that relaxing the disjoint assumption on the subset T k , k = 1, … , N allows to maintain the same complexity. Thus, assuming that T k , k = 1, … , N , are not disjoint subsets does not compromise the computational effort for solving SPTP and its variants.

Generalized dynamic programming
We represent the solution space of GSPTPTW as a state-space S(Y, Γ) composed of a set of states Y and a set of transitions Γ . Each state y h i ∈ Y corresponds to a feasible subpath h si from the source node s to node i ∈ V . The superscript h means that we consider the (1) and (2)  Let Ȳ be the set of generated states and let M j be the number of states associated with node j. Algorithm 1 depicts the steps to generate the state-space S(Y, Γ) . To handle the case where a node belongs to two consecutive sets, Lines 2-9 insert null cost loops. The introduction of these loops allows to obtain tour of the form 3 18 for the instance reported in Fig. 1.
It is worth observing that the construction of the state-space S(Y, Γ) implicitly determines all feasible solutions. Thus, among all final states, i.e., those associated with the destination node d, an optimal path * sd is associated with that at minimum cost, i.e., * sd = arg min y h d ∈Y c h d . It follows that Algorithm 1 implicitly solves GSPTPTW. Thus, it can be used to determine an optimal solution * sd to GSPTPTW. Algorithm 1 has exponential time and exponential space complexity. However, not all states associated with feasible solutions have to be generated, rather only those with the potential of generating an optimal solution. In the following, we present some state-space reduction techniques that have a positive impact, as shown by the computational results, on the practical behavior of the proposed solution approach.

State-space reduction
The state-space S(Y, Γ) can be reduced by eliminating states whose transitions do not allow to conduct to potentially optimal final states. This reduction can be done by applying the dominance rule proposed by [12], given below for the sake of completion. is not stored in Y. This rule does not compromise the optimality of the final solution determined. Indeed, the same feasible sequence of controls and states is generated starting from equivalent states. In addition, having the same cost, also the final states, associated with complete paths, present the same cost. It is also worth to note that discarding equivalent paths allows to prevent cycling on zero cost and zero time cycles, if any.
In addition, we can extend the cost and time boundings proposed in [12].

Cost bounding
Given an upper bound Λ on the optimal solution cost c( * sd ) , all states by solving the generalized SPTP (GSPTP) where the transit and service times are minimized and the time window constraints are removed. In order to improve the cost bounding, given a state y h i , we can compute a valid lower bound on the cost of a partial path from node i to node d, named lb h i . In particular, it represents the minimum shortest path tour cost to reach the destination node d starting from i. In this case, a state y h i can be omitted if SPT is the minimum cost associated with the generalized shortest path tour without time window constraints from node i serving T k to node d, considering the subsets T k , T k+1 , … , T N , and c ij SP is the cost of the shortest path from node i to node j. Algorithm 2 depicts the steps of the proposed solution approach for solving GSPTPTW.

A * implementation
A * technique [21] is widely used to address constrained and multiobjective shortest path problems [22][23][24]. In this technique, the cost of each state is evaluated by considering an approximate extension that allows to evaluate the cost of a complete solution starting from the partial path associated with the state. The cost of each state y h i is defined as f h i = c h i + g h i , where g h i is the approximation cost from node i to node d. Hence, A * technique allows to better identify states that have the potential to generate the optimal sequence of controls and states. This behavior is observed also for the problem at hand (see Sect. 4.3.1). In our context, a valid approximation cost g h i is represented by the cost of a shortest path tour solution, i.e., g h i can be set equal to lb h i computed in (8).

Computational results
We evaluate the performance of the proposed generalized dynamic programming approach with the aim of showing how the characteristics of the addressed problem influence the behavior of the proposed solution strategy. We compare the solution approach GDPB described in Algorithm 2 for GSPTPTW with DPB, the labelling procedure with cost and time bounding proposed in [12] for solving SPTPTW. In particular, starting from an instance of GSPTPTW, we apply Theorem 2 to construct  an equivalent instance of SPTPTW, then the DPB is used to solve the latter. We also analyze the benefit of using A * technique, proved to be efficient for several instances of SPP, and SPTPTW. The algorithms that implement A * technique are referred in the sequel as GDPBA * and DPBA * .

Implementation details
All the algorithms were implemented in C++, compiled with g++ 9. In addition to Y, to quickly access the labels of each node i, an n-dimensional array D of std::list is used to store pointers to the labels associated with each node. Therefore, when a new state y h i is generated for the node i, the

list D[i] is scanned to check if it exists a label that dominates y h i . If it is not the case, D[i]
is scanned again to mark as dominated all the labels that are dominated by y h i . These dominated labels are removed by D[i] (in constant time since D[i] is a std::list), but they are not removed from Y. Indeed, when the algorithm extracts a label from Y, it checks if the label is marked as dominated and, in this case, it discards the label without analyzing the forward star.

Instances generation
The instances are constructed from the benchmarks for SPTP proposed by [3], who considered three topologies of networks: complete, random, and grid networks. More specifically, the set of networks proposed in [3] is composed of three complete networks, characterized by 100, 300, and 500 nodes, respectively; nine random networks; and six grid networks, whose characteristics (i.e., number of nodes, number of arcs, and density defined as the ratio between the number of arcs and the number of nodes) are reported in Tables 1 and 2, respectively. ⌋ with ∈ 1 3 , 1 2 , 1 . In order to generate the instances for GSPTPTW, we modify the instances for SPTP considering different parameters %T and %n , where • %T ∈ {20, 30, 40} defines the percentage of subsets T whose nodes belong to any other subset. • %n ∈ {20, 45, 60} defines the percentage of nodes shared among the subsets T.
In particular, the conversion procedure takes as input an instance of SPTP and gives as output an instance of GSPTPTW applying the following modifications: • for all h = 2, … , N − 1 , randomly pick %n⋅|T h| 100 nodes of T h with uniform probability, and insert them in %T⋅N 100 different subsets T i , i ≠ h; • generate time windows applying the procedure used in [12] for SPTPTW.
The parameters %T and %n characterize GSPTPTW instances. Indeed, for %T = %n = 0 , GSPTPTW instances are actually instances of SPTPTW. Thus, the higher the value of %T and %n, the higher the difference between GSPTPTW and SPTPTW instances.

Numerical results
In this section, we present the numerical results collected on the considered instances. We first analyze the effectiveness of using A * technique (DPBA * and GDPBA * ) with respect to the Dijkstra-like rule (DPB and GDPB). Then, we show the behavior of the proposed algorithms with respect to %T and %n. The behavior of the algorithms is evaluated by considering the following parameters: • tp, the execution time, in seconds, required by the preprocessing. It represents the time needed to compute the bounds for GDPB and GDPBA * , whereas, for DPB and DPBA * , tp is the time to construct the graph by following Theorem 2 and the time to compute the bounds; • ta, the execution time, in seconds, of the dynamic programming algorithm; • t, the overall execution time, i.e., t = tp + ta; • #l, the number of examined states/labels.

Evaluation of A * technique
Preliminaries Before to examine in details the numerical results considering tp, ta, t, and #l, we give an overview of the effectiveness in using A * techniques at varying the network topologies. In particular, in Table 3 we shows the speed up and the number of labels generated without A * over those generated when A * is considered (column l). Table 3 highlights that the highest benefit obtained by using A * technique is observed for grid networks, followed by complete and random ones. In particular, for grid networks, a huge reduction in the number of labels examined is observed. This behavior influences the overall execution time. Indeed, the speed up is 2.04 and 1.55 for DPBA * and GDPBA * , respectively.  Table 4 shows the average values of tp, ta, t, and #l at varying the network topologies. The results collected clearly show the benefit in terms of both execution time and number of generated labels obtained using A * technique. This consideration is valid for both DPB and GDPB.

Detailed results
In particular, DPBA * is 1.56 times faster than DPB, on average. This behavior is justified by the smaller number of generated labels. Indeed, DPBA * shows for #l a value that is 9.09 times lower than the value of #l observed for DPB, on average. The same trend is observed for GDPBA * . In particular, GDPBA * is 1.25 times faster than GDPB, and the former examines 9.48 times less number of labels than the latter, on average. We observe that the A * technique is more performing for DPB than for GDPB. Table 4 highlights the better behavior of GDPB and GDPBA * with respect to DPB and DPBA * , respectively. In particular, GDPB is 1.58 times faster than DPB. This behavior is justified by the number of generated labels. Indeed, GDPB examines 2.15 times less number of labels than DPB, on average. The same trend is observed when A * is applied. In particular, GDPBA * is 1.33 times faster than DPBA * and the former examines 2.16 times less number of labels than those generated by DPBA * . One can readily see that the better performance of GDPB is mitigated when the A * technique is included. However, GDPBA * remains the best performing algorithm.
Due to the high effectiveness of using A * technique, in the following we consider DPBA * and GDPBA * to analyze the behavior of both the algorithms at varying %T and %n. Table 5 shows the average results, varying %T for both DPBA * and GDPBA * . For the sake of clarity, first, we analyze the behavior of DPBA * and GDPBA * separately, then we compare the two algorithms at varying the parameter %T.

Evaluation at varying %T
Results for DPBA * varying %T Table 5 shows that the higher %T, the lower t, on average. Indeed, the overall execution time t for %T = 40 is 1.05 and 1.16 times lower than that observed for %T equal to 30 and 20, respectively. We observe that the preprocessing phase follows an inverted trend. Indeed, it requires more computational overhead for higher value of %T, on average. In particular, tp for %T = 40 is 1.14 and 1.87 times higher than that observed for %T equal to 30 and 20, respectively. This is an expected trend since the higher %T, the higher the number of nodes belonging to different subsets T k . On the one hand, this increases the number of bounds to be computed, on the other hand, more nodes have to be included in the modified graph (see Theorem 2).
The execution time required by the algorithm, i.e., ta, decreases for high value of %T. Indeed, ta for %T equal to 40 is 1.38 and 2.28 times lower than that observed for %T equal to 30 and 20, respectively.
The decreasing of ta for higher value of %T suffices the increasing of tp, thus an overall reduction of computational overhead t is observed for high values of %T.
The higher %T, the higher tp. This trend is observed for each topology of network. Looking at Table 5, the trend of ta at varying %T is strongly influenced by the results obtained on complete network. Indeed, this topology of network is the hardest to solve. In particular, DPBA * requires ta = 25.20 s, whereas, it is equal to 0.37 and 1.13 for random and grid networks, respectively. For random networks, ta follows the same trend of tp, whereas, for grid networks, ta does not follow a regular trend varying %T. The values of ta decrease for increasing values of %T for complete networks. This trend influences the average one.
Results for GDPBA * at varying %T Table 5 shows that the computational overhead of GDPBA * decreases when %T increases. In particular, the value of t when %T is equal to 40 is 1.13 and 1.62 times lower than that observed for %T equal to 30 and 20, respectively, on average. This behavior is influenced by ta. In particular, ta for %T = 40 is 1.42 and 2.36 times lower than that observed for %T equal to 30 and 20, respectively. The observed trend for ta is related to the number of examined labels. Indeed, GDPBA * examines for %T = 40, 1.47 and 1.14 times lower number of labels than those generated with %T equal to 30 and 20, respectively.
The preprocessing execution time follows the same trend observed for DPBA * . Indeed, tp for %T = 40 is 1.22 and 1.73 times higher than that observed for %T equal to 30 and 20. We highlight that for GDPBA * the preprocessing refers only to the computation of the bounds. The decreasing of ta for increasing values of %T is higher than the increasing of tp, thus an overall decreasing of t is observed for high values of %T.
The trend of tp varying %T is the same for each topology of network. Whereas, ta follows the average trend for both complete and grid networks. For the random ones, a clear trend is not observed. Since the most difficult instances to be solved are those based on complete networks, the average trend is influenced by the results obtained for the latters.
Comparing DPBA * and GDPBA * at varying %T Table 5 highlights that GDPBA * outperforms DPBA * for each value of %T. Indeed, GDPBA * is 1.18, 1.39, and 1.47 times faster than DPBA * for %T equals to 20, 30, and 40, respectively, on average. We highlight that the speed up of GDPBA * with respect to DPBA * increases for increasing value of %T. This is an expected trend, since the higher %T, the higher the difference between GSPTPTW and SPTPTW instances. Thus, the tailored algorithm GDPBA * for the GSPTPTW behaves better than DPBA * applied on the SPT-PTW instances constructed from the GSPTPTW ones.
The worst behavior of DPBA * is mainly due to the preprocessing phase. Indeed, tp for DPBA * is 1.68, 1.97, and 1.81 times higher that that observed by GDPBA * for %T equal to 20, 30, and 40, respectively. In addition, considering only ta, GDPBA * behaves the best. In particular, ta for GDPBA * is 1.06, 1.06, and 1.09 times lower than that observed for DPBA * , considering %T equal to 20, 30, and 40, respectively. This behavior is justified by the number of labels examined by GDPBA * . In particular, the latter generates, on average, 1.82, 2.21, and 2.60 times lower labels than those generated by DPBA * for %T equal to 20, 30, and 40, respectively.
The difference between the two approaches are quite impressive for grid networks. In particular, GDPBA * is 2.09, 2.41, and 2.17 times faster than DPBA * and the former examines 2.01, 2.53, and 2.94 times less labels than those generated by the latter for %T equal to 20, 30, and 40, respectively. Table 6 reports the average results at varying the parameter %n for each topology of network.

Evaluation at varying %n
We first analyse the behavior of DPBA * and GDPBA * separately, then a comparison between the two algorithms is provided considering the values of %n. Table 6 shows that the higher %n, the higher the computational overhead. Indeed, t for %n = 60 is 1.15 and 1.13 times higher than the value of t observed for %n equal to 45 and 30, respectively. This behavior is influenced by the preprocessing time. Indeed, the higher %n, the higher tp. An inverted trend is observed for ta. In particular, ta shows the same value for %n equal to both 60 and 45. Whereas, ta for %n = 30 is 1.29 times higher than ta for %n equal to 60. This behavior is justified by the number of examined labels. In particular, DPBA * for %n equal to 60, examines a number of labels 1.11 and 1.15 times higher than those generated with %n equal to 45 and 30, respectively.

Results for DPBA * at varying %n
The trend of tp at varying %n is the same for each topology of network. In particular, it increases when %n increases. This is an expected trend. Indeed, for higher value of %n, on the one hand, a higher number of bounds have to be computed, on the other hand, a higher number of copies of the nodes have to be included in the modified graph.
The profile of ta at varying %n is different for the three topologies of networks. In particular, ta decreases for increases values of %n for complete networks. An clear trend is not observed for both random and grid networks. This behavior is related to the number of generated labels (see column #l of Table 6).
Results for GDPBA * at varying %n The overall computational overhead t seems to not be influenced by the value of %n. Indeed, it is not possible to drawn a trend on average. However, looking at tp and ta, Table 6 highlights a strong correlation between both tp and ta and %n. In particular, tp increases when %n increases. An inverted trend is observed for ta. The latter behavior is justified by the number of examined labels. Indeed, #l for %n equal to 60 is 1.01 and 1.14 times lower than the values of #l observed for %n equal to 45 and 30, respectively.
The average trend is influenced by the behavior of GDPBA * for both complete and grid networks. Indeed, ta increases for lower value of %n due to the increasing of generated labels. The trend is inverted for random networks but the average computational overhead is lower than that observed for both complete and grid networks.
Comparing DPBA * and GDPBA * at varying %n Table 6 shows the better behavior of GDPBA * than DPBA * , see column t. Indeed, the former is 1.07, 2.23, and 2.57 times faster than the latter for %n equal to 30, 45, and 60, respectively, on average.
As observed in the previous sections, the preprocessing for DPBA * requires more computational overhead than that observed for GDPBA * , and the difference of tp between the two algorithms increases for increasing values of %n. This justifies the good behavior of GDPBA * for higher values of %n. However, considering only ta, GDPBA * remains the best performing algorithm. Indeed, we observe a speed up equal to 1.02, 1.03, and 1.03 for complete networks, 2.09, 3.04, and 3.96 for random networks, and 2.53, 3.12, and 3.42 for grid networks, considering values of %n equal to 30, 45, and 60, respectively.

Final remarks
The numerical results highlight the effectiveness of the proposed solution approach tailored for GSPTPTW, i.e., GDPBA * . For high values of both %T and %n, GSPT-PTW instances are more demanding in terms of computational effort to be solved to optimality. Whilst GDPBA * behaves quite similar to DPBA * for low values of both %T and %n, the former remarkably outperforms DPBA * for high values of both %T and %n.

Conclusions and future work
In this paper, we presented the Generalized Shortest Path Tour Problem with Time Windows (GSPTPTW) where the assumption on disjoint subsets T k , k = 1, … , N is relaxed. Thus, each node can belong to different subsets T k and have a possibly different time window associated with each subset it belongs. We prove that GSPT-PTW belongs to the same class of complexity of SPTPTW. This is a strong result since it is possible to consider any definition of subsets T k without compromising the complexity. We also presented a polynomial procedure to reduce a GSPTPTW instance to a SPTPTW instance.
We proposed a dynamic programming algorithm for solving GSPTPTW, named GDPB, and extended the cost and time bounding procedures proposed in [12]. GDPB was compared with DPB, the labelling procedure of [12], which was used to solve SPTPTW instances derived from GSPTPTW instances, by applying the proposed polynomial reduction procedure. In addition, we implemented an A * version of both GDPB and DPB.
We conducted an extensive experimental phase, in order to both study the impact of A * technique and compare the two algorithms. We considered instances generated from benchmarks for SPTP. The results showed that A * technique strongly increases the efficiency of the approaches. Indeed, A * speeds up both GDPB and DPB due to a reduction of the number of generated labels.
The numerical results reveal that GDPB outperforms DPB. This behaviour is justified by the lower computational overhead of both the preprocessing phase and the generalized dynamic programming approach. In addition, the higher the number of nodes belonging to different subsets, the better the performance of GDPB with respect to DPB.
As future work, it could be interesting to study GSPTPTW with uncertain data, using the concept of simheuristics [25] or robust opitmization [26,27].
Funding Open access funding provided by Universitá della Calabria within the CRUI-CARE Agreement.

Data availability
The data and the codes that support the findings of this study are available at the following link: https:// doi. org/ 10. 6084/ m9. figsh are. 12444 791.

Conflict of interest
The authors have no conflict of interests to declare.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article A generalized shortest path tour problem with time windows are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http:// creat iveco mmons. org/ licen ses/ by/4. 0/