You still need to make sure that the objective function does not error when it goes negative, see Using DiffEq isoutofdomain to enforce positivity - #2 by ChrisRackauckas.
You still need to make sure that the objective function does not error when it goes negative, see Using DiffEq isoutofdomain to enforce positivity - #2 by ChrisRackauckas.