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

Maxtime and compilation #190

Closed
BioTurboNick opened this issue Aug 25, 2022 · 7 comments
Closed

Maxtime and compilation #190

BioTurboNick opened this issue Aug 25, 2022 · 7 comments

Comments

@BioTurboNick
Copy link

I'm setting maxtime to avoid an occasional infinite cycle on some inputs, but it triggers during the first execution due to compilation of the objective function.

@odow
Copy link
Member

odow commented Jan 24, 2023

What would you expect to happen? I don't think NLopt can tell whether the time is because of a long-running function, or because of compilation. It can only terminate once maxtime has passed. If it's a problem, you could evaluate the objective once before calling NLopt?

@BioTurboNick
Copy link
Author

That's fair; if Julia had the ability to track non-compilation elapsed time, NLopt.jl could detect this condition and try again.

@stevengj
Copy link
Collaborator

No, the maxtime is actually based on a feature from the NLopt C library — it is just wall-clock time.

Mainly, I find it useful for global optimization (where there aren't good stopping criteria), e.g. "give me the best possible result in 3 hours". But usually in this situation the maxtime is huge compared to any conceivable compilation time.

@BioTurboNick
Copy link
Author

BioTurboNick commented Jan 25, 2023

I understand it's used by NLopt C library, but the Julia library could handle the exceptional condition specific to Julia.

I've used maxtime just recently when most optimizations take less than a second and occasionally runs for minutes at a time on certain inputs to keep the total time to a manageable level.

@odow
Copy link
Member

odow commented Jan 25, 2023

If it's a problem, you could evaluate the objective once before calling NLopt?

Did you consider doing this? Or run NLopt twice? Once with a time limit of 0.0 and once with your larger time limit?

@BioTurboNick
Copy link
Author

Sure I could. That's just annoying 😆

@stevengj
Copy link
Collaborator

You could also just use maxeval instead.

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

No branches or pull requests

3 participants