我正在尝试使用R中的Diffeqr
包(文档的link)来解决ODE系统。解决系统错误时,指出:“ 需要更大的maxiters 。”
示例:
library(diffeqr)
library(plotly)
diffeq_setup()
### Adapted Zombie apocalypse model (Munz, 2009) ###
# Drift function
f <- function(u,p,t) {
du1 = u[4] * u[1] - p[1] * u[1] * u[3] + p[2] * u[2]
du2 = p[1] * u[1] * u[3] - p[2] * u[2] - p[3] * u[2]
du3 = 100 + p[3] * u[2] - p[1] * u[1] * u[3] + p[2] * u[2]
du4 = 0
return(c(du1,du2, du3, du4))
}
# Diffusion function (note that noise terms are 0)
g <- function(u,p,t) {
return(c(0*u[1], 0*u[2], 0*u[3], 0*u[4]))
}
u0 = c(100000, 0, 0, 0.7) # initial conditions
tspan <- list(0.0,1000) # timespan to solve over
p = c(0.0002, 0.005, 0.02) # parameter values
sol = diffeqr::sde.solve(f,g,u0,tspan,p=p,saveat=1, abstol = 10^(-3))
udf = as.data.frame(sol$u)
plot_ly(udf, x = sol$t, y = ~V1, name = 'Zombies', type = 'scatter', mode = 'lines') %>%
add_trace(y = ~V2, name = 'Zombie/human conflicts', mode = 'lines') %>%
add_trace(y = ~V3, name = 'Zombies', mode = 'lines')
发生的错误如下:
> sol = diffeqr::sde.solve(f,g,u0,tspan,p=p,saveat=1, abstol = 10^(-3))
┌ Warning: Interrupted. Larger maxiters is needed.
└ @ DiffEqBase ~/.julia/packages/DiffEqBase/cp0Wf/src/integrator_interface.jl:150
我尝试在maxiter
中指定sde.solve()
,但是无法在其中添加maxiter
参数。
问题
您如何手动将maxiter
设置为更高的值?