NLopt returns BoundsError even though model is properly defined as MathProgBase model
I have run the code
using NLopt
include(joinpath(Pkg.dir("MathProgBase"),"test","nlp.jl"))
convexnlptest(NLoptSolver(algorithm=:LD_SLSQP))
resulting in the output
ERROR: BoundsError
Stacktrace:
[1] optimize!(::NLopt.Opt, ::Array{Float64,1}) at /home/jomi/.julia/v0.6/NLopt/src/NLopt.jl:523
[2] optimize!(::NLopt.NLoptMathProgModel) at /home/jomi/.julia/v0.6/NLopt/src/NLoptSolverInterface.jl:203
[3] convexnlptest(::NLopt.NLoptSolver) at /home/jomi/.julia/v0.6/MathProgBase/test/nlp.jl:245
The code
using NLopt
include(joinpath(Pkg.dir("MathProgBase"),"test","nlp.jl"))
nlptest(NLoptSolver(algorithm=:LD_SLSQP))
The test set called by convexnlptest is in MathProgBase syntax and part of the test set of MathProgBase.
I have compared the functions convexnlptest and nlptest and have observed that nlptest runs MathProgBase.setwarmstart! whereas convexnlptest does not. If the optimization variable say x is initialized by an array of the proper length before calling optimize!, the error does not occur.
I believe you must provide a starting point to NLopt, but I agree the error message could be more helpful.
Closing as won't fix. The MathProgBase interface is deprecated and will be removed in a future release.