# Estimating parameters of ODEs leads to instability

I have a system of ODEs in a form of:

``````  Dt(θ) ~ θ̇
Dt(θ̇) ~ a₁ * θ̇ + a₂ * sin(ψ) + a₃ * ψ̇ + a₄ * u(t)
Dt(ψ) ~ ψ̇
Dt(ψ̇) ~ a₅ * θ̇ + a₆ * sin(ψ) + a₇ * ψ̇ + a₈ * u(t)
``````

where a₁,…,a₈ are parameters to be estimated. But when I try to perform an optimization using examples from DiffEqParamEstim website, I always get an instability detection and aborting afterwards. I also get this error message: dt(3.552713678800501e-15) <= dtmin(3.552713678800501e-15) at t=1.2645985507940618e-5. Aborting. There is either an error in your model specification or the true solution is unstable.

I tried to increase a maxiters value, I tried different loss functions and optimizers (from Optim.jl and NLopt.jl), various amount of initial conditions and stiff/non-stiff ODE solver, but nothing is helping.

Is there anything I can do to make the optimization working?

1 Like

I’ve not used DiffEqParamEstim, but I don’t think it would be too surprising that you run into areas of the parameter space that lead to instabilities when optimising. You could make use of `SciMLBase.successful_retcode` in your objective function, giving infinite loss whenever instabilities occur so that the solver goes away from it - see Optimization-Based Methods · DiffEqParamEstim.jl, “Note About Loss Functions” (use `SciMLBase.successful_retcode(sol)` rather than the `any((s.retcode != :Success for s in sol))` shown). Note that the message `dt(3.552713678800501e-15) <= dtmin(3.552713678800501e-15) at t=1.2645985507940618e-5. Aborting` is a warning rather than an error, and will be detected by `SciMLBase.successful_retcode(sol)` returning `false`.

2 Likes