A dynamic space reduction ant colony optimization for capacitated vehicle routing problem

As a typical meta-heuristic algorithm, ant colony optimization (ACO) has achieved good results in solving discrete combinatorial optimization problems. However, it suffers from poor solutions and the drawback of easily being trapped in local optima. This paper presents a new type of ACO called “dynamic space reduction ant colony optimization” (DSRACO) to solve the capacitated vehicle routing problem, which is a typical nondeterministic polynomial-hard optimization problem. In DSRACO, ACO is integrated with a unique dynamic space reduction method, an elite enhanced mechanism, and large-scale neighborhood search methods to improve the quality of the solution. The performance of DSRACO is evaluated using 73 well-known benchmark instances in comparison with ACO and three other cutting-edge algorithms. The experimental results show that DSRACO can solve CVRP with a satisfactory result.


Introduction
Modern supply chains require the transportation of commodities in a variety of settings, including inside a city, region, country, or even throughout the world. Realizing the importance of this respect, a lot of researchers devote themselves to finding optimal and novel solutions for more efficient transportation and vehicle routing problems are put forward under such circumstances.
Vehicle routing problem (VRP) is one of the fundamental problems in operational research and physical distribution. The typical VRP and its variants, including capacitated VRP, multi-depot VRP, dynamic VRP, and VRP with time window are extensively studied and arouse great interest among researchers. VRP is a typical nondeterministic polynomial-hard (NP-hard) optimization problem (Karp 1972) and the study of VRP effectively promotes the development of evolutionary computation and discrete combinatorial optimization.
The formulation of capacitated vehicle routing problem (CVRP) was proposed by Dantzig and Ramser (1959). CVRP entails meeting the needs of ''n'' geographically dispersed customers from a central depot using a fleet of available vehicles with identical capacity at the lowest possible cost. The main goal of CVRP is to minimize the total distance (TD). The constraints commonly considered for CVRP are: (i)total demand of all the customers served on each route must be less than or equal to the total capacity of each vehicle, (ii)each customer is served by a single vehicle only once, and (iii)all the vehicles must start from and return to the same depot.
Common methods for solving VRP are exact methods and meta-heuristic algorithms. Exact methods, such as the branch and cut algorithm, which uses cutting planes to tighten linear programming relaxations, are only appropriate for small-scale VRP problems (Baldacci et al. 2012(Baldacci et al. , 2008. As the size of the problem grows larger, exact methods take an excessive amount of time to find the best solution. On the contrary, meta-heuristic algorithms are effective to solve various discrete combinatorial optimization problems in reasonable time limits (Costa and Hertz 1997;Huang and Yang 2008;Euchi and Mraihi 2012;Gendreau and Potvin 2005;Gendreau et al. 2008).
Ant colony optimization is a nature-inspired swarm intelligence algorithm and was first proposed by Dorigo and his colleagues in the early 1990's (Dorigo 1992;Dorigo et al. 1996) to forage the behavior of real ants in search of food. When searching for food, ants release pheromones on their path and can communicate via them for decision making. Paths with higher pheromone content will be selected by more ants. Due to evaporation, the pheromone on the path will gradually disappear over time, which motivates ants to explore more paths. Unlike other meta-heuristic algorithms such as particle swarm optimization (PSO) and differential evolution algorithm (DE), the pheromone mechanism of ant colony algorithm (ACO) can more effectively combine probability construction with total distance, making it more suitable for solving VRP. Wang et al. (2016) propose a novel ACO algorithm to solve CVRP. The proposed algorithm allows ants to go in and out of the depots more than once until they have visited all customers, which simplifies the procedure of constructing feasible solutions. Zhang et al. (2019) propose a solution strategy based on ant colony optimization and three mutation operators (2-opt, shift, and inverse), which incorporates the concept of Pareto optimality for multiobjective optimization. Lin et al. (2019) put forward an effective order-aware hybrid genetic algorithm for CVRP. The method is characterized by an improved initialization strategy and a problem-specific crossover operator. The former combines the sweep algorithm, while the latter integrates neighborhood search heuristics to find the offspring with the best fitness and check constraints simultaneously. Szeto et al. (2011) present a variant of the artificial bee colony (ABC) algorithm for VRP. The proposed algorithm is integrated with 7 neighborhood search methods to improve the solution, but its neighborhood search mechanism is still relatively simple and the search range is small. Kao et al. (2012) hybridize ACS and PSO to solve VRP. To avoid the stagnation of pheromone, they propose a pheromone disturbance approach. Altabeeb et al. (2019) propose an improved hybrid firefly algorithm for CVRP. The algorithm is integrated with types of local search (2-opt and 2-h-opt) and genetic operators to enhance the quality of the solution and accelerate the convergence. Goel and Maini (2018) present a hybrid of the ant colony and firefly algorithms (HAFA) to solve CVRP and they test the algorithm both on CVRP and VRPTW. Akpinar (2016) proposes a new hybrid algorithm that executes large neighborhood search (removal and insertion operators) methods in combination with the solution construction mechanism of the ant colony optimization for capacitated vehicle routing problem. Mahdi and Shokouhi (2018) put forward a hybrid algorithm composed of adaptive large neighborhood search and variable neighborhood search. The proposed algorithm aims to solve the multi-depot multi-compartment vehicle routing problem and the neighborhood search methods include one-move, twomove, one-exchange, two-exchange, product spilt, and product aggregation. Juan et al. (2010) propose a hybrid algorithm that combines a CVRP classical heuristic with Monte Carlo simulation using state-of-the-art random number generators, but the experimental results of the proposed algorithm are not good enough. With the goal of decreasing the overall distance, Amous et al. (2017) provide a variable neighborhood search (VNS) algorithm for CVRP, however its neighborhood search mechanism only incorporates simple insertion and swaps.
To solve the drawbacks of poor solutions and local optima of ant colony optimization, this paper presents an improved algorithm, termed ''dynamic space reduction ant colony optimization'' (DSRACO). The main contributions of our work can be described as follows: Dynamic space reduction method In the beginning, the ant colony can freely explore the whole solution space to avoid local optima. With the iteration going on, the next destination of the ant colony is fixed on several cities nearest to improve the quality of the solution.
Elite enhanced mechanism To the best of our knowledge, most of the elite methods applied to ant colony optimization are single elite, and no one has studied the number of elites in detail. In this paper, a method of selecting several individuals as elites is proposed and a detailed corresponding parameter analysis is given.
Large-scale neighborhood search operators As mentioned above, most neighborhood methods include only 2-opt, 2-h-opt, and so on. Its search range is relatively small and cannot effectively explore the solution space. This paper proposes a large-scale neighborhood search method to improve the quality of the solution.
This paper is organized as follows: In Sect. 2, a brief introduction to VRP is given and the mathematical model of CVRP is formulated. The proposed algorithm (DSRACO) is elaborated in Sect. 3. The detailed parameter settings and relevant analysis are given in Sect. 4. Section 5 details the performance of DSRACO and compares it to other algorithms. Section 6 discusses the paper's conclusion based on the current study.

Mathematical modeling of capacitated vehicle routing problem
Capacitated vehicle routing problem is one of the most widely studied typical NP-hard combinatorial optimization problems, and it can be described as a graph, G ¼ ðN; EÞ, with a set of nodes N ¼ f0; 1; . . .; ng where node 0 represents the depot and f1; 2; . . .; ng represents the customers. Each edge fi; jg 2 E has a non-negative cost C ij . Each customer i 2 V 0 ¼ Vnf0g has a specific demand q i (i = 1, 2, …, n). For a single depot 0, a set of homogeneous vehicles K with the same capacity limit Q. The goal of the CVRP is to determine the routes of the vehicles that can satisfy all the customers' needs while minimizing total distance. The mathematical representation of CVRP can be modeled as (Lin et al. 2009): Subject to Equation (1) is the objective function that minimizes the total distance traveled by the vehicles. If the vehicle k travels from customer i to customer j directly, X k ij ¼ 1 otherwise, X k ij ¼ 0. The remaining equations represent a series of constraints as follows:(i) Eqs. (2) and (3) make sure that each customer is severed exactly by one vehicle; (ii) constraint (4) ensures that total demand in a route does not exceed the capacity of each vehicle Q; and (iii) constraints (5) guarantees that each vehicle's route starts and ends at the same depot. A solution is feasible if no customer is severed more than once and all routes meet the capacity constrain. As for the number of the vehicles k, some researchers consider it as a decision variable (Amous et al. 2017), however, some researchers consider it as a constrain (Narasimha et al. 2013).

The proposed dynamic space reduction ant colony optimization
A new variant of ACO, called DSRACO, is proposed. The main goal of DSRACO is to overcome the drawbacks of ACO that easily get stuck in local optima and poor solution. Dynamic space reduction method and elite enhanced mechanism to improve the quality of the solution. In addition, traditional neighborhood search methods cannot effectively avoid local optima, DSRACO integrates a unique large-scale neighborhood search strategy to guarantee the exploitation of the solution space. The pseudocode of DSRACO is shown in Algorithm 1. In each step, DSRACO must satisfy the constraints of CVRP. The proposed DSRACO will be discussed in detail in this section.

Overall framework of DSRACO
The overall framework of DSRACO can be described as follows: (i) Initialization; (ii) Establish the feasible cities set by dynamic space reduction method; (iii) Build the ant colony(named initial ant colony) according to heuristic function and path pheromone content; (iv) Perform neighborhood search on initial ant colonies to generate neighborhood ant colony; (v) Merge initial ant colony with neighborhood ant colony and calculate the distance cost of each ant;(vi) Select several best elites to update the pheromone and update the current global optimal solution; (vii) Repeat step (ii) to step (vi) until the maximum iteration is met; (viii) Output the global optimal solution of each generation. The overall framework of the proposed DSRACO can be seen in Fig. 1.

Solution representations
In order to introduce DSRACO more concisely, we'd like to first explain the representations of the solution. DSRACO generates the solution to CVRP in two permutation representations. As shown in Fig. 2, CVRP solution representation is represented as an array list P K i¼1 ðS i þ 2Þ, where K is the number of vehicles, S i is the number of customers who are assigned to each route, and 0 is the start and the endpoint (the depot) of each route i. TSP solution representation is represented as one-dimension array (N), where N is the number of customers including the depot. The two forms of solution representations can make it simple to convert a TSP solution to a CVRP solution and vice versa. This strategy considerably simplifies the algorithm process and facilitates large-scale neighborhood search.

Initialization
In the initialization phase, the basic parameters of the algorithm are given, as well as the customer location, the distance between each customer, and the distance between each customer and the depot. Besides, set the initial total distance cost to infinity.
The basic parameters to be set are the maximum number of iterations (MI), population size (PS), the pheromone evaporation rate (q), the relative influence of pheromone (a), the relative influence of visibility (b), and the amount of pheromone deposited by each ant (Q). The basic information of distance is the distance between customer i and customer j (d ij ) and the distance from customer i to the depot (d i0 ).

Dynamic space reduction method
As one of the important contributions of this paper, the dynamic space reduction method enables the ant colony to explore the whole solution space in the initial stage of the algorithm, and with the iteration going on, each ant only chooses some nearest cities as the next destination. The dynamic space reduction method greatly improves the quality of the solution, and the method will be elaborated upon in the following content.
First, we need to get a set of cities that have not been visited X ðVnv 0 Þ. Then, sort the elements in X by distance. After that, select the top SR elements from X according to Eq. (6) to form F.
Here, floor denotes the rounding down function, n is the total number of cities to be visited, Iter is the current iteration and MI is the maximum iteration. We can see that when Iter is small, SR is approximately equal to n and when Iter is large SR is approximately equal to 3. Dynamic space reduction is completed by the above method.

Method to build the initial ant colony
As with most ant colony algorithms (Goel and Maini 2018), this paper uses the reciprocal of the distance between two customers (7) as a heuristic function.
Transfer probability between customers is given by (8).
Here, s ij denotes the pheromone content on the path between customer i and customer j, F is the feasible cities generated by dynamic space reduction, a and b represent the biases for pheromone trail and visibility, respectively, and they represent parameters to weigh pheromone concentration.
The pheromone update rule is given by (9).
Each ant is constructed according to the following steps: (i) each route takes the depot as the start point and the endpoint; (ii) each customer is selected from the candidate  list by (8), and once the customer is selected, it is deleted from the list to guarantee the customers is not selected again; (iii) the selected customer is added to the route in order; (iv) if the demand of the corresponding route does not exceed the load limit of the vehicle; repeat step(ii) and step(iii); Otherwise, add the depot to the route as the endpoint and construct the next vehicle's route; (v) steps (i) to (iv) are repeated until all customers' needs are satisfied; (vi) check the feasibility of each route.
Step(vi) is essential to CVRP, but it is often overlooked.

Large-scale neighborhood search operators
The main goal of neighborhood search is to prevent the algorithm from falling into local optima and improve the quality of the solution. The neighborhood search methods of DSRACO mainly include 2-opt, shift, reverse, and random sort operators. These neighborhood search operators will be explained in the TSP solution. It's worth noting that each neighborhood search method has the same probability of being chosen. 2-opt operator Randomly exchange a pair of nodes. Figure 3 shows the new solution obtained by 2-opt operator.
Reverse operator Randomly select two nodes, e.g., by reverse operator, we can get a new sequence shown in Fig. 4.
Shift operator Randomly select two nodes, e.g., the first customer between the two nodes is moved to the last position and the other customers are, respectively, moved to the position next to them. The new solution obtained by shift operator is shown in Fig. 5.
Random sort operator Randomly generate a row vector between 5 and n/2, use this vector as a node subscript, then shuffle its order and sort it randomly. The result is shown in Fig. 6.

Update of global optimal solution and elite enhanced mechanism
Once the ant is constructed, its corresponding objective function value is calculated. The objective function is the total distance cost, which includes the distance from the depot to the first customer and the last customer to depot.
Since the goal of CVRP is to minimize the total distance, the ant with a lower objective function will replace the current global optimal solution. As mentioned above, only elites can update pheromones. Thus, the number of elites is particularly critical. If the number of elites is too small, the global search ability of the algorithm is poor, and the solution is not ideal, but if there are too many elites, the convergence rate of the algorithm will be significantly slower. Each elite updates the pheromone according to (9), and discussion on the number of elites will be introduced later.

Parameter setting
There are many adjustable parameters in ant colony optimization (ACO) (Oliveira et al. 2017), and these parameters have a great influence on the final solution. According to (Situ et al. 2017;Jangra and Kait 2017;Melo et al. 2014), the relative influence of pheromone a is set to 1, the relative influence of visibility b is set to 2, and the pheromone evaporation rate q is set to 0.1. Considering the computing resources required by different problem dimensions, the population size (PS) is set to 10 9 N, where N is the number of customers including the depot. The maximum iteration (MI) is set to 1500 to stop the main loop of DSRACO.
Apart from a, b, q, PS and MI, the number of elites (NE) is also a key parameter for the proposed algorithm. To determine NE, a series of comparison experiments are carried out on different standard benchmarks (Augerat 2006). For A-, B-, P-set benchmarks, A-n33k6, A-n38k5, A-n46k7, A-n65k9, B-n31k5, B-n44k7, B-n68k9, P-n19k2, Pn22k8, P-n60k15 are selected. DSRACO runs 30 times independently for each tested instance in different NE (1,2,3,4,5,10,15) and the statistical results in terms of mean value are shown in Table 1. For each instance, the optimal result is bold and labeled.
As shown in Table 1, the number of elite NE has a great influence on the final solution of the proposed DSRACO. When NE is small, the algorithm is more likely to be guided by optimal individuals and tends to perform local search. When NE is large, the algorithm is more likely to perform global exploration and obtain the global optimal. In all ten tested instances, six optimal results are achieved  Fig. 6 New solution obtained by random sort operator by NE = 3 and the other four optimal results are obtained by NE = 1, NE = 2, NE = 4, and NE = 5, respectively. Without doubt, when NE = 3, DSRACO can have a good balance between local exploitation and global exploration and show the best performance. The parameter settings are summarized in Table 2.

Computational study
A series of comparison experiments were carried out to verify the effectiveness of the proposed DSRACO. DSRACO is compared with the original ant colony optimization in terms of mean value, best solution, and runtime for the same population size and maximum iterations. Besides, an improved version of ACO (LNS-ACO) (Akpinar 2016) and other two state-of-the-art algorithms (OHGA (Lin et al. 2019), CVRP-FA (Altabeeb et al. 2019)) are also tested in three series of standard benchmarks A, B, and P (Augerat 2006). For DSRACO and ACO, each algorithm runs 30 times independently and is tested with specifications of Intel i5-8400 at 2.80 GHz CPU and 8 GB RAM. Runtime is measured in units of seconds. For LNS-ACO, OHGA, and CVRP-FA, the best solutions are intercepted from the paper to maintain the quality of the algorithm.

Comparison results of A-set benchmark
As an important standard benchmark, A-set benchmark contains 27 instances from 32 to 80 customers, which can test the ability of each algorithm to solve discrete combinatorial problems. The comparison results of A-set benchmark are shown in Table 3, and the best result of each instance is bold. Besides, if the best solution reaches the best known solution (BKS), a italics label is added. To show the results more intuitively, Fig. 7 demonstrates the planned routes obtained by DSRACO.
As shown in Table 3, DSRACO gets 15 optimal solutions in 27 instances in comparison with ACO, LNS-ACO, OHGA, and CVRP-FA. It is also worth noting that DSRACO achieves BKS in 12 instances, which fully proves that the proposed algorithm has a satisfactory solution quality. In all 27 tested A-set instances, DSRACO outperforms ACO in terms of mean value and best solution. However, DSRACO takes a little longer runtime than ACO as stated above. Compared to LNS-ACO, DSRACO performs better in A-n45k6, A-n61k9, A-n65k9 but is slightly inferior in six instances.
As Fig. 7 indicates, the routes planned by DSRACO are well organized. In addition, the distance between two neighboring cities along the route is often close, which is the contribution of the dynamic space reduction method. Benefiting from the large-scale neighborhood search operators, the routes between different vehicles are also well coordinated.

Comparison results of B-set benchmark
B-set benchmark plays an indispensable role in CVRP, which consists of customers from 31 to 78 and vehicles from 5 to 10. In B-set benchmark, ACO and DSRACP are compared in terms of mean value, best solution, and runtime. For LNS-ACO, OHGA, and CVRP-FA, the best solutions are intercepted from the corresponding papers. The statistical results are summarized in Table 4 and the optimal value for each instance is bold. Additionally, if the BKS is found, a italics label will be added. Figure 8 shows the planned routes obtained by DSRACO to show the results more intuitively. As shown in Table 4, the optimal solutions obtained by DSRACO are 14 out of 23. Moreover, DSRACO finds 13 BKS, outperforming OHGA and CVRP-FA. DSRACO outperforms ACO in terms of mean value and best solution in all tested B-set instances. It's also worth mentioning that, because of the large-scale neighborhood search operators, DSRACO takes a little longer to run than ACO. As the data in Table 4, DSRACO performs better in B-n63k10, while the LNS-ACO performs better in B-n51k7, B-n56k7, and B-n57k9.
As Fig. 8 demonstrates, the routes planned by DSRACO are not crossed or misplaced despite the dense city distribution, which fully proves the effectiveness of the largescale neighborhood search operators. Each vehicle also prefers a closer city as the next visit target, which also shows the role of the dynamic space reduction method.

Comparison results of P-set benchmark
P-set benchmark is an essential standard benchmark that has 23 instances ranging from 16 to 101 customers and may be used to assess the ability of each algorithm to tackle discrete combinatorial problems. Table 5 shows the comparative results of the P-set benchmark, with the best result of each instance bolded. A italics label is also placed if the optimal solution achieves the best known solution (BKS). The planned routes obtained by DSRACO are shown in Fig. 9 to make the results more apparent.
The optimal solutions obtained by DSRACO are 14 out of 23, as indicated in Table 4. DSRACO also detects 13 BKS, exceeding OHGA and CVRP-FA. In all B-set instances tested, DSRACO exceeds ACO in terms of mean value and best solution. Compared with ACO, DSRACO takes less time to update pheromones but more time to operate the large-scale neighborhood search. According to Table 4, DSRACO outperforms LNS-ACO in P-n51k10 and P-n70k10, while LNS-ACO outperforms P-n50k7, P-n51k7, and P-n55k10. From Fig. 9, the routes between different vehicles are well coordinated, which fully demonstrates the effectiveness of the dynamic space reduction method and the largescale neighborhood search operators.

Performance analysis
This section conducts a series of comparison experiments with benchmarks A, B, and P. DSRACO is compared with ACO in terms of mean value, best solution, and runtime. Furthermore, the best solutions of DSRACO and three other state-of-the-art algorithms are compared. To show the statistical results more intuitively, the BKS and optimal solution found by each algorithm are summarized in Table 6. As Table 6 states, DSRACO finds 38 BKS and 43 optimal solutions out of 73, which is a competitive result. DSRACO and OHGA performed consistently in both BKS and Optimal. Compared with LNS-ACO and CVRP-FA, DSRACO appears to be less satisfactory mainly in terms of Optimal. However, it is also worth noting that DSRACO outperforms ACO in all tested instances with only a slightly longer runtime.
In summary, DSRACO performs much better than ACO and can solve capacitated vehicle routing problem (CVRP) with a satisfactory solution.

Conclusion
This paper presents a dynamic space reduction ant colony optimization to solve capacitated vehicle routing problem.
In the proposed DSRACO, ACO is integrated with a unique dynamic space reduction method, an elite enhanced mechanism, and large-scale neighborhood search methods to improve the solution. The dynamic space reduction method can avoid local optima. The elite enhanced mechanism further improves the quality of the solution.
Besides, four methods of neighborhood search, including 2-opt, reverse, shift, and random sort are integrated to improve the exploitation of the solution space in which random sort can effectively explore the global space. The experimental results show that DSRACO is effective for solving CVRP instances with satisfactory performance. DSRACO shows great advantages in the comparison of ACO and is competitive compared with the other three state-of-the-art algorithms. In future work, the DSRACO algorithm can be applied to solve other types of VRP or other discrete combination optimization problems. Besides, DSRACO can be further developed using a multi-objective optimization framework.
Funding This study was funded by the National Natural Science Foundation of China (Grant No. 51875466) and (Grant No. 52175251).
Data availability The data, models, and code required to reproduce these findings cannot be shared at this time as the data also form part of an ongoing study.

Declarations
Conflict of interest The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
Ethical approval This article does not contain any studies with human participants performed by any of the authors.