cfm_vs_gillepsie.jl 1.01 KB
Newer Older
1
2
using Revise,ABMEv,UnPack

Victor's avatar
Victor committed
3
4
# CFM algorithm
myspace = (RealSpace{1,Float64}(),)
5
6
7
sigma_K = .9;
sigma_a = .7;
K0 = 5000
Victor's avatar
Victor committed
8
9
b(X,t) = gaussian(X[1],0.,sigma_K)
d(X,Y,t) = gaussian(X[1],Y[1],sigma_a)/K0
10
11
12
13
D = (Float16(1e-1),)
mu = [1.]
NMax = 7000
tend = 50
Victor's avatar
Victor committed
14
15
bm= b([0],0.); dm = d([0],[0],0.)
p = Dict{String,Any}();@pack! p = D,mu,NMax,bm,dm
16
17
18
# myagents = [Agent(myspace,(- Float16(0.5) .+ .01 .* randn(Float16),)) for i in 1:K0]
myagents = [Agent(myspace,(0.,)) for i in 1:K0]
w0 = World(myagents,myspace,p,0.)
Victor's avatar
Victor committed
19
@time mysim = run!(w0,CFM(),tend,b,d,dt_saving=1.)
20
21

using Plots
Victor's avatar
Victor committed
22
Plots.plot(mysim)
23
24
25
26
27
28
29
30
31
32
33
34
35


########### GILLEPSIE
K0 = 1000
myspace = (RealSpace{1,Float64}(),)
sigma_K = .9;
sigma_a = .7;
b(X) = gaussian(X[1],0.,sigma_K)
d(X,Y) = gaussian(X[1],Y[1],sigma_a)/K0
D = (1e-1,)
mu = [1.]
NMax = 10000
tend = 100
Victor's avatar
Victor committed
36
p = Dict{String,Any}();@pack! p = D,mu,NMax #,Cbar
37
38
myagents = [Agent(myspace,(0,),ancestors=true,rates=true) for i in 1:K0]
w0 = World(myagents,myspace,p,0.)
Victor's avatar
Victor committed
39
@time mysim = run!(w0,Gillepsie(),tend,b,d,dt_saving=1.)
40

Victor's avatar
Victor committed
41
Plots.plot(mysim)