Optim.jl and runtime dispatch detected errors

Runtime dispatch is expected with Optim.

If you make a post with your real problem, people may have suggestions for how to improve it, or reduce the number of allocations.