DifferentialEquations.jl, Error: Exponentiation yielding a complex result requires a complex argument

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.