# Dynamic Response Threshold Model for Self-Organized Task Allocation in a Swarm of Foraging Robots
## 2 Methods
### Dynamical Response Threshold Model (DRTM)
Herein, the TFD is newly used to calculate the density of foraging robots. The logical extension of Equation (3) is:  
\[k=\frac{1}{L\times L}\times(N_{r}-N_{W}) \tag{4}\]  
where \(L\) is the side length of the foraging arena (in this foraging scenario, robots roam a square area, so the amount of available space is \(L\times L\)), \(N_{r}\) is the total number of robots in the swarm foraging, and \(N_{W}\) is the number of robots in state \(S_{W}\). Therefore, \(N_{r}-N_{W}\) denotes the number of active foraging robots. In swarm foraging, the TFD is the number of active foraging robots per unit area and can be used to reflect the traffic conditions. As can be seen from Equation (4), when \(k\) is large, many robots are foraging. Much more obstacle avoidance will be generated, thereby reducing the foraging efficiency, meaning that we should decrease the number of active foraging robots. The average number of OAEs \(M_{A}\) within a period of time \(T_{2}\) can also reflect the traffic situation, and \(M_{A}\) is defined as:  
\[M_{A}=\frac{M_{T_{2}}}{N_{r}} \tag{5}\]  
where \(M_{T_{2}}\) is the total number of OAEs over time \(T_{2}\). When there is traffic congestion, more avoidance behavior arises; when the traffic is moving smoothly, less avoidance behavior arises. However, traffic conditions change with time, and the number of OAEs reflects the traffic conditions over time \(T_{2}\). Therefore, we need to choose a suitable time period over which to calculate the number of OAEs. Too big or too small a time period \(T_{2}\) will not reflect the traffic conditions correctly. The number of OAEs due to robots within state \(S_{R}\) can well reflect the traffic conditions. Any robot in state \(S_{R}\) can return to the nest in \(L/2v\) seconds, where v is the robot's speed and \(L/2\) is half the side length of the foraging arena; therefore, we set \(T_{2}=L/2v\). The greater \(M_{A}\), the heavier the traffic congestion, meaning that we should decrease the number of active foraging robots. In the DRTM, the response threshold changes dynamically and is defined as:  
\[\theta=\alpha*k+\beta*M_{A} \tag{6}\]  
where \(\alpha\) and \(\beta\) are adjustment factors used to regulate the contributions of \(k\) and \(M_{A}\), respectively. The quantity \(\theta\) can reflect the traffic conditions. As can be seen from Equation (6), \(k\) and \(M_{A}\) together adjust the value of threshold \(\theta\). Larger \(\theta\) means traffic congestion in the foraging arena, and therefore fewer robots should be allocated to foraging. Conversely, smaller \(\theta\) means that many more robots should go foraging. In the DRTM, the state transition probability \(P_{s}\), which is the probability of leaving the nest to perform foraging, is defined as:  
\[P_{s}=\left\{ \begin{array}{cc}\frac{S(t)^{n}}{S(t)^{n}+\theta^{n}},&S(t)>0\\ 0,&S(t)\leq 0\end{array} \right. \tag{7}\]  
where \(n\) determines the slope of the probability function; different values of \(n\) may produce different responses for the same threshold \(\theta\) and stimulus S(t). The value of \(n\) is set randomly for each robot at the outset of foraging to avoid all robots working simultaneously. The larger the stimulus \(S(t)\), the less food there is in the nest for a given desired amount of food; under such circumstances, the foraging probability \(P_{s}\) increases. Conversely, \(P_{s}\) decreases when \(S(t)\) is smaller. When \(S(t)\leq 0\), there is the desired number \(F_{d}\) of food tokens in the nest and the robots can stop foraging. The traffic conditions can also affect the foraging probability; \(P_{s}\) decreases when traffic congestion occurs and increases when the traffic is flowing smoothly. As can be seen from Equation (7), the food information \(S(t)\) and environment information \(\theta\) together adjust the foraging probability, and therefore the swarm allocates a differing number of robots to go foraging based on the foraging probability.