## 5 Dynamic Prey-Predator Spatial Model via African Buffalo Optimization
### Season Definition
#### 5.3.2 Migration
3 while\(birth\_count<prey\_reproductive\_capacity\)do
4\(h_{prey}\leftarrow\) Calculate the number of neighborhood by equation 14. 5\(random\_cell\leftarrow\) Random number between \([1,h_{prey}]\). 6\(new_{x}\leftarrow\) Get \(x\) value from \(random\_cell\). 7\(new_{y}\leftarrow\) Get \(y\) value from \(random\_cell\). 8 if\(lattice[new_{x}][new_{y}]\) is equal to 0 then
9\(lattice[new_{x}][new_{y}]\leftarrow\) Set status 1. 10
11 end if
12
13 end for
14\(birth\_count\gets birth\_count+1\). 15
16 end for
```

**Algorithm 8**Reproduction of prey. ```
input :Lattice. output :Lattice. 1 for all predators \(j\) in the latticedo
2\(predator_{j}\leftarrow\) Get predator \(k\) in the lattice; \(x\leftarrow\) Get \(x\) value of the \(predator_{j}\). 3\(y\leftarrow\) Get \(y\) value of the \(predator_{j}\). 4 ifpredator status is equal to 3 then
5\(lattice[x][y]\leftarrow\) Set status 0. 6 end if
7
8 end for
```

**Algorithm 9**Reproduction of prey. ### Multi-Agent System

The dynamic prey-predator spatial model can extend its characteristics using multi-agents. Using multi-agents, we can easily regulate the population of predators in an _online_ context (at runtime). Figure 6 describes the main components of the architecture used in the design of the dynamic prey-predator spatial model. The main modules for the agent system are described below. #### 5.5.1 Supervising Agent

This agent aims to capture the data of the prey-predator model as the iterations of the simulation progress. Subsequently, the supervising agent sends a message to the regulating agent. When the regulating agent has already responded to the message to the supervising agent, it automatically stores the data in a database (text BBDD with the number of prey, the number of predators and states of the lattice). These data are used by the next cycle of the prey-predator model. Once the data sent by the regulatory agent are stored, the supervising agent makes a call to a submodule in which the cycles of the model are controlled. This submodule is in charge of recharging the prey-predator model again using the parameters stored in the database. The idea is to create a balance and continuity in the model so that it can prevent a predator eats prey. #### 5.5.2 Regulating Agent

The regulating agent is initialized and is automatically waiting to receive a message form supervising agent. The regulating agent at the moment of receiving a message reacts and automatically performs calculations to verify the new parameters that should receive the model and thus generate a balance. The parameter that the regulating agent modifies is the capacity of reproduction. This parameter directly influences the prey-predator model, generating a balance between prey and predator. After generating and sending the data to the supervising agent, the regulating agent is automatically waiting for a new message to make new modifications respective. The multi-agent approach modifies in real time the reproductive capacity of prey and predators using Equations (15) and (16), where \(A\) is the number of prey in the lattice, \(\epsilon\) is a positive value assigned to regulate the prey population, \(B\) is the number of predators in the lattice, and \(\gamma\) is a positive value assigned to regulate the predator population. \[y_{b}= \begin{cases}1&\text{ if }A\geq\epsilon\text{ and }B<\gamma\text{ and }y_{b}=3.\\ 3&\text{ if }A<\epsilon\text{ and }B\leq\gamma\text{ and }y_{b}=1.\end{cases}  \tag{15}\]

Figure 6: Architecture of dynamic prey–predator spatial model with MAS, CA and ABO. \[z_{b}= \begin{cases}3&\quad\text{if $A\geq\epsilon$ and $B<\gamma$ and $z_{b}=1$}.\\ 1&\quad\text{if $A<\epsilon$ and $B\leq\gamma$ and $z_{b}=3$}.\end{cases}  \tag{16}\]

#### 5.5.3 Prey-Predator Module

This module includes basic features such as the dynamic prey-predator spatial model, the logic of the predator with the integration of the movements of the ABO metaheuristic, the prey logic, and the lattice constraints.