Skip to content

Adding dual_ftol_rel keyword for NLopt #922

@miguelborrero5

Description

@miguelborrero5

I’m trying out different solvers for my problem which requires evaluation of non-linear constraints. Currently I’m trying NLopt thought Optimization in particular LD_CCSAQ solver. However, its taking forever across iterations so I wanted to increase the parameter dual_ftol_rel as suggested by NLopt documentation. However, Optimization does not seem to support this.

e.g:

rosenbrock_inp(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
p = [1.0, 100.0]
x0 = [0.0, 0.0]
f2 = OptimizationFunction(rosenbrock_inp, AutoEnzyme())
prob = OptimizationProblem(f2, x0, p)
sol = solve(prob, NLopt.LD_CCSAQ(), xtol_rel = 1e-7, dual_ftol_rel = 1e-7)

Giving the following error:

julia> sol = solve(prob, NLopt.LD_CCSAQ(), xtol_rel = 1e-7, dual_ftol_rel = 1e-7)
┌ Warning: The selected optimization algorithm requires second order derivatives, but `SecondOrder` ADtype was not provided. 
│         So a `SecondOrder` with AutoForwardDiff() for both inner and outer will be created, this can be suboptimal and not work in some cases so 
│         an explicit `SecondOrder` ADtype is recommended.
└ @ OptimizationBase ~/.julia/packages/OptimizationBase/UXLhR/src/cache.jl:49
ERROR: UndefVarError: `dual_ftol_rel!` not defined
Stacktrace:
 [1] eval
   @ ./boot.jl:385 [inlined]
 [2] eval
   @ ~/.julia/packages/OptimizationNLopt/YE3fr/src/OptimizationNLopt.jl:1 [inlined]
 [3] __map_optimizer_args!(cache::OptimizationCache{…}, opt::Opt; callback::Function, maxiters::Nothing, maxtime::Nothing, abstol::Nothing, reltol::Nothing, local_method::Nothing, local_maxiters::Nothing, local_maxtime::Nothing, local_options::Nothing, kwargs::@Kwargs{…})
   @ OptimizationNLopt ~/.julia/packages/OptimizationNLopt/YE3fr/src/OptimizationNLopt.jl:140
 [4] __solve(cache::OptimizationCache{…})
   @ OptimizationNLopt ~/.julia/packages/OptimizationNLopt/YE3fr/src/OptimizationNLopt.jl:289
 [5] solve!(cache::OptimizationCache{…})
   @ SciMLBase ~/.julia/packages/SciMLBase/OKLBE/src/solve.jl:227
 [6] solve(::OptimizationProblem{…}, ::Algorithm; kwargs::@Kwargs{…})
   @ SciMLBase ~/.julia/packages/SciMLBase/OKLBE/src/solve.jl:129
 [7] top-level scope
   @ REPL[70]:1

Could we add support for dual_ftol_rel keyword please?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions