Skip to content

ODEProblem construction crashing when converted from ReactionSystem #637

@isaacsas

Description

@isaacsas

On Catalyst master:

repressilator = @reaction_network begin
    hillr(P₃,α,K,n), ∅ --> m₁
    hillr(P₁,α,K,n), ∅ --> m₂
    hillr(P₂,α,K,n), ∅ --> m₃
    (δ,γ), m₁  ∅
    (δ,γ), m₂  ∅
    (δ,γ), m₃  ∅
    β, m₁ --> m₁ + P₁
    β, m₂ --> m₂ + P₂
    β, m₃ --> m₃ + P₃
    μ, P₁ --> ∅
    μ, P₂ --> ∅
    μ, P₃ -->end α K n δ γ β μ

odesys = convert(ODESystem, repressilator)
p = (.5, 40, 2, log(2)/120, 5e-3, 20*log(2)/120, log(2)/60)
u₀ = [0.,0.,0.,20.,0.,0.]
tspan = (0., 10000.)
oprob = ODEProblem(repressilator, u₀, tspan, p)

works but

u₀map  = Pair.(species(repressilator), u₀)
pmap   = Pair.(params(repressilator), p)
oprob2 = ODEProblem(osys, u₀map, tspan, pmap)

gives the following error

ERROR: ArgumentError: invalid index: nothing of type Nothing
Stacktrace:
 [1] to_index(::Nothing) at ./indices.jl:297
 [2] to_index(::Array{Float64,1}, ::Nothing) at ./indices.jl:274
 [3] to_indices at ./indices.jl:325 [inlined]
 [4] to_indices at ./indices.jl:322 [inlined]
 [5] setindex! at ./abstractarray.jl:1153 [inlined]
 [6] varmap_to_vars(::Array{Pair{Term{Real},Float64},1}, ::Array{Term{Real},1}) at /Users/isaacsas/.julia/packages/ModelingToolkit/tJisO/src/variables.jl:219
 [7] ODEProblem{true,tType,isinplace,P,F,K,PT} where PT where K where F where P where isinplace where tType(::ODESystem, ::Array{Pair{Term{Real},Float64},1}, ::Tuple{Float64,Float64}, ::Array{Pair{Sym{ModelingToolkit.Parameter{Real}},B} where B,1}; version::Nothing, tgrad::Bool, jac::Bool, checkbounds::Bool, sparse::Bool, simplify::Bool, linenumbers::Bool, parallel::ModelingToolkit.SerialForm, eval_expression::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/isaacsas/.julia/packages/ModelingToolkit/tJisO/src/systems/diffeqs/abstractodesystem.jl:270
 [8] ODEProblem{true,tType,isinplace,P,F,K,PT} where PT where K where F where P where isinplace where tType(::ODESystem, ::Array{Pair{Term{Real},Float64},1}, ::Tuple{Float64,Float64}, ::Array{Pair{Sym{ModelingToolkit.Parameter{Real}},B} where B,1}) at /Users/isaacsas/.julia/packages/ModelingToolkit/tJisO/src/systems/diffeqs/abstractodesystem.jl:267
 [9] ODEProblem(::ODESystem, ::Array{Pair{Term{Real},Float64},1}, ::Vararg{Any,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/isaacsas/.julia/packages/ModelingToolkit/tJisO/src/systems/diffeqs/abstractodesystem.jl:240
 [10] ODEProblem(::ODESystem, ::Array{Pair{Term{Real},Float64},1}, ::Vararg{Any,N} where N) at /Users/isaacsas/.julia/packages/ModelingToolkit/tJisO/src/systems/diffeqs/abstractodesystem.jl:240
 [11] top-level scope at REPL[76]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions