**4.1 Simulation setting**

**Figure 2** depicts the simulator. The simulator was constructed with reference to the following previous studies [9, 15, 16, 18], with the best simulation parameters selected through preliminary experiments. **Table 3** shows the parameters used in simulation experiments. The experimental environment comprised a two-dimensional grid space of 150 150 cells. The nest was placed in the centre of the environment. The simulation halted after 10,000 steps in one trial, and we conducted 50 trials in each experimentation setting. A red cell represents a worker agent, and a purple cell represents a non-worker agent. When an agent touches the feed, it carries the feed to the nest; it is represented as an orange cell. A green cell contains a trail pheromone, and a blue cell contains a homing pheromone. As the pheromone evaporates, the pheromone level decreases, and the colour of the cell becomes lighter. The homing and trail pheromones do not mix. In the initial state, food sources were randomly placed in the food source area. When the feed in one source is exhausted, the next food source is placed randomly in the area. In the simulation, we fluctuated the amount and distribution of feeds to evaluate the proposed method's robustness in a dynamic environment. The simulation alternated between three different types of environments as follows:

Type-A: In **Figure 3a**, the environment is dotted with four small food sources. Each food source includes one feed.

Type-B: In **Figure 3b**, the environment is dotted with four medium food sources. Each food source includes nine feeds.

Type-C: In **Figure 3c**, the environment has one large food source. The food source contains one hundred feeds.

*Autonomous Role Assignment Using Contact Stimuli in Swarm Robotic Systems DOI: http://dx.doi.org/10.5772/intechopen.107852*


### **Table 3.**

*Parameters of simulation experiments.*

#### **4.2 Evaporation and diffusion of pheromones**

An agent secretes a trail or homing pheromone while moving. The initial value of each pheromone is 1.0, and each pheromone decreases at a rate of 0.99. The agent returns to the colony when the residual quantity of each pheromone is less than 0.01. These parameters were set through preliminary experiments so that an agent can sufficiently explore an environment. Here, an agent can explore an environment in approximately 450 steps.

Pheromones are spread out by evaporation and diffusion, diluting their density. The equations for these evaporation and diffusion phenomena are defined as follows.

$$F\_p(\mathbf{x}, \mathbf{y}, t) = \mu F\_p(\mathbf{x}, \mathbf{y}, t - \mathbf{1}) + \Delta F\_p(\mathbf{x}, \mathbf{y}, t) \tag{8}$$

$$
\Delta F\_p(\mathbf{x}, y, t) = \begin{cases} Q\_p & \text{if an agent is in the grid } (\mathbf{x}, y) \\ \mathbf{0} & \text{otherwise} \end{cases} \tag{9}
$$

$$a\_{\mathcal{P}}(\mathbf{x}, \mathbf{y}, t) = a\_{\mathcal{P}}(\mathbf{x}, \mathbf{y}, t - \mathbf{1}) + \lambda \Big[a\_{\mathcal{P}}(\mathbf{x} + \mathbf{1}, \mathbf{y} - \mathbf{1}, t - \mathbf{1}) + a\_{\mathcal{P}}(\mathbf{x} + \mathbf{1}, \mathbf{y}, t - \mathbf{1})$$

$$\begin{aligned} & + a\_{\mathcal{P}}(\mathbf{x} + \mathbf{1}, \mathbf{y} + \mathbf{1}, t - \mathbf{1}) + a\_{\mathcal{P}}(\mathbf{x}, \mathbf{y} - \mathbf{1}, t - \mathbf{1}) + a\_{\mathcal{P}}(\mathbf{x}, \mathbf{y} + \mathbf{1}, t - \mathbf{1}) \\ & + a\_{\mathcal{P}}(\mathbf{x} - \mathbf{1}, \mathbf{y} - \mathbf{1}, t - \mathbf{1}) + a\_{\mathcal{P}}(\mathbf{x} - \mathbf{1}, \mathbf{y}, t - \mathbf{1}) + a\_{\mathcal{P}}(\mathbf{x} - \mathbf{1}, \mathbf{y} + \mathbf{1}, t - \mathbf{1}) \Big] \\ & - 9a\_{\mathcal{P}}(\mathbf{x}, \mathbf{y}, t - \mathbf{1}) \Big] + (1 - \mu)F\_{\mathcal{P}}(\mathbf{x}, \mathbf{y}, t), \end{aligned}$$

(10)

#### **Figure 3.**

*Three types of environments, with varying amounts and distributions of feeds.*

where *Qp* denotes the addition quantity of the pheromone, and *Fp*ð Þ *x*, *y*, *t* represents the quantity of the pheromone in a grid ð Þ *x*, *y* at a time, *t*. *ap*ð Þ *x*, *y*, *t* represents the quantity of the pheromone above a grid ð Þ *x*, *y* at a time, *t*. The second term on the right side of Eq. (10) represents the quantity of the pheromone that inflows, outflows and disappears from neighbouring grids, and the third term on the right side represents the quantity of the pheromone that evaporates. An agent detects the pheromone quantity, *ap*, in the three forward cells. In the simulation, the initial pheromone density was set as *Qp* ¼ 1*:*0. *γ* and *λ* represent the rates of evaporation and diffusion, respectively, with values set as *μ* ¼ 0*:*99 and *λ* ¼ 0*:*01. These parameters were set with reference to a previous study [19]. However, if the rates of evaporation and diffusion are very high, agents cannot arrive at a food source by following a pheromone trail because pheromones will disappear rapidly. Conversely, if the rates are very low, agents cannot discover pheromone trails leading to food sources because pheromones will fill the environment. Thus, we made appropriate adjustments to fit the simulation environment through preliminary experiments.

*Autonomous Role Assignment Using Contact Stimuli in Swarm Robotic Systems DOI: http://dx.doi.org/10.5772/intechopen.107852*

### **4.3 Simulation results**

### *4.3.1 Appropriate worker ratio in each environment*

Firstly, we reveal the appropriate worker ratio in the three types of environments with varying amounts and distributions of feeds. **Figure 4** depicts the means and standard deviations of collected feeds by a swarm of agents with different worker ratios in the three types of environments. The swarm of agents needed to increase the number of exploring agents because there was only a small amount of feed in the type-A environment, with four small food sources. Therefore, the mean of collected feeds was higher as the worker ratio was smaller. In the type-B environment, with four medium food sources, both foraging and food exploration were important for the swarm of agents. Therefore, the maximum mean of collected feeds was obtained when the worker ratio was 60%. In the type-C environment, with only one large food source, a swarm of agents could easily discover the large food source. Therefore, the swarm of agents needed to mobilise several ants to collect feeds efficiently. However, if all agents attended to the foraging call, it may take a long time to discover a new food source. Thus, the maximum mean of collected feeds was obtained when the worker ratio was 80%. According to the above results, the swarm of agents uses the appropriate worker ratio in each environment with varying amounts and distributions of feeds.

#### *4.3.2 Adaptability of the proposed method*

We studied the proposed method's adaptability in environments with varying amounts and distributions of feeds. In addition, we compared the proposed method

**Figure 4.** *The means and standard deviations of collected feeds in different worker ratios.*

**Figure 5.**

*Means and standard deviations of collected feeds in type-A environment.*

with the conventional method in terms of the mean of collected feeds by a swarm of agents.

**Figure 5** illustrates the means and standard deviations of collected feeds in the type-A environment. For example, C(1–3) denotes the conventional method, with the load parameter, *δ* and the scale factor, *α*, set as 1 and 3, respectively. On the other hand, P denotes the proposed method. Here, the maximum mean of collected feeds of the conventional method was 126. Similarly, the mean of collected feeds of the proposed method was 131. The conventional and proposed methods had the same foraging ability.

**Figure 6** shows the relationship among the worker ratio, the foraging agent ratio and the amount of existing feeds in an environment. The horizontal axis represents the number of steps. The vertical axis represents the ratio of workers and foraging agents, and the secondary vertical axis represents the amount of existing feeds in the environment. In the simulation, when the feed in one source is exhausted, the next food source is placed randomly in the environment. Therefore, the amount of feeds fluctuated between 3 and 4. That is, the number of vertical blue lines represents the amount of collected feeds, and its slits represent the time spent discovering a new food source. **Figure 6** depicts the results of the proposed and conventional methods in terms of the amount of feeds collected. The worker ratio of the conventional method remained constant at approximately 30%, whereas that of the proposed method

*Autonomous Role Assignment Using Contact Stimuli in Swarm Robotic Systems DOI: http://dx.doi.org/10.5772/intechopen.107852*

#### **Figure 7.**

*Means and standard deviations of collected feeds in type-B environment.*

fluctuated with the amount of existing feeds in the environment. In addition, the mean worker ratio of the proposed method was 28%. As a result, in both methods, the swarm of agents could discover a new food source quickly by increasing the number of exploring agents.

**Figure 7** displays the means and standard deviations of collected feeds in the type-B environment. The maximum mean of collected feeds of the conventional method was 604. Here, the load parameter, *δ* and the scale factor, *α*, were set as 3 and 5, respectively. The mean of collected feeds of the proposed method was 622. As shown in **Figure 8**, the worker ratio of the conventional method remained constant at approximately 60%. On the other hand, the worker ratio of the proposed method increases when a new food source is placed in the environment, whereas its worker ratio decreases when the amount of existing feeds in the environment reduces. That is, with the proposed method, a swarm of agents could collect large amounts of feeds by adjusting the number of foraging and exploring agents according to the amount of existing feeds in the environment. Furthermore, the proposed method's mean worker ratio was 60%, which is mostly identical to that of the conventional method.

**Figure 9** displays the means and standard deviations of collected feeds in the type-C environment. The maximum mean of collected feeds of the conventional method was 997. Here, the load parameter, *δ* and the scale factor, *α*, were set as 9 and 11, respectively. The proposed method's mean of collected feeds was 943. As shown in

**Figure 9.** *Means and standard deviations of collected feeds in type-C environment.*

**Figure 10.**

*The transition of the worker ratio and the amount of existing feeds in type-C environment.*

**Figure 10a**, the conventional method's mean worker ratio is 80% because many workers must collect feed from one large food source effectively. On the other hand, the proposed method's mean worker ratio is 64%, as shown in **Figure 10b**. The reason for this was that, with the proposed method, the swarm of agents exhausted the feed in a food source before its worker ratio reached 80%.

#### *4.3.3 Role assignment process*

We explain the role assignment process in the proposed method in each environment with varying amounts and distributions of feeds. **Figure 11** depicts the relationship between the contact stimuli and the worker/non-worker state for a certain agent. In this graph, the horizontal axis represents the number of steps. The vertical axis represents the response threshold and the probability of changing from a non-worker to a worker. However, the value of the response threshold was normalised from 0.0 to 1.0. The secondary vertical axis represents the strength of the contact stimulus. The red line indicates the strength of contact stimuli with foraging agents. The green line indicates the transition of the response threshold. The blue line indicates the transition of the probability of changing from a non-worker to a worker. The light blue line indicates that an agent is in a worker or non-worker state. In addition, a convex shape indicates a worker state and a concave shape indicates a non-worker state. The

*Autonomous Role Assignment Using Contact Stimuli in Swarm Robotic Systems DOI: http://dx.doi.org/10.5772/intechopen.107852*

**Figure 11.** *Relationship between contact stimuli and worker state in the proposed method.*

probability of changing from a non-worker to a worker varied with the contact stimuli and the response threshold. On the other hand, the probability of changing from a worker to a non-worker remained constant at 0.1%.

As shown in **Figure 11a**, an agent remains in a non-worker state until approximately 5,000 steps, and the duration of the non-worker state is very long. The reason for this was that the frequency of contact stimuli with foraging agents was low because the type-A environment had only a small amount of feed. On the other hand, as shown in **Figure 11b**, an agent contacts foraging agents frequently because there is much feed in the environment, increasing the duration of the worker state. The agent contacted two foraging agents continuously at approximately 2,800 steps. Furthermore, the strength of the contact stimulus reached 1.99, and the agent changed to a worker. As shown in **Figure 11c**, an agent contacts foraging agents frequently after 4,000 steps and changes to a worker quickly even if it had changed to a non-worker. According to the aforesaid results, the proposed method can perform role assignment automatically under different environmental conditions through contact stimuli with foraging agents according to the amounts of feeds.

#### *4.3.4 Robustness in a dynamic environment*

To evaluate the proposed method's effectiveness in a dynamic environment, we compared the proposed method with the conventional method in terms of the mean of collected feeds in an environment with varying amounts and distributions of feeds. **Figure 12** depicts the means and standard deviations of collected feeds in a dynamic

**Figure 12.** *Means and standard deviations of collected feeds in a dynamic environment.*

**Figure 13.**

*The transition of worker ratio and the amount of collected feeds of the proposed method. (A), (B) and (C) in the graph denote an environment with four small food sources, an environment with four medium food sources and an environment with one large food source, respectively. The maximum number of steps in this simulation is 50,000.*

environment. The conventional method's maximum mean of collected feeds was 1102, and its standard deviation was 414. Here, the load parameter, *δ* and the scale factor, *α*, were set as 5 and 7, respectively. Conversely, the proposed method's mean of collected feeds was 1176, and its standard deviation was 61. Based on the difference between standard deviations, the amount of collected feeds of the conventional method was unstable, whereas that of the proposed method was stable in the dynamic environment.

**Figure 13** depicts the proposed method's results. The red line indicates the transition of the worker ratio, and the blue line indicates the amount of existing feeds in the environment. As shown in **Figure 13**, the worker ratio is low in the type-A environment with a small amount of feed. This means that the swarm of agents could discover new food sources by increasing the number of exploring agents. Conversely, the worker ratio was higher in the type-B and C environments, with more feeds. This means that the swarm of agents could collect much feed effectively by increasing the number of foraging agents. As a result, the proposed method could perform autonomous role assignment effectively through contact stimuli with foraging agents according to the external environment fluctuations. On the other hand, to change the

*Autonomous Role Assignment Using Contact Stimuli in Swarm Robotic Systems DOI: http://dx.doi.org/10.5772/intechopen.107852*

worker/non-worker state, the conventional method used the stimulus updated by the previous stimulus, the load parameter and the worker ratio in the colony. This means that the strength of stimuli did not reflect the external environment fluctuations. Therefore, the conventional method did not allow agents to be assigned roles according to external environment fluctuations.
