-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
callback-generated stopping criteria no longer work in OptimizationNLopt #752
Comments
So is this just an upstream issue in NLopt? |
I don't really know. I think it may be possible to exit NLopt gracefully when called from Optimization.NLopt using try catch, thereby working around the NLopt.jl change - but unfortunately I don't have the expertise to be sure without diving in and learning a lot of new things. I was hoping someone might know off the top of their head. |
I don't see the stacktrace anywhere. And no, the Nlopt change is strictly for the better since it now rethrows whatever the julia session throws, earlier it didn't show what the error was making it impossible to debug |
I'm sorry, I'm pretty new to all this. I hope the following is the stacktrace you need. If you need something else, please let me know:
|
Hope I was clear that I intentionally return true from my callback when desired complex stopping criteria are met before objective function is minimized. Perhaps that is not the smart way to get the optimization to stop and exit gracefully so that I can recover the solution at that point? |
Thank you! I seem to be unable to access the updated version of I can see (I think) from the Project.toml files that I need Optimization version 3.25.1 and OptimizationNLopt version 0.2.2. In a clean julia project environment with nothing but Pkg installed, I executed I looked for a way to install the master branch of OptimizationNLopt but could not figure out how to do it (e.g., I certainly can wait until a new version is released, but I wanted to make sure you are aware that the updated version does not seem to be currently accessible. Again, thank you. |
What was the error? |
Sorry. I didn't provide it because I thought the problem is that I don't know how to install the updated version of OptimizationNLopt (v.0.2.2), rather than any underlying problem with OptimizationNLopt. Here's how I produced the error, followed by the error: I started with a clean project environment (only Pkg installed) and added Optimization and OptimizationNLopt, which gave me versions 3.25.1 and 0.2.1 respectively. As noted above, I think I want OptimizationNLopt version 0.2.2. When it went to precompile, it gave a question mark but not an error: When I use the two packages I get the following, including the error "Method overwriting is not permitted during Module precompilation." (However, I assume that error is because I'm not using version 0.2.2 of OptimizationNLopt): I tried to guess at how to install version 0.2.2 of OptimizationNLopt but clearly I guessed the wrong location: I assumed that version 0.2.2 has not yet been released (or something like that - I don't really understand the process), and that I'd just wait until that happened. I don't want to become a pain. |
Ah, yeah that's not an error just a warning so this should still work and yes the release with that fixed is also done so should be available in a bit |
Describe the example
Shows that, when using OptimizationNLopt, returning true from callback function triggers an error rather than allowing a graceful stop.
I think this is related to a change in NLopt.jl that now throws an error where it used to throw a warning. Here are some links that seem relevant:
JuliaOpt/NLopt.jl@1a1c191
Exception thrown by objective function is not rethrown by nlopt JuliaOpt/NLopt.jl#156
Fix #156, exceptions from FORCED_STOP not rethrown JuliaOpt/NLopt.jl#157
My goal here is to define a complex stopping criterion in a callback function (as well as printing key progress information) and exit gracefully if the complex stopping criterion is met. It used to work, but no longer does.
I'm not an expert in julia or optimization so perhaps there is a better way to do this than via a callback function. I see that it is possible, when using NLopt.jl rather than OptimizationNLopt, to throw an error in the objective function when a complex stopping criterion is met and exit gracefully, but that doesn't seem to work in OptimizationNLopt - at least I haven't figured out how to make it work.
Minimal Reproducible Example 👇
Without MRE, we would only be able to help you to a limited extent, and attention to the issue would be limited. to know more about MRE refer to wikipedia and stackoverflow.
Error & Stacktrace⚠️
Not Working Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Working Environment (please complete the following information):
using Pkg; Pkg.status()
I can't easily reproduce this because I am not expert at this and I don't know that I can restore everything. However, I am giving info for a much more extensive environment that worked, from Project.toml and Manifest.toml files.
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
The information is too long for this window. I'm copying selected info from my manifest file. I hope this helps.
Please note that the example above does not work exactly in the working environment because the calling signature of the callback function has changed in Optimization, but the adjustment is simple.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: