Commit 56d7ada2 authored by Victor's avatar Victor

updates docs

parent 67c2f4a7
Pipeline #75069 passed with stage
in 22 minutes and 1 second
# ABMEv.jl
<!-- [![](]( -->
<!-- For now we only direct to dev documentation. In the future, one will need to deploy a ssh key to and use TagBot. -->
[![pipeline status](](
[![coverage report](](
......@@ -3,4 +3,86 @@
In this script, we model the evolution of a population where agents are simply defined by their position on some landscape. We implement the simplest possible birth and death function.
## The landscape
Let's start by a linear landscape. We define a discrete segment of length `9`, with reflecting boundary conditions.
Let's start by a linear landscape. We define a discrete segment of length `9`, with reflecting boundary conditions. In fact, reflecting boundary conditions are implemented for any finite space.
!!! warning "1D Reflections"
As of v1, only reflections on one dimensional space are implemented. We have a two dimensional reflection method that will be released in the future.
There are two ways of implementing a linear landscape. The first one uses a `DiscreteSegment` while the second relies on LightGraphs.jl library. Both are *almost* equivalent.
### DiscreteSegment
using ABMEv
nodes = 10
mysegment = DiscreteSegment(1,nodes)
### grid
using ABMEv, LightGraphs
nodes = 10
g = grid([nodes,1])
mysegmentgraph = GraphSpace(g)
Here is how you can visualise the landscape.
using GraphPlots
gplot(g,locs_x = 1:nodes,locs_y=1:nodes)
## Defining competition processes
We propose that any individual have a constant birth rate, and competes with all the individuals present in the same patch. Let ``i \in \N``,``x_i \in \{1,2,\dots,9\}``.
The competition pressure experience by individual ``i`` is such that
d(x_i) = \sum_j \delta(x_i-x_j)
where ``\delta`` is the dirac function.
In this way, we recover a logistic growth function for subpopulation within a patch.
K0 = 1000 # We will have in total 1000 individuals
b(X,t) = 1 / nodes
d(X,Y,t) = (X[1] Y[1]) / K0
At equilibrium, population size in each deme will reach `K0 / nodes`.
## Dispersal
We assume that anytime an offspring is born, it is given a chance to move (`\mu = 1`).
mu = [1.]
D = (1.5,)
## Running the world
We initialise the world with initial population of size ``K_0 / 9`` located on patch `5`. We keep track of individuals' ancestors by setting `ancestors=true`. Because we wish to use `Gillepsie` algorithm, we need `rates=true` as agents' internal birth and death rates are updated at every time step.
!!! note "Warning"
`rates` treatment is something we might implement in the library internals.
NMax = 2000
tend = 2
p = Dict{String,Any}();@pack! p = d,b,D,mu,NMax
myagents = [Agent(myspace,(5,),ancestors=true,rates=true) for i in 1:K0/nodes]
w0 = World(myagents,myspace,p,0.)
@time sim = run!(w0,Gillepsie(),tend)
## Analysis
Let's verify that the population's growth is logistic. We will plot the population size over time.
To do so, one need to define `dt_saving`.
using Plots
@time sim = run!(w0,Gillepsie(),tend,dt_saving=1)
@animate for (i,t) in tspan(sim)
One might be tempted to plot the world for some time steps. This requires some knowledge of the library Plots.jl.
Agents values are accessed by `get_x(w::World)`.
!!! notes "Plotting"
This will be proposed as a blackbox with PlotRecipes.jl in the near future
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment