# Dynamic Response Threshold Model for Self-Organized Task Allocation in a Swarm of Foraging Robots
## 2 Methods
### Dynamical Response Threshold Model (DRTM)  
To complete the foraging task, we should maintain the swarm energy at the desired level. The food tokens collected by the foraging robots can increase the swarm energy. However, the foraging activities (e.g., the movements of the foraging robots) and interference among robots constitute a loss of swarm energy. The swarm's nest can also constitute a loss of energy at a certain rate (Crate). Therefore, the amount of food (or energy) in the nest will decrease gradually, and when there are fewer food tokens than the desired level, the robots tend to go foraging based on the DRTM. By adjusting the number of foraging robots, the DRTM can complete effective TA and improve foraging efficiency. The DRTM accounts for the TFD and the amount of obstacle avoidance to adjust the response threshold dynamically. In the DRTM, the foraging behavior of an individual robot is influenced by the external stimulus (\(S(t)\)) and the response threshold (\(\theta\)). The external stimulus \(S(t)\) reflects the amount of food in the nest and is defined as:  
\[S(t)=F_{d}-F(t) \tag{2}\]  
where \(F_{d}\) is the desired number of food tokens to be maintained in the nest and \(F(t)\) is the number of food tokens in the nest at time \(t\). The stimulus \(S(t)\) measures the gap between the existing number of food tokens and the desired number. Larger \(S(t)\) means far fewer existing food tokens than desired, and therefore many more robots will be allocated to foraging. Conversely, with smaller \(S(t)\), fewer robots tend to go foraging. When \(S(t)\leq 0\), there are the desired number of food tokens and the robots stop going foraging. In swarm foraging, physical interference refers mainly to obstacle avoidance. If a foraging robot detects an obstacle (e.g., another robot or a wall), it executes avoidance behavior, namely turning away from the obstacle. Such avoidance behavior may interrupt the state of the robot, and after resolving a collision, the robot may spend much time reentering its previous state. For example, if a robot advances toward its nest in a straight line by tracking the light, obstacle avoidance can cause the robot to deviate from its route. After resolving the collision, the robot searches for the light once again in random walk, thereby taking longer to return to the nest. Therefore, obstacle avoidance consumes more energy and decreases foraging efficiency. To have fewer obstacle avoidance events (OAEs), we propose two measurements to evaluate the traffic conditions upon which the number of active foraging robots is adjusted dynamically. One is the TFD and the other is the average number of OAEs. In swarm foraging, the number of OAEs is related not only to the number of active foraging robots but also to the size of the foraging arena. To assess quantitatively how the number of foraging robots and the size of the foraging arena impact the foraging task, we newly introduce the concept of TFD. As a basic concept in traffic engineering, the TFD \begin{table}
\begin{tabular}{c c c c} \hline \hline
**State** & **Detect Attractors** & **ASM’s Input: A(t)** & **Robot’s Motion** \\ \hline \(S_{W}\) & No & 0 & random walk \\ \(S_{W}\) & Yes & 1 & approach to the food \\ \(S_{W}\) & No & 0 & random walk \\ \(S_{W}\) & Yes & 1 & approach to the light \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Foraging behaviors based on attractor selection model (ASM). denotes the number of vehicles within one or several lanes on a unit length of road [36] and is defined as:  
\[k=\frac{N_{V}}{L} \tag{3}\]  
where \(N_{V}\) is the number of vehicles on the road and \(L\) is the length of the road. The TFD can reflect the traffic conditions directly and has been widely used in traffic engineering. When \(k\) is large, there is traffic congestion on the road; otherwise, the traffic flows smoothly. Based on the size of the TFD, different traffic management and control measures are adopted to regulate the road traffic to improve traffic efficiency.