**4.1. Sunn pest-wheat**

This case study [14] presents the predator prey relationship model in the ecology. In this model, three types of agents are defined as sunn pest, wheat, and parasitoid. The sunn pest called bug agent in the model is both the predator and the prey roles. Wheat called habitat in the model is a cereal plant widely cultivated for food. The sunn pest is fed with wheat grain. The parasitoid is the predator which parasitizes the sunn pest's eggs. We have a grid where the sunn pests are randomly distributed illustrated in **Figure 1**.

The grid includes sunn pest, wheat, and parasitoid. In **Figure 2**, the green color shades indicate the growth of wheat, the red color cells indicate the sunn pest, and the white color cells indicate sunn pests' nymphs. About 7000 sunn pest agents and 1000 parasitoid agents are randomly distributed in the 28,000 grid cells.

In modeling of sunn pest-wheat scenario, agent classes and methods are built according to the definitions in **Tables 1**–**3**.

the chemical and/or biological struggles against sunn pest and obtaining maximum gain to produce the wheat. The parasitoids are used only in biological struggles against sunn pest. In the initial time, all of agents distribute randomly on the grid. If the biological struggle is to be

Agent-Based Modeling and Simulation of Biological Systems

http://dx.doi.org/10.5772/intechopen.80070

33

**Figure 2.** The graphical user interface during the running of the simulation [14].

**Figure 1.** Distribution of the sunn pests on the 10 × 10 grid size.

The simulation runs during 90th tick counts which is represented in sunn pests' lifecycle (biological stages) and cultivation cycle of wheat. The aim of this case study is to simulate Agent-Based Modeling and Simulation of Biological Systems http://dx.doi.org/10.5772/intechopen.80070 33


**Figure 1.** Distribution of the sunn pests on the 10 × 10 grid size.

to the environment randomly or with some rules. They may have the energy to make them survive. If the agent's energy is exhausted, the agent may die. If the agent's energy reaches the reproduction threshold, it may reproduce. In the simulation environment, there are heterogeneous agents which have different types. For example, an agent may represent the animal, while the other may represent the human. A style class in two-dimensional (2D) or threedimensional (3D) simulation environment can be created in a way that defines the physical properties of agents such as size, color, and shape. Global parameters associated with agent classes, including initial values of project given by users, may be defined in an xml file.

Repast Simphony provides the users a graphical user interface (GUI). GUI allows the users to manage the simulation processes and to control the parameters. GUI has a user panel that includes run options, parameters, and scenario tree. To form the scenario tree of a project, context builder Java file is defined in data loaders to display agents and the environment on which agents are located. It is possible to observe agents' behavior outputs on the plots and charts. Data sets are created to graphically illustrate time charts defining variables over time. The data set source is determined by pointing out the relevant methods. Histogram bar chart

Agent-based models utilizing Repast Simphony have been developed for a diverse range of scenario including biological systems. In this chapter, three different case studies are presented to better understand ABMS phenomena. These case studies described in subsections

This case study [14] presents the predator prey relationship model in the ecology. In this model, three types of agents are defined as sunn pest, wheat, and parasitoid. The sunn pest called bug agent in the model is both the predator and the prey roles. Wheat called habitat in the model is a cereal plant widely cultivated for food. The sunn pest is fed with wheat grain. The parasitoid is the predator which parasitizes the sunn pest's eggs. We have a grid where the

The grid includes sunn pest, wheat, and parasitoid. In **Figure 2**, the green color shades indicate the growth of wheat, the red color cells indicate the sunn pest, and the white color cells indicate sunn pests' nymphs. About 7000 sunn pest agents and 1000 parasitoid agents are

In modeling of sunn pest-wheat scenario, agent classes and methods are built according to the

The simulation runs during 90th tick counts which is represented in sunn pests' lifecycle (biological stages) and cultivation cycle of wheat. The aim of this case study is to simulate

illustrates the distribution of variables.

32 Modeling and Computer Simulation

**4. Implementation of the case studies**

are highlighted local behaviors of a real system.

randomly distributed in the 28,000 grid cells.

sunn pests are randomly distributed illustrated in **Figure 1**.

**4.1. Sunn pest-wheat**

definitions in **Tables 1**–**3**.

**Figure 2.** The graphical user interface during the running of the simulation [14].

the chemical and/or biological struggles against sunn pest and obtaining maximum gain to produce the wheat. The parasitoids are used only in biological struggles against sunn pest. In the initial time, all of agents distribute randomly on the grid. If the biological struggle is to be


**Table 1.** Local knowledge of sunn pest (bug agent).

done, the parasitoid agents are activated. Until the 15th tick count, sunn pest agents act on the grid and fed from the habitat cells. At the 15th tick count, female sunn pests lay eggs (embryos) and die. In **Figure 2**, white color cells on the grid indicate the embryos, and the histogram bar shows the sunn pests' total numbers for each biological stage. Through 90th tick counts, the sunn pests complete their lifecycle against the parasitoid. At the end of the simulation, the sum of food availability on the habitat cells has been observed illustrated in **Figure 3**.

bacterial agents and 100 immune system cell agents are randomly distributed on the 100 × 100

Parasitizes sunn pest's embriyo at the neighbouring cells around and locates in its cell.

If there is no sunn pest's embriyo in the neighbouring cells, it changes its position and randomly

Bacteria agents are grouped within themselves depending on the range of disease called virulence factor. The virulence factor is assigned between 1 and 4. In **Figure 4**, the white cells on the grid indicate the bacterial agents which have the virulence factor of 1, the yellow cells on the grid indicate the bacterial agents which have the virulence factor of 2, the red cells on the grid indicate the bacterial agents which have the virulence factor of 3, the purple cells on the grid indicate the bacterial agents which have the virulence factor of 4, and the blue cells on the grid indicate the immune system cell agents which have the virulence factor of 4. The simulation has three parts: the first one is bacterial competition on flora, the second is antibiotic usage, and the third is antibiotic resistance. According to these parts, the local

knowledge of bacterial agents and immune system cell agents is defined in **Table 4**.

to help the immune system cell agents and kill the bacterial agents.

In the first part of the simulation, the aim is to balance the population of bacterial agents and immune system cell agents on the grid. Also, bacterial agents compete with their neighbors for space and food resources. A food layer is defined in the simulation environment to live, grow, and reproduce. In the second part of the simulation, antibiotic usage is defined against the bacterial agents. An antibiotic layer is included in the simulation environment. The aim is

grid cells. The grid represents a human tissue or organ.

Remains in the grid until the end of the simulation.

**Roles Food value layer**

**Actions** grow

**Roles Parasitoid Attributes** —

**Actions** move, hunt, kill

**Table 3.** Local knowledge of parasitoid.

**Attributes** production rate, availability value

**Table 2.** Local knowledge of wheat (habitat cell).

**Rules** Randomly distributed in the grid.

moves to another cell.

**Rules** Defined at certain ratio within each cell in the grid.

Grows certain ratio in each step, and it becomes availability value.

Its color scale changes according to its production rate.

The sunn pest consumes food as much as its growth rate in the cell where it is located.

Agent-Based Modeling and Simulation of Biological Systems

http://dx.doi.org/10.5772/intechopen.80070

35

In the result of this case study, the relationship between sunn pest and parasitoid is simulated with the agent-based modeling approach. This case study represents the behavior of a real biological system, even if it is not identified with all the details. In the computer simulation studies, some assumptions can be done, such as in this study, the climate conditions are not included in the simulation. The boundaries of the study must be specified, otherwise undesirable results can be obtained and the system drifts the chaos.

### **4.2. Bacteria – antibiotic**

This work [15] presents bacterial population and resistance to antibiotics. Bacterial population known as bacterial flora are nonharmful microorganisms in the human body that live in the human skin, in the mouth, in the digestive system, etc. There are immune cells that suppress the bacterial flora. Immune cells and bacterial flora should always be balanced in the body. In this model, two types of agents are defined as bacteria and immune system cell. About 4000


**Table 2.** Local knowledge of wheat (habitat cell).


**Table 3.** Local knowledge of parasitoid.

done, the parasitoid agents are activated. Until the 15th tick count, sunn pest agents act on the grid and fed from the habitat cells. At the 15th tick count, female sunn pests lay eggs (embryos) and die. In **Figure 2**, white color cells on the grid indicate the embryos, and the histogram bar shows the sunn pests' total numbers for each biological stage. Through 90th tick counts, the sunn pests complete their lifecycle against the parasitoid. At the end of the simulation, the sum

Randomly goes to one of the neighbour cells around him and feeds and grows from that cell.

If the sunn pest is female and its size is more than 12 mm (i.e. the biological state is mature), lay eggs

If the sunn pest is a male, it dies in condition that the probability of survival (95%) being smaller than

Grows 0.3 mm per step in the embryo phase and except this; it grows as much as the amount that it

If the size of sunn pest is in the range of 0 - 0.8, its biological stage is an "Embryo". If the size of sunn pest is in the range of 0.8 - 2.0, its biological stage is a "First nymph". If the size of sunn pest is in the range of 2.0 - 3.5, its biological stage is an "Second nymph". If the size of sunn pest is in the range of 3.5 - 5.0, its biological stage is a "Third nymph". If the size of sunn pest is in the range of 5.0 - 6.0, its biological stage is a "Fourth nymph". If the size of sunn pest is in the range of 6.0 - 6.0, its biological stage is a "Fifth nymph". If the size of sunn pest is greater than 10.0 mm, its biological stage is in the "Adult".

In the result of this case study, the relationship between sunn pest and parasitoid is simulated with the agent-based modeling approach. This case study represents the behavior of a real biological system, even if it is not identified with all the details. In the computer simulation studies, some assumptions can be done, such as in this study, the climate conditions are not included in the simulation. The boundaries of the study must be specified, otherwise undesir-

This work [15] presents bacterial population and resistance to antibiotics. Bacterial population known as bacterial flora are nonharmful microorganisms in the human body that live in the human skin, in the mouth, in the digestive system, etc. There are immune cells that suppress the bacterial flora. Immune cells and bacterial flora should always be balanced in the body. In this model, two types of agents are defined as bacteria and immune system cell. About 4000

of food availability on the habitat cells has been observed illustrated in **Figure 3**.

able results can be obtained and the system drifts the chaos.

**4.2. Bacteria – antibiotic**

**Roles Predator, prey**

34 Modeling and Computer Simulation

**Attributes** Size, energy, gender, survival probability, state, generation

When the adults come to the field, the simulation starts.

5 times, leaves a total of 80 to 150 eggs and dies.

a random number determined.

**Actions** Move, grow, mortality, reproduce, die

**Rules** Female and male ratio is 50%.

eats.

**Table 1.** Local knowledge of sunn pest (bug agent).

bacterial agents and 100 immune system cell agents are randomly distributed on the 100 × 100 grid cells. The grid represents a human tissue or organ.

Bacteria agents are grouped within themselves depending on the range of disease called virulence factor. The virulence factor is assigned between 1 and 4. In **Figure 4**, the white cells on the grid indicate the bacterial agents which have the virulence factor of 1, the yellow cells on the grid indicate the bacterial agents which have the virulence factor of 2, the red cells on the grid indicate the bacterial agents which have the virulence factor of 3, the purple cells on the grid indicate the bacterial agents which have the virulence factor of 4, and the blue cells on the grid indicate the immune system cell agents which have the virulence factor of 4.

The simulation has three parts: the first one is bacterial competition on flora, the second is antibiotic usage, and the third is antibiotic resistance. According to these parts, the local knowledge of bacterial agents and immune system cell agents is defined in **Table 4**.

In the first part of the simulation, the aim is to balance the population of bacterial agents and immune system cell agents on the grid. Also, bacterial agents compete with their neighbors for space and food resources. A food layer is defined in the simulation environment to live, grow, and reproduce. In the second part of the simulation, antibiotic usage is defined against the bacterial agents. An antibiotic layer is included in the simulation environment. The aim is to help the immune system cell agents and kill the bacterial agents.

**Figure 3.** The graphical user interface at the end of simulation [14].

**Figure 4.** Bacterial agents and immune system cell agents on the grid at the initial time [15].

**Figure 5** shows how the antibiotic usage suppresses the bacterial agent population when the immune system cell agents are insufficient. The third part of the simulation presents the relationship between antibiotic-resistant bacterial agents and immune system cell agents. Most of the bacterial agents with virulence factor between 2 and 4 are killed by the antibiotic, whereas rest is killed by immune system cell agents. However, bacterial agents with virulence factor of 1 survive because they are antibiotic-resistant. Bacterial agents with low virulence factor are

divided very rapidly so that the number of immune system cell agents is increased. **Figure 6** shows the struggle between immune system cell agents and bacterial agents on the grid. The

**Figure 5.** Relationship between bacterial agents and immune system cell agents in the antibiotic usage [15].

**Bacterial agents Immune system cell agents**

**Actions** move, grow, reproduce move, send signal, kill, disappear

Id

Observes the neighbour 48 cells.

Agent-Based Modeling and Simulation of Biological Systems

http://dx.doi.org/10.5772/intechopen.80070

37

it kills and locates on that cell.

system cell agents.

state and disappear.

immune system cell agent and dies.

If there is a bacteria agent in the neighbour cells,

If it kills two bacteria, it sends signals to another

If there are more than 40 bacteria agents in the neighbour cells, it sends signals to other immune

If there are between 2 and 15 bacteria agents in the neighbour cells, it does not see any danger

**Roles** microorganism microorganism

Divided up into empty cells during the simulation

With a low virulence factor reproduce very

With the virulence factor of 1 is resistant to antibiotic which has a concentration value that

**Table 4.** The local knowledge of bacterial agents and immune system cell agents.

can kill bacteria in each cell.

**Attributes** virulance factor, survivalProbability, mutationProbability, size

**Rules** Randomly distributed in the grid.

runtime.

rapidly.

**Figure 7** shows, graphically, the populations of immune system cell agents and bacterial agents during the simulation runtime. At the initial time, there are 4000 bacterial agents and

grid, which indicates green color in **Figure 6**, represents tissue/organ.


**Table 4.** The local knowledge of bacterial agents and immune system cell agents.

**Figure 5.** Relationship between bacterial agents and immune system cell agents in the antibiotic usage [15].

**Figure 5** shows how the antibiotic usage suppresses the bacterial agent population when the immune system cell agents are insufficient. The third part of the simulation presents the relationship between antibiotic-resistant bacterial agents and immune system cell agents. Most of the bacterial agents with virulence factor between 2 and 4 are killed by the antibiotic, whereas rest is killed by immune system cell agents. However, bacterial agents with virulence factor of 1 survive because they are antibiotic-resistant. Bacterial agents with low virulence factor are

**Figure 4.** Bacterial agents and immune system cell agents on the grid at the initial time [15].

**Figure 3.** The graphical user interface at the end of simulation [14].

36 Modeling and Computer Simulation

divided very rapidly so that the number of immune system cell agents is increased. **Figure 6** shows the struggle between immune system cell agents and bacterial agents on the grid. The grid, which indicates green color in **Figure 6**, represents tissue/organ.

**Figure 7** shows, graphically, the populations of immune system cell agents and bacterial agents during the simulation runtime. At the initial time, there are 4000 bacterial agents and

system cell agents starts to increase. Antibiotic usage helps to reduce the population of bacte-

Agent-Based Modeling and Simulation of Biological Systems

http://dx.doi.org/10.5772/intechopen.80070

39

This case study provides an introduction to understand the dynamics of microbiological systems that take place in the process of bacterial evolution. During the simulation runtime, it is observed that how the system dynamics can be adaptive to external influences and effect

Homeostasis is a steady state that regulates the keeping of state variables at a constant or stable condition. Homeostasis is defined as a closed-loop control system that balances changes of target values. Biological systems like human body struggle to control its internal environment against internal and external influences. If homeostasis is unsuccessful in the body, vital functions cannot continue to work and the system drifts into chaos. Almost all homeostatic control mechanisms involve negative feedback loop which provides long-term control to maintain a steady state. Negative feedback has a self-regulating mechanism for maintaining homeostasis. Negative feedback mechanism involves some important factors. The first one is sensor or receptor which senses changes in the system variables that need to be regulated. The second is a control center which has a set point or threshold value that keeps the optimal value of the system variable. The other is an effector which produces a response that eliminates or reduces the changes of the system variables. Negative feedback loop runs until the system variables are adjusted at optimum values.

There are many negative feedback control mechanisms in the biological systems. The human physiology is one of the best examples of the biological systems in which the negative feedback mechanisms are observed. Some negative feedback control mechanisms that occur in the human body include regulation of blood pressure, keeping the pH constant, regulation of oxygen and carbon dioxide concentration in the blood, hormonal regulation of blood glucose

In this chapter, an example of negative feedback control mechanism that occurs in the human

In this case study [16], an agent-based homeostatic control model that regulates the body temperature during fever is presented. Fever is defined by an increase in body temperature above the normal range. Three types of agents, receptor agent, controller agent, and effector agents, are defined. Receptor agent is represented by thermoreceptor agent which senses changes in the body temperature. Controller agent has a set point which keeps the optimal value of body temperature. Effector agents are a set of dynamic autonomous agents which represent blood vessel that is a component of cardiovascular system [17]. Effector agents have been developed with ABMS approach [8]. The blood vessel is divided into segments. Each segment represents an agent. All of the agents in the negative feedback control mechanism

rial agents because the population of bacterial agents is very large.

levels, thyroid regulation, the control of body temperature, etc.

body is presented with ABMS approach.

are illustrated in **Figure 8**.

*4.3.1. The control of the temperature: thermoregulation*

interactions of them.

**4.3. Homeostasis**

**Figure 6.** Struggle between immune system cell agents and bacterial agents [15].

**Figure 7.** Relationship between bacterial agents and immune system cell agents in the antibiotic usage [15].

100 immune system cell agents on the grid. When simulation starts, immune system cell agents kill some of the bacterial agents. Surviving bacterial agents grow and reproduce. When the population of bacterial agents reaches the maximum value, the population of immune system cell agents starts to increase. Antibiotic usage helps to reduce the population of bacterial agents because the population of bacterial agents is very large.

This case study provides an introduction to understand the dynamics of microbiological systems that take place in the process of bacterial evolution. During the simulation runtime, it is observed that how the system dynamics can be adaptive to external influences and effect interactions of them.

### **4.3. Homeostasis**

100 immune system cell agents on the grid. When simulation starts, immune system cell agents kill some of the bacterial agents. Surviving bacterial agents grow and reproduce. When the population of bacterial agents reaches the maximum value, the population of immune

**Figure 7.** Relationship between bacterial agents and immune system cell agents in the antibiotic usage [15].

**Figure 6.** Struggle between immune system cell agents and bacterial agents [15].

38 Modeling and Computer Simulation

Homeostasis is a steady state that regulates the keeping of state variables at a constant or stable condition. Homeostasis is defined as a closed-loop control system that balances changes of target values. Biological systems like human body struggle to control its internal environment against internal and external influences. If homeostasis is unsuccessful in the body, vital functions cannot continue to work and the system drifts into chaos. Almost all homeostatic control mechanisms involve negative feedback loop which provides long-term control to maintain a steady state. Negative feedback has a self-regulating mechanism for maintaining homeostasis. Negative feedback mechanism involves some important factors. The first one is sensor or receptor which senses changes in the system variables that need to be regulated. The second is a control center which has a set point or threshold value that keeps the optimal value of the system variable. The other is an effector which produces a response that eliminates or reduces the changes of the system variables. Negative feedback loop runs until the system variables are adjusted at optimum values.

There are many negative feedback control mechanisms in the biological systems. The human physiology is one of the best examples of the biological systems in which the negative feedback mechanisms are observed. Some negative feedback control mechanisms that occur in the human body include regulation of blood pressure, keeping the pH constant, regulation of oxygen and carbon dioxide concentration in the blood, hormonal regulation of blood glucose levels, thyroid regulation, the control of body temperature, etc.

In this chapter, an example of negative feedback control mechanism that occurs in the human body is presented with ABMS approach.

#### *4.3.1. The control of the temperature: thermoregulation*

In this case study [16], an agent-based homeostatic control model that regulates the body temperature during fever is presented. Fever is defined by an increase in body temperature above the normal range. Three types of agents, receptor agent, controller agent, and effector agents, are defined. Receptor agent is represented by thermoreceptor agent which senses changes in the body temperature. Controller agent has a set point which keeps the optimal value of body temperature. Effector agents are a set of dynamic autonomous agents which represent blood vessel that is a component of cardiovascular system [17]. Effector agents have been developed with ABMS approach [8]. The blood vessel is divided into segments. Each segment represents an agent. All of the agents in the negative feedback control mechanism are illustrated in **Figure 8**.

**Figure 8.** Negative feedback control mechanism of thermoregulation [16].

During the simulation runtime, each agent defined in the negative feedback control mechanism interacts with other agents. All of the agents interact with each other by using Java message service. Java message service supports "publish/subscribe" message delivery model. Receptor agent monitors the change of the body temperature and publishes it to the controller agent who has subscribed to the value. Controller agent receives message that includes the body temperature value. Controller agent compares the body temperature value to its set point value. Controller agent sends a message to the effector agents which start or stop the negative feedback mechanism. Effector agents produce a response based on the message that they receive, and they publish to the receptor agent to correct the deviation with negative feedback. Negative feedback control mechanism achieves a balance between heat production and heat loss. The output of the negative feedback mechanism is illustrated in **Figure 9**.

agents. The effector agents decrease their radius values to produce a response. Local blood

Agent-Based Modeling and Simulation of Biological Systems

http://dx.doi.org/10.5772/intechopen.80070

41

**4.** The body temperature reaches the new set point of the body temperature. The infection is assumed to be cleared inside the body. The set point of the body temperature is set to 37°C. The body temperature is more than the new set point of the body temperature.

**5.** Condition at fourth step triggers sweat. Sweat tries to reduce the body heat which causes the dilation of the blood vessel called vasodilation. The controller agent publishes message "VASODILATION" to the effector agents. The effector agents increase their radius values to produce a response. Local blood flow parameter depending on the radius helps the heat

In the result of this case study, it is observed graphically how the body temperature is regulated during fever. Agent-based negative feedback control mechanism can be called adaptation loop [18]. This is because the negative feedback control mechanism is run by a set of dynamic autonomous agents. In this mechanism, it is possible to observe their local

This chapter has introduced the reader to ABMS, and it described implementations of different case studies utilizing the Repast Simphony toolkit. ABMS offers an extensible way to model biological systems consisting of autonomous and interacting agents which perform their actions and adapt their behaviors. Computer simulation helps the researcher to explore the behavior of a dynamic system. This chapter is concluded by observing interactions of real

flow parameter depending on the radius helps the heat gain.

**Figure 9.** Regulation of the body temperature [16].

loss. Thus, the body temperature returns to the optimal value.

behaviors.

**5. Conclusion**

systems' components in the abstraction level.

The simulation has a scenario of fever disease. This scenario achieves a balance with the agent-based negative feedback control mechanism as follows:


**Figure 9.** Regulation of the body temperature [16].

agents. The effector agents decrease their radius values to produce a response. Local blood flow parameter depending on the radius helps the heat gain.


In the result of this case study, it is observed graphically how the body temperature is regulated during fever. Agent-based negative feedback control mechanism can be called adaptation loop [18]. This is because the negative feedback control mechanism is run by a set of dynamic autonomous agents. In this mechanism, it is possible to observe their local behaviors.
