Commit 0e2751fa authored by vboussange's avatar vboussange
Browse files

some minor updates

parent 56d815ba
Pipeline #87729 failed with stage
in 17 minutes and 11 seconds
...@@ -22,22 +22,32 @@ module ABMEv ...@@ -22,22 +22,32 @@ module ABMEv
@reexport using Distributions, DataFrames @reexport using Distributions, DataFrames
export GraphSpace,ContinuousSegment,DiscreteSegment,RealSpace,NaturalSpace, export
AbstractSpacesTuple,get_inc,DynGraphSpace
export update_rates! GraphSpace,ContinuousSegment,DiscreteSegment,RealSpace,NaturalSpace,
export AbstractAgent,Agent,get_fitness,get_x,get_t,get_dim, AbstractSpacesTuple,get_inc,DynGraphSpace,
nancestors,get_xarray,get_xhist,
get_thist,get_geo,get_b,get_d,increment_x!,get_inc_reflected,world2df, update_rates!,
split_move,split_merge_move,tin,new_world_G
export World,parameters,time,space,agents,size,maxsize,addAgent!,removeAgent! AbstractAgent,Agent,get_fitness,get_x,get_t,get_dim,
export run!,give_birth,updateWorld!,update_clock!,updateBirthEvent!, nancestors,get_xarray,get_xhist,
updateDeathEvent!#,runWorld_G!,runWorld_WF!, get_thist,get_geo,get_b,get_d,increment_x!,get_inc_reflected,world2df,
export Simulation,add_entry!,get_tend,get_size,get_tspan,get_world,get_xnt split_move,split_merge_move,tin,new_world_G,
export H_discrete,findclusters,var,covgeo,hamming,get_beta_div, get_alpha_div,
get_local_abundance,get_dist_hist,get_pairwise_average_isolation, World,parameters,time,space,agents,size,maxsize,addAgent!,removeAgent!,
get_local_pairwise_average_isolation,
truncvar,get_xhist_mat run!,give_birth,updateWorld!,update_clock!,updateBirthEvent!,
export update_afterbirth_std!,update_afterdeath_std! updateDeathEvent!,#,runWorld_G!,runWorld_WF!,
export generalised_gaussian,gaussian,ma,geomsmooth,arithsmooth,eth_grad_std,
DiversityFunction,geomsmooth2D,arithsmooth2D,interpolate_df,groupby,numargs Simulation,add_entry!,get_tend,get_size,get_tspan,get_world,get_xnt,
H_discrete,findclusters,var,covgeo,hamming,get_beta_div, get_alpha_div,
get_local_abundance,get_dist_hist,get_pairwise_average_isolation,
get_local_pairwise_average_isolation,
truncvar,get_xhist_mat,
update_afterbirth_std!,update_afterdeath_std!,
generalised_gaussian,gaussian,ma,geomsmooth,arithsmooth,eth_grad_std,
DiversityFunction,geomsmooth2D,arithsmooth2D,interpolate_df,groupby,numargs
end end
...@@ -177,11 +177,11 @@ function _get_xinc(a::AbstractAgent,s::AbstractSpacesTuple,p::Dict,t::Number) ...@@ -177,11 +177,11 @@ function _get_xinc(a::AbstractAgent,s::AbstractSpacesTuple,p::Dict,t::Number)
@unpack D,mu = p @unpack D,mu = p
_x = copy(get_x(a)) _x = copy(get_x(a))
for (i,ss) in enumerate(s) for (i,ss) in enumerate(s)
if ndims(ss) > 1 if length(mu[i]) > 1
mut = rand(eltype(mu[i]),ndims(ss)) .< mu[i] mut = rand(eltype(mu[i]),ndims(ss)) .< mu[i]
_x[i] .+= mut .* get_inc(_x[i],D[i],ss,t) _x[i] .+= mut .* get_inc(_x[i],D[i],ss,t)
else else
mut = rand(typeof(mu[i])) < mu[i] mut = rand(eltype(mu[i])) < mu[i]
_x[i] += mut * get_inc(_x[i],D[i],ss,t) _x[i] += mut * get_inc(_x[i],D[i],ss,t)
end end
end end
......
...@@ -58,7 +58,7 @@ function run!(w::World{A,S,T},alg::L,tend::Number,b,d; ...@@ -58,7 +58,7 @@ function run!(w::World{A,S,T},alg::L,tend::Number,b,d;
end end
# Saving last time step # Saving last time step
add_entry!(sim,w,cb) add_entry!(sim,w,cb)
@info "simulation stopped at t=$(t), after $(i) generations" @info "simulation stopped at t=$(t), after $(i) steps"
return sim return sim
end end
......
...@@ -13,6 +13,10 @@ function World(w::Vector{A},s::S,p::Dict,t::T=0.) where {A<:AbstractAgent,S<:Abs ...@@ -13,6 +13,10 @@ function World(w::Vector{A},s::S,p::Dict,t::T=0.) where {A<:AbstractAgent,S<:Abs
# if typeof(p["D"]) != eltype(skipmissing(w)[1]) # if typeof(p["D"]) != eltype(skipmissing(w)[1])
# throw(ArgumentError("Diffusion coefficient does not match with underlying space\n `D::Tuple`")) # throw(ArgumentError("Diffusion coefficient does not match with underlying space\n `D::Tuple`"))
# end # end
if typeof(first(w)) !== A
throw(ArgumentError("eltype(w) should be equal to typeof(first(w)), which is not the case.\n
Try to generate the array of Agents in an other way"))
end
World{A,S,T}(w,s,p,t) World{A,S,T}(w,s,p,t)
end end
......
Supports Markdown
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