An improved two-phased heuristic algorithm for the capacitated vehicle routing problem and a case study

The Capacitated Vehicle Routing Problem (CVRP) is a special variant of the Vehicle Routing Problem which has been extensively addressed in the literature of Operations Research. Since CVRP is a NP-hard problem, only heuristic algorithms are capable of solving relatively large-scale problems. In this research paper, a new Improved Two-phased Heuristic algorithm is presented for solving CVRP. The Improved Two-phased Heuristic algorithm is comprised of two phases and cluster-first rout-second approach is used. In the first phase, best sets (≤ five) of clusters are obtained using an iterative procedure based on five parameters. In the second phase, the Traveling Salesman Problem (TSP) of each cluster of the obtained sets of clusters is separately solved by applying the standard Genetic algorithm (GA). Subsequently, the best set of clusters with the minimum total traveling distance is selected as the final solution. The performance of the improved algorithm was compared with three prominent algorithms find in the literature: Efficient Two-phased Heuristic algorithm, Savings algorithm and GA, using thirty well-known benchmarked instances. The computational results of the comparison revealed that the Improved Two-phased Heuristic algorithm finds the least total traveling distance within a reasonable CPU time, compared to the three stated prominent algorithms. To illustrate the proposed algorithm and its applicability, the algorithm was applied for a food manufacturing company located in Sri Lanka. The results showed that there was a significant impact in reducing the transportation cost in distributing the company products by reducing the total traveling distance.


INTRODUCTION
The Vehicle Routing Problem (VRP) is one of the most studied combinatorial optimization problems in the field of Operations Research. The VRP is directly related to the economically valued sections of almost all the businesses of the current world such as transportation and logistics. In VRP, an optimal set of routes is determined for a fleet of vehicles to satisfy the demands of geographically dispersed customers from one or more depots. Many variants of VRP have been introduced in the literature by imposing additional requirements and operational constraints for the route construction. A comprehensive literature review on the classification of the VRP was conducted by Hoff et al. (Hoff et al., 2010). The CVRP is more important among these variants due to the higher practical relevance.
The objective of CVRP is to minimize the total traveling cost which directly depends on the total traveling distance. In the CVRP, all customers have known deterministic demands, the operation is deliveries only, customer locations are known, the capacities of vehicles are identical and based at a single depot. The operational constraints of the CVRP are; each customer is visited exactly once by exactly one vehicle to satisfy the demand, the routes of vehicles are initiated and terminated at the prime depot, and summation of customer demands of each route does not exceed the vehicle capacity.
Since the CVRP was initially formulated (Dantzig and Ramser, 1959), numerous solving techniques have been introduced. Basically, these techniques are classified into exact algorithms, heuristic algorithms, and metaheuristic algorithms. The exact algorithms solve CVRP optimally by examining all the feasible solutions in the search space such as Branch and Bound algorithm (Christofides et al., 1981), and Branch and Cut algorithm (Augerat et al., 1995;Lysgaard et al., 2004). The CVRP is a NP-hard problem which means the complexity of the problem grows exponentially as the number of customers increases. Therefore, heuristic and metaheuristic algorithms are generally used to solve CVRP. The heuristic algorithms are reached to a near-optimal solution by examining a limited area of the search space, for examples, Savings algorithm (Clarke and Wright, 1964), Sweep algorithm (Gillett and Miller, 1971), Cluster-first Route-second algorithms (Fisher and Jaikumar, 1981;Sandaruwan et al., 2019). The metaheuristic algorithms are mechanisms which iteratively improve a feasible solution of the search space and find a near-optimal solution. These mechanisms can be used to solve many optimization problems by modifying the objective function and constraints accordingly. The GA (Holland, 1995), Tabu Search algorithm (Glover, 1986) and Ant Colony algorithm (Bullnheimer et al., 1997) are a few examples for the metaheuristic algorithms.
In this research paper, an Improved Cluster-first Routesecond Two-phased Heuristic algorithm is presented for solving CVRP and the performance of the presented heuristic algorithm is compared with another three prominent heuristic algorithms find in the literature: Efficient Twophased Heuristic algorithm, Savings algorithm and GA, using thirty well-known benchmarked problem instances. To illustrate the performance of the algorithm, a CVRP of a reputed spices and allied food manufacturing company was considered as a case study.

Mathematical formulation of the CVRP
The CVRP can be clearly represented by a weighted directed complete graph. Let G = (V, A), where V = {ν 1 , ν 2 , …, ν n } is a set of vertices that denotes the prime depot and customers, and A is a set of arcs that connects the vertices. For each arc (ν i , ν j ) there is a non-negative associated weight which represents the traveling cost between ν i and ν j . The mathematical model of the CVRP can be expressed as follows: where d i : demand of the i th customer, c ij : the distance between the vertices ν i and ν j , v 1 : the prime depot, Q: the vehicle capacity, x rij : a binary variable which represents the vehicle r traverses from ν i to ν j . The expression (1) represents the objective: minimizing the total traveling distance. The constraints, each customer is visited by exactly one vehicle, each vehicle initiates routing from the depot only once, and the number of vehicles arriving and leaving a particular vertex is equal are represented by equations (2) to (4) respectively. The vehicle capacity constraint is represented by the inequality (5) while the sub-tour elimination constraint is ensured by the inequality (6). The binary variable is stated in (7).

Two-phased heuristic algorithms
In two-phased heuristic algorithms, two separate consecutive phases are used to solve the CVRP. According to the literature, the two-phased heuristic algorithms are categorized into two approaches: route-first cluster-second approach and cluster-first rout-second approach. In the first approach, the first phase is used to create a large-scale TSP route disregarding the constraints of the CVRP. In the second phase, this TSP route is split into feasible vehicle routes. In the second approach, all the customers are clustered into several feasible clusters and subsequently, one of the TSP algorithms is used to construct the actual vehicle routes.
A recently proposed competitive cluster-first routsecond two-phased heuristic algorithm (Sandaruwan et al., 2019) was considered for improvements. At the beginning of the considered two-phased heuristic, a distance matrix is formed which contained the distances among all the vertices including the depot. Subsequently, an iterative procedure is used to create n (number of customers) number of sets of clusters. In each iteration, all customer vertices are clustered depending on a repeatedly updating distance list without exceeding the vehicle capacity. The sets of clusters may have different number of clusters (k). At the end of the first phase, the best set of clusters is selected based on the parameter defined in equation (8): In the second phase of the algorithm, the GA is separately applied to create the TSP routes of each cluster of the selected best set of clusters. The size of the initial population of the used GA is set to 100. The number of generations and elitism rate are set to 400 and 0.25 respectively. A special procedure is used for creating new generations which consists of three mutation techniques, namely Flip, Swap and Shift instead of standard crossover and mutation operators.

The improved two-phased heuristic algorithm
In the improved two-phased heuristic algorithm, several enhancements were made to both phases of the aforementioned two-phased heuristic algorithm. The same method is used to construct n number of sets of feasible clusters at the beginning of the first phase in the improved algorithm. Then five parameters, including the parameter defined above by (8), are evaluated for each and every set of feasible clusters. The new four parameters are stated from (9) to (12) as follows: At the end of the first phase, the five best sets of clusters are selected with regard to the above five parameters such that each set of clusters corresponds to a minimum value of the five parameters. Several parameters may take the minimum value for a selected set of clusters. Therefore, the unique sets of clusters are chosen from the five selected best sets and initiate the second phase of the heuristic.
In the second phase of the Improved Heuristic algorithm, only the chosen best unique sets of clusters (≤ 5) are considered. The TSP of each cluster is separately solved by applying the standard GA and the total traveling distance of each unique best set of clusters is evaluated. The pseudocode of the standard GA is mentioned in Figure  1. Then the set of clusters that has the minimum total traveling distance is selected as the final solution for the considered CVRP. The used configurations of the GA to solve the TSP are briefly explained here: The population size is set to 100 and the Tournament Selection is used as the selection operator of the Genetic algorithm with tournament size 4. The well-known Ordered Crossover operator is applied to generate new offspring. The Swap mutation operator is applied under the mutation probability 0.9. The best 10% chromosomes of the current population are directly sent to the next generation without any change (Elitism rate = 0.1). The stopping criterion is reaching 1000 number of generations or fitness value is not improved within 300 number of generations.
Since four additional parameters are evaluated in the first phase and the GA is applied to solve TSP of more than one set of clusters in the second phase of the improved heuristic algorithm, more CPU time is consumed by the improved heuristic algorithm than the original algorithm for solving CVRP. And also, the lower boundary of the solution generated by the Improved Heuristic algorithm is the optimal solution of the original heuristic algorithm.

The Clarke and Wright heuristic algorithm (Savings algorithm)
In the literature, the Clarke and Wright heuristic is the most frequently used algorithm for solving CVRP (Clarke and Wright, 1964). This heuristic is widely known as 'Savings algorithm' due to the fact that the heuristic is based on the notion of saving distance. The heuristic is initiated with an infeasible solution in which each customer is served by a separate vehicle which means n vehicles are used to serve n customers. Subsequently, saving distances S ij are calculated by the equation (13) for each pair of customers i and j, i ≠ j, where the cost of traveling between customers i and j is represented by C ij .
Then customer pairs are arranged in descending order of the saving distances and merging starts from the top. Two routes are merged if i and j are belonging to separate routes, subject to the vehicle capacity is not exceeded and, either i or j is the first or last customer on their routes. In the literature, there are two versions of the heuristic: Parallel version and Sequential version. In the Sequential version, the same route is expanded until no more merging is feasible but in the Parallel version the highest saving yielding pair is always merged. According to the literature, the Parallel version of the Clarke and Wright heuristic is more efficient (Volna and Kotyrba, 2016). Therefore, the Parallel version of the Clarke and Wright heuristic is used for this study.

The genetic algorithm
Among the various available metaheuristic algorithms for solving NP-hard optimization problems in the literature, the GA is considered to be more prominent and extensively used. The GA was derived based on the Charles Darwin's theory of biological evolution (Holland, 1995). The parameters and other configurations used for the GA to solve the CVRP are the same as the GA in the second phase of the Improved Heuristic which is applied to solve the TSP, except the following changes: The well-known Partially Mapped Crossover operator is applied to generate new offspring instead of the Ordered Crossover. The mutation probability is changed to 0.5 and the stopping criterion is changed to 5000 number of generations or fitness value does not improve within 500 number of generations. The fitness function and the operational constraints are changed accordingly.

The case study
The distribution schedule of a prominent Sri Lankan manufacturing company of spices and allied products was considered as a case study. The main manufacturing plant of the company is located in the Southern Province of Sri Lanka and it has 81 sub-distribution centers that are widely spread across the country. The demands of all the sub-distribution centers are obtained by the Logistics Department of the company and it schedules the weekly distribution routes. The transportation cost of this CVRP mainly depends on the total traveling distance. The company has a fleet of mini trucks, each having a capacity of 3,500 82 Padaviya 244.14 kg, to distribute the products which are assigned multiple trips in a week to satisfy the demands. For this study, demands of all the sub-distribution centers of a particular week, and the geographical locations of the distribution centers and the manufacturing plant were obtained from the Logistics Department of the company. The distances between all vertices were obtained from Google Maps. The predefined demands of the sub-distribution centers and the reference numbers are exhibited in the Table 1.
The objective of this case study was to determine a better distribution schedule to satisfy the weekly demands of all the sub-distribution centers while minimizing the total traveling distance.

The performance comparison
To compare the performance of the Improved Two-Phased Heuristic algorithm with the prominent heuristic algorithms find in the literature for solving the CVRP, thirty wellknown benchmarked problem instances (22 instances of Augerat et al. 1995 and8 instances of Christofides andEilon 1969) were considered. All the used benchmarked problem instances and their Best-Known Solutions (BKS) are available online at Capacitated Vehicle Routing Problem Library (CVRPLIB) ("CVRPLIB -All Instances", n.d.). Subsequently, all four heuristic algorithms including the Improved Two-Phased Heuristic algorithm were implemented in MATLAB 2014a (8.3.0.532) environment and run on a 1.60 GHz Intel Core i5 with 8.0 GB of RAM computer with the previously mentioned configurations. All the benchmarked problem instances were solved by applying these four heuristic algorithms. The total traveling distance, the CPU time required for execution and Relative Percentage Deviation (RPD) of the four heuristic algorithms for solving each benchmarked problem instance are presented in the following Table 2: To compare the significance of the optimal total traveling distances obtained by the considered four algorithms, a oneway ANOVA test (α = 0.05) was conducted by using RPD values. The results of the one-way ANOVA test revealed that there is a significant difference (p = 0.026). Therefore, the Fisher's Least Significant Difference (LSD) test was applied to perform the pairwise comparisons among the algorithms. The results of the Fisher's LSD test are shown in the Figure 2.
According to the results of the Fisher's LSD test, the optimal solutions reached by the Improved Two-Phased Heuristic is significantly better than the solutions found by the GA (p = 0.005) and the Savings algorithm (p = 0.038). According to the results of the Fisher's LSD test, the difference between the Two-phased Heuristic and the Improved Two-phased Heuristic is not statistically significant (p = 0.357). But, when comparing the obtained total traveling distance for each benchmarked problem instance alone as it is seen in Table 2, better optimal solutions are found by the Improved Two-phased Heuristic for 15 out of 30 instances which are highlighted in the Table  2 and for the remaining 15 instances, both algorithms have reached to the same near-optimal solutions. Therefore, from the optimal solutions point of view, the Improved Two-phased Heuristic algorithm has performed better than the counter three algorithms considered in the study.
For each algorithm, a line graph of CPU time against 30 benchmarked problem instances is given in the Figure 3 below. The line graph exhibits that marginally more CPU time is consumed by the Improved Heuristic algorithm than the original Two-phased Heuristic and Savings algorithms. However, when compared to the CPU time consumed by the GA, the Improved Heuristic algorithm is moderately better.
Moreover, Table 2 shows that there are three negative values for RPD correspond to problem instance P-n22-k8 and E-n30-k3 which indicate that the related solutions have reached better solutions than the BKS. Therefore, in this study, the BKS of the benchmarked problem instances P-n22-k8 and E-n30-k3 are improved to 588.79 and 520.20 units respectively.

The case study
To illustrate the proposed Improved Two-phased Heuristic algorithm and its applicability, the distribution schedule of a reputed food manufacturing company was considered as a case study. The considered case study problem was solved by applying the aforementioned four heuristic algorithms separately. As the solution of each heuristic algorithm: set of routes, corresponding load and distance of the routes, total traveling distance, number of required vehicles and CPU time taken for the execution were observed. The summary of the results obtained by all four heuristic algorithms is stated in Table 3.
The main objective of the considered CVRP is to minimize the total traveling distance of the weekly distribution schedule. According to the Table 3, the minimum total traveling distance (10567 km) was determined by the Improved Two-phased Heuristic algorithm. Compared to the GA, less CPU time was consumed by the improved algorithm and requires 26 vehicles to distribute the products to all the sub-distribution centers. The details of the routes generated by the improved algorithm are exhibited in Table  4. In the table, routes are denoted by reference numbers of the sub-distribution centers which represent the sequence of routing, where number 1 referred to the manufacturing plant.
The solutions found by the heuristic algorithms clearly show that the manufacturing company prepares the distribution schedule not using any logical or analytical reasoning, but based only on its experience. The optimum distribution schedule generated by the improved heuristic algorithm has proven that the total traveling distance for distributing the manufactured products of the company to the sub-distribution centers is significantly reduced. In addition, the proposed algorithm has simplified and eased the process of preparing the weekly distribution schedules of the company.

CONCLUSION
In this research paper, an improved cluster-first routesecond two-phased heuristic algorithm was presented for solving CVRP. At the completion of solving 30 wellknown benchmarked problem instances, it was revealed that the Improved Two-phased Heuristic algorithm finds the least total traveling distance, compared to the Twophased Heuristic algorithm, GA, and Savings algorithm. Also, in this study, the BKSs of two benchmarked problem instances were improved. The case study of the food manufacturing company was solved satisfactorily. The distribution schedule recommended by the proposed algorithm has reduced the total traveling distance and also optimized the company resources. As a future direction, optimizing the route distance balancing and reducing the travel time of the CVRP could be investigated.