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

NLopt roundoff-limited error from simple example #468

Open
imbacalvin opened this issue Aug 18, 2022 · 1 comment
Open

NLopt roundoff-limited error from simple example #468

imbacalvin opened this issue Aug 18, 2022 · 1 comment

Comments

@imbacalvin
Copy link

imbacalvin commented Aug 18, 2022

I saw https://www.reddit.com/r/cpp_questions/comments/k6743d/nlopt_round_off_error/ and translated it to Python.

import nlopt

def obj_fn(x,grad):
    print("%.16f,%.16f"%(x[0],x[1]))
    print("%.16f"%(-x[0]+x[1]))
    return -x[0]+x[1]

opt = nlopt.opt(nlopt.LN_COBYLA,2)
opt.set_lower_bounds([-3.0,-3.0])
opt.set_upper_bounds([3.0,3.0])
opt.set_min_objective(obj_fn)
opt.set_ftol_abs(1)
opt.optimize([-1.5,-1.5])
print(opt.last_optimize_result())

The python version also always throws an nlopt roundoff-limited error. Do you think there is a bug causing this? More generally, what should we do to avoid hitting nlopt roundoff-limited errors? Thanks!

@jschueller
Copy link
Collaborator

jschueller commented Nov 10, 2024

indeed it seems the ftol criterion (nlopt_stop_ftol function) is not called when it should be, xtol criterion works though:
opt.set_ftol_abs(1e-6)

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

2 participants