I'm trying to implement an inequality constraint by having my cost function return "false" when the function being optimized takes on negative values over a certain range. I haven't had any success using this method however. On the first iteration of the optimizer, the message returned is: "trust_region_minimizer.cc:71] Terminating: Residual and Jacobian evaluation failed".
I assume this is because, even if I set an initial guess is set which is in a valid region, when numeric differentiation occurs some of the calls to the cost function are in the "forbidden region" preventing the derivative from being calculated.
Primarily, my question is, have others had success using this approach for setting inequality constraints while using numeric differentiation? and if so, can you provide any advice on how to proceed?
Thank you very much,