Commit 629d8201 authored by Victor's avatar Victor
Browse files

updating CFM

parent 61201fb0
Pipeline #77570 passed with stage
in 23 minutes and 29 seconds
......@@ -31,15 +31,15 @@ function updateWorld!(w::World{A,S,T},c::CFM) where {A,S,T}
alive = agents(w)
# Total rate of events
n = size(w)
Cbar = (bm + dm)*n
dt = rand(Exponential(Cbar)) / n
Cbar = (bm + dm)
dt = rand(Exponential(Cbar)) / (n*(n+1))
update_clock!(w,dt)
i = rand(1:n)
x = get_x(w[i])
W = rand()
if dt > 0.
deathprob = (sum(d.(get_x.(alive),Ref(x),w.t)) .- d(x,x,w.t)) / Cbar
birthprob = b(x,w.t) / Cbar
deathprob = (sum(d.(get_x.(alive),Ref(x),w.t)) .- d(x,x,w.t)) / (Cbar*(n+1))
birthprob = b(x,w.t) / (Cbar*(n+1))
if W <= deathprob
updateDeathEvent!(w,c,i)
elseif W <= deathprob + birthprob
......
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