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 172eb449 authored by Victor's avatar Victor
Browse files

we removed the Distributed package, and its subsequent macro call @ distributed in runworld.

Test have also been modified, because it seems that this change also changes the random seed.
parent 647b81fc
name = "ABMEv"
uuid = "837ac870-fb52-4b0c-9a0e-030f2f36f5ed"
authors = ["Victor Boussange "]
version = "0.1.4"
version = "0.1.5"
[deps]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
......
......@@ -2,7 +2,7 @@ __precompile__()
module ABMEv
using Distributions,LinearAlgebra,Reexport,StatsBase
using SharedArrays,Distributed,LightGraphs
using LightGraphs
include("ABMEv_Agent.jl")
include("ABMEv_WF.jl")
......
......@@ -8,8 +8,6 @@ using RecipesBase
p["tspan" ] = p["tspan"][idx_reduced]
world = world[:,idx_reduced]
end
# here we can take xhist because every agent is updated at the same time
# world should correspond to a one dimensional array
if count(ismissing,world) > 0
tspan_ar = vcat([p["tspan"][i]*ones(Int(p["NMax"] - count(ismissing,world[:,i]))) for i in 1:length(p["tspan"]) ]...);
else
......@@ -106,4 +104,14 @@ using RecipesBase
p["tspan"],i->first(covgeo(world[:,Int(i)]))
end
end
# if "density_t" in what
# @series begin
# linewidth := 2
# seriestype := :plot3d
# label := "Variance of geotrait"
# xlabel := "Time"
# ylabel := "Variance"
# p["tspan"],i->first(covgeo(world[:,Int(i)]))
# end
# end
end
......@@ -11,9 +11,9 @@ function update_rates_std!(world,p::Dict,t::Float64)
traits = get_x.(world)
# traits = get_xhist.(world)
N = length(traits)
D = SharedArray{Float64}(N)
D = zeros(N)
# Here you should do a shared array to compute in parallel
@sync @distributed for i in 1:(N-1)
for i in 1:(N-1)
for j in i+1:N
C = α(traits[i],traits[j])
D[i] += C
......@@ -46,7 +46,7 @@ function update_rates_2D!(world,C,p::Dict,t::Float64)
N = length(traits)
# C = SharedArray{Float64}((N,N))
# Here you should do a shared array to compute in parallel
@sync @distributed for i in 1:(N-1)
for i in 1:(N-1)
C[i,i] = 1.
for j in i+1:N
# be careful, for xhist what is return is an array hence no need of []
......@@ -80,7 +80,7 @@ function update_rates_grad2D!(world,C,p::Dict,t::Float64)
N = length(traits)
# C = SharedArray{Float64}((N,N))
# Here you should do a shared array to compute in parallel
@sync @distributed for i in 1:(N-1)
for i in 1:(N-1)
C[i,i] = 1.
for j in i+1:N
# be careful, for xhist what is return is an array hence no need of []
......@@ -104,7 +104,7 @@ function update_rates_mountain!(world,C,p::Dict,t::Float64)
N = length(traits)
# C = SharedArray{Float64}((N,N))
# Here you should do a shared array to compute in parallel
@sync @distributed for i in 1:(N-1)
for i in 1:(N-1)
C[i,i] = 1.
for j in i+1:N
# be careful, for xhist what is return is an array hence no need of []
......@@ -137,7 +137,7 @@ function update_rates_std_split!(world,C,p::Dict,t::Float64)
N = length(traits)
# C = SharedArray{Float64}((N,N))
# Here you should do a shared array to compute in parallel
@sync @distributed for i in 1:(N-1)
for i in 1:(N-1)
C[i,i] = 1.
for j in i+1:N
C[i,j] = α(traits[i],traits[j],p["n_alpha"],p["sigma_a"])
......
......@@ -30,8 +30,10 @@ world_alive_test = collect(skipmissing(worldall[:,end]))
@test p_default["tspan"][end] >= p_default["tend"]
end
## Comparing simulation
xarray = get_xarray(world_alive,1);xarray_test = get_xarray(world_alive_test,1);
@test xarray xarray_test
@testset "Matching new vs old results " begin
xarray = get_xarray(world_alive,1);xarray_test = get_xarray(world_alive_test,1);
@test xarray xarray_test
end
@testset "Testing update rates matrix" begin
bs_end = get_b.(world_alive);ds_end = get_d.(world_alive)
......
No preview for this file type
......@@ -20,10 +20,8 @@ agents2 = [Agent( [σ σ] .* randn(2) .- .5) for i in 1:K0]
# there is a problem here
@testset "covgeo2d" begin
cmat = covgeo(agents2,2);
smat = [σ^2 σ^2; σ^2 σ^2]
for i in 1:length(cmat)
@test cmat[i] smat[i] atol=0.001
end
smat = [σ^2 0; 0 σ^2]
@test cmat smat atol=0.01
end
end
......
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