Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbolic remaking of jump problem errors #758

Closed
gaurav-arya opened this issue Jan 4, 2024 · 3 comments
Closed

Symbolic remaking of jump problem errors #758

gaurav-arya opened this issue Jan 4, 2024 · 3 comments
Labels

Comments

@gaurav-arya
Copy link
Member

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
@gaurav-arya gaurav-arya added the bug label Jan 4, 2024
@isaacsas
Copy link
Member

isaacsas commented Jan 4, 2024

This is from some bugs introduced when SciMLBase switched the symbolic indexing backend. You can see what @TorkelE reported there at SciML/SciMLBase.jl#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.

@gabo-di
Copy link

gabo-di commented Jan 4, 2024

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

@isaacsas
Copy link
Member

This is fixed on the V14 branch via changes to SciMLBase and SymbolicIndexingInterface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants