## 4 Proposed Algorithm for Multi-Agent Configuration Change
### Trajectory Reference Generation
#### 4.1.2 DMPC-Based Reference Generation  
While each agent shares assumed state trajectories with neighbors in DMPC techniques (prediction/optimization/feedback module), there is a problem of finite horizon that limits the algorithm's prediction capability. Thus, the affine-based global trajectory sequences \(\{p_{i}^{*}(k)\}\) from Section4.1.1 are designed as the input into the feedback module and local environment \(\{p_{o},\mathbf{v}_{i}\}_{i=1}^{n}\) in the prediction module. In addition, the feedback is carried out by the predefined state value \(\{\mathbf{p}_{d},\mathbf{v}_{d},\mathbf{u}_{d}\}_{t}^{n}\). This paper proposes a two-layer cost function in the optimization module to generate the reference sequences, denoted as \(\mathbf{u}_{i,t}^{*}=\underset{X^{*}}{\text{argmin}}J(X^{*})\). The sets of constraints \(C_{inputs}\), \(C_{output}\) are designed as follows:  
\[C_{input}=\left\{ \begin{array}{l}v_{min}\leq\|\mathbf{v}_{i}\|\leq v_{max}\\ u_{\min}\leq\mathbf{u}_{i}\leq u_{\max}\end{array} \right., \tag{4}\]  
where the limits of \(v_{min}\) and \(v_{max}\) are given by the motion capabilities of the UAVs. \(R_{a}\) and \(R_{s}\) denote the safety distance of the agent and the obstacle. \[C_{output}=\left\{ \begin{array}{l}\left\|\mathbf{p}_{j}(t)-\mathbf{p}_{j}(t)\right\| \geq R_{s}\\ \left\|\mathbf{p}_{o}(t)-\mathbf{p}_{i}(t)\right\|\geq 2R_{a}\end{array} \right.. \tag{5}\]  
The cost function is designed by penalizing on the errors between the predicted and the affine-based global trajectory sequences \(\{p_{i}^{*}(k)\}\). The optimization module takes \(\mathbf{p}_{d}^{*}\) as the optimization variable, obtained as \(\mathbf{u}_{d}^{*}=\underset{p_{d}^{*}}{\text{argmin}}/(X^{*})\), where a two-layer \(J(X^{*})\) is designed consisting of two components as below:  
\[ \begin{split} J(X^{*})&=\lambda_{1}\Bigg{(}\min\bigg{\{} 0,\frac{dist(p_{i}^{*},p_{j}^{*})-R_{s}}{dist(p_{i}^{*},p_{j}^{*})-R_{s}} \bigg{\}}^{2}\bigg{)}+\lambda_{2}\bigg{(}\min\bigg{\{}0,\frac{dist(p_{i}^{*},p _{\text{obs}})-R_{s}}{dist(p_{i}^{*},p_{\text{obs}})-R_{s}}\bigg{\}}^{2} \bigg{)},\\ &\quad\quad+\sum\limits_{j\in N^{k},j\
eq i}[(\mathbf{v}_{i}-\mathbf{v}_{j}) ^{2}+(\mathbf{v}_{i}-\mathbf{v}_{d})^{2}]\end{split}  \tag{6}\]  
where \(\lambda_{1}\) and \(\lambda_{2}\) represents the adjusting factor. From the above Formulation (6), it can be seen that this cost function is divided into two terms, which mainly describes the avoidance function in distance and the adjustment of average velocity. The purpose of utilizing these two terms is to reflect this method's ability to generate a more flexible trajectory from the collision among the agents and obstacles. The details of the description are as follows: the  
Figure 5: Affine-based predefined configuration patterns for illustrations: (**a**) predefined path; (**b**) predefined configuration. first term uses the predefined trajectory \(p_{i}^{*}\), agents' neighbor \(p_{j}\) (considered as dynamic obstacle) and the obstacles \(p_{obs}\) to evaluate the trajectory's feasibility in the environment at current time step \(t\). The second term represents the agents' velocity \(\mathbf{v}_{i}\) dynamically adjusted by utilizing the weighted average velocity of its neighbors \(\mathbf{v}_{j}\) and the predefined velocity \(\mathbf{v}_{d}\). Then, a complete reference path is generated by the optimal output \(\mathbf{u}_{d}^{*}(p_{t}^{*}(k)\rightarrow\mathbf{p}_{d}^{*})\) in double-integrator (1) form. Formulation (6) describes a two-layer cost function to obtain the optimal reference sequences through the minimum value (Algorithm 1).