# An Artificial Plant Community Algorithm for Collision-Free Multi-Robot Aggregation
## 5 An Artificial Plant Community Algorithm
### Algorithm Flow  
As shown the APC algorithm flow shown in Figure 4, based on the iterative execution of the seeding, growing, and fruiting operations, the edge robots can search for the optimal candidate solution to the collision-free multi-robot aggregation problem through the swarm intelligence of multi-robot systems. The algorithm flow in Figure 4 is composed of five primary steps and a big loop, including initialization, seeding operation, growing operation, the fruiting operation,  
Figure 4: The APC algorithm flowchart for the collision-free multi-robot aggregation problem. and checking for the end condition. During initialization, the parameters of CMAP, the APC parameters, and the solution system parameters--that is, the fitness function in Equation (30)--are defined. In the seeding operation, random seeds are generated according to the seeding probability \(p_{seed}\), and seeds are produced from the previous fruits. In the growing operation, fitness calculation and comparison are conducted in order to determine the optimal seeds to grow according to the growing probability \(p_{grow}\), selecting the seeds with the highest fitness. In the fruiting operation, fruits are generated according to the fruiting probability \(p_{fruit}\), and optimal fruits are generated via parthenogenesis. After checking for the end condition, the APC will decide to continue the calculation loop or output the optimal candidate solution to the CMAP. According to the APC algorithm flowchart shown in Figure 4, the pseudo-code for robotic edge implementation is shown in Algorithm 1. This algorithm describes the solution process of the APC algorithm with respect to the collision-free multi-robot aggregation problem, where the candidate solution is encoded using Equation (31), the fitness function is that given in Equation (30), and the constraints are Equations (13)-(28). The task state transition process is shown in Figure 3.  
```
1: task state = new
2: robot state = idle
3: initialize the parameters of collision-free multi-robot aggregation problem
4: initialize the parameters of APC
5: initialize the parameters of the solving system
6: encode the APC individual by Equation (31)
7: select fitness function by Equation (30)
8: for ite = 1 to \(\mathit{1 te}_{max}\)
9: generate the random seeds by \(p_{seed}\)
10: generate seeds from the previous fruits
11: calculate fitness by Equation (30)
12: calculate the constraints by Equations (13)-(28)
13: select the best candidate solutions through the group sort by \(p_{grow}\)
14: select the elite individual with the highest fitness
15: generate a fruit through parthenogenesis
16: generate fruits through social-learning by \(p_{fruit}\)
17: to check end condition by \(e_{th}\)
18: end for
19: output the optimal candidate solution to CMAP
20: if assigned then task state = assignment & robot state = occupied
21: if scheduled then robot state = aggregation & task state = processing
22: if reached then robot state = processing
23: if interrupted then task state = waiting
24: if returned then task state = assignment
25: if detected then robot state = collision avoidance
26: if avoided then robot state = aggregation
27: if completed then task state = end & robot state = idle
```  
**Algorithm 1** The APC to solve the CMAP  
Then, the best candidate solution to the CMAP will be output for robot assignment. Algorithm 1 depicts the solution process for a collision-free multi-robot aggregation problem, where the APC individuals are encoded as a feasible solution via Equation (31). The fitness function in Equation (30) and constraints in Equations (13)-(28) are employed to instruct the APC to search for the optimal candidate solutions. When implementing the optimal candidate solution, the robots will be assigned to a suitable task, and the state transitions of tasks and robots will change during assignment. In Algorithm 1, after a task is completed, the completed task disappears from the REI system and will no longer be reused, while the robot that completed the task can be reused for the next task.