On efficient testing of capacity constraints in pickup-and-delivery problems with trailers

Efficient feasibility tests are important in many heuristics for routing problems. This paper considers several variants of pickup-and-delivery problems with trailers. Its contribution consists in the description of constant-time procedures for testing observance of capacity constraints when inserting tasks into routes. It is demonstrated that the presence of vehicles with detachable trailers makes capacity feasibility tests considerably more involved.


Introduction
Pickup-and-delivery problems (PDPs) are concerned with the transport of goods or persons from different origins to different destinations. PDPs come in several variants and have received a lot of attention in the literature (see the surveys by Parragh et al. (2008a), Parragh et al. (2008b), Doerner and Salazar-González (2014), and Battarra et al. (2014)). Whereas vehicle routing problems (VRPs, the special case of the PDP where either all pickups or all deliveries occur at a central depot) with trailers are rather well examined (see the surveys by Prodhon and Prins (2014), Section 3.3, Cuda et al. (2015), Section 4, and the more recent works by Parragh and Cordeau (2017) and Rothenbächer et al. (2018)), PDPs with trailers (PDPTs) are rarely studied in the B Michael Drexl michael.drexl@th-deg.de 1 Faculty of Applied Natural Sciences and Industrial Engineering, Deggendorf Institute of Technology, Deggendorf, Germany literature, despite their practical relevance. Trailers are advantageous as they increase the overall vehicle capacity. However, some locations may be accessible only by a lorry without a trailer, e.g., because of insufficient manoeuvring space. Therefore, special parking and transshipment locations (PTLs) are available where trailers can be parked while lorries visit accessibility-constrained locations. This induces a nontrivial trade-off between an enlarged vehicle capacity and the necessity of making detours to park and reattach trailers, and, as will be demonstrated in this paper, makes capacity feasibility tests considerably more involved.
There are several works on PDPs where vehicles consisting of a tractor and a semitrailer are employed to perform full-load tasks, i.e., where a vehicle can transport only one task at a time (for example, Cheung et al. (2008), Xue et al. (2014), Tilk et al. (2018)), but the author of the present work is aware of only two papers (Bürckert et al. (2000), Drexl (2018)) dealing with less-than-truckload tasks, i.e., the case where more than one task can be on a vehicle at the same time. The present paper is concerned with PDPTs of the latter type.
Heuristics based on neighbourhood search are widely used approaches for solving many different kinds of vehicle routing problem, including the various types of PDPs. A decisive aspect for the performance of such methods is their ability to quickly test the feasibility of an insertion of a customer or task into a route. There are several theoretical papers on efficient feasibility testing, for example, Hunsaker and Savelsbergh (2002), Haugland and Ho (2010), Firat and Woeginger (2011) (dial-a-ride problems), and Masson et al. (2013) (PDP with time windows and transfers).
In a similar vein, the present work deals with efficient testing whether the insertion of a task into a feasible PDPT route at specified positions for the pickup and for the delivery part of the task maintains capacity feasibility of the route. 'Efficient' means that, given auxiliary data which is computed in a preprocessing step that requires quadratic time in the number of tasks on the route, the test itself takes constant time for any pair of positions at which to insert the pickup and the delivery of the task. For testing whether a certain task can be feasibly inserted at all into a certain route, in the worst case, insertion of the pickup must be tried at each position (after the first and before the last one), and insertion of the delivery must be tried at all subsequent positions (ditto). With a naïve procedure that passes linearly over each such tentative enlargement of a route, a test whether a certain task can be feasibly inserted at all takes cubic time in the number of tasks on that route. Consequently, a constant-time test for insertion at specified positions can reduce the one-round time (a term coined by Yagiura and Ibaraki (1999)), i.e., the time for determining the task to insert in one iteration of an insertion heuristic or a local search procedure, by one order of magnitude. The contribution of the present paper consists precisely in the description of such a test for several variants of PDPTs.
The rest of the paper is structured as follows. In the next section, the PDP(T) types of interest in this work are specified. Then, the notation used in the paper and the formal modelling of the different PDPT variants are explained in Sect. 3. Afterwards, Sect. 4 describes how capacities can be tested in linear and in constant time. Section 5 concludes the paper with a summary and an outlook.

PDP variants
Following the PDP classification of Battarra et al. (2014), the problem variants covered in this paper are: • One-to-one problems: each task consists in the transport of a particular commodity from a given pickup location to a given delivery location. The transported commodities are not interchangeable. This is obvious for passenger transport. In goods transport, applications arise, e.g., in letter mail and parcel services as well as full and less-than-truckload forwarding. • One-to-many-to-one problems: each task consists in either the transport of a commodity from a central depot to a delivery location (linehaul tasks) or the transport from a pickup location to the depot (backhaul tasks). Practical applications are common in supplying supermarkets, beverage stores, apparel stores and, above all, in the less-than-truckload business. Several subtypes of one-to-many-to-one problems can be distinguished: -The VRP with mixed backhauls: linehaul and backhaul tasks can occur anywhere on a route. -The VRP with backhauls: all linehaul tasks on a route must be fulfilled before a pickup location of a backhaul task can be visited. In this and the previous subtype, it is possible that a route fulfils only linehaul or only backhaul tasks. -The VRP: the special case where all tasks are either linehaul or backhaul tasks. -The simultaneous PDP: any task location may require a delivery of a good from the depot and a pickup of another good for transport back to the depot; the delivery and the pickup must be performed during one visit.
Note that the goods to be transported in one-to-many-to-one problems may be interchangeable or not. For linehaul tasks, this makes a difference. For example, in soft drink distribution, crates with full bottles are delivered to households, and empty crates are taken back. It is irrelevant whether household A receives crate 1 of a particular soft drink brand and household B receives crate 2 of the same brand or the other way round. By contrast, in freight forwarding of consignments on pallets, each loaded pallet of a linehaul task has a specific destination. For the algorithmic treatment of such problems, these issues do not matter. What counts is that the capacity requirements of each task are taken into account correctly. In reality, however, if goods are not interchangeable, the driver must ensure that the right items are delivered to linehaul customers. • Many-to-many PDPs: goods picked up at a location can be used to fulfil demand at several other locations (e.g., bike-sharing systems, empty container movement, raw milk bulk transports). Mostly, only a single commodity is considered in this problem type. Many-to-many PDPs come in four sub-variants: it may be allowed or forbidden that a vehicle leave or enter the depot with some load.
For all these problem variants, it is sensible to consider the use of vehicles with detachable trailers.

Notation and modelling
The following subsections describe how each of the above PDPT variants is represented by a suitable digraph D = (V , A). This is helpful to understand which insertions of tasks into routes are possible and how capacity feasibility can be tested. In all variants, each task t has a pickup capacity requirement q t p ≥ 0 and a delivery capacity requirement q t d ≤ 0. The vertex set V of D contains a start and an end depot vertex, s and e respectively, one pickup and one delivery vertex for each task, and one vertex for each PTL. The pickup and the delivery vertices are referred to as task vertices. Each vertex v ∈ V has an associated capacity requirement q v ∈ R, which is zero for the depot and the PTL vertices. Moreover, for modelling some of the above PDPT variants, 'artificial' task vertices are used. Each task vertex is visited exactly once in a feasible solution, whereas PTL vertices can be visited more than once. All artificial vertices are reachable with a trailer. The arc set A, in principle, contains one arc for each pair of vertices, and, to model the possibility of consecutive subroutes (definition in next paragraph), there is a loop on each PTL vertex. Some exceptions apply: there is no arc entering s, leaving e, leading from s to a delivery vertex, from a pickup vertex to e, or from a delivery vertex to the associated pickup vertex. Moreover, there are additional restrictions on the arc sets of the different problem variants as specified in the respective subsections below.
Associated with D is a vehicle fleet made up of single lorries and lorry-trailer combinations (LTCs). All vehicles start their routes at s and end them at e. Each vehicle k has a lorry capacity of Q l k and a trailer capacity of Q t k . For single lorries k, Q t k = 0. The route of an LTC consists of the main route, where the lorry pulls its trailer, and zero or more subroutes starting and ending at a PTL where the trailer is parked while the lorry performs one or more pickups and/or deliveries. Several consecutive subroutes can start and end at the same PTL before the trailer is re-coupled and pulled away. If the pickup of a task whose delivery is performed on a subroute has been performed before this subroute, the entire load of the task must be on the lorry at the start of the subroute. This may require a load transfer from a trailer to its lorry when decoupling. In the present paper, it is assumed that such load transfers are possible without restrictions, and that, at pickup locations reachable by trailer, the load to be picked up can be split arbitrarily between a lorry and its trailer.
Although costs and times are not relevant for capacity tests, note that the locations associated with any two vertices u and v determine the distance-dependent costs and the travel times of the arcs (u, v) and (v, u), if these exist, and are therefore relevant for the definition of the objective function and for time-window feasibility tests. With regard to the PDPTs considered here, for non-artificial ('real') vertices, travel costs and times are computed on the basis of the respective physical locations, and artificial task vertices are located at the start or the end depot, as indicated in each case.

The one-to-one PDPT
The one-to-one PDPT is the simplest case. For any task t, the associated pickup vertex has a capacity requirement of q t p > 0, and the delivery vertex requires q t d < 0 capacity units. There is an arc between each pair of vertices, with the exceptions mentioned above.

The VRPT with mixed backhauls
Extending the approach by Ropke and Pisinger (2006) to trailers, this problem type is modelled as follows. Each linehaul task is represented by an artificial pickup vertex located at the central depot and a delivery vertex at the physical delivery location. Similarly, for each backhaul task, there is a pickup vertex at the physical pickup location and an artificial delivery vertex at the depot. For a linehaul or backhaul task t, the capacity requirements of linehaul and backhaul pickup and delivery vertices are q t p > 0 and q t d < 0. The only arcs leading to an artificial pickup vertex come from the start depot vertex or other artificial pickup vertices, the only arcs emanating from an artificial delivery vertex lead to other artificial delivery vertices or to the end depot. There is no arc from an artificial pickup to an artificial delivery vertex.

The VRPT with backhauls
When all linehauls must be performed before any backhaul, the setup described in the previous subsection can be modified as follows. No arc exists from an artificial pickup vertex to a real pickup vertex or from a real pickup vertex to a real delivery vertex. Moreover, it must be ensured that the precedence requirements are not undermined by visiting PTLs; i.e., sequences such as … → linehaul delivery → decoupling → backhaul pickup → coupling → linehaul delivery → … must not be allowed. This can be achieved by storing, for each route, the position of the last linehaul delivery. When an insertion is tested and the pickup vertex is a pickup of a backhaul, i.e., a non-artificial pickup, insertion of this vertex is considered only after the last linehaul delivery position. Similarly, the last insertion position to consider for a non-artificial delivery of a linehaul is after the last non-artificial delivery. Ropke and Pisinger (2006) use a different concept, that of precedences, which is applicable in the presence of trailers as well.

The VRPT
Vehicle routing problems with trailers can be represented as instances of VRPTs with mixed backhauls without requiring further modelling. Ropke and Pisinger (2006) propose the following modelling approach for the simultaneous PDP: each task location requiring a delivery and a pickup is represented by a 'delivery task' and a 'pickup task'. The delivery (pickup) vertex of each pickup (delivery) task is located at the depot. Moreover, the costs of all arcs emanating from a delivery vertex of a delivery task are set to a very high value, except for the arc leading to the pickup vertex of the partner task, which has cost zero. These high-cost arcs are necessary, because otherwise, inserting a single task would be impossible. After inserting a single task, whether a delivery or a pickup task, the next task that is inserted will always be the partner task, because this will remove a high-cost arc and will thus dramatically improve the current solution.

The simultaneous PDPT
An alternative approach that avoids having to create two tasks for each original task, i.e., avoids doubling the instance size, and prevents difficulties with precedences in the presence of PTLs works as follows. Each task t is represented by an artificial pickup vertex located at the start depot and a delivery vertex located where the simultaneous delivery and pickup must occur. The amount to be picked up at the artificial pickup vertex equals q t d , the original amount to be delivered. The actual amount to be delivered at the delivery vertex is set to q t p − q t d , i.e., to (original pickup amount − original delivery amount). This means that delivery vertices with positive capacity requirement are possible (note that the delivery amount of a task is always non-positive), and that there can be different absolute values for the pickup and the delivery amount of a task; see the example in Sect. 4.2.1. No arc exists from a delivery vertex or from a PTL vertex to an artificial pickup vertex.

The many-to-many PDPT
Similar to the modelling of backhauling problems, a task is represented by an artificial vertex located at the depot, and similar to the approach for the simultaneous PDP(T), the absolute values of the pickup and the delivery amount of a task may differ. If the task consists of a pickup (delivery) at a vertex, the artificial vertex is located at the end (start) depot. The capacity requirement at an artificial vertex is zero; its partner vertex has the original positive (if it is a pickup) or negative (if it is a delivery) capacity requirement. The only arcs leading to an artificial pickup vertex come from the start depot or other artificial pickup vertices, the only arcs emanating from an artificial delivery vertex lead to other artificial delivery vertices or the end depot. Moreover, there is no arc from an artificial pickup to an artificial delivery vertex.
Many-to-many PDP(T)s are special in (at least) two respects. First, as mentioned, four sub-variants are possible: it may be allowed or forbidden that a vehicle leave or enter the depot with some load.
When no loading at the start depot is allowed but load may be brought to the end depot, it should be tested in a preprocessing step whether the total load to be picked up is at least as much as the total load to be delivered. If this is not the case, no feasible solution exists. Moreover, on each route, sufficiently many pickups must be performed before any deliveries are possible, and it must be ensured in the capacity tests that the total load of a single lorry or an LTC is always non-negative. Likewise, if it is forbidden to bring load to the end depot, but loading at the start depot is allowed, it should be tested in advance whether the total load to be delivered is at least as much as the total load to be picked up, and one or more delivery tasks must be inserted into an empty route before any pickup task. If it is forbidden that a loaded vehicle leave or enter the depot, a route with one task is necessarily infeasible, and the insertion of a task into a feasible route also makes the route infeasible. This can be handled by allowing (penalized) infeasible solutions in a surrounding algorithm that uses the capacity test. Then, the return value of the test should not be simply 'true' or 'false', but the amount by which the vehicle capacity and/or the zero load balance at the start and/or end depot is/are violated.
Second, many-to-many PDP(T)s are special because they possess the property, rarely encountered in vehicle routing problems, that removing a task from a feasible route can make the route infeasible. This holds true irrespective of whether or not it is allowed to pick up or deliver load at the depot. For example, consider the following route, performed by a single lorry with capacity 100 (the artificial pickup and delivery vertices at the depot are omitted for simplicity): Removing vertex 5 makes the route infeasible even if loading at the depot is allowed. In the present paper, however, the focus is on (feasible) insertions, so issues arising when removing tasks are not discussed further here.

Feasibility tests
Generally speaking, for a route to be feasible regarding capacity constraints, it must be ensured that the vehicle capacity is not exceeded at any vertex, and that enough load can be aboard the LTC (when on the main route) or the lorry (when on a subroute) to satisfy any subsequent negative capacity requirements. Put differently, it must be ensured on the main route and on all subroutes that, when reaching a vertex with positive capacity requirement, the load in the LTC or the lorry plus this positive capacity requirement does not exceed the LTC or the lorry capacity; likewise, when reaching a vertex with negative capacity requirement, enough load must be in the LTC or the lorry to satisfy this capacity requirement. It will become clear in the following that in particular the latter aspect is non-trivial on subroutes and, for the many-to-many PDPT, also on the main route.
The algorithms and data structures presented in this section are extensions of those described in Drexl (2018) for the one-to-one PDPT. The algorithmic descriptions assume that the feasibility of an insertion of a task t with associated pickup vertex p and delivery vertex d, written as t = ( p, d), into a feasible route r = (0, 1, . . . , n − 1, n) which is performed by single lorry or LTC k is to be tested. Vertex p is to be inserted directly after position (zero-based index of the route) h; d is to be inserted directly after position/index i. If p cannot be reached with a trailer, r is performed by an LTC, and the trailer is attached when leaving h, a location triplep = ptl p → p → ptl p corresponding to a new subroute must be inserted after h; similar for i and d. ptl p is a PTL vertex; similar for d. Note that p, d, ptl p , and ptl d are vertices, whereas h and i are indices on a route. However, to simplify notation, when referring to a vertex visited at a certain position on a route, only the index is used: for example, the capacity requirement of the vertex at index i is denoted by q i .
Indices h and i indicate positions in the route before p and d are inserted. Hence, if h == i, then d is to be inserted directly after p, or, if a triplep = ptl p → p → ptl p must be inserted, directly after the triple. If, however, d cannot be reached with a trailer and p is left with the trailer attached or a triplep is to be inserted, then a tripled = ptl d → d → ptl d is inserted. If h == i and p and/or d must be surrounded by a decouple-couple pair, it would also be possible to surround both p and d by one such pair, but this makes no difference for capacity feasibility. Several consecutive subroutes by one LTC lorry at the same PTL are modelled by inserting a decouple-couple pair for each subroute. For simplicity, the vehicle index k is omitted: Q l and Q t are used instead of Q l k and Q t k to denote the lorry and the trailer capacity. The capacity requirements of the task t = ( p, d) to be inserted are indicated by q p and q d . For each problem type, q p and q d are determined from the original capacity requirements of task t as described in Sects. 3.1-3.6. In the pseudocode, the symbol '==' serves as equality operator, '=' is the assignment operator, and 'x += y' is used as shortcut for 'x = x + y'.

Testing capacities in linear time
Testing capacity in linear time for single-lorry routes is simple: the to-be-inserted task is tentatively inserted, one pass over the route is performed, and the capacity requirement at each visited vertex is added to the total load and compared with the lorry capacity, cf. lines 16-20 in Algorithm 1. By contrast, testing capacity in the presence of trailers is not entirely straightforward. The procedure detailed in Algorithm 1 can be used. The procedure covers all problem types considered in this paper, because large parts of the routine apply to all types. As indicated in the pseudocode, lines 2-15 can be omitted for problem types other than many-to-many, and lines 23-30 can be ignored for many-to-many-problems.
For problem types other than many-to-many, it must be known at the start of a subroute how much load must be in the lorry to be able to perform the deliveries whose pickups are not on this subroute. This information is gathered in one forward pass over the route (lines 23-30) and stored in an array LoadDeliveredButNotPickedUpOnSubroute. Note that, in practice, it is not sufficient to have the correct amount of load in the lorry at the start of a subroute. It is also necessary to have the right commodities on the lorry, those that must be delivered on this subroute, but this must be ensured by the driver.
For many-to-many problems, one forward pass over the route is performed to determine how much load must be picked up at the depot. This amount is determined by the most negative load balance at any vertex on the route. If loading at the start depot is not allowed and a negative load balance occurs at a vertex, the insertion is infeasible (lines 2-8). If load may be picked up at the start depot, a second pass over the route (lines 17-20 or 34-52) tests whether there is sufficient capacity taking this load into account. If no load may be brought to the end depot, but the load balance from any index to the end of the route is positive, the route is infeasible as well (lines 9-14). Moreover, for many-to-many problems, it must be ensured for all subroutes that at each non-artificial delivery vertex, sufficient load is available on the lorry to perform the delivery. This load may have been picked up earlier on the subroute or before the subroute. It is possible that not enough load has been picked up earlier on the subroute and that, at the same time, not enough load has been picked up before the subroute. This is tested in lines 50-52.

Testing capacities in constant time
In the following, it is described how capacity feasibility can be tested in constant time. Algorithm 2 is for the one-to-one and the one-to-many-to-one problem types. The constant-time test for many-to-many PDPTs differs significantly from the tests for the other problem types. Thus, it is presented separately, in Algorithm 3.

One-to-one and one-to-many-to-one PDPTs
The following data structures are used in the test for the one-to-one and the one-tomany-to-one PDPT variants. These were introduced by Drexl (2018) for the one-to-one PDPT.

MaxTotalLoadOfSegment[i][offset]
is the maximal load balance from the start of the route at any index from i up to and including i + offset. In particular, is the overall load picked up but not delivered yet from the start depot to and including the location at index i. For example, consider the following route in a one-to-one PDPT: sum of the pickup amounts of those tasks on the subroute whose pickups lie before i.

Algorithm 1 TestCapacityLinear(r , k)
Input: Route r = (0, 1, 2, . . . , n) with to-be-inserted task tentatively inserted, including decoupling and coupling vertices where necessary, and capacity requirements q v ∈ R, v = 0, 1, 2, . . . , n Vehicle k (single lorry or LTC) with capacities Q l and Q t ; for single lorries, Q t == 0 Result: Returns true iff lorry and, if applicable, trailer capacity of k are maintained at each vertex of r ; false otherwise 1 TotalLoad = 0 2 if Problem type is many-to-many As an example of the simultaneous PDPT, consider the following five tasks: Task Original amount to be delivered +5 +20 +10 +12 +16 Original amount to be picked up -5 0 +6 -3 Assume these five tasks are fulfilled by the following route: I n d e x 0 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 The decisive aspect for the feasibility test of simultaneous PDPTs is that the delivery amount is not necessarily the negative of the pickup amount. In Algorithm 2, this is taken into account in lines 6-8 and 32-36.
MaxTotalLoadOfSegment and MaxLoadBalanceFromStartOfSubroute can be initialized and updated with a nested loop, by iterating over all indices j ≥ i for each index i. The other data structures can be determined in a single loop. Hence, computing the preprocessing data is possible in quadratic time in the number of tasks on the route.
Algorithm 2 uses these data to test the capacity feasibility of an insertion of a task t = ( p, d) into an existing route r , with p to be inserted directly after position (zero-based index of the route) h and d to be inserted directly after position i. It is evident that the running time of the algorithm is constant, independent of the number of vertices visited on the route.
Algorithm 2 returns false in line 4 if the total capacity is less than the maximal total load between the pickup and the delivery plus the pickup amount. For the simultaneous PDPT, false is returned in line 8 if the former condition is fulfilled or the total capacity is less than the maximal load between the delivery and the end of the route plus the pickup plus the delivery amount. The latter condition must be tested because, as explained in Sect. 3.5, for the simultaneous PDPT the sum of the pickup and the delivery amount indicates the change of load at deliveries.
The algorithm returns false in line 23 if p is to be inserted on a subroute and the minimal load that must be in the lorry when leaving the decoupling vertex plus the load balance from the start of the subroute up to h plus q p plus the maximal load balance, counted from the beginning of the subroute, from h + 1 to i or to the end of the subroute, whichever vertex is visited earlier, exceeds the lorry capacity.
False is also returned if d is to be inserted on a subroute and the minimal load that must be in the lorry when leaving the decoupling vertex plus the maximal load balance from the start of the subroute up to i plus q p exceeds the lorry capacity (line 31).
Moreover, for the simultaneous PDPT, similar to the situation on the main route, the algorithm returns false in line 36 if the minimal load aboard the lorry when leaving i plus q d plus the maximal load balance from i + 1 to the end of the subroute exceeds the lorry capacity.
Finally, Algorithm 2 returns false in line 43 if d is to be inserted directly after p on a subroute and the total load upon leaving h plus q p exceeds the lorry capacity.
If Algorithm 2 returns false from line 4, 8, or 23, further potential insertion positions for d need not be tested with the current insertion position of p. Instead, the next potential position for inserting p can be considered. Hence, it is sufficient to execute lines 2-23 of Algorithm 2 only once for each h.
Note also that lines 14-23 and 37-43 in Algorithm 2 are never reached for the simultaneous PDPT, as a pickup is never on a subroute.

The many-to-many PDPT
In the capacity test for the many-to-many PDPT, all data structures from Sect. 4.2.1 are employed, except for LoadDeliveredButNotPickedUpOnSubroute. In addition, the following data structures are used: For testing the total vehicle capacity: 1. OffsetsToWhereActualTotalLoadIsMaximal[i] indicates, for each index i on the route, the non-negative offset from i to the index where the overall load in the vehicle, not taking into account what might have to be picked up at the depot, is maximal. 2. MaxActualTotalLoad[i] stores the maximal physical load from each index i until the end of the route, not taking into account any load that might have to be picked up at the depot. This load is aboard the vehicle at index i + OffsetsToWhereActualTotalLoadIsMaximal[i]. ( p, d, r , h, i, k) Input: Pickup-and-delivery task t = ( p, d) with capacity requirements q p ≥ 0 and q d ∈ R Route r = (0, 1, 2, . . . , n) Indices of insertion positions h, i with 0 ≤ h ≤ i ≤ n − 1 Vehicle k (single lorry or LTC) with lorry and trailer capacities Q l and Q t ; for single lorries, Q t == 0 Result: Returns true iff inserting p or a triplep = ptl p → p → ptl p into r after index h and d or a tripled = ptl d → d → ptl d after i (or, iff h == i, after p orp) is feasible regarding lorry and trailer capacity, false otherwise 1 // Evaluate feasibility of insertion regarding total capacity 2 if Problem type is not simultaneous For testing lorry capacities on subroutes:

MostNegativeLoadBalanceOnSubrouteFromTo[i][offset]
is the most negative load balance from i until i + offset on the subroute where i is visited, counted from the beginning of the subroute.
As an example, consider the following route: LoadBalanceFromTo and MostNegativeLoadBalanceOnSubrouteFromTo can be filled using a nested forward pass, i.e., by iterating over all indices j ≥ i for each index i on the route; the other data structures can be filled or updated in one pass. As explained in Sect. 4.2,MaxTotalLoadOfSegment[i][offset] is the maximal load balance from the start of the route at any index from i up to and including i + offset.
For the many-to-many problem where loading at the start depot is allowed, MaxTotal-LoadOfSegment also takes into account the load that must be picked up at the depot, by adding this load to each component of MaxTotalLoadOfSegment. Computing the load to be picked up at the depot can be done in one additional forward pass over the route, which does not change the time complexity of determining the preprocessing data. Hence, the preprocessing data for a many-to-many-PDPT route can be computed in quadratic time in the number of tasks on the route. With these data structures, capacity feasibility can be tested as described in Algorithm 3. It is easy to see that the algorithm itself runs in constant time. Algorithm 3 returns false in line 8 if the maximal load in the vehicle, disregarding any load brought from the depot, at any index from and including h until the end of the route (i.e., MaxActualTotalLoad[h]) plus q p plus the rest of the load that still needs to be picked up at the depot even after inserting p exceeds the total vehicle capacity. To exemplify this, consider the following route and assume h = 3 and q p = 40: The value to be subtracted from q p in line 6 is (−1) · (−90) + (−10) = +80. This value is greater than q p , so that the overall value of line 6 is negative, and this means that the entire amount q p can be used to substitute load brought from the depot. This, in turn, means that inserting p does not increase the load at any index, which implies that the insertion is feasible. Now assume that the capacity requirement at index 6 is −50. Then, 40 units must be picked up at the depot, and line 5 equals (−1) · (−40) + (−20) = +20. In line 6, +30 must be subtracted from q p , so that the value of line 6 is +40 − 30 = +10. This means that 30 units of q p can be used to help satisfy the negative capacity requirements at indices 4 and 6, so that the 30 units picked up at the depot to this end are no longer necessary. This, in turn, means that inserting p after h increases the load from h + 1 onwards by 10 units, which may or may not violate the total vehicle capacity. The return false in line 11 is self-explanatory. The return false in line 19 has the following rationale: q p ≤ 0 implies that |q d | > 0. To satisfy this negative capacity requirement, additional load can be picked up at the depot if this is allowed and if there is free capacity up to index i. In any case, for the insertion of d to be feasible, it must still be possible to satisfy all negative capacity requirements after i, which, in other words, means that the maximal possible load after d must be at least as much as the absolute value of the most negative load balance computed from i until the end of the route.
The return false in line 35 can be explained as follows. The minimal load aboard the lorry when leaving a decoupling vertex must be the maximum of the following quantities: (i) the absolute value of the most negative load balance on the subroute up to and including h, (ii) the absolute value of the most negative load balance on the subroute from h + 1 until the end of the subroute minus q p , and (iii) the total load in the vehicle when leaving the decoupling vertex minus the trailer capacity. Then, when p is inserted, the load after p is the sum of this minimal load, the load balance from the start of the subroute up to h, and q p . If this sum exceeds the lorry capacity, the insertion is infeasible.
The algorithm returns false in line 40 if the absolute value of the most negative load balance on the subroute on which d is to be inserted, computed from any index before i up to i, plus |q d | exceeds the lorry capacity, as this quantity is a lower bound for the amount of load that must be aboard the lorry after decoupling when d shall be inserted after i.
Finally, Algorithm 3 returns false in line 51 when, after inserting d directly behind i, not enough load can be in the lorry to satisfy the most negative load balance on the subroute after i. This is tested as follows. The load that can be in the lorry at the decoupling vertex equals the load balance from the start of the route up to the decoupling vertex plus the maximal additional load that can be picked up at the depot. The load at i is the minimum of the lorry capacity and the load at the decoupling vertex plus the most positive load balance from the start of the subroute up to i plus the most negative load balance on the subroute from any vertex before up to i. The load after visiting d is then equal to the load at i plus q d , and this load must be non-negative and greater than or equal to the absolute value of the most negative load balance from i + 1 to the end of the subroute.
Note that lines 21 ff. are valid whether or not loading at the start depot is allowed. An alternative feasibility testing procedure for the many-to-many PDP without trailers is described by Kindervater and Savelsbergh (1997).

Conclusion and outlook
This paper has studied several variants of the PDPT, a routing problem where transport tasks between pickup and delivery locations must be fulfilled by a fleet of capacity-constrained single lorries and lorry-trailer combinations subject to accessibility restrictions at locations. Procedures to test the capacitive feasibility of inserting a task into an existing route have been presented. The procedures run in constant time, given appropriate auxiliary data that can be computed in a preprocessing step.
In their survey, Battarra et al. (2014) write (p. 181): 'When looking at the pickup and delivery literature as a whole, one cannot fail to notice that there exists a very large number of problem variants which differ in their structure but nevertheless share many similarities. One can thus hope to see the development of general modelling and Algorithm 3 TestCapacityConstantManyToManyPDPT( p, d, r , h, i, k) Input: Pickup-and-delivery task ( p, d) with capacity requirements q p ≥ 0 and q d ≤ 0 Route r = (0, 1, 2, . . . , n) Indices of insertion positions h, i with 0 ≤ h ≤ i ≤ n − 1 Vehicle k (single lorry or LTC) with lorry and trailer capacities Q l and Q t ; for single lorries, Q t == 0 Result: Returns true iff inserting p or a triplep = ptl p → p → ptl p into r after index h and d or a tripled = ptl d → The author hopes that the present paper constitutes a step in this direction.
In any case, there is ample opportunity for further research: throughout the paper at hand, it was assumed that the goods to be transported are homogeneous and load can be split arbitrarily between a lorry and its trailer. This is true for many practical situations, most notably, for the transport of liquids, bulk cargo, and palleted goods.
However, in all problem variants, the transported goods might just as well consist of a number of distinct items with different sizes, so that load splitting between lorry and trailer is possible only in discrete amounts. The transfer of load between a lorry and its trailer can even be completely forbidden or impossible for technical reasons. Taking this into account would require major changes to the procedures described above. It is thus beyond the scope of the present work and left for future research.