-
-
Notifications
You must be signed in to change notification settings - Fork 101
Description
Describe the example
I updated from Optimization 4.6.0 and OptimizationNLopt 0.3.2 to Optimization 4.7.0 and OptimizationNLopt 0.3.3 and noticed the following behavior change:
Minimal Reproducible Example 👇
using Pkg, BenchmarkTools
using Optimization, OptimizationNLopt
Pkg.status(["Optimization", "OptimizationNLopt"])
function rosenbrock(x, p)
error = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
# @info x, error
return error
end
x0 = zeros(2)
p = [1.0, 100.0]
f = OptimizationFunction(rosenbrock)
prob = Optimization.OptimizationProblem(f, x0, p, lb = [-1.0, -1.0], ub = [1.0, 1.0])
sol = solve(prob, NLopt.LN_AUGLAG(); local_method = NLopt.LN_NELDERMEAD(), stopval=1e-8)
@info sol
# This works in both versions.
sol = solve(prob, NLopt.LN_AUGLAG(); stopval=1e-8)
@info sol
# This only works in the previous version.
# The previous version is also faster.
Error & Stacktrace
No explicit error returned.
Optimization 4.6.0 + OptimizationNLopt 0.3.2 returns:
┌ Info: retcode: Success
│ u: [0.9999001039659396, 0.9997998202628237]
└ Final objective value: 9.99503003591396e-9
Optimization 4.7.0 + OptimizationNLopt 0.3.3 returns:
┌ Info: retcode: Success
│ u: [0.0, 0.0]
└ Final objective value: Inf
If NLopt.LN_AUGLAG()
should never be used without a local_method
specified, it may be worthwhile to throw an error. But it did work just fine in the previous version.
Not Working Environment (please complete the following information):
- Output of
using Pkg; Pkg.status()
Status `~/.julia/environments/v1.11/Project.toml`
[7f7a1694] Optimization v4.7.0
[4e6fcdb7] OptimizationNLopt v0.3.3
- Output of
versioninfo()
julia> versioninfo()
Julia Version 1.11.6
Commit 9615af0f269 (2025-07-09 12:58 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin24.0.0)
CPU: 14 × Apple M4 Pro
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 6 default, 0 interactive, 3 GC (on 10 virtual cores)
Environment:
JULIA_VSCODE_REPL = 1
JULIA_DEPOT_PATH = /Users/flin/.julia_vscode
JULIA_NUM_THREADS = 6
JULIA_EDITOR = code
Working Environment (please complete the following information):
- Output of
using Pkg; Pkg.status()
Status `~/.julia/environments/v1.11/Project.toml`
⌃ [7f7a1694] Optimization v4.6.0
⌃ [4e6fcdb7] OptimizationNLopt v0.3.2
- Output of
versioninfo()
julia> versioninfo()
Julia Version 1.11.6
Commit 9615af0f269 (2025-07-09 12:58 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin24.0.0)
CPU: 14 × Apple M4 Pro
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 6 default, 0 interactive, 3 GC (on 10 virtual cores)
Environment:
JULIA_VSCODE_REPL = 1
JULIA_DEPOT_PATH = /Users/flin/.julia_vscode
JULIA_NUM_THREADS = 6
JULIA_EDITOR = code
Additional context
A potentially related problem (which I do not have a minimal reproducible example here as I encountered it in my code that involves lots of other stuff) is that NLopt.LN_NELDERMEAD()
also ends up being slower after the update (around 10x more time and allocations).