Domain ERROR issue in differential equation system

I have a model where in equation I have something like A^n where A is a state and n is a parameter. Now the issue is when I know that initial state values and parameters are positive I should not get a domain error. Only possible option I see at the moment is due to overflow issue as in my model state initial condition varies from very small to big numbers. I suspect somewhere in multiplication in equations making A negative so when it goes in A^n it gives a domain error. Is there any way to avoid such issue. like defining variable type beforehand for states ? I tried big() but its not accepted I guess.

If you use NaNMath.jl you’ll get a NaN instead which the differential equation solver will recover from. This is suggested by the error message.

After using NaNmath, I don’t get error anymore but also I don’t get any solution. I have this condition to check solution if not, predicted stays a vector of 0. So, at the moment im only getting zeros when i print.

if SciMLBase.successful_retcode(sol.retcode)  == 1
      predicted[i] = sol'[16,6] 
     end

Print the retcode?

I’m getting this warning and error :

β”Œ Warning: Instability detected. Aborting
β”” @ SciMLBase ~/.julia/packages/SciMLBase/qp2gL/src/integrator_interface.jl:606
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

ArgumentError: matrix contains Infs or NaNs

Have you checked whether the move to zero makes sense given the properties of the equation you have written down?

I don’t give A value 0. if that u meant. Previously i was just checking solution success and collecting desired values from solution which is working fine during inference but while plotting it throws domain error and thats why I put the question.

So, predicted vector is something like this [0, 0, 0, 0, 0] where I collect resultant values from my solution of differential equations system for some specific state. Upon checking if solution is success it collects values otherwise it stay same as [0, 0, 0, 0, 0] which I plot. So, when everything is working fine I see simulated lines with data points.

Yes that’s because you setup the optimization to do that. You should have an else predicted[i] .= NaN branch for safety. But the bigger issue is that the value in the equation goes negative.

For inference I reject the particle if solution is not success but major confusion is that domain error comes at stage of solving right? so even before it can test solution for success then why I don’t see domain error issue while inference if I have similar setup for model simulation while I see in case of plotting?

NaNMath will make it not error, and then .= Inf or .= NaN would make it reject the step. But if you don’t put anything into predicted then it’ll just be zero.

I added your suggestion.

Getting this error

ArgumentError: matrix contains Infs or NaNs

Stacktrace:
  [1] chkfinite
    @ /Volumes/Julia-1.9.0-rc2/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/LinearAlgebra/src/lapack.jl:86 [inlined]
  [2] generic_lufact!(A::Matrix{Float64}, pivot::RowMaximum; check::Bool)
    @ LinearAlgebra /Volumes/Julia-1.9.0-rc2/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/LinearAlgebra/src/lu.jl:135
  [3] generic_lufact!
    @ /Volumes/Julia-1.9.0-rc2/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/LinearAlgebra/src/lu.jl:133 [inlined]
  [4] do_factorization
    @ ~/.julia/packages/LinearSolve/7ER8k/src/factorization.jl:65 [inlined]
  [5] #solve#6
    @ ~/.julia/packages/LinearSolve/7ER8k/src/factorization.jl:11 [inlined]
  [6] solve
    @ ~/.julia/packages/LinearSolve/7ER8k/src/factorization.jl:9 [inlined]
  [7] #solve#5
    @ ~/.julia/packages/LinearSolve/7ER8k/src/common.jl:161 [inlined]
  [8] solve
    @ ~/.julia/packages/LinearSolve/7ER8k/src/common.jl:160 [inlined]
  [9] #dolinsolve#3
    @ ~/.julia/packages/OrdinaryDiffEq/vIqLB/src/misc_utils.jl:109 [inlined]
 [10] dolinsolve
    @ ~/.julia/packages/OrdinaryDiffEq/vIqLB/src/misc_utils.jl:83 [inlined]
 [11] perform_step!(integrator::OrdinaryDiffEq.ODEIntegrator{Rodas4{1, true, GenericLUFactorization{RowMaximum}, typeof(OrdinaryDiffEq.DEFAULT_PRECS), Val{:forward}, true, nothing}, true, Vector{Float64}, Nothing, Float64, Vector{Float64}, Float64, Float64, Float64, Float64, Vector{Vector{Float64}}, ODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, Rodas4{1, true, GenericLUFactorization{RowMaximum}, typeof(OrdinaryDiffEq.DEFAULT_PRECS), Val{:forward}, true, nothing}, OrdinaryDiffEq.InterpolationData{ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, OrdinaryDiffEq.Rodas4Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, Matrix{Float64}, Matrix{Float64}, OrdinaryDiffEq.RodasTableau{Float64, Float64}, SciMLBase.TimeGradientWrapper{ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Vector{Float64}, Vector{Float64}}, SciMLBase.UJacobianWrapper{ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Float64, Vector{Float64}}, LinearSolve.LinearCache{Matrix{Float64}, Vector{Float64}, Vector{Float64}, SciMLBase.NullParameters, GenericLUFactorization{RowMaximum}, LU{Float64, Matrix{Float64}, Vector{Int64}}, LinearSolve.InvPreconditioner{Diagonal{Float64, Vector{Float64}}}, Diagonal{Float64, Vector{Float64}}, Float64, true}, SparseDiffTools.ForwardColorJacCache{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Vector{Tuple{Float64}}}, UnitRange{Int64}, Nothing}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Float64, Rodas4{1, true, GenericLUFactorization{RowMaximum}, typeof(OrdinaryDiffEq.DEFAULT_PRECS), Val{:forward}, true, nothing}}}, DiffEqBase.DEStats, Nothing}, ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, OrdinaryDiffEq.Rodas4Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, Matrix{Float64}, Matrix{Float64}, OrdinaryDiffEq.RodasTableau{Float64, Float64}, SciMLBase.TimeGradientWrapper{ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Vector{Float64}, Vector{Float64}}, SciMLBase.UJacobianWrapper{ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Float64, Vector{Float64}}, LinearSolve.LinearCache{Matrix{Float64}, Vector{Float64}, Vector{Float64}, SciMLBase.NullParameters, GenericLUFactorization{RowMaximum}, LU{Float64, Matrix{Float64}, Vector{Int64}}, LinearSolve.InvPreconditioner{Diagonal{Float64, Vector{Float64}}}, Diagonal{Float64, Vector{Float64}}, Float64, true}, SparseDiffTools.ForwardColorJacCache{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Vector{Tuple{Float64}}}, UnitRange{Int64}, Nothing}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Float64, Rodas4{1, true, GenericLUFactorization{RowMaximum}, typeof(OrdinaryDiffEq.DEFAULT_PRECS), Val{:forward}, true, nothing}}, OrdinaryDiffEq.DEOptions{Float64, Float64, Float64, Float64, PIController{Rational{Int64}}, typeof(DiffEqBase.ODE_DEFAULT_NORM), typeof(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{}, Int64, Tuple{}}, Vector{Float64}, Float64, Nothing, OrdinaryDiffEq.DefaultInit}, cache::OrdinaryDiffEq.Rodas4Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, Matrix{Float64}, Matrix{Float64}, OrdinaryDiffEq.RodasTableau{Float64, Float64}, SciMLBase.TimeGradientWrapper{ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Vector{Float64}, Vector{Float64}}, SciMLBase.UJacobianWrapper{ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Float64, Vector{Float64}}, LinearSolve.LinearCache{Matrix{Float64}, Vector{Float64}, Vector{Float64}, SciMLBase.NullParameters, GenericLUFactorization{RowMaximum}, LU{Float64, Matrix{Float64}, Vector{Int64}}, LinearSolve.InvPreconditioner{Diagonal{Float64, Vector{Float64}}}, Diagonal{Float64, Vector{Float64}}, Float64, true}, SparseDiffTools.ForwardColorJacCache{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Vector{Tuple{Float64}}}, UnitRange{Int64}, Nothing}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Float64, Rodas4{1, true, GenericLUFactorization{RowMaximum}, typeof(OrdinaryDiffEq.DEFAULT_PRECS), Val{:forward}, true, nothing}}, repeat_step::Bool)
    @ OrdinaryDiffEq ~/.julia/packages/OrdinaryDiffEq/vIqLB/src/perform_step/rosenbrock_perform_step.jl:1237
...
    @ ~/.julia/packages/DiffEqBase/wtukj/src/solve.jl:892 [inlined]
 [19] solve(prob::ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, SciMLBase.AutoSpecialize, typeof(CTL), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, args::Rodas4{0, true, Nothing, typeof(OrdinaryDiffEq.DEFAULT_PRECS), Val{:forward}, true, nothing}; sensealg::Nothing, u0::Nothing, p::Nothing, wrap::Val{true}, kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:saveat,), Tuple{Int64}}})
    @ DiffEqBase ~/.julia/packages/DiffEqBase/wtukj/src/solve.jl:829
 [20] top-level scope
    @ ./In[69]:65

I’ll patch that to be less aggressive. For now, change the solver to something like TRBDF2(linsolve=LUFactorization()) (requires using LinearSove) and see if that is fine.

I tried not working. what you meant by this - β€œI’ll patch that to be less aggressive.” I didn’t get.

I’m still getting : error - **Matrix conatains NaN or Inf * which make sense because of using NaNMath there must be NaN values right?

So, in a way…before it was domain error now this matrix error…

The fix is in OrdinaryDiffEq v6.53 which I just released this morning. If you update you shouldn’t get the domain error there anymore and that should help. Let me know if you’re still hitting an issue. If you can post code that I can test that would be helpful.

Getting this when I’m trying to update

ERROR: Unsatisfiable requirements detected for package OrdinaryDiffEq [1dea7af3]:
 OrdinaryDiffEq [1dea7af3] log:
 β”œβ”€possible versions are: 4.0.0-6.52.0 or uninstalled
 └─restricted to versions 6.53 by an explicit requirement β€” no versions left

I think you might’ve updated before the release merged, since the Pkg merge was 3 hours ago and your response was 4 hours ago. New version: OrdinaryDiffEq v6.53.0 by JuliaRegistrator Β· Pull Request #85046 Β· JuliaRegistries/General Β· GitHub. Give it another try?

still getting same error.

ERROR: Unsatisfiable requirements detected for package OrdinaryDiffEq [1dea7af3]:
 OrdinaryDiffEq [1dea7af3] log:
 β”œβ”€possible versions are: 4.0.0-6.52.0 or uninstalled
 └─restricted to versions 6.53 by an explicit requirement β€” no versions left

Did you run ]up first? It needs the updated registry to then grab the new version.

when I did ]up and it showed precomplie error around ordinaryDiffEq

 Progress [=====================================>   ]  72/78
  β—“ OrdinaryDiffEq
β”Œ Error: Pkg.precompile error
β”‚   exception =
β”‚    ArgumentError: Number of elements must be nonnegative
β”‚    Stacktrace:
β”‚     [1] last(v::Vector{Base.PkgId}, n::Int64)
β”‚       @ Base ./abstractarray.jl:548
β”‚     [2] (::Pkg.API.var"#241#272"{Int64, Pkg.MiniProgressBars.MiniProgressBar, Vector{String}, Bool, Pkg.Types.Context, String, String, Pkg.API.var"#ansi_moveup#267", Pkg.API.var"#color_string#266", Base.Event, Vector{Base.PkgId}, Dict{Base.PkgId, String}, Vector{Base.PkgId}, Dict{Base.PkgId, Bool}, Dict{Base.PkgId, Bool}, Dict{Base.PkgId, String}, Vector{Base.PkgId}, Base.TTY})()
β”‚       @ Pkg.API /snap/julia/76/share/julia/stdlib/v1.9/Pkg/src/API.jl:1316
β”‚     [3] lock(f::Pkg.API.var"#241#272"{Int64, Pkg.MiniProgressBars.MiniProgressBar, Vector{String}, Bool, Pkg.Types.Context, String, String, Pkg.API.var"#ansi_moveup#267", Pkg.API.var"#color_string#266", Base.Event, Vector{Base.PkgId}, Dict{Base.PkgId, String}, Vector{Base.PkgId}, Dict{Base.PkgId, Bool}, Dict{Base.PkgId, Bool}, Dict{Base.PkgId, String}, Vector{Base.PkgId}, Base.TTY}, l::ReentrantLock)
β”‚       @ Base ./lock.jl:229
β”‚     [4] macro expansion
β”‚       @ /snap/julia/76/share/julia/stdlib/v1.9/Pkg/src/API.jl:1312 [inlined]
β”‚     [5] (::Pkg.API.var"#239#270"{Bool, Pkg.Types.Context, String, String, String, String, Pkg.API.var"#ansi_moveup#267", Pkg.API.var"#color_string#266", Base.Event, Base.Event, ReentrantLock, Vector{Base.PkgId}, Dict{Base.PkgId, String}, Vector{Base.PkgId}, Dict{Base.PkgId, Bool}, Dict{Base.PkgId, Bool}, Dict{Base.PkgId, Vector{Base.PkgId}}, Dict{Base.PkgId, String}, Vector{Base.PkgId}, Bool, Base.TTY})()
β”‚       @ Pkg.API ./task.jl:514
β”” @ Pkg.API /snap/julia/76/share/julia/stdlib/v1.9/Pkg/src/API.jl:1289

  1 dependency had warnings during precompilation:
β”Œ AdvancedVI [b5ca4192-6429-45e5-a2d9-87aec30a685c]
β”‚  β”Œ Warning: Module DistributionsADForwardDiffExt with build ID fafbfcfd-a1f5-62e4-0009-47334916e79c is missing from the cache.
β”‚  β”‚ This may mean DistributionsADForwardDiffExt [95af61a0-22df-51ed-b826-bfe4426ad132] does not support precompilation but is imported by a module that does.
β”‚  β”” @ Base loading.jl:1758
β”‚  β”Œ Error: Error during loading of extension DistributionsADForwardDiffExt of DistributionsAD, use `Base.retry_load_extensions()` to retry.
β”‚  β”‚   exception =
β”‚  β”‚    1-element ExceptionStack:
β”‚  β”‚    Declaring __precompile__(false) is not allowed in files that are being precompiled.
β”‚  β”‚    Stacktrace:
β”‚  β”‚      [1] _require(pkg::Base.PkgId, env::Nothing)
β”‚  β”‚        @ Base ./loading.jl:1762
β”‚  β”‚      [2] _require_prelocked(uuidkey::Base.PkgId, env::Nothing)
β”‚  β”‚        @ Base ./loading.jl:1625
β”‚  β”‚      [3] _require_prelocked(uuidkey::Base.PkgId)
β”‚  β”‚        @ Base ./loading.jl:1623
β”‚  β”‚      [4] run_extension_callbacks(extid::Base.ExtensionId)
β”‚  β”‚        @ Base ./loading.jl:1198
β”‚  β”‚      [5] run_extension_callbacks(pkgid::Base.PkgId)
β”‚  β”‚        @ Base ./loading.jl:1255
β”‚  β”‚      [6] run_package_callbacks(modkey::Base.PkgId)
β”‚  β”‚        @ Base ./loading.jl:1083
β”‚  β”‚      [7] _tryrequire_from_serialized(modkey::Base.PkgId, path::String, ocachepath::String, sourcepath::String, depmods::Vector{Any})
β”‚  β”‚        @ Base ./loading.jl:1363
β”‚  β”‚      [8] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
β”‚  β”‚        @ Base ./loading.jl:1459
β”‚  β”‚      [9] _require(pkg::Base.PkgId, env::String)
β”‚  β”‚        @ Base ./loading.jl:1748
β”‚  β”‚     [10] _require_prelocked(uuidkey::Base.PkgId, env::String)
β”‚  β”‚        @ Base ./loading.jl:1625
β”‚  β”‚     [11] macro expansion
β”‚  β”‚        @ ./loading.jl:1613 [inlined]
β”‚  β”‚     [12] macro expansion
β”‚  β”‚        @ ./lock.jl:267 [inlined]
β”‚  β”‚     [13] require(into::Module, mod::Symbol)
β”‚  β”‚        @ Base ./loading.jl:1576
β”‚  β”‚     [14] top-level scope
β”‚  β”‚        @ ~/.julia/packages/DistributionsAD/GGe2E/ext/DistributionsADTrackerExt.jl:9
β”‚  β”‚     [15] include
β”‚  β”‚        @ ./Base.jl:457 [inlined]
β”‚  β”‚     [16] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
β”‚  β”‚        @ Base ./loading.jl:2010
β”‚  β”‚     [17] top-level scope
β”‚  β”‚        @ stdin:2
β”‚  β”‚     [18] eval
β”‚  β”‚        @ ./boot.jl:370 [inlined]
β”‚  β”‚     [19] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
β”‚  β”‚        @ Base ./loading.jl:1864
β”‚  β”‚     [20] include_string
β”‚  β”‚        @ ./loading.jl:1874 [inlined]
β”‚  β”‚     [21] exec_options(opts::Base.JLOptions)
β”‚  β”‚        @ Base ./client.jl:305
β”‚  β”‚     [22] _start()
β”‚  β”‚        @ Base ./client.jl:522
β”‚  β”” @ Base loading.jl:1204
β””  
[ Info: We haven't cleaned this depot up for a bit, running Pkg.gc()...
      Active manifest files: 1 found
      Active artifact files: 83 found
      Active scratchspaces: 3 found
     Deleted no artifacts, repos, packages or scra

Looks like AdvancedVI.jl hit the precompile error. Try it in a new REPL.