# A Task Allocation Strategy of the UAV Swarm Based on Multi-Discrete Wolf Pack Algorithm
## 2 Task Assignment Model
### Objective Function
#### 2.2.1 Cost Function  
Most studies only consider the traveled distance or time in the evaluation of resource consumption, which makes the obtained task assignment result one-sided. To address this defect, we jointly consider the impact of distance and time on resource consumption. Following this idea, the distance cost and time cost of the UAV system is constructed as follows.  
1. Distance Cost  
The distance cost of the UAV system is denoted by \(d_{total}\), which can be achieved by  
\[d_{total}=\sum_{i=1}^{N_{u}}\sum_{j=1}^{N_{l}}\left(d_{jkj}(i)x_{ijk}\right) \tag{1}\]  
where \(d_{jkj}(i)\) represents the flight distance of the UAV \(u_{i}\) from the target point \(t_{j}\) to the target point \(t_{j}\); where \(x_{ijk}\) is a binary variable that represents the k execution of target \(t_{j}\) by UAV \(u_{i}\), and the specific expression is shown as follows.  
\[x_{ijk}=\left\{\begin{array}{ll}1,\ if\ M_{k}\ on\ t_{j}\ is\ assigned\ to\ u_{i}\\ 0,\ others\end{array}\right. \tag{2}\]  
If there are no obstacles in the flight path from the task point \(t_{j}\) to the next task point \(t_{j}\), the distance \(d_{jkj}\) can be easily obtained according to the calculation Formula (3).  
\[d_{jkj}(i)=\sqrt{\left(x_{t_{j}}^{k}(u_{i})-x_{t_{j}}^{k^{\prime}}(u_{i}) \right)^{2}+\left(y_{t_{j}}^{k}(u_{i})-y_{t_{j}}^{k^{\prime}}(u_{i})\right)^{ 2}} \tag{3}\]  
\begin{table}
\begin{tabular}{c c} \hline \hline
1 & \(T_{j}\) \\
2 & \(M_{K}\) \\
3 & \(X_{i}^{j}\) \\ \hline \hline \end{tabular}
\end{table}
Table 2: The vector of cooperative task allocation for UAVs.  
where \([x_{i_{j}}^{k}(u_{i}),\ y_{i_{j}}^{k}(u_{i})]\) and \([x_{i_{j}}^{k^{\prime}}(u_{i}),y_{i_{j}}^{k^{\prime}}(u_{i})]\) represent the position coordinates of the UAV \(u_{i}\) in executing the task \(M_{k}\) of the target \(t_{j}\) and the task \(M_{k}\) of the target \(t_{j}\), respectively.  
In order to ensure that the tasks are completed as quickly as possible, the model also considers the completion time of all tasks as another optimization index, where the shortest completion time of all tasks can ensure that the entire task can be completed quickly. The time cost of the UAV system to perform the task is represented by \(\tau_{total}\).  
\[\tau_{total}=max\Big{(}\tau_{ijk}^{e}+\tau_{ijk}^{f}\Big{)} \tag{4}\]  
where \(\tau_{ijk}^{e}\) and \(\tau_{ijk}^{f}\) represents the time that \(u_{i}\) execute \(M_{k}\) on \(t_{j}\) and the flight time of the UAV \(u_{i}\) from \(t_{j}\) to the next target point \(t_{j}\), respectively. The \(\tau_{total}\) is the maximum sum of \(\tau_{ijk}^{e}\) and \(\tau_{ijk}^{f}\). \(\tau_{ijk}^{e}\) is a predetermined parameter, and the calculation formula of \(\tau_{ijk}^{f}\) is shown in Formula (5).  
\[\tau_{ijk}^{f}=\frac{d_{jk,j}(i)}{v_{i}} \tag{5}\]  
This paper defines a cost function to quantify the resource consumption of the UAV system. Distance and time are the main indicators to measure resource consumption. Therefore, the distance cost and time cost of the UAV system should be the main components of the cost function. However, the evaluation indicators of distance and time are in different numerical dimensions, the direct addition of these two indicators affects the fairness of the cost function. Therefore, these two indicators should be standardized to eliminate dimensional effects. Based on the above analysis, the cost function of the UAV system can be obtained as followed.  
\[f_{cost}=\frac{d_{total}}{\sum_{i=1}^{N_{u}}d_{i}^{max}}+\frac{\tau_{total}}{ \underset{i\in[1,N_{u}]}{max}\tau_{i}^{max}} \tag{6}\]  
The first and second terms of Formula (6) measure resource consumption in terms of distance and time, respectively. In order to eliminate the dimensional influence between distance and time indicators, divide the different indicators by their respective upper bounds (the maximum flight distance of the UAV system \(\sum_{i=1}^{N_{u}}d_{i}^{max}\) and the endurance time of the UAV system \(\underset{i\in[1,N_{u}]}{max}\tau_{i}^{max}\) for normalization.