Characteristics of the presented problem distinguish its nature as NP-hard. Approaches based on branch & bound and branch & cut are tedious in terms of computation time. A promising alternative to those methods is a metaheuristic algorithm. Metaheuristics use different concepts derived from artificial intelligence and evolutionary algorithms, which are inspired from mechanisms of natural evolution [40]. From the literature, it could be found that metaheuristics can also be called as soft computing techniques, evolutionary algorithms, and nature-inspired algorithms. Metaheuristic methods are designed for solving a wide range of hard optimization problems without having to adapt deeply into each problem. These algorithms are fast and easy to implement [44]. From the literature review, it could be seen that different metaheuristic algorithms have been proposed to obtain feasible solutions for general scheduling problems [16].
Particle swarm optimization (PSO) algorithm is a swarm-based stochastic optimization technique developed by Kennedy and Eberhart [21] based on the characteristics of social behaviour of birds in flocks or fish in schools. This metaheuristic algorithm is chosen to be incorporated in the proposed methodology in this paper. PSO algorithm does not involve the usage of genetic operators (mutation and crossover) which are commonly used for evolutionary algorithms. On top of that, PSO utilizes a minimum number of parameters to achieve the near-optimum solution in a faster computation time [31]. These factors have influenced the authors to choose PSO to solve the presented problem, where there is a requirement of generating a fast and feasible schedule in a real-time application.
PSO is an optimization method based on the population which is referred as swarm in this paper. Simplicity in application, easy implementation, and faster convergence of PSO have made the algorithm widely acceptable among researchers for solving different types of optimization problem [18]. Different variants of PSO have been developed and employed by researchers to solve scheduling problems. This paper employs the standard PSO [21] model to solve the UAV scheduling problem. The pseudocode of PSO is presented in Algorithm 1. All particles in the swarm share the global best particle information which helps to search towards the best position in the search space. Each single solution in the search space is called as a particle. All particles are to be evaluated by an objective function (explained in the following section) which is to be optimized. Each particle in the swarm searches for the best position, and it travels in the search space with a certain velocity. Best fitness encountered by each particle (local best) is stored and the information is shared with other particles to obtain the best particle (global best). In this paper, the velocity and position update of PSO are based on [36] to suit the presented UAV scheduling problem.
The procedural steps of the PSO algorithm are given below:
-
Step 1
:
-
The initial population is generated based on priority rules. Initial velocities for each particle are randomly generated.
-
Step 2
:
-
Based on the objective function, each particle is evaluated.
-
Step 3
:
-
Each particle remembers the best result achieved so far (local best) and exchange information with other particles to obtain the best particle (global best) among the swarm.
-
Step 4
:
-
The velocity of the particle is updated using Eq. (14), and the position of the particle is updated using Eq. (15).
Velocity update equation:
$$\begin{aligned} v_i^{t+1}=v_i^{t}+\underbrace{c_1*\left[ U_1*\left( ^{lo}P_i^t-P_i^t\right) \right] }_\text {cognitive part}+\underbrace{c_2*\left[ U_2*\left( G^t-P_i^t\right) \right] }_\text {social part} \end{aligned}$$
(14)
where \(U_1\) and \(U_2\) are known as velocity coefficients (random numbers between 0 and 1), \(c_1\) and \(c_2\) are known as learning (or acceleration) coefficients, \(v_i^t\) is the initial velocity (which comprises pairs of transposition—see Sect. 4.1.2), \(^{lo}P_i^t\) is the local best, \(G^t\) is the global best solution at generation t, and \(P_i^t\) is the current particle position.
Acceleration coefficients \(c_1\) and \(c_2\) are the important parameters of PSO. Parameter \(c_1\) is used to guide the particle towards its own (local) best position, and this behaviour enhances the grouping ability and keeps the diversity of the population. Parameter \(c_2\) acts as a convergence factor that attracts all the particles towards the global best position.
To suit the considered problem, the particle is represented in the form of a task sequence (for an example, refer the value of particle in Table 5). This enables a tractable update during the numerous iterations. A particle represents a feasible solution which consists of a sequence of tasks. The sequence shall satisfy the precedence relationships, and it is initially generated based on a priority rule. The priority rules which are considered in this study are explained in Sect. 4.1.1. A velocity of a particle is a collection of transpositions, where each transposition is represented as position indices of two tasks in a sequence (particle) which will be swapped accordingly (during the velocity update). In this study, the position index starts from 0 instead of 1 for a seamless implementation (from the programming perspective).
Table 5 Example data and parameters for PSO procedure Each particle changes its position according to its velocity, which is randomly generated towards the local best (\(^{lo}P_i^t\)) and the global best (\(G^t\)) positions. The moving direction of the particle is decided by three parts as shown in Eq. (14). These three parts comprise the initial velocity \(v_i^t\) of the particle at a particular iteration, the optimum distance of \({^{lo}P_i^t-P_i^t}\) that the particle passed (this is known as a cognitive part which controls the exploration of the particle based on its own exploration experience), and the optimum distance of \({G^t-P_i^t}\) that the particle swarm passed (this is known as a social part which helps in collaborating with other particles based on the group exploration experience [7]). The proportions of impact for cognitive and social parts are decided based on the coefficients \(c_1\) and \(c_2\). These coefficients determine whether a particle prefers to move closer to the local best or global best position.
A particle moves from its current position to the new position using Eq. (15). The position of every particle in the swarm is updated in every iteration.
Position update equation:
$$\begin{aligned} P_i^{t+1}=P_i^{t}+v_i^{t+1} \end{aligned}$$
(15)
Different operators used in computing the particle velocity and position are explained as follows [36].
-
Subtraction (position–position) operator Let two positions \(x_1\) and \(x_2\) represent two different task sequences (see Sect. 4.1.1). The difference of \(x_2-x_1\) is a velocity v. In Eq. (14), subtracting two positions, i.e. \(^{lo}P_i^t-P_i^t\) results in a velocity which is a set of transpositions (see Sect. 4.1.2). The difference of the positions of two particles can be obtained in various implementation ways. For instance, each element (A) in the first particle is compared with element (B) in the second particle at the same position index. When they are different, the position of B is searched in the first particle. That position index is then coupled with the position index of A. After completing all iterations, a collection of position index pairs (for performing a transposition) is obtained. This procedure has been widely used in [31, 36].
-
Addition (position + velocity) operator Let \(x_1\) be a position, and v be a velocity of the particle. New position \(x_2\) is calculated by applying each transposition pair in v consecutively to \(x_1\).
-
Addition (velocity + velocity) operator Let \(v_1\) and \(v_2\) be two velocities (which may come from either one of the three parts of Eq. (14)). In order to calculate \(v_1+v_2\), the list of transpositions combines the subsets of transpositions from \(v_1\) and \(v_2\).
-
Multiplication (constant * velocity) operator Let c be a constant and v be a velocity (which consists of one or more transposition pairs). The operation of \(c*v\) results in a new velocity with an equal or less number of transposition pairs, where the first \(c*100\%\) proportion of the collection is selected.
Step 5 Go back to step 2 until the termination criterion is met. Equations (14) and (15) describe the path in which the particles move in the search space.
In this paper, PSO is used to optimize the proposed problem, where one of the key challenges encountered is the encoding of the particle. In most applications of PSO, particle position \(P_i^t\) is directly denoted as the solution in the form of a sequence of tasks. The arrangement of the sequence is ensured to satisfy the precedence relationships. To illustrate how the velocity and position update work, an example is explained as follows—the notations of the required data or parameters are depicted in Table 5.
The current velocity of a particle is updated based on Equation (14) as follows.
$$\begin{aligned} v_i^{t+1}&= (6,7) (10,11) + 0.2\; *\\&[(1, 2, 4, 6, 5, 8, 3, 7, 10, 9, 11, 12) - (1, 2, 4, 6, 5, 8, 7, 3, 10, 9, 12, 11)] \\ &+0.8 * [(2, 6, 1, 4, 3, 5, 7, 8, 10, 9, 11, 12) - (1, 2, 4, 6, 5, 8, 7, 3, 10, 9, 12, 11)]\\ &= (6, 7) (10, 11) + 0.2 * (6, 7) (10, 11)\\&+ 0.8 * (0, 1) (1, 3) (2, 3) (4, 7) (5, 7) (10, 11)\\= & {} (6, 7) (10, 11) (0, 1) (1, 3) (2, 3) (4, 7) (5, 7) \end{aligned}$$
Using Eq. (15), the current particle is updated to a new particle using the new velocity.
$$\begin{aligned} P_i^{t+1}&= (1, 2, 4, 6, 5, 8, 7, 3, 10, 9, 12, 11) \\ &+(6, 7) (10, 11) (0, 1) (1, 3) (2, 3) (4, 7) (5, 7)\\ &= (2, 6, 1, 4, 7, 5, 3, 8, 10, 9, 11, 12) \end{aligned}$$
The products of coefficient values \(c_1\), \(U_1\) and \(c_2\), \(U_2\) represent the proportion which decides how many pairs of transposition would be copied to form the updated velocity. For example, when the proportion is 80% (\(c_2 * U_2= 2 * 0.4 =0.8\)), 80% of the pairs would be copied to the updated velocity. In this example, 6 pairs are formed when transpositions take place between the global best and the current particle. Based on this proportion, 5 pairs are chosen out of 6 for the updated velocity. However, if any of the pairs is already present from other transpositions or initial velocity, it is discarded. A repair mechanism is incorporated to convert an infeasible sequence to a feasible one which meets the precedence relationships—presented as Algorithm 3 in this paper.
PSO entities
To illustrate the explanation of different entities in PSO, a sample dataset presented in Tables 2 and 3 is used.
Initial population
Metaheuristic algorithms start with a random search state which iteratively evolves to find a near-optimum solution [34]. Despite the search state being random, the generation of the initial population is not purely random but guided by the priority (heuristic) rules. The purpose for doing this is to start the search from hypothetically good starting points rather than random ones, so that global optimum is more likely achieved in less computation time. In this paper, six priority rules (maximum rank positional weight, minimum inverse positional weight, minimum total number of predecessor tasks, maximum total number of follower tasks, maximum and minimum task time) presented in [34] are used to generate the initial particles. Two more priority rules based on the number of predecessor and follower tasks are added to the existing rules, and these are named as cumulative number of predecessor and follower tasks. Based on these eight priority rules, eight initial particles can be generated respectively. In regard to the number of initial particles, it is reported in the literature that a high initial population size improves the quality of the solution. Hence, up to forty initial particles are generated in the experiments. Each remaining particle apart from the aforementioned eight is generated by randomly swapping the tasks in one of the eight particles without violating the precedence relationships and produces a new one. Table 6 reports the set of initial particles generated using the priority rules and conformed with Algorithm 3 to satisfy the precedence relationships. The precedence relationships of tasks are available in Table 2. Each particle is structured as a string of tasks which are to be executed in the UAV operation.
Table 6 Priority rules for initial swarm generation Initial velocity
Each particle is assigned with velocity pairs, and these pairs are randomly generated. Based on the pilot experiments, it is decided to have different sizes of velocity pairs for different problems based on the number of tasks. Table 7 presents the maximum number of velocity pairs used in this research for different numbers of task. The velocity is updated from the second iteration using Eq. (14). The number of pairs is the same throughout all iterations. For example, if the number of tasks is within the range of 0–20, the number of velocity pairs is selected as 2.
Table 7 Number of initial velocity pairs in regard to the number of tasks Schedule creation and evaluation
In the addressed methodology, the initial population is generated according to the priority rules explained in Table 6. Tasks in the task sequence are scheduled, where each of them is assigned to a UAV to be executed in a particular timespan, one by one (per step) according to its order in the sequence. Figure 4 depicts the sequential steps of creating a schedule from a sequence of 12 tasks.
The aforementioned heuristic for creating a schedule from a task sequence is depicted in Algorithm 2. The idea behind this algorithm is to create a schedule which is driven to utilize the available resources in the following manners, which generally lead to a time-efficient characteristic:
The detailed procedure of the heuristic is explained in Algorithm 2.
In the incorporated PSO, a particle indicates a solution (a schedule) which is selected through an iterative search process based on its fitness value. However, in regard to the position update process in PSO algorithm, it is difficult to define a step (of position update) due to the rigid structure of the schedule. A schedule may contain the following possible elements: flight, hover, wait-on-ground, recharge, and task. When a schedule is observed, there is a precise timespan in the schedule which most likely fits to only one particular task. An action’s existence may also depend on another one (i.e. flight, hover, wait-on-ground, and recharge existence is relative to the task execution manner). Thus, when some elements in a schedule are swapped (manipulated to produce different solution), an infeasible schedule is frequently formed.
Considering the aforementioned conditions, the sequence representation (before it is transformed into a schedule) of the tasks is considered. Swapping tasks in a sequence forms a new one—it is tractable and robust. Since each task sequence uniquely corresponds to a schedule, it is valid to use task sequence as the particle representation. Obviously, the representation gap (of sequence and schedule) is filled with the proposed heuristic method, which creates a schedule from a task sequence. In the end, the fitness of the schedule is evaluated based on its makespan. In this manner, both position update operation (in PSO iteration) and solution fitness evaluation are done seamlessly.
According to Algorithm 2, each task in the sequence (line 1) is put into the schedule, based on the earliest available time characteristic of the involved objects, described as follows.
-
1.
Task availability check
-
(a)
Position availability (line 2)
An abstraction of task is broken down into possible flights and other actions (e.g. pickup and release payload, inspection/capture image), which involves start position and end position. The time spent at start and end position is not defined for any task in this study. Hence, both positions are occupied during the whole execution time of the respective task. Consequently, start position and end position are checked for its occupancy status when a task is picked to be put into the schedule. The latest released (not occupied) timestamp is used for the position availability timestamp.
-
(b)
Task precedence (line 3)
A task is checked for its existing preceding task. If preceding tasks exist, the last completion timestamp of them will be set as the earliest available timestamp for the task. If there is no preceding task, then the task is available at time 0.
-
2.
UAV availability check
-
(a)
UAV ready time (8)
Task occupancy of each UAV is checked. The moment it goes to idle after completing the most recent task is recorded as its ready time.
-
(b)
Battery level (lines 10–11)
After a task execution, a UAV must have enough battery level to at least fly towards the nearest recharge station.
-
(c)
Recharge time (lines 10–15)
The battery check which is done in the part of line 10 is done to guarantee a sufficient battery level to go to at least the nearest recharge station. If a UAV doesn’t have enough battery to go to the recharge station after executing a task, then it needs to go to the recharge station with the earliest recharge completion time before flying to the start position of the task and execute it. To ensure that the UAV is fully charged (at a capacity of 1200 s flight), an actual recharge timespan is always set to 2700 s; it is the time required to do a full battery recharge. Recharge time is the summation of round-trip time and actual recharging timespan (which may be longer than 2700 s due to the delayed recharge station availability time).
-
(d)
Recharge station availability (line 13)
A limited number of recharge slots at the recharge station are considered. When all recharge slots at a recharge station are occupied, its earliest available time is the earliest timestamp when an occupying UAV leaves the recharge station. The next selection criteria is based on the shortest round-trip (end position of previous task \(\rightarrow\) recharge station \(\rightarrow\) start position of current task) time to a recharge station. It means that the nearest recharge station might not be preferred due to its far distance to the start position of the current task.
-
3.
Overall availability check (lines 4–18)
Incorporating the aforementioned task availability and UAV availability check, the start timestamp of the respective task is calculated. A UAV with the earliest overall available time is selected (line 18), and the task is put into the respective UAV’s schedule. Completion (end) timestamp of a task potentially performed by each UAV is also included in the execution period calculation (line 9) and used to release the occupied positions (lines 22–23).
For readability, putTaskIntoSchedule (line 24) in Algorithm 2 encapsulates the following processes:
-
1.
Insert a task into the schedule of the selected (earliest available) UAV
-
2.
Insert a recharge action (if required) into the schedule of the selected UAV
-
(a)
update occupancy status of the respective recharge slot
-
3.
Update battery level of the respective UAV
-
4.
Insert hover and wait-on-ground in between tasks in the schedule when needed
These supplementary actions are required to generate a feasible schedule of UAV operations [22].
To illustrate the usage of the heuristic described in Algorithm 2, steps 1–7 of the task scheduling process for a given task sequence in Fig. 4 are presented. Steps 1 and 2 are depicted in Figs. 5 and 6, while steps 3–7 are presented in “Appendix A”. Steps 8–12 which are principally doing the same procedure as the previous ones are not presented in the paper. In accordance with the explanation of Algorithm 2, task and UAV availability check are performed every time a task is picked to be put into the schedule. Detailed stepwise procedure for the first two steps is explained below the figures. Task, UAV, and overall availability check are referred as point (a), (b), and (c), respectively.
After completing all 12 steps, a schedule of 12 task executions is obtained. The schedule has a makespan of 4963 s, which is called as fitness value of the particle (in the incorporated PSO).
Furthermore, when there is an infeasible sequence (which doesn’t meet the precedence relationships) during the position update, a repair mechanism is conducted based on Algorithm 3.
The process can be pictured as moving the tasks from a sequence to a new one where precedence feasibility is held along the way. An agent visits the tasks in the task sequence sequentially as long as there is at least one task in the original sequence (lines 1–2). It checks each predecessor in the (immediate) predecessor list of the currently visited task. If it is contained in the new sequence, then it shall be removed from the list (lines 3–10). If the list of predecessors of the currently visited task is empty, then this task is ready to be moved into the new sequence (lines 11–15)—the task is added at the end of the sequence (line 12). Otherwise, it searches the following tasks (according to the sequence) to find a task which is ready to be moved (line 2). In the end, a feasible sequence that meets the precedence relationships is produced, which represents one valid particle in the PSO framework.
The sample data (Tables 2 and 3) being used in this section bring an example of task dataset which strongly displays the logic of Algorithm 2. For further analysis and evaluation, several datasets with different data volumes are generated. Respectively, the mechanism of generating the data is also presented in the following section.