为什么 Julia (DifferentialEquations.jl) JumpProblem 会在稍后停止跳跃?
Why does Julia (DifferentialEquations.jl) JumpProblem stop jumping at later times?
我正在尝试使用 DifferentialEquations.jl 中的工具实现离散随机模拟。它适用于较早的时间点,但后来莫名其妙地不做任何跳跃。
using DifferentialEquations
using Plots
#initial conditions
far1_ic = 0
cln_ic = 100
ste12_ic = 1000
far1cln_ic = 0
u0 = [far1_ic, cln_ic, ste12_ic, far1cln_ic]
#paramaters
#Far1
ks_F = 10 #1
kd_F = 0.01 #2
kd_F_C = 0.01 #3
kA_C = 200 #4
ks_F_S = 200 #5
#Cln
ks_C = 10 #6
kd_C = 0.1 #7
kA_F = 500 #8
ks_C_C = 100 #9
#Ste12
ks_S_alpha = 80 #10
ks_S = 1 #11
ks_S_S = 100 #12
kd_S = 0.01 #13
kA_S = 500 #14
kd_S_F = 0.005 #15
#Far1Cln
ks_FC = 100 #16
kd_FC = 0.05 #17
krev_FC = 600 #18
#misc
alpha = 17 #19
power_alpha = 1 #20
alpha_halfmax = 50 #21
p = [ks_F, kd_F, kd_F_C, kA_C, ks_F_S, ks_C, kd_C, kA_F, ks_C_C,
ks_S_alpha, ks_S, ks_S_S, kd_S, kA_S, kd_S_F, ks_FC, kd_FC,
krev_FC, alpha, power_alpha, alpha_halfmax];
s_far1(u,p,t) = (p[5] * ((u[3]^2)/(u[3]^2+p[14]^2)) + p[1]) * (p[19]^p[20]/(p[19]^p[20]+p[21]^p[20]))
d_far1(u,p,t) = p[2]*u[1] + p[3]*u[1]*u[2]
s_cln(u,p,t) = p[6] + p[9]*((u[2]^2)/(u[2]^2+p[4]^2))
d_cln(u,p,t) = p[7]*u[2]
s_ste12(u,p,t) = p[11]+(p[10]+p[12]*(u[3]^2/(u[3]^2+p[14]^2)))*(p[19]^p[20]/(p[19]^p[20]+p[21]^p[20]))
d_ste12(u,p,t) = p[13]*u[3] + p[15]*u[1]*u[3]
s_far1cln(u,p,t) = p[16]*u[1]*u[2]
d_far1cln(u,p,t) = p[17]*u[4]
r_far1cln(u,p,t) = p[18]*u[4]
function syn_f(integrator)
integrator.u[1] += 1
end
function deg_f(integrator)
integrator.u[1] -= 1
end
function syn_c(integrator)
integrator.u[2] += 1
end
function deg_c(integrator)
integrator.u[2] -= 1
end
function syn_s(integrator)
integrator.u[3] += 1
end
function deg_s(integrator)
integrator.u[3] -= 1
end
function syn_fc(integrator)
integrator.u[4] += 1
integrator.u[1] -= 1
integrator.u[2] -= 1
end
function deg_fc(integrator)
integrator.u[4] -= 1
end
function rev_fc(integrator)
integrator.u[4] -= 1
integrator.u[1] += 1
integrator.u[2] += 1
end
jump1 = ConstantRateJump(s_far1, syn_f)
jump2 = ConstantRateJump(d_far1, deg_f)
jump3 = ConstantRateJump(s_cln, syn_c)
jump4 = ConstantRateJump(d_cln, deg_c)
jump5 = ConstantRateJump(s_ste12, syn_s)
jump6 = ConstantRateJump(d_ste12, deg_s)
jump7 = ConstantRateJump(s_far1cln, syn_fc)
jump8 = ConstantRateJump(d_far1cln, deg_fc)
jump9 = ConstantRateJump(r_far1cln, rev_fc)
p[19] = 27 # reset parameter alpha
tspan = (0.0,600.0) #time span
prob = DiscreteProblem(u0,tspan,p) # variables must be discrete. Provide IC, span, paramaters.
jump_prob = JumpProblem(prob,DirectFW(),jump1,jump2,jump3,jump4,jump5,jump6,jump7,jump8,jump9,save_positions=(false,false))
sol = solve(jump_prob,SSAStepper(),saveat=1);
plot of simulation
我试过保存所有位置而不是只保存每个整数。我试过使用 Direct 而不是 DirectFW。我试过使用默认值而不是 SSAStepper。我检查了 ODESolution 对象,它确实只是在以后的每个时间步重复相同的值;不仅仅是情节。
非常感谢任何建议!
这是一个已修复的错误。 运行 ]up
您的代码将有效。
我正在尝试使用 DifferentialEquations.jl 中的工具实现离散随机模拟。它适用于较早的时间点,但后来莫名其妙地不做任何跳跃。
using DifferentialEquations
using Plots
#initial conditions
far1_ic = 0
cln_ic = 100
ste12_ic = 1000
far1cln_ic = 0
u0 = [far1_ic, cln_ic, ste12_ic, far1cln_ic]
#paramaters
#Far1
ks_F = 10 #1
kd_F = 0.01 #2
kd_F_C = 0.01 #3
kA_C = 200 #4
ks_F_S = 200 #5
#Cln
ks_C = 10 #6
kd_C = 0.1 #7
kA_F = 500 #8
ks_C_C = 100 #9
#Ste12
ks_S_alpha = 80 #10
ks_S = 1 #11
ks_S_S = 100 #12
kd_S = 0.01 #13
kA_S = 500 #14
kd_S_F = 0.005 #15
#Far1Cln
ks_FC = 100 #16
kd_FC = 0.05 #17
krev_FC = 600 #18
#misc
alpha = 17 #19
power_alpha = 1 #20
alpha_halfmax = 50 #21
p = [ks_F, kd_F, kd_F_C, kA_C, ks_F_S, ks_C, kd_C, kA_F, ks_C_C,
ks_S_alpha, ks_S, ks_S_S, kd_S, kA_S, kd_S_F, ks_FC, kd_FC,
krev_FC, alpha, power_alpha, alpha_halfmax];
s_far1(u,p,t) = (p[5] * ((u[3]^2)/(u[3]^2+p[14]^2)) + p[1]) * (p[19]^p[20]/(p[19]^p[20]+p[21]^p[20]))
d_far1(u,p,t) = p[2]*u[1] + p[3]*u[1]*u[2]
s_cln(u,p,t) = p[6] + p[9]*((u[2]^2)/(u[2]^2+p[4]^2))
d_cln(u,p,t) = p[7]*u[2]
s_ste12(u,p,t) = p[11]+(p[10]+p[12]*(u[3]^2/(u[3]^2+p[14]^2)))*(p[19]^p[20]/(p[19]^p[20]+p[21]^p[20]))
d_ste12(u,p,t) = p[13]*u[3] + p[15]*u[1]*u[3]
s_far1cln(u,p,t) = p[16]*u[1]*u[2]
d_far1cln(u,p,t) = p[17]*u[4]
r_far1cln(u,p,t) = p[18]*u[4]
function syn_f(integrator)
integrator.u[1] += 1
end
function deg_f(integrator)
integrator.u[1] -= 1
end
function syn_c(integrator)
integrator.u[2] += 1
end
function deg_c(integrator)
integrator.u[2] -= 1
end
function syn_s(integrator)
integrator.u[3] += 1
end
function deg_s(integrator)
integrator.u[3] -= 1
end
function syn_fc(integrator)
integrator.u[4] += 1
integrator.u[1] -= 1
integrator.u[2] -= 1
end
function deg_fc(integrator)
integrator.u[4] -= 1
end
function rev_fc(integrator)
integrator.u[4] -= 1
integrator.u[1] += 1
integrator.u[2] += 1
end
jump1 = ConstantRateJump(s_far1, syn_f)
jump2 = ConstantRateJump(d_far1, deg_f)
jump3 = ConstantRateJump(s_cln, syn_c)
jump4 = ConstantRateJump(d_cln, deg_c)
jump5 = ConstantRateJump(s_ste12, syn_s)
jump6 = ConstantRateJump(d_ste12, deg_s)
jump7 = ConstantRateJump(s_far1cln, syn_fc)
jump8 = ConstantRateJump(d_far1cln, deg_fc)
jump9 = ConstantRateJump(r_far1cln, rev_fc)
p[19] = 27 # reset parameter alpha
tspan = (0.0,600.0) #time span
prob = DiscreteProblem(u0,tspan,p) # variables must be discrete. Provide IC, span, paramaters.
jump_prob = JumpProblem(prob,DirectFW(),jump1,jump2,jump3,jump4,jump5,jump6,jump7,jump8,jump9,save_positions=(false,false))
sol = solve(jump_prob,SSAStepper(),saveat=1);
plot of simulation
我试过保存所有位置而不是只保存每个整数。我试过使用 Direct 而不是 DirectFW。我试过使用默认值而不是 SSAStepper。我检查了 ODESolution 对象,它确实只是在以后的每个时间步重复相同的值;不仅仅是情节。
非常感谢任何建议!
这是一个已修复的错误。 运行 ]up
您的代码将有效。