Predator Prey model
Here a short description.
The first thing is to create an eclipse project :
- You have to choose a name
- You must attach the file simaqualife-2.0.jar to your project.
- You can then export your created project on a git repository.
Individuals data structure
Let's define the data structure for the individuals. As we have two types of individuals, we create two packages named "prey" and "predator", and we create an abstract class that will correspond to the common caracteristics needed for the model. This call has two constructors that set the age to 0, one with only the initial position, and the second with the position and the weight. Then, we create the two classes corresponding to these two types (in their corresponding package) : Predator.java and Prey.java. These classes override the constructor with only the position to set correctly the weight, 1g for the prey and 10g for the predator. We also add a new attribute to Prey class, ingestedFood which will be used in the hunting and growth processes.
(EXPLAIN WHY WE NEED PreysGroup AND PredatorsGroup, RELATION WITH THE LISTS IN Cell) Expliquer que dans ce cas on n'en a pas besoin.
Now, we need to define the concept Position. The space is a grid, so a position corresponds to a cell. A cell could contain predators and preys, so we must maintain two lists of the individuals of each type that are present in a cell. Note that we could have choose to use only one list, but two lists will be more convenient for the next. We need also to store the habitat value, and the cell position in the grid. See the class Cell. This class needs a constructor to initialize the value of the habitat quality.
To store these cells, we need an environment structure. We choose the class
fr.cemagref.simaqualife.extensions.spatial2D.Grid2DTorus that implements a toric bidimensional grid. So we create a subclass of this one. This abstract class contain an abstract method
void initTransientParameters(), that is needed for intialize the envionment structure, and that we should implement.
Note the parametrization of the super class
public class Grid2D extends Grid2DTorus<Cell,Individual>, that specify the type handled by the structure used. These parametrization implies to our class
Cell to inherit of the class
fr.cemagref.simaqualife.extensions.spatial2D.IndexedCell, [changeset:923 see the changes]. Same thing for our class
Individual, [changeset:925 see the changes].
The time step unit is the month.
There is a populate process to initialize the model (group process).
There is 4 processes for the Prey (individual processes) :
And processes for the Predator (individual processes) :
Now consider the first process for the predators. Predators are supposed to search the cell with the maximum number of accessible preys in the 8 surrounding cells. Predators move twice as fast as the preys.
To this end, we define a new class implementing the interface MovementStrategy (WHY ??). The initializeation of a pseudo random numbers genarator following an uniform distribution (see the package umontreal.iro.lecuyer...)is made in the constructor. The seed is obtained from the static class Pilot. We then should implement the inherited abstract method move to compute the cell destination according to the best suitability. The surrounding cells are obtained by calling the method getVoisinage (with the current position of the predator) of the environment obtainend from Aquanism. The suitabilty of a cell is the product of the number of preys (size of the Preys list) and the habitat quality (attribute of the Cell class). The destination is randomly choosen (from an uniform distribution) among cells with equivalent suitability.
Notice that predators positions are automatically updated afer the call of this process.
The difference of speed between predators and preys will be simulated by running this process twice during a time steo (see later).
The reproduction is supposed to occur once (semelparous species) the 6th month when fish are 5 years old.
In that case we define a new class extending LoopAquaNismsGroupProcess (WHY ??). Two methods, initTransiantParameters() and doProcess() should be overrided. The first one is uses to initialize a pseudo random numbers genarator following a Poisson distribution with the mean corresponding to the predator fertility. The second computes the numbers of offsprings per indiduals, creates the children and inter the parent. The month is obtained with the call of the static method of Pilot (EXPLAIN) modulo 12. The age in year in converted from the attribute age of the predator. The number of offsprings is calculated by generating a new random number from the Poisson distribution. Notice that weigth at birth of the predators is fixed in constructor of the Predator Offsprings are then added to the PredatorsGroup. The parent dies by calling the method inter of the AquaNismGroup.
In a cell, after movement, predators eat the ligther preys until the ingested food is equal to 10 % of its weight.
Again a new class extending LoopAquaNismsGroupProcess. Nothing to to for the initTransiantParameters() method. In the doProcess, the list of the preys in the cell where the predator is is recuperated and sorted. then the ingested food are addes with the first preys until 10 % of the weight of the predator. THE PROBLEM IS NOW TO REMOVE THE EATEN PREYS.
The growth of a predator correspeonds to the transformation of the ingested food into body weight with ratio of .25.
Always a new class extending LoopAquaNismsGroupProcess. In the doProcess method, the age is incremented, the predator weight is added with 25% of the ingested food, and ingested food reseted to 0.
A predator will die when its weight according to its age is to much lower. We suppose that a predator will die if its weight divided by its age (in year) is lower then 0.5.
IMPOSSIBLE FOR ME TO CODE
A prey always try to avoid the predators
As for predators movements we define a new class implementing the interface MovementStrategy. Again, the constructor serves to start a random number generator with an uniform distribution. The method move() is similar to this for a predatoar except taht the suitability of a cell is simply the number of predators in a cell.
Preys growth steadily and linearly until 5 g. The mean of individual growth rate is 0.1 g/month with standard deviation of 0.01 g/month.
A simplistic new class extending LoopAquaNismsGroupProcess where the doProcess() increments age, and updates the weight.
Preys reproduce each year in March from their first year of life. To complete the maturation a minimum density is necessary; at least 5 individuals par zone. No specific habitat is described. The mean nubmer of offspring’s is estimated to 2.1 juveniles per parent. The weight at birth is 1 g. Classically a new class extending LoopAquaNismsGroupProcess.
The initTransiantParameters() method initialise two random number generators, one with an uniform distribution, the other with a Gaussian distribution with the mean and the standard deviation of the growth rate. The doProcess is similar to this for predator. To use the constructor of prey we should obtain a growth rate from the gaussian random generator.
Except when they are eaten by the predator , preys die when there a huge density (more 200 individuals in a zone)
IMPOSSIBLE FOR ME TO CODE
How to run the application
The best way is to use eclipse to launch SimAquaLife with your model. Open the «run configuratio» dialog box using the menu «Run->Run...». Select the section «Java Application», and click on the «New» button. Now fill the fields :
- choose a name, for example «PreyPredator»
- The project that will be used to launch our application must have been automatically field with your project name (choosen at the beginning of this tutorial). On my configuration, it is «PreyPredator» too.
- give the SimAquaLife entry point for the «Main class» : fr.cemagref.simaqualife.pilot.gui.SwingPilot
- in the second tab «Arguments», give as «Program Arguments» the option to set the duration of the simulation, for example 1200 (months) :
And click on «Apply» and «Run».