@ode_def macro leads to UndefRefError: access to undefined reference

Hi,
I tried to use the @ode_def macro, but somehow got stuck in an UndefRefError:

julia> sir_ode = @ode_def SIRModel begin
           dS = -β*S*I
           dI = β*S*I-γ*I
           dR = γ*I
           end β γ
┌ Warning: Symbolic calculations could not initiate. Likely there's a function which is not differentiable by SymEngine.
└ @ ParameterizedFunctions ~/.julia/packages/ParameterizedFunctions/WcTrd/src/ode_def_opts.jl:244
ERROR: LoadError: UndefRefError: access to undefined reference
Stacktrace:
 [1] getindex at ./array.jl:745 [inlined]
 [2] getindex at ./multidimensional.jl:486 [inlined]
 [3] _broadcast_getindex at ./broadcast.jl:596 [inlined]
 [4] _getindex at ./broadcast.jl:627 [inlined]
 [5] _broadcast_getindex at ./broadcast.jl:612 [inlined]
 [6] getindex at ./broadcast.jl:563 [inlined]
 [7] copyto_nonleaf!(::Array{Expr,2}, ::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2},Tuple{Base.OneTo{Int64},Base.OneTo{Int64}},typeof(convert),Tuple{Base.RefValue{Type{Expr}},Base.Broadcast.Extruded{Array{SymEngine.Basic,2},Tuple{Bool,Bool},Tuple{Int64,Int64}}}}, ::CartesianIndices{2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}, ::CartesianIndex{2}, ::Int64) at ./broadcast.jl:1003
 [8] copy at ./broadcast.jl:857 [inlined]
 [9] materialize at ./broadcast.jl:819 [inlined]
 [10] #ode_def_opts#1(::Symbol, ::typeof(ode_def_opts), ::Symbol, ::Dict{Symbol,Bool}, ::Expr, ::Symbol, ::Vararg{Symbol,N} where N) at /home/joerg/.julia/packages/ParameterizedFunctions/WcTrd/src/ode_def_opts.jl:295
 [11] ode_def_opts(::Symbol, ::Dict{Symbol,Bool}, ::Expr, ::Symbol, ::Vararg{Symbol,N} where N) at /home/joerg/.julia/packages/ParameterizedFunctions/WcTrd/src/ode_def_opts.jl:5
 [12] @ode_def(::LineNumberNode, ::Module, ::Any, ::Any, ::Vararg{Any,N} where N) at /home/joerg/.julia/packages/ParameterizedFunctions/WcTrd/src/macros.jl:11
in expression starting at REPL[5]:1

That syntax hasn’t existed for years. Where did you find it?

searching “ode_def SIRModel begin” brings me:

Cool. I contacted Simon and we’ll get it updated for years. In the meantime, I suggest you follow the tutorials,

https://docs.juliadiffeq.org/latest/tutorials/ode_example/

function sir_ode(du,u,p,t)
  S,I,R = u
  β,γ = p
  du[1] = -β*S*I
  du[2] = β*S*I-γ*I
  du[3] = γ*I
end
2 Likes

Thank you. So the entire macro is obsolete?
Because, I really found it everywhere…

Everywhere? Where else?

I mean, you can do using ParameterizedFunctions and it still exists as a separate package, but it’s quite limited so we don’t develop it anymore, and since it has binary dependencies we don’t ship it with DifferentialEquations.jl. It’s largely being replaced by ModelingToolkit and crew though.

Ah ok, yeah, thats what I did, which gave me the error above.
I guess, I saw it first in your video tutorials. I also searched for “parameter estimation ODE” and “julia” and found a reference to an old version of the documentation https://docs.juliadiffeq.org/v1.6/analysis/parameter_estimation.html (Of course, I did’t paid attention to the doc version, when I found this site… I found it out just now, that the site has moved ;-))
It seems to be a google problem, that ranks older sites higher…

Oh dang, we put stuff in the header to ensure the latest stable version is given higest priority, but :man_shrugging:I wonder if it takes a bit to kick in.

1 Like