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

  • Esteban Perez-WohlfeilEmail author
  • Francisco Chicano
  • Enrique Alba
Conference paper
Part of the Advances in Intelligent Systems and Computing book series (AISC, volume 682)


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.


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

In the original paper by Whitley et al., a first version of the partition crossover (PX) is presented. In short, a series of random tours in the Symmetric Travelling Salesman Problem (STSP) are converted into local optima under the heuristic operator 2-OPT [5]. PX is applied between all possible combinations of the generated local optima (which accounts for \(\frac{m(m-1)}{2}\), being 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. 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. 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\).

Nonetheless, the original PX could only be applied when just two partitions along with the residual partition (complement of the two partitions) coexisted. This is, a recombination graph with more than two partitions could not be recombined, and thus \(2^{q}-2\) possible recombinations would be missed (being 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. 1.

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

  2. 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. 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. 1.

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

  2. 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:
Fig. 1.

Chromosome encoding (top right) of a trivial CVRP solution (left) with seven customers and one depot. The depot is labeled 0 and is used as separator of each individual vehicle route. Each route followed by a different car is depicted with either a solid, dotted or dashed line.

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.

A 2-OPT local search is applied to each generated solution. Notice that under the 2-OPT operator, these improved solutions will be locally optima. A local optima under 2-OPT occurs when there exists no path of edges,
$$ (v_i,v_{i+1}), (v_{i+1}, v_{i+2}), ..., (v_{j-2}, v_{j-1}), (v_{j-1}, v_{j}) $$
such that the reversion of the succession in between starting and ending node,
$$ (v_i,v_{j-1}), (v_{j-1}, v_{j-2}), ..., (v_{i+2}, v_{i+1}), (v_{i+1}, v_{j}) $$
does not produce an improved solution. Additionally, a Don’t Look Bits, Neighborhood Lists and delta-evaluations schemes are applied to reduce the computational complexity of the 2-OPT operator from cubic to nearly linear.

2.5 Improving the Recombination Rate Using Node Shifting

As argued in Sect. 2.2, the capacity constraint along with the fixed starting and ending node produce a lack in common edges that promote the generation of larger and feasible partitions. To overcome this limitation, we propose using an incremental generation of initial petal solutions by shifting the starting angle \(\rho \) in polar coordinates from which solutions are created. This procedure aims to force the creation of overlapping petals that take advantage of the radial order of nodes to find common edges that will generate partitions in the extremes of such common edges. However, creating initial solutions shifted by \(\rho \) degrees will produce long common edges, since (assuming uniform demands in customers) a petal solution 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. 1.

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

  2. 2.

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

Therefore the proposed recurrence to visit nodes attempts to only share an initial and ending edge between the first and last customer and the depot, whereas the rest of the route between these nodes crosses nodes alternatively. To do so, the following recurrence equation is proposed:
$$\begin{aligned} T_k={\left\{ \begin{array}{ll} 0, &{} \text {if }k=0\\ (T_{k-1} - 1)\ \text {mod}\ n, &{} \text {if }k\equiv \ 2\ \text {mod} \ 3\\ (T_{k-1} + 2)\ \text {mod}\ n, &{} \text {otherwise} \end{array}\right. } \end{aligned}$$
where 0 is the initial customer corresponding given the reordering of the shift angle \(\rho \) and 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.
Fig. 2.

Petal shifting with alternating partition routes. (a) On the left, initial solution generated by the Petal algorithm, in blue solid line. (b) On the right, the modified petal structure using a shift of zero (i.e. no shift), in dashed red. (Color figure online)

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

In order to tunnel through local optima in the CVRP, a number of initial solutions are generated following the algorithm described in Sect. 2.5, which are then recombined using the modified PX operator. That is, each solution is recombined with all other solutions, hence generating \(\frac{m(m-1)}{2}\), being 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

In this section, we perform an analysis over the proposed PX operator for the CVRP. Briefly, we will:
  1. 1.

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

  2. 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

Using a small sized instance, namely A-n80-k10 (extracted from CVRPLIB1), 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.
Fig. 3.

Comparison of the petal structure of two solutions generated by the proposed method. Blue and red colors are used to alternate between vehicle routes, whereas dashed or solid lines differentiate the two solutions. On top, the generated structure without 2-OPT. Bottom, the same structure with 2-OPT. (Color figure online)

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.

An average recombination rate of 65, 59 and 55 is found respectively for each instance, which accounts for a recombination rate of approximately 30%. On the best node shifts, a promising rate of 66%, 41% and 51% is found for each instance. Moreover, when applying 2-OPT to the offspring, 22%, 47% and 10% (respectively) of the recombined offspring were found to be local optima with improved fitness. Although the results shown herein are for the shift interval of \(\rho = [1,30] \in \mathbb {N}\), we have verified that the patterns hold for larger ranges.
Fig. 4.

Number of recombinations found as a function of the node shift \(\rho \) used to generate the solutions. On the x-axis, the \(\rho \) shift. On the y-axis, the number of new local optima found out of 190 recombination. The selected instances are plotted in different colors and lines: blue solid line for Tai-150a, red dashed line for X-459 and purple dotted line for M-200. (Color figure online)

4 Conclusions

In this manuscript, we have presented an initial approach to tackle the Partition Crossover operator in the Capacitated Vehicle Routing Problem. At a first step, we have discussed the initial operator through its different improvements, and at a second step, we have argued about the difficulties of adapting such operator to the CVRP. The main contribution of this work is our analysis of underlying structures that appear in local optima, which shows that a natural pattern exists. This experimental analysis suggests a strong dependence between the vehicle capacity and the number of shifts and that this information can be used for an efficient recombination and improvement of solutions. Additionally, we have proposed a combined PX operator which obtains a recombination rate of up to 66% depending on the node shift \(\rho \). These recombination rates are promising and could be applied in evolutionary programming to escape local optima in latter stages of execution, thus avoiding fitness stagnancy. However, more work needs to be carried out in this area, which we plan to continue, such as:
  1. 1.

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

  2. 2.

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

  3. 3.

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

  4. 4.

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

  5. 5.

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





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.


  1. 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. 2.
    Radcliffe, N.J.: Forma analysis and random respectful recombination. In: ICGA, vol. 91, pp. 222–229 , July 1991Google Scholar
  3. 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. 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. 5.
    Croes, G.A.: A method for solving traveling-salesman problems. Oper. Res. 6(6), 791–812 (1958)MathSciNetCrossRefGoogle Scholar
  6. 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. 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. 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

Copyright information

© Springer International Publishing AG 2018

Authors and Affiliations

  • Esteban Perez-Wohlfeil
    • 1
    Email author
  • Francisco Chicano
    • 1
  • Enrique Alba
    • 1
  1. 1.University of MalagaMalagaSpain

Personalised recommendations