Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Returning NaNs to the optimizer #279

Open
MichaelRThompson opened this issue Jun 27, 2019 · 5 comments
Open

Question: Returning NaNs to the optimizer #279

MichaelRThompson opened this issue Jun 27, 2019 · 5 comments

Comments

@MichaelRThompson
Copy link

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.

@jschueller
Copy link
Collaborator

I dont think most solvers will like being fed nans.

@MichaelRThompson
Copy link
Author

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.

@tepperly
Copy link

tepperly commented Jul 2, 2019

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.

@Martin-Oehler
Copy link

I am facing the same problem. Currently, I just do return std::numeric_limits<double>::max(); which seems to work fine.

@stevengj
Copy link
Owner

The ORIG_DIRECT algorithm actually lets you return NaN to indicate infeasible points: https://github.com/stevengj/nlopt/blob/master/src/algs/direct/README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants