Julia 在运行 DifferentialEquations.jl 中的示例时抛出错误

问题描述 投票:0回答:1

我正在尝试在 Julia 中求解随机延迟微分方程。我没有成功地从手册中找出语法,所以我尝试运行一些示例。从here运行示例:

function hayes_modelf(du, u, h, p, t)
    τ, a, b, c, α, β, γ = p
    du .= a .* u .+ b .* h(p, t - τ) .+ c
end
function hayes_modelg(du, u, h, p, t)
    τ, a, b, c, α, β, γ = p
    du .= α .* u .+ γ
end
h(p, t) = (ones(1) .+ t);
tspan = (0.0, 10.0)

pmul = [1.0, -4.0, -2.0, 10.0, -1.3, -1.2, 1.1]
padd = [1.0, -4.0, -2.0, 10.0, -0.0, -0.0, 0.1]

prob = SDDEProblem(hayes_modelf, hayes_modelg, [1.0], h, tspan, pmul;
                   constant_lags = (pmul[1],));
sol = solve(prob, RKMil())

抛出一个让我困惑的错误。朱莉娅抱怨:

ERROR: LoadError: MethodError: no method matching default_algorithm(::SDDEProblem{Vector{Float64}, Tuple{Float64, Float64}, Tuple{Float64}, Tuple{}, true, Vector{Float64}, Nothing, SDDEFunction{true, SciMLBase.FullSpecialize, typeof(hayes_modelf), typeof(hayes_modelg), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, typeof(hayes_modelg), typeof(h), Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing})

Closest candidates are:
  default_algorithm(::SciMLBase.AbstractSDEProblem{uType, tType, isinplace, ND}; kwargs...) where {uType, tType, isinplace, ND}
   @ DifferentialEquations ~/.julia/packages/DifferentialEquations/nHZ7l/src/sde_default_alg.jl:1
  default_algorithm(::SciMLBase.AbstractDAEProblem{uType, duType, tType, isinplace}; kwargs...) where {uType, duType, tType, isinplace}
   @ DifferentialEquations ~/.julia/packages/DifferentialEquations/nHZ7l/src/dae_default_alg.jl:1
  default_algorithm(::SciMLBase.AbstractDDEProblem{uType, tType, lType, isinplace}; kwargs...) where {uType, tType, lType, isinplace}
   @ DifferentialEquations ~/.julia/packages/DifferentialEquations/nHZ7l/src/dde_default_alg.jl:1
  ...

我的代码以

using DifferentialEquations
开头,并且求解 DDE 和 ODE 按预期工作。

我可以从中收集到以下信息:求解函数需要不同类型的对象作为问题,我的问题是 SDDEProblem 但它需要类似 SciMLBse.AbstractSDEProblem(?)

我不确定我是否遗漏了某些内容,或者我是否应该在他们的 GitHub 上提出问题。任何帮助将不胜感激!

我尝试使用 Julia 中的 DifferentialEquations.jl 库求解 SDDE。由于我只是运行一个示例,因此我希望solve()函数返回一组元素,这些元素近似于Hayes模型的实际解决方案(或更准确地说,是它的一个特定实现)。

Julia 没有返回该值,而是抱怨 prob 对象的格式。我不明白为什么,因为我只是运行一个例子。

julia differential-equations differentialequations.jl
1个回答
0
投票

这是因为您需要不同的包来处理延迟微分方程。

using StochasticDelayDiffEq
应该可以解决问题。

© www.soinside.com 2019 - 2024. All rights reserved.