Catalyst.jl
Catalyst.jl copied to clipboard
Symbolic remaking of jump problem errors
MWE:
using Catalyst
using JumpProcesses
rn = @reaction_network begin
k, X --> ∅
end
@unpack k = rn # NB: if I use rn.k directly below, I get a different error even in construction which I don't understand, but that's probably a separate issue.
op = ODEProblem(rn, [1.0], (0.0, 1.0), [k => 1.0])
remake(op; p = [k => 3.0]) # works fine
dp = DiscreteProblem(rn, [1.0], (0.0, 1.0), [k => 1.0])
jp = JumpProblem(rn, dp, Direct())
remake(jp; p = [k => 3.0]) # error
Version info:
[479239e8] Catalyst v13.5.1
[ccbc3e58] JumpProcesses v9.10.1
Error:
ERROR: MethodError: Cannot `convert` an object of type Pair{Num, Float64} to an object of type Float64
Closest candidates are:
convert(::Type{T}, ::DualNumbers.Dual) where T<:Union{Real, Complex}
@ DualNumbers ~/.julia/packages/DualNumbers/5knFX/src/dual.jl:24
convert(::Type{T}, ::VectorizationBase.AbstractSIMD) where T<:Union{Bool, Float16, Float32, Float64, Int16, Int32, Int64, Int8, UInt16, UInt32, UInt64, UInt8, SIMDTypes.Bit}
@ VectorizationBase ~/.julia/packages/VectorizationBase/xE5Tx/src/base_defs.jl:201
convert(::Type{T}, ::Union{Static.StaticBool{N}, Static.StaticFloat64{N}, Static.StaticInt{N}} where N) where T<:Number
@ Static ~/.julia/packages/Static/dLrtk/src/Static.jl:414
...
Stacktrace:
[1] setindex!(h::Dict{…}, v0::Pair{…}, key::SymbolicUtils.BasicSymbolic{…})
@ Base ./dict.jl:376
[2] updateparams!(ratemap::ModelingToolkit.JumpSysMajParamMapper{Vector{…}, Vector{…}, Float64}, params::Vector{Pair{…}})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/arrCl/src/systems/jumps/jumpsystem.jl:479
[3] (::ModelingToolkit.JumpSysMajParamMapper{…})(maj::MassActionJump{…}, newparams::Vector{…}; scale_rates::Bool, kwargs::@Kwargs{…})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/arrCl/src/systems/jumps/jumpsystem.jl:506
[4] JumpSysMajParamMapper
@ ~/.julia/packages/ModelingToolkit/arrCl/src/systems/jumps/jumpsystem.jl:502 [inlined]
[5] #update_parameters!#14
@ ~/.julia/packages/JumpProcesses/HPjOl/src/jumps.jl:450 [inlined]
[6] update_parameters!
@ ~/.julia/packages/JumpProcesses/HPjOl/src/jumps.jl:447 [inlined]
[7] remake(thing::JumpProblem{…}; kwargs::@Kwargs{…})
@ JumpProcesses ~/.julia/packages/JumpProcesses/HPjOl/src/problem.jl:104
This is from some bugs introduced when SciMLBase switched the symbolic indexing backend. You can see what @TorkelE reported there at https://github.com/SciML/SciMLBase.jl/issues/581
They should hopefully get fixed soon in SciMLbase and this should work again, but in the meantime I’d suggest manually adding and downgrading SciMLBase.
maybe you can add the following code into ~/.julia/packages/ModelingToolkit/arrCl/src/systems/jumps/jumpsystem.jl around line 479
function updateparams!(ratemap::JumpSysMajParamMapper{U, V, W},
params::Vector{Pair{Num,T}}) where {U <: AbstractArray, V <: AbstractArray, W, T}
for (i, p) in enumerate(params)
sympar = ratemap.sympars[i]
ratemap.subdict[sympar] = Dict(p)[sympar]
end
nothing
end
just for the moment
This is fixed on the V14 branch via changes to SciMLBase and SymbolicIndexingInterface.