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" ...@@ -8,9 +8,9 @@ version = "0.5.0"
[[Adapt]] [[Adapt]]
deps = ["LinearAlgebra"] deps = ["LinearAlgebra"]
git-tree-sha1 = "0fac443759fa829ed8066db6cf1077d888bb6573" git-tree-sha1 = "42c42f2221906892ceb765dbcb1a51deeffd86d7"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "2.0.2" version = "2.3.0"
[[ArnoldiMethod]] [[ArnoldiMethod]]
deps = ["DelimitedFiles", "LinearAlgebra", "Random", "SparseArrays", "StaticArrays", "Test"] deps = ["DelimitedFiles", "LinearAlgebra", "Random", "SparseArrays", "StaticArrays", "Test"]
...@@ -35,9 +35,9 @@ version = "1.0.6+4" ...@@ -35,9 +35,9 @@ version = "1.0.6+4"
[[CategoricalArrays]] [[CategoricalArrays]]
deps = ["DataAPI", "Future", "JSON", "Missings", "Printf", "Statistics", "StructTypes", "Unicode"] deps = ["DataAPI", "Future", "JSON", "Missings", "Printf", "Statistics", "StructTypes", "Unicode"]
git-tree-sha1 = "e7cb4f23938914f09afae58b611a59f3aa8d8f66" git-tree-sha1 = "2ac27f59196a68070e132b25713f9a5bbc5fa0d2"
uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597" uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597"
version = "0.8.2" version = "0.8.3"
[[CodeTracking]] [[CodeTracking]]
deps = ["InteractiveUtils", "UUIDs"] deps = ["InteractiveUtils", "UUIDs"]
...@@ -53,9 +53,9 @@ version = "0.7.0" ...@@ -53,9 +53,9 @@ version = "0.7.0"
[[ColorSchemes]] [[ColorSchemes]]
deps = ["ColorTypes", "Colors", "FixedPointNumbers", "Random", "StaticArrays"] deps = ["ColorTypes", "Colors", "FixedPointNumbers", "Random", "StaticArrays"]
git-tree-sha1 = "7a15e3690529fd1042f0ab954dff7445b1efc8a5" git-tree-sha1 = "5d472aa8908568bc198564db06983913a6c2c8e7"
uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4" uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
version = "3.9.0" version = "3.10.1"
[[ColorTypes]] [[ColorTypes]]
deps = ["FixedPointNumbers", "Random"] deps = ["FixedPointNumbers", "Random"]
...@@ -71,9 +71,9 @@ version = "0.12.4" ...@@ -71,9 +71,9 @@ version = "0.12.4"
[[Compat]] [[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"] 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" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.15.0" version = "3.18.0"
[[CompilerSupportLibraries_jll]] [[CompilerSupportLibraries_jll]]
deps = ["Libdl", "Pkg"] deps = ["Libdl", "Pkg"]
...@@ -128,10 +128,10 @@ deps = ["Random", "Serialization", "Sockets"] ...@@ -128,10 +128,10 @@ deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
[[Distributions]] [[Distributions]]
deps = ["FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns"] deps = ["FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "StaticArrays", "Statistics", "StatsBase", "StatsFuns"]
git-tree-sha1 = "3676697fd903ba314aaaa0ec8d6813b354edb875" git-tree-sha1 = "501c11d708917ca09ce357bed163dbaf0f30229f"
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f" uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
version = "0.23.11" version = "0.23.12"
[[DocStringExtensions]] [[DocStringExtensions]]
deps = ["LibGit2", "Markdown", "Pkg", "Test"] deps = ["LibGit2", "Markdown", "Pkg", "Test"]
...@@ -139,6 +139,12 @@ git-tree-sha1 = "50ddf44c53698f5e784bbebb3f4b21c5807401b1" ...@@ -139,6 +139,12 @@ git-tree-sha1 = "50ddf44c53698f5e784bbebb3f4b21c5807401b1"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.3" 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]] [[ExprTools]]
git-tree-sha1 = "7fce513fcda766962ff67c5596cb16c463dfd371" git-tree-sha1 = "7fce513fcda766962ff67c5596cb16c463dfd371"
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
...@@ -212,10 +218,10 @@ uuid = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" ...@@ -212,10 +218,10 @@ uuid = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
version = "0.52.0" version = "0.52.0"
[[GeometryBasics]] [[GeometryBasics]]
deps = ["IterTools", "LinearAlgebra", "StaticArrays", "StructArrays", "Tables"] deps = ["EarCut_jll", "IterTools", "LinearAlgebra", "StaticArrays", "StructArrays", "Tables"]
git-tree-sha1 = "119f32f9c2b497b49cd3f7f513b358b82660294c" git-tree-sha1 = "49d13ebd048bd71315ff98bdc2c560ec16eda2b4"
uuid = "5c1252a2-5f33-56bf-86c9-59e7332b4326" uuid = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
version = "0.2.15" version = "0.3.1"
[[GeometryTypes]] [[GeometryTypes]]
deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "StaticArrays"] deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "StaticArrays"]
...@@ -223,11 +229,16 @@ git-tree-sha1 = "34bfa994967e893ab2f17b864eec221b3521ba4d" ...@@ -223,11 +229,16 @@ git-tree-sha1 = "34bfa994967e893ab2f17b864eec221b3521ba4d"
uuid = "4d00f742-c7ba-57c2-abde-4428a4b178cb" uuid = "4d00f742-c7ba-57c2-abde-4428a4b178cb"
version = "0.8.3" version = "0.8.3"
[[Grisu]]
git-tree-sha1 = "03d381f65183cb2d0af8b3425fde97263ce9a995"
uuid = "42e2da0e-8278-4e71-bc24-59509adca0fe"
version = "1.0.0"
[[HTTP]] [[HTTP]]
deps = ["Base64", "Dates", "IniFile", "MbedTLS", "Sockets"] deps = ["Base64", "Dates", "IniFile", "MbedTLS", "Sockets"]
git-tree-sha1 = "2ac03263ce44be4222342bca1c51c36ce7566161" git-tree-sha1 = "c7ec02c4c6a039a98a15f955462cd7aea5df4508"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.8.17" version = "0.8.19"
[[Inflate]] [[Inflate]]
git-tree-sha1 = "f5fc07d4e706b84f72d54eedcc1c13d92fb0871c" git-tree-sha1 = "f5fc07d4e706b84f72d54eedcc1c13d92fb0871c"
...@@ -280,9 +291,9 @@ version = "1.0.0" ...@@ -280,9 +291,9 @@ version = "1.0.0"
[[JLD2]] [[JLD2]]
deps = ["CodecZlib", "DataStructures", "MacroTools", "Mmap", "Pkg", "Printf", "Requires", "UUIDs"] deps = ["CodecZlib", "DataStructures", "MacroTools", "Mmap", "Pkg", "Printf", "Requires", "UUIDs"]
git-tree-sha1 = "d2c0db66530ff444846d6e84bcf948a74ce31635" git-tree-sha1 = "d71a4c4adfc1ec8e2b988b19d5800668b038aa89"
uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819" uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
version = "0.2.0" version = "0.2.2"
[[JSON]] [[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"] deps = ["Dates", "Mmap", "Parsers", "Unicode"]
...@@ -400,9 +411,9 @@ uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" ...@@ -400,9 +411,9 @@ uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
version = "0.3.4" version = "0.3.4"
[[OffsetArrays]] [[OffsetArrays]]
git-tree-sha1 = "b8500f9d73999cfbab4add5136ec26894081581e" git-tree-sha1 = "3fdfca8a532507d65f39ff0ad34fe81097a55337"
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
version = "1.1.3" version = "1.3.0"
[[Ogg_jll]] [[Ogg_jll]]
deps = ["Libdl", "Pkg"] deps = ["Libdl", "Pkg"]
...@@ -429,15 +440,15 @@ uuid = "91d4177d-7536-5919-b921-800302f37372" ...@@ -429,15 +440,15 @@ uuid = "91d4177d-7536-5919-b921-800302f37372"
version = "1.3.1+2" version = "1.3.1+2"
[[OrderedCollections]] [[OrderedCollections]]
git-tree-sha1 = "293b70ac1780f9584c89268a6e2a560d938a7065" git-tree-sha1 = "16c08bf5dba06609fe45e30860092d6fa41fde7b"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.3.0" version = "1.3.1"
[[PDMats]] [[PDMats]]
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse", "Test"] deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse", "Test"]
git-tree-sha1 = "b3405086eb6a974eba1958923d46bc0e1c2d2d63" git-tree-sha1 = "95a4038d1011dfdbde7cecd2ad0ac411e53ab1bc"
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150" uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
version = "0.10.0" version = "0.10.1"
[[Parsers]] [[Parsers]]
deps = ["Dates", "Test"] deps = ["Dates", "Test"]
...@@ -457,21 +468,21 @@ version = "2.0.0" ...@@ -457,21 +468,21 @@ version = "2.0.0"
[[PlotUtils]] [[PlotUtils]]
deps = ["ColorSchemes", "Colors", "Dates", "Printf", "Random", "Reexport", "Statistics"] deps = ["ColorSchemes", "Colors", "Dates", "Printf", "Random", "Reexport", "Statistics"]
git-tree-sha1 = "8d23333aee2e2733a5cd4e1985462df8203f47f7" git-tree-sha1 = "4e098f88dad9a2b518b83124a116be1c49e2b2bf"
uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043" uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043"
version = "1.0.6" version = "1.0.7"
[[Plots]] [[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"] 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" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
version = "1.6.3" version = "1.6.7"
[[Polynomials]] [[Polynomials]]
deps = ["Intervals", "LinearAlgebra", "OffsetArrays", "RecipesBase"] deps = ["Intervals", "LinearAlgebra", "OffsetArrays", "RecipesBase"]
git-tree-sha1 = "7ce1a60df1a8eb61df4cef5698abc9a18575c91f" git-tree-sha1 = "ce5fe493693b1ca81aa70b806e353a288f73ec7f"
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
version = "1.1.7" version = "1.1.9"
[[PooledArrays]] [[PooledArrays]]
deps = ["DataAPI"] deps = ["DataAPI"]
...@@ -521,15 +532,15 @@ version = "0.2.0" ...@@ -521,15 +532,15 @@ version = "0.2.0"
[[Requires]] [[Requires]]
deps = ["UUIDs"] deps = ["UUIDs"]
git-tree-sha1 = "8c08d0c7812169e438a8478dae2a529377ad13f7" git-tree-sha1 = "28faf1c963ca1dc3ec87f166d92982e3c4a1f66d"
uuid = "ae029012-a4dd-5104-9daa-d747884805df" uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.0.2" version = "1.1.0"
[[Revise]] [[Revise]]
deps = ["CodeTracking", "Distributed", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "Pkg", "REPL", "UUIDs", "Unicode"] 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" uuid = "295af30f-e4ad-537b-8983-00126c2a3abe"
version = "2.7.5" version = "2.7.6"
[[Rmath]] [[Rmath]]
deps = ["Random", "Rmath_jll"] deps = ["Random", "Rmath_jll"]
...@@ -554,10 +565,10 @@ deps = ["Distributed", "Mmap", "Random", "Serialization"] ...@@ -554,10 +565,10 @@ deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
[[Showoff]] [[Showoff]]
deps = ["Dates"] deps = ["Dates", "Grisu"]
git-tree-sha1 = "e032c9df551fb23c9f98ae1064de074111b7bc39" git-tree-sha1 = "ee010d8f103468309b8afac4abb9be2e18ff1182"
uuid = "992d4aef-0814-514b-bc4d-f2e9a6c4116f" uuid = "992d4aef-0814-514b-bc4d-f2e9a6c4116f"
version = "0.3.1" version = "0.3.2"
[[SimpleTraits]] [[SimpleTraits]]
deps = ["InteractiveUtils", "MacroTools"] deps = ["InteractiveUtils", "MacroTools"]
...@@ -630,9 +641,9 @@ version = "1.0.0" ...@@ -630,9 +641,9 @@ version = "1.0.0"
[[Tables]] [[Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"] deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
git-tree-sha1 = "b7f762e9820b7fab47544c36f26f54ac59cf8abf" git-tree-sha1 = "24a584cf65e2cfabdadc21694fb69d2e74c82b44"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "1.0.5" version = "1.1.0"
[[Test]] [[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
...@@ -640,9 +651,9 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" ...@@ -640,9 +651,9 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[TimeZones]] [[TimeZones]]
deps = ["Dates", "EzXML", "Mocking", "Pkg", "Printf", "RecipesBase", "Serialization", "Unicode"] deps = ["Dates", "EzXML", "Mocking", "Pkg", "Printf", "RecipesBase", "Serialization", "Unicode"]
git-tree-sha1 = "338ddbb2b9b50a9a423ba6c3fad1824553535988" git-tree-sha1 = "2c48caca8f3912857973590a9757e1f86cbbff81"
uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53" uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53"
version = "1.3.2" version = "1.4.0"
[[TranscodingStreams]] [[TranscodingStreams]]
deps = ["Random", "Test"] deps = ["Random", "Test"]
......
...@@ -10,7 +10,7 @@ module ABMEv ...@@ -10,7 +10,7 @@ module ABMEv
include("ABMEv_Agent.jl") include("ABMEv_Agent.jl")
include("ABMEv_world.jl") include("ABMEv_world.jl")
include("ABMEv_Sim.jl") include("ABMEv_Sim.jl")
# include("ABMEv_metrics.jl") include("ABMEv_metrics.jl")
# include("ABMEv_plot.jl") # include("ABMEv_plot.jl")
include("ABMEv_utils.jl") include("ABMEv_utils.jl")
include("algo/ABMEv_WF.jl") include("algo/ABMEv_WF.jl")
...@@ -32,10 +32,10 @@ module ABMEv ...@@ -32,10 +32,10 @@ module ABMEv
export run!,give_birth,updateWorld!,update_clock!,updateBirthEvent!, export run!,give_birth,updateWorld!,update_clock!,updateBirthEvent!,
updateDeathEvent!#,runWorld_G!,runWorld_WF!, updateDeathEvent!#,runWorld_G!,runWorld_WF!,
export Simulation,add_entry!,get_tend,get_size,get_tspan export Simulation,add_entry!,get_tend,get_size,get_tspan
# export H_discrete,findclusters,var,covgeo,hamming,get_beta_div, get_alpha_div, export H_discrete,findclusters,var,covgeo,hamming,get_beta_div, get_alpha_div,
# get_dist_hist,get_pairwise_average_isolation, get_dist_hist,get_pairwise_average_isolation,
# get_local_pairwise_average_isolation, get_local_pairwise_average_isolation,
# truncvar,get_xhist_mat truncvar,get_xhist_mat
export update_afterbirth_std!,update_afterdeath_std! export update_afterbirth_std!,update_afterdeath_std!
export generalised_gaussian,gaussian,ma,geomsmooth,arithsmooth,eth_grad_std, export generalised_gaussian,gaussian,ma,geomsmooth,arithsmooth,eth_grad_std,
DiversityFunction,geomsmooth2D,arithsmooth2D,interpolate_df,groupby DiversityFunction,geomsmooth2D,arithsmooth2D,interpolate_df,groupby
......
...@@ -57,7 +57,7 @@ end ...@@ -57,7 +57,7 @@ end
$(SIGNATURES) $(SIGNATURES)
Initialises agent with `pos` provided 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) T = eltype.(s)
for (i,p) in enumerate(pos) for (i,p) in enumerate(pos)
if typeof(p) !== T[i] if typeof(p) !== T[i]
...@@ -76,6 +76,24 @@ function Agent(s::S, pos::P;ancestors=false,rates=false) where {P,S <: Abstract ...@@ -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) Agent{Ancestors{ancestors},Rates{rates},Tuple{T...},U,V}([pos],[t],d,b)
end 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 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)) 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 ...@@ -52,7 +52,6 @@ If trait > 0, returns the covariance matrix, with first row geotrait and second
""" """
function var(world::World;trait=1) function var(world::World;trait=1)
world = agents(world)
xarray = get_x(world,trait) xarray = get_x(world,trait)
return var(xarray,dims=1,corrected=false) return var(xarray,dims=1,corrected=false)
end end
...@@ -64,11 +63,10 @@ If trait > 0, returns the covariance matrix, with first row geotrait and second ...@@ -64,11 +63,10 @@ If trait > 0, returns the covariance matrix, with first row geotrait and second
# Arguments # Arguments
""" """
function covgeo(world::Array{U,1},t::Number,trait = 0) where U <: Union{Missing,Agent} function covgeo(world::World,trait = 0)
world = collect(skipmissing(world)) xarray = Float64.(get_geo(world))
xarray = Float64.(get_geo.(world,t))
if trait > 0 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) xarray = hcat(xarray,xstd)
end end
return cov(xarray,corrected=false) return cov(xarray,corrected=false)
...@@ -80,10 +78,10 @@ Returns a matrix H where H_ij = hamming(a_i,a_j). ...@@ -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 The hamming distance is taken through the whole history
and functional space of the agents. and functional space of the agents.
""" """
function hamming(world::Array{Agent,1}) where T <: Int function hamming(world::World) where T <: Int
N = size(world,1) n = size(world)
H = zeros(N,N) H = zeros(n,n)
for (i,a) in enumerate(world) for (i,a) in enumerate(agents(world))
for (j,b) in enumerate(world) for (j,b) in enumerate(world)
H[i,j] = hamming(get_xhist(a),get_xhist(b)) H[i,j] = hamming(get_xhist(a),get_xhist(b))
end end
...@@ -92,17 +90,16 @@ function hamming(world::Array{Agent,1}) where T <: Int ...@@ -92,17 +90,16 @@ function hamming(world::Array{Agent,1}) where T <: Int
end end
""" """
get_alpha_div(world::Array{U,1},t::Number,trait=1) where U <: Union{Missing,Agent} 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 # Arguments
""" """
function get_alpha_div(world::Array{U,1},t::Number,trait=1) where U <: Union{Missing,Agent} function get_alpha_div(world::World,trait=1)
_xall_df = world2df(world,t,true) xarray = get_xarray(world,true)
xall_per_patch = groupby(_xall_df, :x1,sort=true) g = groupby(x->x[1],collect(eachrow(xarray)))
if trait == 0 if trait == 0
# need to convert to Float64, otherwise infinite variance return mean([var(Float64.([x[end] for x in xp]),corrected=false) for xp in values(g)])
return mean([var(Float64.(xp.g),corrected=false) for xp in xall_per_patch])
else 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
end end
...@@ -111,14 +108,14 @@ end ...@@ -111,14 +108,14 @@ end
Variance of the mean of `trait` per patch Variance of the mean of `trait` per patch
# Arguments # Arguments
""" """
function get_beta_div(world::Array{U,1},t::Number,trait=1) where U <: Union{Missing,Agent} function get_beta_div(world::World,trait=1)
_xall_df = world2df(world,t,true) xarray = get_xarray(world,true)
xall_per_patch = groupby(_xall_df, :x1,sort=true) g = groupby(x->x[1],collect(eachrow(xarray)))
if trait == 0 if trait == 0
# need to convert to Float64, otherwise infinite variance # 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 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 end
return var(sbar_i,corrected=false) return var(sbar_i,corrected=false)
end end
......
...@@ -52,25 +52,32 @@ update_clock!(w::World{A,S,T},dt) where {A,S,T} = begin ...@@ -52,25 +52,32 @@ update_clock!(w::World{A,S,T},dt) where {A,S,T} = begin
return nothing return nothing
end end
#TODO : code it #TODO : modify this
""" """
$(SIGNATURES) $(SIGNATURES)
Returns trait of every agents of world in the form of an array which dimensions corresponds to the input. 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. 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) $(SIGNATURES)
Returns every traits of every agents of `world` in the form **of a one dimensional array** (in contrast to `get_x`). 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}`. 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) function get_xarray(world::World,geotrait::Bool=false)
xarray = hcat(get_x.(agents.(world))...) xarray = get_x(world,Colon())
if geotrait if geotrait
xarray = vcat( xarray, get_geo.(agents(world),world.t)') xarray = hcat( xarray, get_geo.(agents(world),world.t))
end end
return xarray return xarray
end end
@deprecate get_xarray(world,geotrait=false) get_x(world,Colon()) @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 # CFM = Champagnat Ferriere Meleard
# This contains all methods for algorithm described in article # This contains all methods for algorithm described in article
# DOI : 10.1016/j.tpb.2005.10.004 # 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