How to use a NLopt solver together with MathProgBase?

429 views Asked by At

I would like to use the MathProgBase interface to formulate an optimization problem. Furthermore, I would like to use an open-source solver, such as NLopt (or any other).

The doc at https://github.com/JuliaOpt/NLopt.jl#using-with-mathprogbase mentions that NLopt can be called via MathProgBase. Unfortunately, I can not find a fool-proof example. On the other hand, MathProgBase does not mention NLopt. So let's try it. Here is the code:

using NLopt, MathProgBase
quadprog([0., 0., 0.],[2. 1. 0.; 1. 2. 1.; 0. 1. 2.],[1. 2. 3.; 1. 1. 0.],'>',[4., 1.],-Inf,Inf,NLoptSolver(algorithm=:NLOPT_AUGLAG))

I get the following error message:

`loadproblem!` has no method matching loadproblem!(::NLoptMathProgModel, ::Array{Float64,2}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Symbol)
while loading In[1], in expression starting on line 2

 in quadprog at /Users/harmeling/.julia/v0.3/MathProgBase/src/HighLevelInterface/quadprog.jl:46

What's wrong? I am also fine with any other open source solver. Important for me is to use MathProgBase calling convention like quadprog. Thanks for your help!

2

There are 2 answers

1
mlubin On

NLopt includes a collection of algorithms for solving general nonlinear optimization problems. Currently, only the nonlinear, derivative-based interface is implemented. So if you want to solve a quadratic problem, you'll have to go through this more general interface. It's certainly possible for this to be done automatically, but it hasn't been implemented yet.

For quadprog, Ipopt would be a much more powerful solver than NLopt. Ipopt currently supports the linear interface and the nonlinear interface, but not yet the quadratic interface. I intend to implement this soon.

0
Fred Schoen On

The NLopt documentation now has such an example of using JuMP via the MathProgBase interface https://github.com/JuliaOpt/NLopt.jl#tutorial