Showing each iteration results of JuMP and NLopt optimization routines in Julia

1.2k views Asked by At

I found a combination of JuMP and NLopt example while I was trying to see the way Julia implements different routines for optimization.

The following example (that can be found here: https://github.com/JuliaOpt/NLopt.jl) gives you the final solution without the other steps in between.

Although this may be OK for simple problems, for some we need to see how each iteration goes (for example does it converge with each iteration?)

My question is: how the following code can be modified so as to show the number of each iteration and the error (which we want it to become smaller and smaller)?

I hope I made myself clear (the code follows):

using JuMP
using NLopt

m = Model(solver=NLoptSolver(algorithm=:LD_MMA))

a1 = 2
b1 = 0
a2 = -1
b2 = 1

@variable(m, x1)
@variable(m, x2 >= 0)

@NLobjective(m, Min, sqrt(x2))
@NLconstraint(m, x2 >= (a1*x1+b1)^3)
@NLconstraint(m, x2 >= (a2*x1+b2)^3)

setvalue(x1, 1.234)
setvalue(x2, 5.678)

status = solve(m)

println("got ", getobjectiveValue(m), " at ", [getvalue(x1),getvalue(x2)])

By the way: here (http://ab-initio.mit.edu/wiki/index.php/NLopt_Algorithms#Nelder-Mead_Simplex) we can find all the possible algorithms for NLOpt. I wanted to try with Nelder-Mead and instead of LD_MMA I entered NLOPT_LN_NELDERMEAD, but to no avail. Does anyone know the shortcuts of all those algos. that can be used in Julia?

=> None

1

There are 1 answers

0
IainDunning On

It seems like this isn't a possible option for NLopt, but it could be maybe added to JuMP as an option. You should open an issue on the JuMP issues page to ask for it.