world.jl 1.16 KB
Newer Older
1
2
3
using LightGraphs
using Test
using Revise,ABMEv
Victor's avatar
Victor committed
4
using UnPack
5
6
7
8
9
10
11
12
13
14
15
myspace = (GraphSpace(SimpleGraph(10,10)),RealSpace{1,Float64}())
myagents = [Agent(myspace,ancestors=true,rates=true) for i in 1:10]
d(X,Y) = gaussian(X[1],Y[1],1)
b(X,Y) = gaussian(X[1],0,1)
D = (Int64(1),Float64(1.))
mu = [1,1]
NMax = 100
p = Dict{String,Any}();@pack! p = d,b,D,mu,NMax



Victor's avatar
Victor committed
16
17
@test eltype(myagents) <: AbstractAgentM
@test typeof(myagents) <: Vector{A} where {A<:AbstractAgentM}
18

Victor's avatar
Victor committed
19
w = World(myagents,myspace,p,0.)
20
21
22
23
24
25
26
27
@test size(w)  10
newa = give_birth(1,w)
addAgent!(w,newa)
@test size(w)  11
removeAgent!(w,11)
@test size(w)  10
@test isnothing(update_clock!(w,.1))

Victor's avatar
Victor committed
28
using BenchmarkTools
29
30
31
32
33
34
35
36
37
38
39
40
41
if false
    # TODO
    # Here we observe that deleting an agent is a bit of a pain
    # Since one has to look where this agent is located in the structure
    # This should be improved at some point
    # This could be improved by maintaining a list of agents IDs
    dicttest = Dict((i,w.agents[i]) for i in 1:p["NMax"]);
    @btime w.agents[ABMEv._get_idx(w)[8]]
    @btime dicttest[8]
    @btime ABMEv.agents(w)
end
##############  Testing world with Gillepsie
@test !isnothing(updateWorld!(w,Gillepsie()))