*Article* **An Artificial Bee Colony Algorithm for Static and Dynamic Capacitated Arc Routing Problems**

**Zsuzsanna Nagy 1,\*, Ágnes Werner-Stark <sup>1</sup> and Tibor Dulai <sup>1</sup>**

Department of Electrical Engineering and Information Systems, Faculty of Information Technology, University of Pannonia, Egyetem St. 10, 8200 Veszprém, Hungary; werner.agnes@virt.uni-pannon.hu (Á.W.); dulai.tibor@virt.uni-pannon.hu (T.D.)

**\*** Correspondence: nagy.zsuzsanna@virt.uni-pannon.hu

**Abstract:** The Capacitated Arc Routing Problem (CARP) is a combinatorial optimization problem, which requires the identification of such route plans on a given graph to a number of vehicles that generates the least total cost. The Dynamic CARP (DCARP) is a variation of the CARP that considers dynamic changes in the problem. The Artificial Bee Colony (ABC) algorithm is an evolutionary optimization algorithm that was proven to be able to provide better performance than many other evolutionary algorithms, but it was not used for the CARP before. For this reason, in this study, an ABC algorithm for the CARP (CARP-ABC) was developed along with a new move operator for the CARP, the sub-route plan operator. The CARP-ABC algorithm was tested both as a CARP and a DCARP solver, then its performance was compared with other existing algorithms. The results showed that it excels in finding a relatively good quality solution in a short amount of time, which makes it a competitive solution. The efficiency of the sub-route plan operator was also tested and the results showed that it is more likely to find better solutions than other operators.

**Keywords:** capacitated arc routing problem; dynamic capacitated arc routing problem; artificial bee colony algorithm; evolutionary optimization; move operator

**MSC:** 68W50; 90B06; 90B20; 90C27; 90C35; 90C59; 90C90

#### **1. Introduction**

The Capacitated Arc Routing Problem (CARP) is an NP-hard combinatorial optimization problem that was first introduced by Golden and Wong in [1]. The CARP requires determining the least cost route plans on a graph of a road network for vehicles subject to some constraints. It has many applications in real life, for instance, in winter gritting [2,3] or in urban solid waste collection [4,5]. Since the CARP is an NP-hard problem, instead of exact methods, mainly heuristics and meta-heuristics (e.g., [6–10]) are considered in the literature to find solutions. The existing methods are either too slow or do not give enough good quality solutions, so there is still room for improvements.

The standard CARP assumes a static problem, which is not the closest to real life, where changes may happen during the execution of the solution. These changes modify the instance, and thus, may have an effect on the feasibility and optimality of the current solution [11]. For this reason, the Dynamic CARP (DCARP), which is a variation of the CARP that takes into account dynamic changes, is a better approach. To make the model of the problem under consideration closer to the real-life problem, the changes should be made based on the collected information about the vehicles and the roads. For instance, information can be provided by the drivers of the vehicles about the executed tasks, by the GPS of the vehicles about their current position, and (indirectly) by traffic patrol drones [12] about the current state of the roads.

The Artificial Bee Colony (ABC) algorithm is a swarm intelligence-based algorithm for optimization problems [13]. It was successfully applied on multiple combinatorial optimization problems that are similar to the CARP [14–19] and was shown that the ABC

**Citation:** Nagy, Z.; Werner-Stark, Á.; Dulai, T. An Artificial Bee Colony Algorithm for Static and Dynamic Capacitated Arc Routing Problems. *Mathematics* **2022**, *10*, 2205. https:// doi.org/10.3390/math10132205

Academic Editors: Zsolt Tibor Kosztyán and Zoltán Kovács

Received: 27 May 2022 Accepted: 22 June 2022 Published: 24 June 2022

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Copyright:** © 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

algorithm provides better performance than most of the evolutionary computation-based optimization algorithms [16]. However, the ABC algorithm was never applied before, neither on the CARP nor on the DCARP.

In our previous work [20], we collected all the possible events and analyzed their effects on the model. Based on the results, a data-driven DCARP framework with three event handling algorithms and a rerouting algorithm (RR1) was developed. The framework uses 'the 'virtual task" strategy [21] to be able to use static CARP solvers for DCARP instances. The contributions of this work are as follows:


The rest of the paper is structured as follows. In Section 2, the related works are presented. In Section 3, the basic concepts related to the proposed CARP-ABC algorithm is introduced. In Section 4 and Section 5, the algorithm and the sub-route plan move operator are formulated in detail, respectively. In Section 6, the experiments and their results are discussed. The paper is concluded in Section 7.

#### **2. Related Works**

In this section, the related works are introduced. In Section 2.1, the algorithms that were developed for CARP are presented. In Section 2.2, the approaches for DCARP are summarized. In Section 2.3, the ABC algorithms that were developed for problems that are similar to the CARP are presented.

#### *2.1. Algorithms for the CARP*

As it was mentioned in Section 1, there are mainly approximate approaches (i.e., heuristics and metaheuristics) for the CARP. For this reason, only the methods that belong to that category are mentioned in this subsection.

#### 2.1.1. Heuristics

Golden et al. developed the first heuristic algorithms for the CARP, namely, the path-scanning and the augment-merge [22]. Other notable heuristics for the CARP are the parallel-insert method [23], Ulusoy's tour splitting method [24], the augment-insert method [25], the path-scanning with ellipse rule [26] and the path-scanning with efficiency rule [27].

#### 2.1.2. Metaheuristics

The metaheuristic algorithms for the CARP can be divided into two main categories (with some exceptions): trajectory-based and population-based.

From the trajectory-based algorithms, the notable ones are the guided local search algorithm [28], the tabu search algorithms [29,30], the variable neighborhood search algorithm [31], and the greedy randomized adaptive search procedure with evolutionary path relinking [32]. It must be mentioned that in [29], two versions of the tabu search

algorithm (TSA) were proposed (TSA1 and TSA2), from which the latter performed better. In [33], a global repair operator was developed and embedded into the TSA, creating the repair-based tabu search (RTS), which outperforms the TSA.

From the population-based algorithms, the notable ones are the genetic algorithm [34], the memetic algorithms [6,35], and the ant colony optimization algorithms [8,36,37]. From these, the Memetic Algorithm with Extended Neighborhood Search (MAENS) [6] is the most popular one, even though it only gives relatively good quality solutions and also has slow runtime. There are multiple solutions that try to improve some parts of the MAENS (e.g., [9,10]), but these improvements do not really increase the overall performance of it. The Ant Colony Optimization Algorithm with Path Relinking (ACOPR) [8] gives only relatively good quality solutions, but currently it has the fastest runtime on most of the CARP instances from the benchmark test sets.

The Hybrid Metaheuristic Approach (HMA) [7] is a population-based algorithm that utilizes a randomized tabu thresholding procedure as a part of its local refinement procedure. The HMA gives the best quality solutions among all existing algorithms and has faster runtime than MAENS, but it is still relatively slow on some real-life based CARP instances. The ACOPR gives only relatively good quality solutions, but currently, it has the fastest runtime on most of the CARP instances from the benchmark test sets.

#### *2.2. Approaches for the DCARP*

Despite the importance of the DCARP, the number of studies about CARP (or ARP) that consider dynamic changes in the problem during the execution of the solution are relatively small [20,21,38–45]. Moreover, there are only three studies that consider more than two type of changes [20,21,42] and only two of them (including our previous work) considers all the critical changes that can happen [20,21]. (For a more detailed comparison see [11,20].) Critical changes or events may change the problem to such an extent that the current solution is not feasible anymore, so handling them is essential. Both [20,21] propose a framework for the DCARP that, instead of using complex specialized algorithms, allows the use of any static CARP solvers for solving a DCARP instance.

To the best of our knowledge, the data-driven solution for the DCARP introduced in [20] is the only data-driven approach for DCARP or even CARP.

#### *2.3. The ABC Algorithm and Its Applications*

The original ABC algorithm was proposed by Karaboga in [13]. In [46], Karaboga and Görkemli proposed a new definition for the search behavior of the onlooker bees, which improved the convergence performance of the algorithm. For this reason, the new version of the ABC algorithm was named quick ABC (qABC).

The ABC algorithm was introduced as an algorithm for multivariable and multi-modal continuous function optimization, but later it was successfully applied on other types of optimization problems as well. Karaboga and Görkemli introduced an ABC and a qABC algorithm for combinatorial problems (CABC and qCABC, respectively) and applied them to the Traveling Salesman Problem (TSP) [14,15]. Both algorithms use the Greedy Sub Tour Mutation (GSTM) operator [47], which was developed to increase the performance of a genetic algorithm (GA) that solves the TSP. It was proven that the GSTM is significantly faster and and more accurate than other existing mutation operators [47]. Furthermore, it was shown that the ABC and the qABC algorithm provide better performance than many evolutionary computation-based optimization algorithms [16]. Since the TSP is similar to the CARP, in the hope that an ABC algorithm with a mutation operator such as GSTM will perform well, we developed the CARP-ABC algorithm (Section 4) with the sub-route plan operator (Section 5).

There are also ABC algorithms for the Vehicle Routing Problem (VRP) [48] and its variations [17,18]. However, there is only one ABC algorithm for the CARP and even that is for just a variation of CARP, the undirected CARP with profits [19]. Therefore, to the best of our knowledge, currently there are no ABC algorithms, neither for the CARP nor for the DCARP.

#### **3. Problem Formulations**

This section introduces basic concepts related to the proposed CARP-ABC algorithm to help to understand how it works. The concepts are introduced only briefly, for a more detailed description the corresponding works are referred to.

In this section, first, the static CARP, then the (data-driven) DCARP is formulated. It is followed by the introduction of the basic ABC algorithm and the existing move operators for CARP (which are used in the proposed CARP-ABC solution). The notations used for the CARP and the DCARP are collected in Table A1 in Appendix A.

#### *3.1. The CARP*

In the existing works, as the input graph, some assume an undirected graph [7], others assume a directed graph [8,49], and other ones a mixed graph [6,34]. In this work, a directed graph is assumed, in which undirected edges are regarded as two oppositely directed edges.

The (directed) graph of the CARP can be described the following way: *G* = (*V*, *A*), with a set of vertices *V* and a set of arcs (directed edges) *A*. A set of tasks *T* ⊆ *A* is also given, which defines the arcs that have tasks assigned to them. If the graph of a CARP instance contains (undirected) edges, then an edge is added to *A* as a pair of arcs, one for each direction. For instance, if (*vi*, *vj*) is an edge and *vi*, *vj* ∈ *V*, then the arcs (*vi*, *vj*) and (*vj*, *vi*) are added to *A*. Similarly, if (*vi*, *vj*) is an edge with tasks assigned to it and *vi*, *vj* ∈ *V*, then the arcs (*vi*, *vj*) and (*vj*, *vi*) are added to *T*. The graph also has a special vertex *v*<sup>0</sup> (*v*<sup>0</sup> ∈ *V*), the depot, and a dummy task *t*<sup>0</sup> = (*v*0, *v*0), the significance of which is explained later.

The tasks are performed by a fleet of *w* homogeneous vehicles of capacity *q*. Every vehicle starts and ends its route at the depot (*v*0). Each task must be performed in a single operation, and each vehicle can satisfy at most as many demands as its maximum capacity.

The graph can be mapped to a road network where the arcs are road segments. Some of the road segments have tasks. To fulfill the tasks, different amounts but the same type of demand must be served. Each arc is characterized by the following functions:


In addition, each task is characterized by the following functions:


Although an edge is regarded as two oppositely directed arcs, if a task is assigned to it, then the task should be executed only once, in either direction. Let *t* ∈ *T* be a task of one of the arcs of an edge, then let *inv*(*t*) denote the inversion of *t*, the other task of the edge. If *head*(*t*) and *tail*(*t*) are the head and the tail vertexes of *t*, then *head*(*inv*(*t*)) = *tail*(*t*) and *tail*(*inv*(*t*)) = *head*(*t*) are the head and the tail vertexes of *inv*(*t*). The *dc*, *dem* and *sc* values are the same for *t* and *inv*(*t*).

Let the total number of tasks that have to be executed by at least one of the vehicles be denoted by *n*. The value of *n* depends on the composition of *T*: if *T* only contains arc tasks from edges, then *n* = |*T*|/2, if *T* only contains arc tasks from arcs then *n* = |*T*|.

The minimal total dead-heading cost between two vertices is provided by the *mdc* : *V* × *V* → *N* function, which uses Dijkstra's algorithm as the search algorithm. For instance, *mdc*(*vi*, *vj*) denotes the minimal total dead-heading cost traversing from vertex *vi* to vertex *vj*, where *vi*, *vj* ∈ *V*.

A CARP instance (*I*) is defined as follows:

$$I = (V, v\_0, A, T, n, w, q, \text{head}, \text{tail}, \text{clc}, \text{id}, \text{dem}, \text{sc}, \text{inv}, \text{mdc}) \tag{1}$$

#### 3.1.1. Solution Representation

A solution for a CARP instance is expressed as a set of route plans. The route plans are sequences of the *t* ∈ *T* tasks that need to be executed in the given order. The consecutive tasks are connected by the shortest paths, which is provided by the *mdc* function. Therefore, a solution *S* for a CARP instance can be expressed the following way:

$$S = \{r\_1, r\_2, \dots, r\_{|S|}\}\tag{2}$$

where |*S*| is the number of route plans and *rk* (*k* ∈ {1, 2, ... , |*S*|}) is the *k*-th route plan within the solution *S*. The *k*-th route plan can be expressed the following way:

$$r\_k = \langle t\_{0\prime}, t\_{k,1\prime}, t\_{k,2\prime}, \dots, t\_{k,l\_k\prime}, t\_0 \rangle \tag{3}$$

where *lk* is the number of (not dummy) tasks and *tk*,*<sup>i</sup>* is the *i*-th task within the *k*-th route plan. It must be noted that here, *k* is an index, which is only used to identify a specific route plan in the solution. The order of the route plans within the solution has no effect on the quality of the solution.

Since every route starts and ends in the depot, the dummy task *t*<sup>0</sup> – which represents the vehicle being in the depot – is added also as the first and the last element of the route plan sequences. Its *id*, *dc*, *dem* and *sc* are set to 0, and both the head and the tail vertexes are the depot vertex.

For the solution representation of the CARP, a natural encoding approach can be used, just like in most vehicle routing problems. This means that all route plans can be encoded as an ordered list of ids of the tasks, so a solution can be represented as the concatenation of these lists. However, every route plan starts and ends with the dummy task *t*0, so if the encoded route plans are concatenated, then there are consecutive dummy tasks in the resulting list. For the sake of simplicity, only one of each consecutive dummy task is kept in the encoded solution. Figure 1 shows an example of a solution representation.
