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

sympatric_speciation.jl 1.14 KB
Newer Older
Victor's avatar
Victor committed
1
2
3
4
5
using ABMEv,UnPack,Plots

myspace = (RealSpace{1,Float64}(),)
σ_b = .9;
σ_d = .7;
Victor's avatar
Victor committed
6
K0 = 1000
Victor's avatar
Victor committed
7
8
9
10
11
b(X,t) = 1.
d(X,Y,t) = gaussian(X[1],Y[1],σ_d)/K0 / gaussian(X[1],0.,σ_b)
D = (1e-2,)
mu = [.1]
NMax = 2000
Victor's avatar
Victor committed
12
tend = 1500
Victor's avatar
Victor committed
13
p = Dict{String,Any}();@pack! p = d,b,D,mu,NMax
Victor's avatar
Victor committed
14
myagents = [Agent(myspace,(1e-2 * randn(),),rates=true) for i in 1:K0]
Victor's avatar
Victor committed
15
w0 = World(myagents,myspace,p,0.)
Victor's avatar
Victor committed
16
@time sim = run!(w0,Gillepsie(),tend,dt_saving = 10)
Victor's avatar
Victor committed
17

Victor's avatar
Victor committed
18
19
20
using JLD2
@save joinpath(@__DIR__,"sim_sympatric_speciation.jld2") sim

Victor's avatar
Victor committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Plots.plot(sim, ylabel = "Adaptive trait")
savefig(joinpath(@__DIR__, "sympatric_speciation.png"))

# plotting lineages
world = get_world(sim,get_size(sim))
xhistall = get_xhist.(world[:],1)
thist = get_thist.(world[:])
xplot = Plots.plot(thist,xhistall,
                linecolor = eth_grad_std[0.],
                label = "",
                # title = latexstring("\\sigma_\\mu=",@sprintf("%1.2f",world.p["D"][2][1]),", \\sigma_D=",@sprintf("%1.2f",world.p["D"][1])),
                grid = false,
                xlabel = "time",
                ylabel = "Historical adaptive trait"
Victor's avatar
Victor committed
35
                )
Victor's avatar
Victor committed
36
savefig(joinpath(@__DIR__, "x_hist_sympatric_speciation.png"))