Commit 1f6a4ad1 authored by Victor's avatar Victor

updates on possibilities for dispersal on graphs. It is now ok to set D =...

updates on possibilities for dispersal on graphs. It is now ok to set D = nothing, which triggers a new dispersal kernel where individuals exactly move to neighbours
parent 68ea8cfa
Pipeline #80004 failed with stage
in 28 minutes and 54 seconds
name = "ABMEv"
uuid = "837ac870-fb52-4b0c-9a0e-030f2f36f5ed"
authors = ["Victor Boussange "]
version = "2.1.0"
version = "2.1.1"
[deps]
Arpack = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97"
......
......@@ -96,6 +96,7 @@ function get_inc(x,D,s::DiscreteSegment{T}) where {T}
return round(T,_reflect1D(x,inc,s))
end
# normal dispersal kernel that gets truncated
function get_inc(x,D,s::GraphSpace{T}) where {T}
niter = round(Int,abs(D*randn())) + 1
# here we add +1 since randomwalk(s.g,x,niter) returns x
......@@ -105,6 +106,10 @@ function get_inc(x,D,s::GraphSpace{T}) where {T}
return 0
end
end
# short range dispersal kernel, jump to neighbour node
function get_inc(x,D,s::GraphSpace{T}) where {T}
return last(randomwalk(s.g,x,2)) - x
end
## Dynamic spaces
abstract type AbstractDynSpace{Dim,T<:Number} <: AbstractSpace{Dim,T,IsFinite{true}} end
......@@ -132,9 +137,9 @@ Returns the graph correseponding to `d::DynGraphSpace` at time `t`
get_graph(d::DynGraphSpace,t) = d.g[d.f(t)]
## Increments - specialised functions
function get_inc(x,D,d::DynGraphSpace{T},t) where {T}
## Increments - specialised functions for dynamic graphs
# normal dispersal kernel that gets truncated
function get_inc(x,D::Number,d::DynGraphSpace{T},t) where {T}
niter = round(Int,abs(D*randn())) + 1
# here we add +1 since randomwalk(s.g,x,niter) returns x
if niter > 0
......@@ -144,6 +149,11 @@ function get_inc(x,D,d::DynGraphSpace{T},t) where {T}
end
end
# short range dispersal kernel, jump to neighbour node
function get_inc(x,D::Nothing,d::DynGraphSpace{T},t) where {T}
return last(randomwalk(get_graph(d,t),x,2)) - x
end
"""
$(SIGNATURES)
Here we increment the trajectory of trait 1 such that it follows a reflected brownian motion (1D)
......
"""
generalised_gaussian(x::Number,mu::Number,sigma::Number,epsilon::Number)
Returns `exp( -.5 * ((x-mu) / sigma)^epsilon)`
"""
function generalised_gaussian(x::Number,mu::Number,sigma::Number,epsilon::Number)
return exp( -.5 * ((x-mu) / sigma)^epsilon)
......
......@@ -27,7 +27,7 @@ myspace2 = (mysegment,mycontinuoussegment,real2d)
@test ABMEv.get_inc(0.,mydiscreteline) (0.)
@test !(ABMEv.get_inc(1.,myline) 0.)
@test !(get_inc(1,1.,myline) 0.)
@test !(get_inc(1,1.,mydiscreteline) 0.)
# @test !(get_inc(1,1.,mydiscreteline) ≈ 0.)
@test typeof(ABMEv.get_inc([1.,0.],real2d)) == Tuple{Float64,Float64}
......@@ -52,6 +52,7 @@ myspace2 = (mysegment,mycontinuoussegment,real2d)
#checking if graph works
@test prod([get_inc(1,10,mygraph) + 1 vertices(mygraph.g) for i in 1:30])
@test prod([get_inc(1,nothing,mygraph) + 1 vertices(mygraph.g) for i in 1:30])
end
##### AGENTS #######
......
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