SciML / FiniteStateProjection.jl

Finite State Projection algorithms for chemical reaction networks
MIT License
18 stars 7 forks source link

Seems to be a bug, but not sure... #14

Open xuelx1 opened 5 months ago

xuelx1 commented 5 months ago

Describe the bug 🐞

Examples given, Birth-Death System and Telegraph Model, doesn't work well.

When I run Birth-Death System one line after another, it goes right until the last line "sol = solve(prob, Vern7())", and it comes" LoadError: BoundsError: attempt to access Tuple{Int64} at index [2]"

Same thing happens when I tried Telegraph Model, but this time, "ERROR: LoadError: BoundsError: attempt to access Tuple{Int64, Int64} at index [3]"

Error & Stacktrace ⚠️

ERROR: LoadError: BoundsError: attempt to access Tuple{Int64, Int64} at index [3]
Stacktrace:
  [1] getindex
    @ .\tuple.jl:31 [inlined]
  [2] getindex
    @ .\multidimensional.jl:98 [inlined]
  [3] macro expansion
    @ C:\Users\xlx\.julia\packages\RuntimeGeneratedFunctions\Yo8zx\src\RuntimeGeneratedFunctions.jl:163 [inlined]
  [4] macro expansion
    @ .\none:0 [inlined]
  [5] generated_callfunc
    @ .\none:0 [inlined]
  [6] (::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:du, :u, :p, :t), FiniteStateProjection.var"#_RGF_ModTag", FiniteStateProjection.var"#_RGF_ModTag", (0xbf4759ff, 0xd5f410d0, 0xba16b9ab, 0x61ffe46e, 0xd93d7742), Expr})(::Matrix{Float64}, ::Matrix{Float64}, ::Vector{Float64}, ::Float64)
    @ RuntimeGeneratedFunctions C:\Users\xlx\.julia\packages\RuntimeGeneratedFunctions\Yo8zx\src\RuntimeGeneratedFunctions.jl:150
  [7] (::ODEFunction{true, SciMLBase.FullSpecialize, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:du, :u, :p, :t), FiniteStateProjection.var"#_RGF_ModTag", FiniteStateProjection.var"#_RGF_ModTag", (0xbf4759ff, 0xd5f410d0, 0xba16b9ab, 0x61ffe46e, 0xd93d7742), Expr}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing})(::Matrix{Float64}, ::Vararg{Any})
    @ SciMLBase C:\Users\xlx\.julia\packages\SciMLBase\szsYq\src\scimlfunctions.jl:2266
  [8] ode_determine_initdt(u0::Matrix{Float64}, t::Float64, tdir::Float64, dtmax::Float64, abstol::Float64, reltol::Float64, internalnorm::typeof(DiffEqBase.ODE_DEFAULT_NORM), prob::ODEProblem{Matrix{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, SciMLBase.FullSpecialize, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:du, :u, :p, :t), FiniteStateProjection.var"#_RGF_ModTag", FiniteStateProjection.var"#_RGF_ModTag", (0xbf4759ff, 0xd5f410d0, 0xba16b9ab, 0x61ffe46e, 0xd93d7742), Expr}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, integrator::OrdinaryDiffEq.ODEIntegrator{Vern7{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, true, Matrix{Float64}, Nothing, Float64, Vector{Float64}, Float64, Float64, Float64, Float64, Vector{Matrix{Float64}}, ODESolution{Float64, 3, Vector{Matrix{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Matrix{Float64}}}, ODEProblem{Matrix{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, SciMLBase.FullSpecialize, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:du, :u, :p, :t), FiniteStateProjection.var"#_RGF_ModTag", FiniteStateProjection.var"#_RGF_ModTag", (0xbf4759ff, 0xd5f410d0, 0xba16b9ab, 0x61ffe46e, 0xd93d7742), Expr}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, Vern7{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{ODEFunction{true, SciMLBase.FullSpecialize, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:du, :u, :p, :t), FiniteStateProjection.var"#_RGF_ModTag", FiniteStateProjection.var"#_RGF_ModTag", (0xbf4759ff, 0xd5f410d0, 0xba16b9ab, 0x61ffe46e, 0xd93d7742), Expr}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Vector{Matrix{Float64}}, Vector{Float64}, Vector{Vector{Matrix{Float64}}}, OrdinaryDiffEq.Vern7Cache{Matrix{Float64}, Matrix{Float64}, Matrix{Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, DiffEqBase.Stats, Nothing}, ODEFunction{true, SciMLBase.FullSpecialize, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:du, :u, :p, :t), FiniteStateProjection.var"#_RGF_ModTag", FiniteStateProjection.var"#_RGF_ModTag", (0xbf4759ff, 0xd5f410d0, 0xba16b9ab, 0x61ffe46e, 0xd93d7742), Expr}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, OrdinaryDiffEq.Vern7Cache{Matrix{Float64}, Matrix{Float64}, Matrix{Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.DEOptions{Float64, Float64, Float64, Float64, PIController{Rational{Int64}}, typeof(DiffEqBase.ODE_DEFAULT_NORM), typeof(LinearAlgebra.opnorm), Nothing, CallbackSet{Tuple{}, Tuple{}}, typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, Nothing, Nothing, Int64, Tuple{}, Tuple{}, Tuple{}}, Matrix{Float64}, Float64, Nothing, OrdinaryDiffEq.DefaultInit})
    @ OrdinaryDiffEq C:\Users\xlx\.julia\packages\OrdinaryDiffEq\FFFcA\src\initdt.jl:53
  [9] auto_dt_reset!
    @ C:\Users\xlx\.julia\packages\OrdinaryDiffEq\FFFcA\src\integrators\integrator_interface.jl:449 [inlined]
 [10] handle_dt!(integrator::OrdinaryDiffEq.ODEIntegrator{Vern7{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, true, Matrix{Float64}, Nothing, Float64, Vector{Float64}, Float64, Float64, Float64, Float64, Vector{Matrix{Float64}}, ODESolution{Float64, 3, Vector{Matrix{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Matrix{Float64}}}, ODEProblem{Matrix{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, SciMLBase.FullSpecialize, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:du, :u, :p, :t), FiniteStateProjection.var"#_RGF_ModTag", FiniteStateProjection.var"#_RGF_ModTag", (0xbf4759ff, 0xd5f410d0, 0xba16b9ab, 0x61ffe46e, 0xd93d7742), Expr}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, Vern7{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{ODEFunction{true, SciMLBase.FullSpecialize, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:du, :u, :p, :t), FiniteStateProjection.var"#_RGF_ModTag", FiniteStateProjection.var"#_RGF_ModTag", (0xbf4759ff, 0xd5f410d0, 0xba16b9ab, 0x61ffe46e, 0xd93d7742), Expr}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Vector{Matrix{Float64}}, Vector{Float64}, Vector{Vector{Matrix{Float64}}}, OrdinaryDiffEq.Vern7Cache{Matrix{Float64}, Matrix{Float64}, Matrix{Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, DiffEqBase.Stats, Nothing}, ODEFunction{true, SciMLBase.FullSpecialize, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:du, :u, :p, :t), FiniteStateProjection.var"#_RGF_ModTag", FiniteStateProjection.var"#_RGF_ModTag", (0xbf4759ff, 0xd5f410d0, 0xba16b9ab, 0x61ffe46e, 0xd93d7742), Expr}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, OrdinaryDiffEq.Vern7Cache{Matrix{Float64}, Matrix{Float64}, Matrix{Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.DEOptions{Float64, Float64, Float64, Float64, PIController{Rational{Int64}}, typeof(DiffEqBase.ODE_DEFAULT_NORM), typeof(LinearAlgebra.opnorm), Nothing, CallbackSet{Tuple{}, Tuple{}}, typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, Nothing, Nothing, Int64, Tuple{}, Tuple{}, Tuple{}}, Matrix{Float64}, Float64, Nothing, OrdinaryDiffEq.DefaultInit})
    @ OrdinaryDiffEq C:\Users\xlx\.julia\packages\OrdinaryDiffEq\FFFcA\src\solve.jl:555
 [11] __init(prob::ODEProblem{Matrix{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, SciMLBase.FullSpecialize, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:du, :u, :p, :t), FiniteStateProjection.var"#_RGF_ModTag", FiniteStateProjection.var"#_RGF_ModTag", (0xbf4759ff, 0xd5f410d0, 0xba16b9ab, 0x61ffe46e, 0xd93d7742), Expr}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, alg::Vern7{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, timeseries_init::Tuple{}, ts_init::Tuple{}, ks_init::Tuple{}, recompile::Type{Val{true}}; saveat::Tuple{}, tstops::Tuple{}, d_discontinuities::Tuple{}, save_idxs::Nothing, save_everystep::Bool, save_on::Bool, save_start::Bool, save_end::Nothing, callback::Nothing, dense::Bool, calck::Bool, dt::Float64, dtmin::Nothing, dtmax::Float64, force_dtmin::Bool, adaptive::Bool, gamma::Rational{Int64}, abstol::Nothing, reltol::Nothing, qmin::Rational{Int64}, qmax::Int64, qsteady_min::Int64, qsteady_max::Int64, beta1::Nothing, beta2::Nothing, qoldinit::Rational{Int64}, controller::Nothing, fullnormalize::Bool, failfactor::Int64, maxiters::Int64, internalnorm::typeof(DiffEqBase.ODE_DEFAULT_NORM), internalopnorm::typeof(LinearAlgebra.opnorm), isoutofdomain::typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), unstable_check::typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), verbose::Bool, timeseries_errors::Bool, dense_errors::Bool, advance_to_tstop::Bool, stop_at_next_tstop::Bool, initialize_save::Bool, progress::Bool, progress_steps::Int64, progress_name::String, progress_message::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), progress_id::Symbol, userdata::Nothing, allow_extrapolation::Bool, initialize_integrator::Bool, alias_u0::Bool, alias_du0::Bool, initializealg::OrdinaryDiffEq.DefaultInit, kwargs::@Kwargs{})
    @ OrdinaryDiffEq C:\Users\xlx\.julia\packages\OrdinaryDiffEq\FFFcA\src\solve.jl:517
 [12] __init (repeats 5 times)
    @ C:\Users\xlx\.julia\packages\OrdinaryDiffEq\FFFcA\src\solve.jl:10 [inlined]
 [13] #__solve#740
    @ C:\Users\xlx\.julia\packages\OrdinaryDiffEq\FFFcA\src\solve.jl:5 [inlined]
 [14] __solve
    @ C:\Users\xlx\.julia\packages\OrdinaryDiffEq\FFFcA\src\solve.jl:1 [inlined]
 [15] solve_call(_prob::Any, args::Vararg{Any}; merge_callbacks::Any, kwargshandle::Any, kwargs...)
    @ DiffEqBase C:\Users\xlx\.julia\packages\DiffEqBase\s433k\src\solve.jl:559 [inlined]
 [16] solve_call
    @ C:\Users\xlx\.julia\packages\DiffEqBase\s433k\src\solve.jl:529 [inlined]
 [17] solve_up(prob::ODEProblem{Matrix{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, SciMLBase.FullSpecialize, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:du, :u, :p, :t), FiniteStateProjection.var"#_RGF_ModTag", FiniteStateProjection.var"#_RGF_ModTag", (0xbf4759ff, 0xd5f410d0, 0xba16b9ab, 0x61ffe46e, 0xd93d7742), Expr}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, sensealg::Nothing, u0::Matrix{Float64}, p::Vector{Float64}, args::Vern7{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}; kwargs::@Kwargs{})
    @ DiffEqBase C:\Users\xlx\.julia\packages\DiffEqBase\s433k\src\solve.jl:1020
 [18] solve_up
    @ DiffEqBase C:\Users\xlx\.julia\packages\DiffEqBase\s433k\src\solve.jl:993 [inlined]
 [19] #solve#40
    @ DiffEqBase C:\Users\xlx\.julia\packages\DiffEqBase\s433k\src\solve.jl:930 [inlined]
 [20] solve(prob::ODEProblem{Matrix{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, SciMLBase.FullSpecialize, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:du, :u, :p, :t), FiniteStateProjection.var"#_RGF_ModTag", FiniteStateProjection.var"#_RGF_ModTag", (0xbf4759ff, 0xd5f410d0, 0xba16b9ab, 0x61ffe46e, 0xd93d7742), Expr}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, args::Vern7{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False})
    @ DiffEqBase C:\Users\xlx\.julia\packages\DiffEqBase\s433k\src\solve.jl:920
 [21] top-level scope
    @ D:\HuaweiMoveData\Users\xlx\Desktop\创\julia\test2.jl:22

Environment (please complete the following information):

kaandocal commented 5 months ago

Hi @xuelx1, I think you ran into some versioning issue that should have been resolved much earlier. The updated version 0.3 of this package is out just now and should fix this - could you please try to re-run the code after updating FSP.jl and let me know if it works? Thanks!