Open MichaelRThompson opened 5 years ago
I dont think most solvers will like being fed nans.
I certainly don't think so either, which is why I was asking if there is an easier way.
For now I'm working around it by using the augmented Lagrangian algorithm, and essentially using the successful evaluation of the objective function as an equality constraint. A bit of a weird workaround, but it's mostly working for now.
I have the same question. It would be very useful if the objective function could throw an exception or return a value indicating that the current x is infeasible or the objective function can't be evaluated at x for unspecified reasons. I don't want the optimization to stop. In absence of another approach, I suppose the best thing to do is to return a value that's large compared to normal function values for a minimization problem or a value that's small compared to normal function values for a maximization problem.
I am facing the same problem. Currently, I just do return std::numeric_limits<double>::max();
which seems to work fine.
The ORIG_DIRECT algorithm actually lets you return NaN to indicate infeasible points: https://github.com/stevengj/nlopt/blob/master/src/algs/direct/README
Currently I'm working on optimizing a very sensitive problem, and especially for global optimization algorithms, there are some inputs that the objective function isn't able to evaluate. All of the optimization variables are within the bound constraints, but for some specific combinations, it's too numerical difficult to evaluate.
Is there a way to return something to the optimizer to tell it to ignore that result? For example, I like the idea of something as simple as returning NaNs or something along those lines.