Issue with Optimization.LBFGS

Hi there,

Disclaimer: I can not share the actual data or objective function so this might be a long shot but maybe the error itself has enough information.

I am trying to optimize a function g with non-linear constraints through cons and I use the solver Optimization.LBFGS() which allows for non-linear solving with constraints but I am getting a strange error.

To be clear: without cons = cons it works. The code I am running is:

optf = OptimizationFunction(g, AutoEnzyme(), cons = cons)
prob = OptimizationProblem(optf, y_init, p, lcons = repeat([-Inf], num_schools), ucons = repeat([0.0], num_schools))
sol_lbfgs = solve(prob, Optimization.LBFGS())
julia> sol_lbfgs = solve(prob, Optimization.LBFGS())
ERROR: MethodError: no method matching (::Colon)(::Int64, ::Nothing)

Closest candidates are:
  (::Colon)(::T, ::Any, ::T) where T<:Real
   @ Base range.jl:50
  (::Colon)(::A, ::Any, ::C) where {A<:Real, C<:Real}
   @ Base range.jl:10
  (::Colon)(::T, ::Any, ::T) where T
   @ Base range.jl:49
  ...

Stacktrace:
 [1] __solve(cache::OptimizationCache{…})
   @ Optimization ~/.julia/packages/Optimization/PnmC0/src/lbfgsb.jl:176
 [2] solve!(cache::OptimizationCache{…})
   @ SciMLBase ~/.julia/packages/SciMLBase/2TYas/src/solve.jl:187
 [3] solve(::OptimizationProblem{…}, ::Optimization.LBFGS; kwargs::@Kwargs{})
   @ SciMLBase ~/.julia/packages/SciMLBase/2TYas/src/solve.jl:95
 [4] solve(::OptimizationProblem{…}, ::Optimization.LBFGS)
   @ SciMLBase ~/.julia/packages/SciMLBase/2TYas/src/solve.jl:92
 [5] top-level scope
   @ REPL[6225]:1
Some type information was truncated. Use `show(err)` to see complete types.

Does someone have any information regarding where the error could be coming from?

I apologize for not being able to provide a MWE.

LBFGS-B is not compatible with nonlinear constraints IIRC. Try IPOPT instead.

We should throw a better error message here.

1 Like