# An Intelligent Data Analysis of the Structure of NP Problems for Efficient Solution: The Vehicle Routing Case

- 1 Citations
- 488 Downloads

## Abstract

The Vehicle Routing Problem is a combinatorial problem with considerable industrial applications such as in traditional logistics and transportation, or in modern carpooling. The importance of even small contributions to this problem is strongly reflected in a significant cost savings, pollution, waste, etc., given the high impact of the sector in almost any economic transaction. The VRP is often treated as an optimization problem, however, the fitness function converges quickly and the algorithms become stagnant in late steps of the executions, which is a recurrent problem. In this work, we perform an analysis of the structure of solutions to identify potential use of existing ideas from other domains to achieve higher efficiency. In this sense, the feasibility of applying the Partition Crossover –an operator initially designed to tunnel through local optima for the Travelling Salesman Problem– to the Capacitated Vehicle Routing Problem is studied in order to escape local optima. Moreover, an implementation is provided along with an analysis applied to real use-cases, which show a promising rate of local optima tunneling.

## Keywords

Optimization Data analysis Crossover operator Genetic algorithms Local optima Graph theory Smart cities## 1 Introduction

In this work, we research the similitude of the Vehicle Routing Problem (VRP) to the Travelling Salesman Problem (TSP), and try to make an exercise of cross-fertilization by analyzing the underlying structure of their solutions. We try to find a way of using this analysis to port recent advances in TSP, the *partition crossover*, to VRP. In particular, we will try to apply such methodology to the Capacitated Vehicle Routing Problem (CVRP). The CVRP is an extension of the VRP, an NP-hard problem –that is, the best known algorithm to solve it requires polynomial time in a non-deterministic Turing Machine– which can be seen as a *n*-dimensional generalization of the TSP. The CVRP is formalized as an undirected graph \(G = (\mathbf V , \mathbf E )\) where \(\mathbf V \) is a set of vertices \(\{v_0, v_1, ..., v_n\}\) and \(\mathbf E \) is a set of edges \((v_i, v_j)\). Each edge \((v_i, v_j)\) has an associated travelling cost, and each vertex \(v_i\) has an associated customer demand. A fleet of *m* vehicles with uniform capacity must determine the set of *m* non-overlapping routes except for the initial vertex (depot) of minimum cost and while holding the capacity constraint, incremented by the customer demand as each vertex is travelled.

Whitley et al. [1] showed that jumping between local optimal solutions in genetic algorithms is possible by applying a recombination method called partition crossover that respects and maintains certain properties of the parents across offspring (i.e. a respectful operator [2]). Additionally, it was shown that local optima is often found between the offspring, thus making the partition crossover (PX from now on) a powerful operator to guide the search in latter stages, where traditional evolutionary algorithms get stuck and do not generate new solutions [3]. PX and its generalizations (e.g. [4]) are based on searching in the space of a partition of the solution components (i.e. vertices). If the cardinality of the partition is *q*, PX returns the best solution among \(2^q\) solutions in linear time. Therefore, the operator is able to jump through an exponential number of possible solutions to find new local optima when certain conditions in the solutions are met.

Such landscape jumps can be performed to quickly produce better solutions and thus improve graph-like problems, which can be found commonly within the design of Smart Cities: from vehicle parking applications or smart carpooling to modeling urban water-supplies networks. Moreover, in this manuscript, we first propose an analysis and then an operational method to port PX from TSP to CVRP while hopefully maintaining the same properties, which finally leads to unseen performances. Furthermore, we perform an in-depth analysis of the relation between the geometry of the solutions that are being recombined and the success rate of yielding new local optima. At last, we apply the algorithm to state-of-the-art instances that could depict recurrent scenarios to deal with in Smart Cities.

## 2 Analysis and Operational Proposal

In this section, we start our analysis of the problem solutions within TSP and CVRP, so that the different methods that compose the Partition Crossover (PX) operator are highlighted and discussed. In particular, this section will address: (1) Original PX operator applied to the TSP, (2) Modifications performed to the PX operator in order to apply it to CVRP, (3) Encoding of chromosomes in the CVRP, (4) Generation of initial solutions and local search methods and (5) Application of the modified PX operator to the CVRP.

### 2.1 Original Partition Crossover for the Travelling Salesman Problem

*m*the number of solutions used in the TSP) by finding a partition of cost 2 of the original graph

*G*. Such partition can be found in polynomial time as described below:

- 1.
First, the reduced graph \(G^{*}\) is constructed by removing common edges (common tours between parent solutions \(P_1\) and \(P_2\)). If more than two partitions exists, the crossover operator fails.

- 2.
Secondly, the two tours contained in the partitions are swapped with each other. Thus two offspring are produced, \(O_1\) and \(O_2\), where \(O_1\) is equal to \(P_1\) except for a tour in one of the partitions. Likewise, \(O_2\) is equal to \(P_2\) except for the contrary tour to that of \(O_1\).

*q*the number of partitions). On a second paper [6], Whitley et al. described an improvement upon the PX operator such that reduced graphs \(G^*\) with more than two partitions could be recombined, and additionally, the procedure was developed not only for the Symmetric TSP but for the Asymmetric one. In particular, this was accomplished by splitting nodes with degree 4 into two nodes of degree 3 with a common edge of cost zero between them. Such procedure enables to partition the space of nodes, and more important, allows to detect entries and exits within partitions. Entries and exits depend on the direction of the edges (i.e. the order within a partition matters), which has to be accounted for in the case of the asymmetric TSP. The detection of entries and exits is crucial for the operator since it allows to recombine partitions on their own, without the limitation imposed on the previous algorithm. Partitions will be feasible if their entries and exits are equal, since a partition is composed of the same nodes in both parent solutions, therefore if both solutions enter and exit the partition in the same fashion, they have travelled all nodes but using a distinct route. In short, the described PX operator produces more partitions since:

- 1.
Nodes with degree 2 are common, and either belong to a partition, or separate two partitions.

- 2.
Nodes with degree 3 belong to a partition, since these are connected to common edges in one side, and are the entry or exit to a partition on the other.

- 3.
Nodes with degree 4 are converted to degree 3 by adding a ghost vertex. Thus, these nodes also belong to a partition given the above argument.

Therefore, all nodes either belong to a partition or separate two partitions because they are common edges shared by the parent solutions.

### 2.2 Modifications in the PX Operator to Fit CVRP Constraints

The Vehicle Routing Problem includes unique characteristics that are not present in the Travelling Salesman Problem; although several ones are shared, the porting of the PX from TSP to VRP is not straightforward. In this section we will review which changes have to be addressed in order to transit from one operator to the other.

**Starting Route Node.** As reflected in the encoding of the chromosome, all routes are required to start from the depot and to return back once their capacity is reached. This limitation forces that a subset of edges between the ending nodes (i.e. last customers visited before return to depot) and the depot can not be used for the generation of partitions. Briefly, the depot node could be considered as being part of *any* partition, thus making it a common edge available to connect petals. However, a recombination performs a rearrangement (permutation) on the nodes that belong to the partition, and thus the order in which the depot is visited would be affected and the capacity constraints would not hold for the resulting route. Hence, the depot node must be considered as a partition breakpoint, and recombination must be performed between overlapping petals without including the depot.

**Capacity.**The biggest drawback in the generation of recombinable partitions is the capacity limitation. When the capacity constraint is reached, the vehicle is forced to return to the depot. From the perspective of optimal routing (as in TSP), this limitation abruptly breaks (and starts) a route that follows a greedy (or even near-optimal) path, which has a higher probability of being included in the optimal solution. Therefore, the capacity constraint produces two main effects:

- 1.
Common edges that could connect partitions are removed, since these are forced to return to the depot.

- 2.
The number of partitions is larger than that of the same instance treated as a TSP. However, these partitions are of smaller size, and since there is a reduction of common edges that tend to form part of the optimal solutions, entries and exits into these make a considerable amount of partitions become unfeasible.

Moreover, to improve the feasibility of the smaller partitions, subroutes can also be evaluated inside unfeasible partitions (partitions whose entries and exits do not match), since an unfeasible partition can contain feasible subroutes, i.e. a route in each solution and partition shares the same entry and exit. Such route can be used to recombine the solutions, although the partition is not fully recombinable.

### 2.3 Application of the Modified PX Operator to the CVRP

This section describes how the PX is applied to CVRP while addressing the constraints depicted in the previous section.

**Encoding of CVRP Solutions.**In order to enable manipulation of the CVRP instance, the solutions have to firstly be encoded in chromosomes. This is done by numbering nodes (customers and the depot) from 0 to

*n*, being

*n*the number of customers, and 0 the depot, from which all vehicles start their routes. Such encoding is accomplished by using a string of integer numbers. Therefore, a single chromosome for a CVRP with

*k*vehicles and

*n*nodes is a string containing all of the

*n*nodes, separated with the depot marker 0. Hence, the length of a chromosome with

*n*nodes and

*k*vehicles is \(n+k-1\). For instance, a representation of a CVRP instance with \(n=8\) and \(k=3\) could be depicted as shown in the chromosome in Fig. 1:

### 2.4 Generation of Initial Solutions

Initial solutions are generated using the Petal algorithm [7]. In particular, the Petal algorithm has proved to be a good starting point in the resolution of the VRP [8], since optimal solutions often show a petal-like structure. In order to produce the petal structures, all nodes are firstly labeled radially in polar coordinates \(r\ \rho \) with respect to the cartesian coordinates of the depot. The ray *r* is discarded and the nodes are sorted by their angle \(\rho \). This procedure enables the construction of a sequence of sorted nodes to generate petal-like structured routes in the CVRP. In later sections, we will address the use of this sequence to improve the number of recombinations in the PX operator.

### 2.5 Improving the Recombination Rate Using Node Shifting

*A*visiting first customer \(c_1\) and ending in \(c_n\) will share \(n-1\) nodes with a solution

*B*that visits first customer \(c_2\) and ends in \(c_n+1\). The partitions generated by this method rely on customer demands not following a uniform distribution and hence sharing less nodes between overlapping solutions. To overcome this limitation, a recurrence equation to visit nodes is introduced as a modification of the petal algorithm. This modification is based on two principles:

- 1.
The ideal partition has only one entry and one exit, and the rest of nodes is within these two common edges.

- 2.
The nodes within the common edges (inside the partition) should have the minimum number of common edges in order to favor recombination.

*n*is the number of nodes in the instance. This recurrence generates the succession \(s_i, s_{i+2}, s_{i+1}, s_{i+3}, s_{i+5}, s_{i+4}, s_{i+6}, \dots \) which is represented graphically in Fig. 2. Notice that no initial shift is used in the generation of the modified solution in order to enable a visual appreciation of the recurrence. However, a shift in the starting node by \(\rho \) would discard nodes from \(c_0\) to \(c_i\) and end in nodes from \(c_j\) to \(c_{j+k}\), thus modifying the overlapping of the structure.

Additionally, notice that the routes inside the common edges (\(\{d, c_0\}\) and \(\{c_{10}, d\}\)) share no common edges and thus pose the most adequate scenario for the PX operator.

### 2.6 Application of the Modified PX Operator to the CVRP

*m*the number of initial solutions. For each offspring \(O_{ij}\) from parents \(P_i\) and \(P_j\), the fitness value is stored along with the number of recombinations obtained. Algorithm 1 shows the pseudo code for the incremental recombination of shifted solutions.

## 3 Results and Discussion

- 1.
Compare the petal structure of the shifting strategy with and without local search.

- 2.
Compare the number of recombinations and tunnels between local optima as a function of the shift across several CVRP instances.

As discussed throughout this manuscript, the main contribution of this work is a first approach to the PX operator in the CVRP and to analyze the underlying structures that appear near local-optima. Additionally, we propose a procedure to port the PX operator from TSP to VRP, and a procedure to obtain a higher ratio of recombination between solutions along with the tunneling of local optima. In this sense, it is important to remark that this work, in its current state, does not aim to compete with state of the art methods in terms of fitness and performance. At this point, we present a framework to perform tunneling between local optima in the CVRP. Moreover, relatively simple changes such as the introduction of Iterated Local Search in the post-generation of initial solutions could yield considerably better results.

### 3.1 Petal Structure Comparison

^{1}), we show the petal structure generated from a node shift of 1. Figure 3 illustrates such structure showing two random solutions with and without 2-OPT local search optimization. Notice for the top plot on Fig. 3 that there is a considerably small amount of common edges, except for those connecting with the depot. This enables larger partitions with less entries and exits. Moreover, on the bottom plot of Fig. 3, it can be seen that even after 2-OPT several edges are now common for both solutions, since these are now optima under the operator. However, still a significant amount of uncommon edges can be detected inside vehicle routes, such as those in nodes 15, 33, 55, 56, 64. On the other hand, the edge between 4, 71 is clearly not a good choice for this instance, and should be addressed in further work.

### 3.2 Recombinations and Tunnels as a Function of the Shift \(\rho \)

In this section, we compare the number of recombinations generated by the proposed operators (Sect. 2.5) as a function of the node shift using the recurrence described in Sect. 2.4. Figure 4 shows such function for three selected instances, namely Tai-n150a-k15, X-n459-k26 and M-n200-k17 (in advance, Tai-150, X-459 and M-200, respectively). Firstly, notice that the number of recombinations appears to not be related to the size of the problem, since in Tai-150 there is a somewhat continuous rate of 40 recombinations in most of the node shifts, except for the interesting peaks which appear to happen at the node shifts that are multiples of 3 (i.e. \(\{3, 6, 9, 12, \dots , 24, 27, 30\}\)). This result suggests that the optimal recombination rate is intrinsically related to the node shift and other parameters, such as capacity, or the geometry of the instance itself. However, this evidence seems to be specific to each instance (as can be observed on the other instances, where the peaks differ).

On the other hand, in X-459 a clear tendency of alternating recombination rates is observed, except for the case of the shift \(\rho = 15\) that produces the highest peak at 78. However, the repeated peaks alternating between higher and lower recombination rates, suggest that a single node shift can displace the solutions enough to break common edges between partitions. Furthermore, on M-200, the pattern alternates less, and a surprising peak shows with a much higher recombination rate than the rest at \(\rho = 12\). The geometrical analysis of such finding is left for further studies.

## 4 Conclusions

- 1.
Study the peaks and patterns discovered in the recombination rate as a function of the node shift.

- 2.
Further improve the PX operator to enable the swapping of nodes between different vehicle routes.

- 3.
Study the usage of meta-algorithms to automatically discover features on the above mentioned patterns.

- 4.
Inclusion of other local search heuristics such as the Iterated Local Search to improve the overall fitness and goodness of solutions.

- 5.
Addition of a genetic algorithm scheme using the recombined solutions as population.

## Footnotes

## Notes

### Acknowledgements

This work has been partially supported by the projects Moveon TIN2014-57341-R (2015–2018) and Red Nacional de Investigación en Smart Cities TIN2016-81766-REDT.

## References

- 1.Whitley, D., Hains, D., Howe, A.: Tunneling between optima: partition crossover for the traveling salesman problem. In: Proceedings of the 11th Annual Conference on Genetic and Evolutionary Computation, pp. 915–922. ACM, July 2009Google Scholar
- 2.Radcliffe, N.J.: Forma analysis and random respectful recombination. In: ICGA, vol. 91, pp. 222–229 , July 1991Google Scholar
- 3.Andre, J., Siarry, P., Dognon, T.: An improvement of the standard genetic algorithm fighting premature convergence in continuous optimization. Adv. Eng. Softw.
**32**(1), 49–60 (2001)CrossRefzbMATHGoogle Scholar - 4.Whitley, D., Hains, D., Howe, A.: A hybrid genetic algorithm for the traveling salesman problem using generalized partition crossover. In: Parallel Problem Solving from Nature, PPSN XI, pp. 566–575 (2010)Google Scholar
- 5.Croes, G.A.: A method for solving traveling-salesman problems. Oper. Res.
**6**(6), 791–812 (1958)MathSciNetCrossRefGoogle Scholar - 6.Tinós, R., Whitley, D., Ochoa, G.: Generalized asymmetric partition crossover (GAPX) for the asymmetric TSP. In: Proceedings of the 2014 Annual Conference on Genetic and Evolutionary Computation, pp. 501–508. ACM, July 2014Google Scholar
- 7.Ryan, D.M., Hjorring, C., Glover, F.: Extensions of the petal method for vehicle routeing. J. Oper. Res. Soc.
**44**, 289–296 (1993)CrossRefzbMATHGoogle Scholar - 8.Renaud, J., Boctor, F.F., Laporte, G.: An improved petal heuristic for the vehicle routeing problem. J. Oper. Res. Soc.
**47**(2), 329–336 (1996)CrossRefzbMATHGoogle Scholar