Skip to content

remake no longer works for ODE-jump models #3571

Closed
@isaacsas

Description

@isaacsas

The following worked on 9.69 but does not work on 9.72:

using ModelingToolkit, JumpProcesses
t = ModelingToolkit.t_nounits
D = ModelingToolkit.D_nounits
@variables X(t)
@parameters a b
eq = D(X) ~ a
rate = b*X
affect = [X ~ X - 1]
crj = ConstantRateJump(rate, affect)
@named jsys = JumpSystem([crj, eq], t, [X], [a,b])
jsys = complete(jsys)
oprob = ODEProblem(jsys, [:X => 1.0], (0.0, 10.0), [:a => 1.0, :b => .5])
jprob = JumpProblem(jsys, oprob)  
jprob2 = remake(jprob; u0 = [:X => 10.0]) 

gives

ERROR: UndefVarError: `X(t)` not defined in local scope
Suggestion: check for an assignment to a local variable that shadows a global of the same name.
Stacktrace:
  [1] macro expansion
    @ ~/.julia/packages/SymbolicUtils/NGWJM/src/code.jl:411 [inlined]
  [2] macro expansion
    @ ~/.julia/packages/Symbolics/B6Z8m/src/build_function.jl:366 [inlined]
  [3] macro expansion
    @ ~/.julia/packages/RuntimeGeneratedFunctions/M9ZX8/src/RuntimeGeneratedFunctions.jl:163 [inlined]
  [4] macro expansion
    @ ./none:0 [inlined]
  [5] generated_callfunc
    @ ./none:0 [inlined]
  [6] (::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{…})(::Nothing, ::MTKParameters{…})
    @ RuntimeGeneratedFunctions ~/.julia/packages/RuntimeGeneratedFunctions/M9ZX8/src/RuntimeGeneratedFunctions.jl:150
  [7] macro expansion
    @ ~/.julia/packages/ModelingToolkit/aau6A/src/systems/codegen_utils.jl:0 [inlined]
  [8] _generated_call(::ModelingToolkit.GeneratedFunctionWrapper{…}, ::Nothing, ::MTKParameters{…})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/aau6A/src/systems/codegen_utils.jl:262
  [9] (::ModelingToolkit.GeneratedFunctionWrapper{…})(::Nothing, ::Vararg{…})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/aau6A/src/systems/codegen_utils.jl:259
 [10] (::SymbolicIndexingInterface.TimeIndependentObservedFunction{…})(::SymbolicIndexingInterface.NotTimeseries, prob::NonlinearProblem{…})
    @ SymbolicIndexingInterface ~/.julia/packages/SymbolicIndexingInterface/3UAF0/src/state_indexing.jl:142
 [11] (::SymbolicIndexingInterface.TimeIndependentObservedFunction{…})(prob::NonlinearProblem{…})
    @ SymbolicIndexingInterface ~/.julia/packages/SymbolicIndexingInterface/3UAF0/src/value_provider_interface.jl:166
 [12] call_composed(fs::Tuple{…}, x::Tuple{…}, kw::@Kwargs{})
    @ Base ./operators.jl:1054
 [13] call_composed
    @ ./operators.jl:1053 [inlined]
 [14] (::ComposedFunction{…})(x::NonlinearProblem{…}; kw::@Kwargs{})
    @ Base ./operators.jl:1050
 [15] get_initial_values(prob::ODEProblem{…}, valp::ODEProblem{…}, f::Function, alg::SciMLBase.OverrideInit{…}, iip::Val{…}; nlsolve_alg::Nothing, abstol::Nothing, reltol::Nothing, kwargs::@Kwargs{})
    @ SciMLBase ~/.julia/packages/SciMLBase/c6Noy/src/initialization.jl:277
 [16] get_initial_values(prob::ODEProblem{…}, valp::ODEProblem{…}, f::Function, alg::SciMLBase.OverrideInit{…}, iip::Val{…})
    @ SciMLBase ~/.julia/packages/SciMLBase/c6Noy/src/initialization.jl:234
 [17] maybe_eager_initialize_problem(prob::ODEProblem{…}, initialization_data::SciMLBase.OverrideInitData{…}, lazy_initialization::Nothing)
    @ SciMLBase ~/.julia/packages/SciMLBase/c6Noy/src/remake.jl:1167
 [18] remake(prob::ODEProblem{…}; f::Missing, u0::Vector{…}, tspan::Missing, p::Missing, kwargs::Missing, interpret_symbolicmap::Bool, build_initializeprob::Type, use_defaults::Bool, lazy_initialization::Nothing, _kwargs::@Kwargs{})
    @ SciMLBase ~/.julia/packages/SciMLBase/c6Noy/src/remake.jl:266
 [19] remake(jprob::JumpProblem{…}; kwargs::@Kwargs{…})
    @ JumpProcesses ~/.julia/packages/JumpProcesses/9lwA6/src/problem.jl:126
 [20] top-level scope
    @ REPL[15]:1
Some type information was truncated. Use `show(err)` to see complete types.

The same error about X(t) is given if one tries to update a parameter

jprob2 = remake(jprob; p = [:a => 10.0])

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions