# Effect of Formation Size on Flocking Formation Performance for the Goal Reach Problem
## 2 Materials and Methods
### Performance Metrics  
The performance metrics use the time steps taken by the flock as a measurement unit. To study the effect of the flock size on the flock's performance, in terms of completing the task of reaching a goal zone, the algorithm outputs the following metrics. Table 1 summarizes the notation used. * Number of agents within the goal area. Each agent \(i\) has a status variable, \(g_{i}\) (Equation (7)), which checks at every step whether agent \(i\) is in the goal zone or not. \[g_{i}= \begin{cases}1,&\text{goal zone detected by agent $i$}\\ 0,&\text{otherwise}\end{cases} \] (7)
* Time to reach the goal zone: This metric provides the minimum number of steps taken by at least one of the flock agents to reach the goal zone. In other words, the number of steps for the first agent \(i\) to achieve \(g_{i}=1\). * Time required to complete the flocking task: This metric provides the actual time (in minutes) from the start of the simulation until the last agent enters the goal zone. * Speed matching time: This metric provides the minimum number of steps taken by the flock to match the speeds of all of its agents. * Localization window: This metric provides the difference in the number of steps from the time the first agent enters the goal zone until the last agent does. * Number of applying flocking rules (collision avoidance \"separation\", attraction \"cohesion\", and alignment) per agent, as defined in Equations (8)-(10): \[separations=\frac{1}{n}\sum_{s=1}^{T}sep_{s},\] (8) \[alignments=\frac{1}{n}\sum_{s=1}^{T}al_{s},\] (9) \[cohesions=\frac{1}{n}\sum_{s=1}^{T}co_{s}.\] (10)  
In addition to these metrics, some objective functions used in ref. [14] are used as well, as follows:  
* Goal zone localization time: The average number of steps to localize the goal zone by every member of the flock (Equation (11)). \[localizationTime=\frac{1}{n}\sum_{i=1}^{n}s_{i}\] (11) \begin{table}
\begin{tabular}{c l} \hline \hline
**Notation** & **Definition** \\ \hline \(n\) & Number of agents \\ \(T\) & Total number of steps \\ \(g_{i}\) & The status of goal detection of agent \(i\) \\ \(sep_{s}\) & The total number of applied separations at step \(s\) \\ \(al_{s}\) & The total number of applied alignments at step \(s\) \\ \(co_{s}\) & The total number of applied cohesions at step \(s\) \\ \(s_{i}\) & The \(i^{\text{th}}\) agent’s total steps for the localization of the goal zone \\ \(c_{s}\) & The average center of mass of the flock at a specific step \(s\) \\ \(r_{i,s}\) & The \(i^{\text{th}}\) agent’s linear position at step \(s\) \\ \(d(c_{s},r_{i,s})\) & The Euclidean distance between points \(c_{s}\), and \(r_{i,s}\) \\  & A matrix with the Euclidean distance between each pair of agents \(i\) and \(j\) at \\ \(D_{s}\) & step \(s\) (Equation (14)) \\ \(a_{s}\) & The number of collisions between agents at step \(s\) (Equation (15)) \\ \(d_{c}\) & The maximum collision distance between agents \\ \(o_{i}\) & Obstacles detected by agent \(i\) (Equation (16)) \\ \(o_{s}\) & A vector of of all \(o_{i},i\in n\) agents at step \(s\) (Equation (17)) \\ \(b_{s}\) & The total number of collisions at step \(s\) (Equation (18)) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Notation used for the design of the flock controller. * Average distance to the center of mass (Equation (12)), where the average center of mass of the flock at each step, \(s\), is defined by Equation (13): \[distanceToCoM=\frac{1}{T}\sum_{s=1}^{T}\left(\frac{1}{n}\sum_{i=1}^{n}d(c_{s},r_{ i,s})\right),\] (12) \[c_{s}=\frac{1}{n}\sum_{i=1}^{n}r_{i,s}.\] (13)
* Collisions per member. This metric reports the number of collisions that occurred between agents and obstacles. The number of collisions \(a_{s}\) among all flock agents \(i\), \(j\) at step \(s\) is computed based on the distances between them in \(D_{s}\) (Equation (14)), according to Equation (15). \[D_{s}= \begin{bmatrix}0&d_{12}&\ldots&d_{1n}\\ d_{21}&0&\ldots&d_{2n}\\ \vdots&\vdots&\ddots&\vdots\\ d_{n1}&d_{n2}&\ldots&0\end{bmatrix} ,\] (14) \[a_{s}=