Well the warning says that it was unstable so it exited, which means it won’t save every point in ts
and you need to check if sol.retcode == :Success
like the tutorials show. I don’t see that done here, so I would presume that’s where your issue comes from.
Why is it unstable? See PSA: How to help yourself debug differential equation solving issues . If it’s unstable at the first set of parameters, then it’s likely there’s an issue in the definition of the ODE and you should re-check that. If it’s only after the optimization has started, then maybe the parameters turn stiff while optimizing, in which case you need to use a different solver, or there are just some parameters where the ODE is unstable, which means you need to check and reject.