To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit a40ab282 authored by Victor's avatar Victor
Browse files

all tests running except covgeo

parent cc9341a3
......@@ -8,9 +8,9 @@ version = "0.5.0"
[[Adapt]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "0fac443759fa829ed8066db6cf1077d888bb6573"
git-tree-sha1 = "42c42f2221906892ceb765dbcb1a51deeffd86d7"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "2.0.2"
version = "2.3.0"
[[ArnoldiMethod]]
deps = ["DelimitedFiles", "LinearAlgebra", "Random", "SparseArrays", "StaticArrays", "Test"]
......@@ -35,9 +35,9 @@ version = "1.0.6+4"
[[CategoricalArrays]]
deps = ["DataAPI", "Future", "JSON", "Missings", "Printf", "Statistics", "StructTypes", "Unicode"]
git-tree-sha1 = "e7cb4f23938914f09afae58b611a59f3aa8d8f66"
git-tree-sha1 = "2ac27f59196a68070e132b25713f9a5bbc5fa0d2"
uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597"
version = "0.8.2"
version = "0.8.3"
[[CodeTracking]]
deps = ["InteractiveUtils", "UUIDs"]
......@@ -53,9 +53,9 @@ version = "0.7.0"
[[ColorSchemes]]
deps = ["ColorTypes", "Colors", "FixedPointNumbers", "Random", "StaticArrays"]
git-tree-sha1 = "7a15e3690529fd1042f0ab954dff7445b1efc8a5"
git-tree-sha1 = "5d472aa8908568bc198564db06983913a6c2c8e7"
uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
version = "3.9.0"
version = "3.10.1"
[[ColorTypes]]
deps = ["FixedPointNumbers", "Random"]
......@@ -71,9 +71,9 @@ version = "0.12.4"
[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "215f1c81cfd1c5416cd78740bff8ef59b24cd7c0"
git-tree-sha1 = "8cd7b7d1c7f6fcbe7e8743a58adf57788ec7f787"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.15.0"
version = "3.18.0"
[[CompilerSupportLibraries_jll]]
deps = ["Libdl", "Pkg"]
......@@ -128,10 +128,10 @@ deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
[[Distributions]]
deps = ["FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns"]
git-tree-sha1 = "3676697fd903ba314aaaa0ec8d6813b354edb875"
deps = ["FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "StaticArrays", "Statistics", "StatsBase", "StatsFuns"]
git-tree-sha1 = "501c11d708917ca09ce357bed163dbaf0f30229f"
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
version = "0.23.11"
version = "0.23.12"
[[DocStringExtensions]]
deps = ["LibGit2", "Markdown", "Pkg", "Test"]
......@@ -139,6 +139,12 @@ git-tree-sha1 = "50ddf44c53698f5e784bbebb3f4b21c5807401b1"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.3"
[[EarCut_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "eabac56550a7d7e0be499125673fbff560eb8b20"
uuid = "5ae413db-bbd1-5e63-b57d-d24a61df00f5"
version = "2.1.5+0"
[[ExprTools]]
git-tree-sha1 = "7fce513fcda766962ff67c5596cb16c463dfd371"
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
......@@ -212,10 +218,10 @@ uuid = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
version = "0.52.0"
[[GeometryBasics]]
deps = ["IterTools", "LinearAlgebra", "StaticArrays", "StructArrays", "Tables"]
git-tree-sha1 = "119f32f9c2b497b49cd3f7f513b358b82660294c"
deps = ["EarCut_jll", "IterTools", "LinearAlgebra", "StaticArrays", "StructArrays", "Tables"]
git-tree-sha1 = "49d13ebd048bd71315ff98bdc2c560ec16eda2b4"
uuid = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
version = "0.2.15"
version = "0.3.1"
[[GeometryTypes]]
deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "StaticArrays"]
......@@ -223,11 +229,16 @@ git-tree-sha1 = "34bfa994967e893ab2f17b864eec221b3521ba4d"
uuid = "4d00f742-c7ba-57c2-abde-4428a4b178cb"
version = "0.8.3"
[[Grisu]]
git-tree-sha1 = "03d381f65183cb2d0af8b3425fde97263ce9a995"
uuid = "42e2da0e-8278-4e71-bc24-59509adca0fe"
version = "1.0.0"
[[HTTP]]
deps = ["Base64", "Dates", "IniFile", "MbedTLS", "Sockets"]
git-tree-sha1 = "2ac03263ce44be4222342bca1c51c36ce7566161"
git-tree-sha1 = "c7ec02c4c6a039a98a15f955462cd7aea5df4508"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.8.17"
version = "0.8.19"
[[Inflate]]
git-tree-sha1 = "f5fc07d4e706b84f72d54eedcc1c13d92fb0871c"
......@@ -280,9 +291,9 @@ version = "1.0.0"
[[JLD2]]
deps = ["CodecZlib", "DataStructures", "MacroTools", "Mmap", "Pkg", "Printf", "Requires", "UUIDs"]
git-tree-sha1 = "d2c0db66530ff444846d6e84bcf948a74ce31635"
git-tree-sha1 = "d71a4c4adfc1ec8e2b988b19d5800668b038aa89"
uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
version = "0.2.0"
version = "0.2.2"
[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
......@@ -400,9 +411,9 @@ uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
version = "0.3.4"
[[OffsetArrays]]
git-tree-sha1 = "b8500f9d73999cfbab4add5136ec26894081581e"
git-tree-sha1 = "3fdfca8a532507d65f39ff0ad34fe81097a55337"
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
version = "1.1.3"
version = "1.3.0"
[[Ogg_jll]]
deps = ["Libdl", "Pkg"]
......@@ -429,15 +440,15 @@ uuid = "91d4177d-7536-5919-b921-800302f37372"
version = "1.3.1+2"
[[OrderedCollections]]
git-tree-sha1 = "293b70ac1780f9584c89268a6e2a560d938a7065"
git-tree-sha1 = "16c08bf5dba06609fe45e30860092d6fa41fde7b"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.3.0"
version = "1.3.1"
[[PDMats]]
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse", "Test"]
git-tree-sha1 = "b3405086eb6a974eba1958923d46bc0e1c2d2d63"
git-tree-sha1 = "95a4038d1011dfdbde7cecd2ad0ac411e53ab1bc"
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
version = "0.10.0"
version = "0.10.1"
[[Parsers]]
deps = ["Dates", "Test"]
......@@ -457,21 +468,21 @@ version = "2.0.0"
[[PlotUtils]]
deps = ["ColorSchemes", "Colors", "Dates", "Printf", "Random", "Reexport", "Statistics"]
git-tree-sha1 = "8d23333aee2e2733a5cd4e1985462df8203f47f7"
git-tree-sha1 = "4e098f88dad9a2b518b83124a116be1c49e2b2bf"
uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043"
version = "1.0.6"
version = "1.0.7"
[[Plots]]
deps = ["Base64", "Contour", "Dates", "FFMPEG", "FixedPointNumbers", "GR", "GeometryBasics", "GeometryTypes", "JSON", "LinearAlgebra", "Measures", "NaNMath", "PlotThemes", "PlotUtils", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "Requires", "Showoff", "SparseArrays", "Statistics", "StatsBase", "UUIDs"]
git-tree-sha1 = "b81e3dfb1f0ece1e170b8768d2d0f10a78dfb4d7"
git-tree-sha1 = "b179dff12ef580cbf1c0a68eadae18f6683475bc"
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
version = "1.6.3"
version = "1.6.7"
[[Polynomials]]
deps = ["Intervals", "LinearAlgebra", "OffsetArrays", "RecipesBase"]
git-tree-sha1 = "7ce1a60df1a8eb61df4cef5698abc9a18575c91f"
git-tree-sha1 = "ce5fe493693b1ca81aa70b806e353a288f73ec7f"
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
version = "1.1.7"
version = "1.1.9"
[[PooledArrays]]
deps = ["DataAPI"]
......@@ -521,15 +532,15 @@ version = "0.2.0"
[[Requires]]
deps = ["UUIDs"]
git-tree-sha1 = "8c08d0c7812169e438a8478dae2a529377ad13f7"
git-tree-sha1 = "28faf1c963ca1dc3ec87f166d92982e3c4a1f66d"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.0.2"
version = "1.1.0"
[[Revise]]
deps = ["CodeTracking", "Distributed", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "Pkg", "REPL", "UUIDs", "Unicode"]
git-tree-sha1 = "a860e786779be1ab6407d427470e1415711dd459"
git-tree-sha1 = "d6b380e331f5ace89033617b575cfac40f9b312d"
uuid = "295af30f-e4ad-537b-8983-00126c2a3abe"
version = "2.7.5"
version = "2.7.6"
[[Rmath]]
deps = ["Random", "Rmath_jll"]
......@@ -554,10 +565,10 @@ deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
[[Showoff]]
deps = ["Dates"]
git-tree-sha1 = "e032c9df551fb23c9f98ae1064de074111b7bc39"
deps = ["Dates", "Grisu"]
git-tree-sha1 = "ee010d8f103468309b8afac4abb9be2e18ff1182"
uuid = "992d4aef-0814-514b-bc4d-f2e9a6c4116f"
version = "0.3.1"
version = "0.3.2"
[[SimpleTraits]]
deps = ["InteractiveUtils", "MacroTools"]
......@@ -630,9 +641,9 @@ version = "1.0.0"
[[Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
git-tree-sha1 = "b7f762e9820b7fab47544c36f26f54ac59cf8abf"
git-tree-sha1 = "24a584cf65e2cfabdadc21694fb69d2e74c82b44"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "1.0.5"
version = "1.1.0"
[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
......@@ -640,9 +651,9 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[TimeZones]]
deps = ["Dates", "EzXML", "Mocking", "Pkg", "Printf", "RecipesBase", "Serialization", "Unicode"]
git-tree-sha1 = "338ddbb2b9b50a9a423ba6c3fad1824553535988"
git-tree-sha1 = "2c48caca8f3912857973590a9757e1f86cbbff81"
uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53"
version = "1.3.2"
version = "1.4.0"
[[TranscodingStreams]]
deps = ["Random", "Test"]
......
......@@ -10,7 +10,7 @@ module ABMEv
include("ABMEv_Agent.jl")
include("ABMEv_world.jl")
include("ABMEv_Sim.jl")
# include("ABMEv_metrics.jl")
include("ABMEv_metrics.jl")
# include("ABMEv_plot.jl")
include("ABMEv_utils.jl")
include("algo/ABMEv_WF.jl")
......@@ -32,10 +32,10 @@ module ABMEv
export run!,give_birth,updateWorld!,update_clock!,updateBirthEvent!,
updateDeathEvent!#,runWorld_G!,runWorld_WF!,
export Simulation,add_entry!,get_tend,get_size,get_tspan
# export H_discrete,findclusters,var,covgeo,hamming,get_beta_div, get_alpha_div,
# get_dist_hist,get_pairwise_average_isolation,
# get_local_pairwise_average_isolation,
# truncvar,get_xhist_mat
export H_discrete,findclusters,var,covgeo,hamming,get_beta_div, get_alpha_div,
get_dist_hist,get_pairwise_average_isolation,
get_local_pairwise_average_isolation,
truncvar,get_xhist_mat
export update_afterbirth_std!,update_afterdeath_std!
export generalised_gaussian,gaussian,ma,geomsmooth,arithsmooth,eth_grad_std,
DiversityFunction,geomsmooth2D,arithsmooth2D,interpolate_df,groupby
......
......@@ -57,7 +57,7 @@ end
$(SIGNATURES)
Initialises agent with `pos` provided
"""
function Agent(s::S, pos::P;ancestors=false,rates=false) where {P,S <: AbstractSpacesTuple}
function Agent(s::S, pos::P;ancestors=false,rates=false) where {P<:Tuple,S <: AbstractSpacesTuple}
T = eltype.(s)
for (i,p) in enumerate(pos)
if typeof(p) !== T[i]
......@@ -76,6 +76,24 @@ function Agent(s::S, pos::P;ancestors=false,rates=false) where {P,S <: Abstract
Agent{Ancestors{ancestors},Rates{rates},Tuple{T...},U,V}([pos],[t],d,b)
end
# TODO : to be modified
function Agent(s::S,pos::Vector,t::Vector{U};ancestors=false,rates=false) where {S <: AbstractSpacesTuple,U}
T = eltype.(s)
for (i,p) in enumerate(pos[1])
if typeof(p) !== T[i]
try
p = convert(T[i],p)
catch e
throw(ArgumentError("Position provided does not match with underlying space"))
end
end
end
d = rates ? Float64(.0) : nothing
b = d
V = rates ? Float64 : Nothing
Agent{Ancestors{ancestors},Rates{rates},Tuple{T...},U,V}(pos,t,d,b)
end
import Base:copy,show
Base.copy(a::A) where {A<:AbstractAgent} = A(copy(a.x_history),copy(a.t_history),copy(a.d),copy(a.b))
......
......@@ -52,7 +52,6 @@ If trait > 0, returns the covariance matrix, with first row geotrait and second
"""
function var(world::World;trait=1)
world = agents(world)
xarray = get_x(world,trait)
return var(xarray,dims=1,corrected=false)
end
......@@ -64,11 +63,10 @@ If trait > 0, returns the covariance matrix, with first row geotrait and second
# Arguments
"""
function covgeo(world::Array{U,1},t::Number,trait = 0) where U <: Union{Missing,Agent}
world = collect(skipmissing(world))
xarray = Float64.(get_geo.(world,t))
function covgeo(world::World,trait = 0)
xarray = Float64.(get_geo(world))
if trait > 0
xstd = reshape(Float64.(get_x.(world,trait)),size(world,1),size(world,2))
xstd = reshape(Float64.(get_x(world,trait)),size(world,1),size(world,2))
xarray = hcat(xarray,xstd)
end
return cov(xarray,corrected=false)
......@@ -80,10 +78,10 @@ Returns a matrix H where H_ij = hamming(a_i,a_j).
The hamming distance is taken through the whole history
and functional space of the agents.
"""
function hamming(world::Array{Agent,1}) where T <: Int
N = size(world,1)
H = zeros(N,N)
for (i,a) in enumerate(world)
function hamming(world::World) where T <: Int
n = size(world)
H = zeros(n,n)
for (i,a) in enumerate(agents(world))
for (j,b) in enumerate(world)
H[i,j] = hamming(get_xhist(a),get_xhist(b))
end
......@@ -92,17 +90,16 @@ function hamming(world::Array{Agent,1}) where T <: Int
end
"""
get_alpha_div(world::Array{U,1},t::Number,trait=1) where U <: Union{Missing,Agent}
Mean of the local variance of `trait` per patch
Mean of the local variance of `trait` per patch. If trait=0, we get the geotrait
# Arguments
"""
function get_alpha_div(world::Array{U,1},t::Number,trait=1) where U <: Union{Missing,Agent}
_xall_df = world2df(world,t,true)
xall_per_patch = groupby(_xall_df, :x1,sort=true)
function get_alpha_div(world::World,trait=1)
xarray = get_xarray(world,true)
g = groupby(x->x[1],collect(eachrow(xarray)))
if trait == 0
# need to convert to Float64, otherwise infinite variance
return mean([var(Float64.(xp.g),corrected=false) for xp in xall_per_patch])
return mean([var(Float64.([x[end] for x in xp]),corrected=false) for xp in values(g)])
else
return mean([var(Float64.(xp[:,trait+1]),corrected=false) for xp in xall_per_patch])
return mean([var(Float64.([x[trait] for x in xp]),corrected=false) for xp in values(g)])
end
end
......@@ -111,14 +108,14 @@ end
Variance of the mean of `trait` per patch
# Arguments
"""
function get_beta_div(world::Array{U,1},t::Number,trait=1) where U <: Union{Missing,Agent}
_xall_df = world2df(world,t,true)
xall_per_patch = groupby(_xall_df, :x1,sort=true)
function get_beta_div(world::World,trait=1)
xarray = get_xarray(world,true)
g = groupby(x->x[1],collect(eachrow(xarray)))
if trait == 0
# need to convert to Float64, otherwise infinite variance
sbar_i = [mean(Float64.(xp.g)) for xp in xall_per_patch]
sbar_i = [mean(Float64.([x[end] for x in xp])) for xp in values(g)]
else
sbar_i = [mean(Float64.(xp[:,trait+1])) for xp in xall_per_patch]
sbar_i = [mean(Float64.([x[trait] for x in xp])) for xp in values(g)]
end
return var(sbar_i,corrected=false)
end
......
......@@ -52,25 +52,32 @@ update_clock!(w::World{A,S,T},dt) where {A,S,T} = begin
return nothing
end
#TODO : code it
#TODO : modify this
"""
$(SIGNATURES)
Returns trait of every agents of world in the form of an array which dimensions corresponds to the input.
If `trait = 0` , we return the geotrait.
# Warning
This works only for linear subspace, indexed with a single value
"""
get_x(w::World,trait) = vcat(getindex.(agents(w),trait)...)
get_x(w::World,trait) = hcat(collect.(getindex.(agents(w),trait))...)'
"""
$(SIGNATURES)
Returns every traits of every agents of `world` in the form **of a one dimensional array** (in contrast to `get_x`).
If `geotrait=true` the geotrait is also added to the set of trait, in the last line.
If `geotrait=true` the geotrait is also added to the set of trait, in the last column.
If you do not want to specify `t` (only useful for geotrait), it is also possible to use `get_xarray(world::Array{T,1}) where {T <: Agent}`.
"""
function get_xarray(world::World,geotrait::Bool=false)
xarray = hcat(get_x.(agents.(world))...)
xarray = get_x(world,Colon())
if geotrait
xarray = vcat( xarray, get_geo.(agents(world),world.t)')
xarray = hcat( xarray, get_geo.(agents(world),world.t))
end
return xarray
end
@deprecate get_xarray(world,geotrait=false) get_x(world,Colon())
"""
$(SIGNATURES)
"""
get_geo(w::World) = map(a-> get_geo(a,time(w)), agents(w))
# CFM = Champagnat Ferriere Meleard
# This contains all methods for algorithm described in article
# DOI : 10.1016/j.tpb.2005.10.004
# In this file lie the function for Gillepsie algorithm
"""
$(TYPEDEF)
"""
struct CFM <: AbstractAlg end
export CFM
function updateBirthEvent!(w::World,::CFM,mum_idx::Int)
# updating competition only the two columns corresponding to agent idx
offspring = give_birth(mum_idx,w)
addAgent!(w,offspring)
end
function updateDeathEvent!(world::World,::CFM,i_event::Int)
removeAgent!(world,i_event)
end
"""
$(SIGNATURES)
Updating rule for CFM setting.
algorithm described in article
DOI : 10.1016/j.tpb.2005.10.004
"""
function updateWorld!(w::World{A,S,T},c::CFM) where {A,S,T}
# total update world
alive = agents(w)
events_weights = ProbabilityWeights(vcat(get_d.(alive),get_b.(alive)))
# Total rate of events
= sum(events_weights)
dt = - log(rand(T))/
update_clock!(w,dt)
if dt > 0.
i_event = sample(events_weights)
# This is ok since size is a multiple of 2
n = size(w)
if i_event <= n
# DEATH EVENT
# In this case i_event is also the index of the individual to die in the world_alive
updateDeathEvent!(w,g,i_event)
else
# birth event
# i_event - n is also the index of the individual to give birth in the world_alive
updateBirthEvent!(w,g,i_event-n)
end
return dt
else
return -1
end
end
"""
clean_world(world::Array{T}) where {T <: Agent}
Get rid of missing value in `world`
"""
#TODO : put some type specs here
clean_world(world) = collect(skipmissing(world))
......@@ -15,7 +15,7 @@ d(X,Y) = gaussian(X[1],Y[1],sigma_a)/K0
D = (1e-2,)
mu = [.1]
NMax = 10000
tend = 100
tend = 1.5
p = Dict{String,Any}();@pack! p = d,b,D,mu,NMax
myagents = [Agent(myspace,(0,),ancestors=true,rates=true) for i in 1:K0]
......
using LightGraphs
using Test
using Revise,ABMEv
using UnPack
myspace1 = (RealSpace{1,Float64}(),)
myspace2 = (RealSpace{2,Float64}(),)
myspace2 = (RealSpace{1,Float64}(),RealSpace{1,Float64}())
myspace3 = (DiscreteSegment(Int16(1),Int16(10)),RealSpace{1,Float64}())
K0 = 1000; σ = 1e-1
w1 = [Agent(myspace1, (σ,) .* randn() .- .5) for i in 1:K0]
w2 = [Agent(myspace2,(tuple((σ, σ) .* randn(2) .- .5...),)) for i in 1:K0]
w3 = [Agent(myspace3, (rand(Int16.(1:10)), 1e-1* randn() + 5.5 )) for i in 1:K0]
p = Dict("mu" => [1. 1.],"D" => [0. 0.], "nodes" =>10 )
a1 = [Agent(myspace1, (σ,) .* randn() .- .5,ancestors=true) for i in 1:K0]
a2 = [Agent(myspace2,tuple((σ, σ) .* randn(2) .- .5...),ancestors=true) for i in 1:K0]
a3 = [Agent(myspace3, (rand(Int16.(1:10)), 1e-1* randn() + 5.5 ),ancestors=true) for i in 1:K0]
D = (1.,);
mu = [1.,1.]
NMax = 1000
p1 = Dict{String,Any}();@pack! p1 = D,mu,NMax
D = (1.,1.);
p2 = Dict{String,Any}();@pack! p2 = D,mu,NMax
D = (Int16(0.),0.)
p3 = Dict{String,Any}();@pack! p3 = D,mu,NMax
w1 = World(a1,myspace1,p1)
w2 = World(a2,myspace2,p2)
w3 = World(a3,myspace3,p3)
## testing variance
@testset "Testing metrics" begin
@testset "var" begin
......@@ -28,22 +44,22 @@ p = Dict("mu" => [1. 1.],"D" => [0. 0.], "nodes" =>10 )
@test cmat smat atol=0.01
end
@testset "Alpha diversity" begin
α = get_alpha_div(w3,1.0,2);
α = get_alpha_div(w3,2);
@test abs(α) < Inf
end
@testset "Beta diversity" begin
β = get_beta_div(w3,1.0,2);
β = get_beta_div(w3,2);
@test abs(β) < Inf
end
@testset "Isolation by history - hamming distance" begin
a1 = Agent{StdAgent,Float64}([1 2 3],[0,1,4],0.,1.)
a2 = Agent{StdAgent,Float64}([1 10 3 10],[0,3,4,5],0.,1.)
a1 = Agent((DiscreteSegment(1,10),),[(1,),(2,),(3,)],[0,1,4],ancestors=true)
a2 = Agent((DiscreteSegment(1,10),),[(1,),(10,),(3,),(10,)],[0,3,4,5],ancestors=true)
@test get_dist_hist(a1,a2,(x,y)->y!=x,1) 3.0
end
end
@testset "Geotrait computation" begin
a = Agent{MixedAgent}( Float16[1, randn()] ); increment_x!(a,1.,p);
a = Agent(myspace3, (Int16.(1), randn() ),ancestors=true); increment_x!(a,myspace3,p3,2.0);
@test get_geo(a,2.0) 2.0
end
......
......@@ -5,12 +5,7 @@ using ABMEv, Test, JLD2,Random
# include("wrightfisher.jl")
include("metrics.jl")
include("utilstest.jl")
# we might want to put this in a separate file at some point
@testset "Reflection" begin
@test get_inc_reflected(0.,2.0) .0
@test get_inc_reflected(0.,-2.0) .0
@test get_inc_reflected(0.,4.0) .0
@test get_inc_reflected(0.,1.1) 1 - .1
end
include("simulation.jl")
include("space_agent.jl")
include("world.jl")
end
......@@ -34,8 +34,16 @@ ABMEv.initpos(myspace2)
# increment on finite spaces
# checking if reflection works
@test mysegment.s - eps() < get_inc(5.,100.,mysegment) + 5. < mysegment.e + eps()
@test mycontinuoussegment.s < get_inc(0.,100.,mycontinuoussegment) < mycontinuoussegment.e
@testset "Reflection" begin
@test mysegment.s - eps() < get_inc(5.,100.,mysegment) + 5. < mysegment.e + eps()
@test mycontinuoussegment.s < get_inc(0.,100.,mycontinuoussegment) < mycontinuoussegment.e
mysegment2 = DiscreteSegment(-1,1)
@test ABMEv._reflect1D(0.,2.0,mysegment2) .0
@test ABMEv._reflect1D(0.,-2.0,mysegment2) .0
@test ABMEv._reflect1D(0.,4.0,mysegment2) .0
@test ABMEv._reflect1D(0.,1.1,mysegment2) 1 - .1
end
#checking if graph works
@test prod([get_inc(1,10,mygraph) + 1 vertices(mygraph.g) for i in 1:30])
......
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