An Insertion Heuristic for the Capacitated Vehicle Routing Problem with Loading Constraints and Mixed

In this paper, a capacitated vehicle routing problem with mixed linehauls and backhauls is presented. The addressed problem belongs to the subclass of pickup and delivery problems. Loading and sequencing constraints are also considered. These constraints arise in many realworld situations, and can improve efficiency since backhaul customers do not need to be delayed in a route when it is possible to load their items without rearrengements. The suggested approach is based on an insertion heuristic presented in the literature but extended to tackle the explicit consideration of loading constraints. Different strategies are presented and tested. An exhaustive computational study is performed on instances adapted from benchmark instances for integrated routing and loading problems.


INTRODUCTION
In the last decades, Pickup and Delivery Problems (PDP) deserved an important attention by the scientific community in the transportation field.The PDP can be briefly defined by the routing problems where goods or even people must be collected and distributed from an origin to a destination.Due to the extensive number of approaches and denominations in this field, Parragh et al. [1,2], suggested a classification where the general Pickup and Delivery Problem is divided in two classes.The first class considers the problems in which delivered goods (or, respectively, the picked goods) are only loaded (or, respectively, unloaded) at one or more depots, meaning that the transport of goods is only performed from or to the depot.The second class considers the transportation of goods from pickup customers to delivery customers.The problems of the first class are usually denominated by Vehicle Routing Problems with Backhauls (VRPB) whereas the second class is denominated by Vehicle Routing Problem with Pickups and Deliveries.In this paper we will focus our attention on the VRPB, which has four subclasses.In the first subclass, customers are assigned to one and only one of two disjoint clusters, one for delivery customers (also denominated by linehaul customers) and another one for the pickup customers (also denominated by backhaul customers).In this subclass, one backhaul customer can only be visited after visiting all linehaul customers assigned to that route.Since the order of visit is determined by the cluster in which a certain customer belongs, the authors named these problems as Vehicle Routing Problem with Clustered Backhauls (VRPCB).In the second subclass this constraint does not apply, even though the division into disjoint sets of delivery and pickup customers is still mandatory.Since customers of both clusters can be indistinctly visited without that precedence constraint, the authors referred to the problems of this subclass as Vehicle Routing Problems with Mixed linehauls and Backhauls (VRPMB).The last two subclasses consider the situations where customers require both a quantity to be delivered and a quantity to be picked up.However, in the third subclass, a given customer can be visited twice.The visits can be divided in one visit to deliver goods and another one to pick up goods.These problems were denominated by Vehicle Routing Problems with Divisible Delivery and Pickup (VRPDDP).On the contrary, in the fourth class, both loading and unloading operations must be performed simultaneously in exactly one visit, and then the authors denominated these problems as Vehicle Routing Problems with Simultaneous Delivery and Pickup (VRPSD).

VRPMB
As referred to above, the Vehicle Routing Problem with Mixed Linehauls and Backhauls (VRPMB) is a subclass of problems belonging to the Vehicle Routing Problem with Bakchauls (VRPB), in which the customers are divided in two different groups: linehaul and backhaul customers.Each linehaul customer has a given demand quantity that can only be provided by the depot, while each backhaul customer has a given supply quantity which the only destination is the depot.In the VRPMB, both the linehaul and backhaul customers can be indistinctly visited, which means that within the same route, it is not required to visit all linehuals customers before visiting backhauls customers.
In [3], the Clarke and Wright method is applied to assign all linehauls customers to the routes.Then, an insertion-based heuristic evaluates the insertion of each backhaul customer in all route points where that customer can be feasibly inserted.This insertion cost is obtained by the additional routing cost when inserting that customer in a given arc, and by adding the product of a penalty multiplier with the number of delivers after that insertion.The minimum cost defines the backhaul customer and its insertion point.The process is repeated until all backhaul customers are visited.
The insertion cost was revised in [4] by subtracting a value which is proportional to the distance between the backhaul customer to be inserted and the depot, and by adding the product of a penalty multiplier with the quantity that is still to be delivered after the insertion point.Based on this insertion cost, a more concise formula is proposed in [5].The multiplier associated to the remaining load that has to be delivered is calculated in distance units.The authors proposed four heuristics procedures.Each heuristic starts from a solution where all linehauls customers are already assigned to the routes.The first heuristic is based in [3] and in [4] by computing the insertion cost of each customer/arc and inserting the customer with the least cost.The second heuristic computes both the insertion cost for each customer/arc as in first heuristic and the insertion cost of each pair of backhaul customers.The least cost defines the insertion of one or two customers.These procedure allows small improvements when two backhaul customers can be near each other.Since this situation can happen with more than two customers, the authors suggested two more heuristics in which clusters of backhauls customers can be inserted.In these heuristics, the insertion costs for each customer, for each pair of customers, and for each cluster are computed in each iteration, and the best cost defines the customer (or group of costumers) and its position in a route.The analysis of the insertion costs will allow to have the perception, at each iteration, if each customer has a smaller insertion cost is inserted alone or associated with another customer.In order to define the clusters, the authors defined a graph of all backhauls customers, where all customers which are better inserted in pairs are linked by an edge.The difference between the two last heuristics is the strategy to build clusters.For the third heuristic, only customers which form a complete graph can be grouped in a cluster, while in the fourth heuristic, it is sufficient to the customers to form a connected graph to be grouped in a cluster.
Based in [5], an improved insertion heuristic is presented in [6].It is also possible to insert one or two customers at each iteration, depending on the least insertion cost.This approach is improved with a so called restriction percentage.The restriction percentage is defined by the user and it is based on his experience to define how backhaul and linehaul customers can appear mixed in a route.This percentage value will be used when evaluating the insertion of a backhaul customer in a given arc.The percentage of linehaul goods already delivered must be greater or equal to the restriction percentage, in order to enable the insertion of a backhaul customer in that arc.Otherwise, the insertion on that arc will not be evaluated again.
An heuristic for both the VRPMB and the VRPSDP is suggested in [7].Firstly, a so called weakly feasible solution is obtained.One solution is weakly feasible if it satisfies the maximum route length, and if the capacity of the vehicle is not exceeded by the total load to be delivered or by the total load to be picked up.In contrast, a strongly feasible solution satisfies the maximum route length and, additionally, the vehicle capacity is not exceed in each arc of the route.Some improvements are then performed by applying local search on the initial solution, and turning the solution in a strongly feasible solution.Additional local search procedures are applied, improving the quality of the solution while keeping it as strongly feasible.

Loading and routing
The approaches referred to in the previous subsection have in common the fact of only considering the weight as the single measure of the capacity constraints.However, a single measure may not be able to reflect some real world situations.These situations occur when the weight of the loads satisfy the weight limit, but they exceed the area or the volume of the vehicle.In such cases, transporting items is impossible even satisfying the constraints of the problem.In order to incorporate these specificities, some works were presented in the last decade, by associating the Capacitated Vehicle Routing Problem (CVRP) with the bin packing problem (or the strip packing problem) considering two or three dimensions.The resulting problem is denominated by Capacitated Vehicle Routing Problem with two-or three-dimensional Loading constrains (2L-or 3L-CVRP, respectively).A comprehensive survey in routing problems with loading constraints can be found in [8].In this work, we will focus our attention in the 2L-CVRP.The generality of the approaches in that field are based in metaheuristics, which is not surprising given the complexity of the problem.Nevertheless, one exact approach was suggested [9].Despite obtaining solutions in relatively small amount of time, this approach is only able to deal with a relatively small number of customers.
A usual constraint for both the 2L-CVRP and 3L-CVRP is the assumption that unloading an item to deliver to a given customer does not require to move items from customers to be served later.Therefore, items must be loaded into the vehicle according to the opposite order by which they are unloaded, following a Last-In, First-Out (LIFO) policy.For that reason, these constrains are known as LIFO or as sequential constraints.

Pickup and Delivery with loading
The interest of Pickup and delivery problems where loading constraints are considered has been increasing.For instance, the Pickup and Delivery Travelling Salesman Problem (PDTSP) with loading constraints considers the transportation between vertices in which pickups and deliveries are performed according to a sequence policy (LIFO or FIFO).
Some approaches addressed Pickup and Delivery problems considering more than a single dimension of the goods, generalizing the problems referred in Section 1.2.A constraint programming model based on the scheduling field for the two-dimensional loading with sequential constraints is presented in [10].The PDP with three-dimensional loading constraints is addressed in [11].This approach is based on a local search method by swapping the vertices if it leads to a lower route length.After deriving a valid packing solution, another local search procedure is performed by assigning customers to other routes.It is important to note that for both approaches referred above, the transportation of goods is performed between the customers.In contrast, transportation from and to the depot is considered in [12], addressing the 3L-CVRP with Clustered Backhauls.As referred before, backhauls customers should be visited after the linehaul customers within the same route.Sequential constraints are taken into account, and these constraints should be satisfied also when visiting backhaul customers.In this work two procedures were suggested and in both of them, routing and packing are solved by different procedures, and then integrated to perform a solution.The first algorithm is based in the Adaptive Large Neighborhood Search, while the second algorithm relies in a Variable Neighbourhood Search.The packing component of both problems is tackled with a tree search heuristic presented in [13].
This paper is organized as follows.In Section 2, we describe the Capacitated Vehicle Routing Problem with Mixed linehauls and Backhauls and twodimensional loading constraints (2L-CVRPMB).In Section 3, we present our approach for the 2L-CVRPMB.In Section 4 the computational results of this approach are presented and discussed.Finally we draw some conclusions in Section 5.

PROBLEM DESCRIPTION
The Capacitated Vehicle Routing Problem with Mixed Linehauls and Backhauls with two-dimensional Loading constraints (2L-CVRPMB) can be described as follows.Let G=(V,E) be a complete graph, where V={0,1,…, l, l+1,…, l+b} is the set of nodes and E is the set of edges.The set V includes n+1 vertices corresponding to the depot (vertex 0) and to the n customers including l linehaul customers and b backhaul customers.The set E includes all pair of vertices such that E={(i,j): i, j ∈ V, i ≠ j}.Let cij be the nonnegative cost of traversing the edge (i,j).There is a set of K identical vehicles, each one having a weight capacity C and a two-dimensional rectangular loading area with height H and width W. Each linehaul customer (or, respectively, backhaul customer) has a demand (or, respectively, a supply) composed by twodimensional rectangular items.The 2L-CVRPMB consists in finding the set of optimal routes, each one starting and ending at the depot and satisfying the following constraints: (C1) the number of used vehicles cannot be greater than K; (C2) each customer is visited exactly once; (C3) the total weight associated to each arc of each route cannot exceed the capacity C; (C4) items have a fixed orientation in the loading area, i.e., items cannot be rotated; (C5) in each vehicle, the items must be completely within the surface, must not overlap, and the edges of each items must be parallel to the loading area edges; (C6) unloading an item at a given customer must be performed in a straight movement, without moving items of other customers, and thus the loaded items from backhaul customers cannot block items to be delivered.

INSERTION HEURISTIC FOR THE 2L-CVRPMB
We extended the insertion-based heuristics presented in [5] for the 2L-CVRPMB.Firstly, a solution to visit all linehaul customers is built (Section 3.1).The backhaul customers are then successively inserted on the generated routes (Section 3.2).The successive insertion of pairs of backhaul customers is also considered (Section 3.3).To ensure the feasibility of routes, a heuristic is proposed in Section 3.4.

Constructing routes for Linehaul customers
In order to assign all linehaul customers to the routes, we adapted the method to construct initial solutions presented in [14].The process starts by generating K empty routes.All linehaul customers are sorted according to the area of their items.By this order each customer will be successively inserted.To evaluate if a given customer can be inserted in a feasible way, Bottom-Left heuristic enhanced in order to satisfy the loading constraints is used.From the set of routes in which a given customer can be inserted in a feasible way, the route leading to a minimum remaining free area is selected.The customer is inserted at the route point which leads to the minimum cost increase and which insertion is valid.

1-Insertion heuristic for backhaul customers
The set of all backhaul customers will be assigned to the routes obtained in the previous subsection using the insertion heuristics based in [5] but with different cost functions.In that approach the cost of inserting one backhaul customer c in one arc (a,b) is given by: where d ij is the distance between vertex i and j, L b is the remaining load (in terms of weight) after vertex b, T ab is the length of the route which contains arc (a,b) and MQ is the weight capacity of the vehicle.The parameters α and β are penalty parameters, and their default values are 1.5 and 1, respectively.In our approach, we adapted this expression of cost in order to incorporate the area capacity of the vehicle.So the insertion cost will be determined by: where A b is the remaining area of the items to deliver after vertex b, and area v is the area of the vehicle.Note that, as stated in [5], the cost will be expressed in units of distance.It is worth noting that operations of validation are necessary to determine if one customer can be inserted in a feasible way.

2-Insertion heuristic for backhaul customers
The authors of [5] extended the 1-insertion heuristic to the case where a pair of backhaul customers can be inserted instead of a single customer.Besides computing the cost of each feasible insertion for a single backhaul customer in every routes, this procedure also computes de cost of all feasible insertions for all combinations of pairs c and d of backhauls customers using (3): ( ) The least cost defines the insertion of a single customer or a pair of customers.The process is repeated until all backhaul customers are assigned to the routes.One special case arises when there is no feasible positions in any route for a given customer.In such case, the customer is assigned to a new route.This new route will be dedicated to backhaul customers since all linehaul customers are already assigned to other routes.The penalty parameter β in the expressions of insertion costs is used in many works in order to delay the insertion of backhaul customers [4,5,6].One reason for this delayed insertion is due the real situations were rearrangements are time consuming or even impossible when performing the route.In our approach, the validation of one route guarantees that no rearrangements will be necessary since it is a constraint of the 2L-CVBPMB.In this sense, reducing the value of β can lead to less costly routes where backhauls customers can be inserted earlier.However, satisfying loading constraints with mixed types of customers is more challenging, because every loaded item blocks the space area backwards that item, and so the item can only be placed if there is no items to be delivered in the referred area.In this sense, it is easy to see that inserting earlier a backhaul customer can lead to an infeasible route.Therefore, it is expected that reducing the value of β will increase the number of route validations, due to the higher number of failures in infeasible but less costly routes.Since the validation of one route spends a significant part of the computational time, the reduction of β may also modify the execution time.

Feasibility of routes
The capacity constraints in terms of weight are ensured not only by imposing a weight limit to the weight of items to deliver, but also limiting the load in each arc to the weight capacity of vehicle.The same procedure can be applied to the total area of items.On the other hand, the validation of packing and sequencing constrains is required either to build valid routes to linehaul customers or to check if a backhaul customer can be feasibly inserted into a given route point.For the first case, it is necessary to have a feasible layout that can be seen as the layout of the vehicle when it leaves the depot.For this situation, we propose a Bottom-Left heuristic with Loading constraints (L-BL).For a given route with mixed types of customers, it is not only required to have a linehaul layout but also ensure that every collected items of backhaul customers will not block a straight movement to unload the items to deliver later.In other words, the collected items cannot be placed between the rear-side of the vehicle and the items to deliver.Obviously, this does not apply to the items already collected.It is important to note that since one item is loaded in a given position of the loading area, it cannot be rearranged.For this situation we propose a Bottom-Left heuristic with Loading constraints and Mixed Linehauls and Backhauls (L-BLMB).
For the L-BL, in order to manage the relative position of items in the loading area, we use the concept of free spaces, which was successfully adopted in similar problems with loading constraints [15].The loading area is considered to be the first free space.When an item is placed in the loading area, at most four free spaces are created.These free spaces identify the places where next items can be placed, and the original free space where the item was placed is removed from the list of free spaces.Taking into account all the free spaces, we select the bottom most and leftmost position where the item fits, such that the capacity and sequencing constraints are satisfied.The item is placed in such a way in order to match the bottom-left corner coordinates of both the item and the free space.A small example of free spaces generation is given in Figure 1.
The L-BLMB has some differences that can be described as follows.Given a route with mixed linehaul and backhaul customers, the procedure starts by attempting to derive a packing layout only for linehaul customers using L-BL.If it is not possible to achieve a valid packing for all linehaul customers, clearly the route is infeasible for the mixed case.Otherwise, we get a feasible layout for the linehaul part.At this step the layout will be analyzed seeking a strip of height H with no items.This procedure allows to know if the vehicle has a free space available for backhaul customers right after leaving the depot.If there are such strips, they are added to the list of free spaces for collected items.Thereafter, the customers of the route are successively analyzed by the order in which they are visited.If the analyzed customer is a linehaul customer, then their items will be removed from the layout and the original gap where the removed items were placed is recovered.Otherwise, if it is a backhaul customer, then their items are attempt to be placed in a free space for backhaul items ensuring all the constraints.The process runs until all backhaul items are loaded on the vehicle, or until it is impossible to place a given item.Clearly, in this last case the route is infeasible.

Pseudocode
The algorithms 1 and 2 refer to the 1-and 2-Insertion, respectively.The construction of routes for linehauls is denoted by findSolutionLinehaul().The procedure findMinInsCost1() finds the arc (a,b) and the customer c which lead to the minimum insertion cost using (2), while findMinInsCost2() uses (3) to find the pair of customers c 1 and c 2 and the arc (a,b) leading to the minimum cost.Inserting a backhaul c (or a pair) in the arc (a,b) is denoted by InsertCustomerInArc(c,ab) (or InsertPairCustomersIn Arc(c1, c2, ab), respectively).

Instances
The proposed approach was tested using adapted instances from benchmark instances for the 2L-CVRP used in [10,16].
Since the presented approach has insertion costs based on the area of the items, the instances in which area is not a considered (pure CVRP instances) are not tested.Based in the generation of instances in [5], we adapt the 2L-CVRP benchmark instances by replicating each one three times in order to obtain three instances having each one 50%, 25% and 10% of backhaul customers in relation to the total number of customers.We will denote by Class 1, 2 and 3 the instances which consider respectively 50%, 25%, and 10% of backhauls customers.For this purpose, we assign as backhaul customers the ones whose number is a multiple of 10 for Class 3, multiple of 10 and 4 for Class 2 and multiple of 10, 4 and 2 for Class 1.
The original demand of the assigned customer is now the supply of the new backhaul customers.Only instances with more than 50 customers were considered, as in [5].
With this procedure 72 instances are obtained for each class.The number of customers ranges from 50 up to 255.The number of items of each instance varies between 82 and 786.The default values of α and β are 1.5 and 1, respectively.
The algorithms were coded in C++, and the tests were run on a PC with an i7 CPU with 3.0 GHz and 8 GB of RAM.
As referred in Section 3, reducing the value of β can lead to different solutions.In order to explore this feature, we conduct on computational experiments for different values of β.

Obtained results
The obtained results were divided in 11 groups according to the number of customers.
In Table 1, we report on average results for each of these groups where n is the total number of customers including n b backhaul customers, #inst is the number of instances of each group, it is the average number of items, RC is the average value of route cost obtained with the corresponding heuristic (1-or 2-Insertion heuristic), %out is the average percentage of used spaced in the vehicle when leaving the depot, %in is the average percentage of used space in the vehicle when returning to the depot, #Val corresponds to the average number of validations using both L-BL and BLMB, t is the average computational time in seconds, inc corresponds to the percentage of the average increase of the route cost when comparing 1-Insertion with 2-Insertion, and avg corresponds to the average values in each column for each class.All the results were obtained firstly by running the 1-Insertion heuristic and right after running the 2-Insertion heuristic for the same instances.
Therefore, all the following considerations will take into account the modified values from the former to the latter heuristic.The obtained results for Class 1 show average reduction of 2.03% in the average route cost when comparing the 1-and 2-Insertion heuristics.
The maximum average reduction is 5.38% and it is achieved in the group of 71 customers.All groups present an average decrease in the route cost.However, in all groups the average computational time is greater for the 2-Insertion heuristic.For the groups considering 252 customers, the computational time can increase more than four times when the 2-Insertion heuristic is applied.There is also an increase of the number of validations.
Considering the average value for all groups, the number of validations in the 2-Insertion is greater than twice the validations required for the 1-Insertion.For the group of 255 customers, the number of validations increases more than three times when 2-Insertion is used.
The increase of validations is also verified in results concerning Class 2, since in the 2-Insertion there is an increase of roughly 34.72% in the average number considering all groups for that class.The average computational time increases in all groups.For the group of 240 customers the average time increases by approximately two times.Considering the quality of the solution, the average route cost has a slight increase in 8 of 11 groups, performing an average increase of 0.21%.An increase in the average route cost is also verified in 9 of 11 groups in Class 3.An improvement in the route cost can only be verified in two groups of instances, namely the group of 71 customers (7 of those are backhaul customers) and the group of 100 customers (10 of those are backhaul customers).One possible explanation for this increase in both Class 2 and Class 3 can be the preference that is given to the double insertion of customers instead of a single one [6].
The number of validations in Class 3 has an average increase of roughly 3.87% considering all groups, which is less significant when comparing all the classes.The average computational time is slightly greater for the second heuristic.For the group of 199 customers (19 of those are backhaul customers) the average spent time decreases to 1.34 seconds.
The average percentage of space used in the vehicle for all groups shows a slight decrease for the Class 1 (0.4% for both leaving and for returning to the depot) when comparing both insertion heuristics.For the classes 2 and 3, the values are equal for both heuristics.
Considering the insertion heuristic which achieved best results for each class, namely the 2-Insertion for Class 1 and 1-insertion for Class 2 and 3, additional computational experiments were conducted, by decreasing the value of β in 0.25 in each run.In Table 2, the obtained results conducted for the same 11 groups referred to above, and for the best heuristic, are presented.For sake of clarity, we will report on the percentage difference, which is achieved by taking the values presented in Table 1 as a reference.In Table 2, the percentage difference of the average route cost and percentage difference of the average number of validations is represented by %RD and %ValD, respectively.The results of Table 2 show that the average route cost tends to decrease as the value of β decreases.The best improvement is 1.68% and it is obtained in the group of 150 customers in Class 1 (2-Insertion heuristic) when β=0. However in some cases the reduction of the value of β can lead to an increase in the average costs.The worst case (increase of 0.89%) is also in Class 1 in the group composed by 120 customers and β=0.Therefore it is not possible to stablish a clear and proportional relation between β and the route cost.The average number of validations tends to increase as β increases.This increase is more significant in groups of Class 1.In this class, when β is zero, there is an increase of more than 163% in the average number of that validations.For other classes, the increase is less expressive, with average values of 26.53% for the Class 2 and 4.27 for Class 3. The computational time tends to be greater when reducing the value of β.The increase of time is more expressive for instances of Class 1. Indeed, if the number of validations increases significantly, the time required will be significantly greater.For instance, for β=0, for the results of Class 1 in the group of 252 customers present an average increase of 269.73% in the number of validations, spending on average more than 26.55 seconds, and have a slight improve in the cost (-0,55%).

CONCLUSIONS
In this work a capacitated vehicle routing problem with mixed linehauls and backhauls with Loading and sequencing constraints was addressed.
The results show, as in other works in literature, that some savings can be achieved by visiting backhaul customers earlier in the route.The innovative feature of this approach is that for instances with a relatively small number of backhaul customers, and even with more feasibility tests, the solution can be obtained within a small additional amount of time.The computational time strongly relies in the number of validations.However, instances involving 50% of backhaul customers can lead to solutions requiring a significant amount of time to achieve a feasible solution for the 2L-CVRPMB.