Reabo
Reabo

Reputation: 87

Using NLopt as a solver of JuMP

I'm trying to optimize a function using NLopt.

I tried to use the example in NLopt.jl but I wasn't able to fix the error.

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)])


I don't know how to use with_optimizer.

Upvotes: 0

Views: 866

Answers (1)

Luis Flosi
Luis Flosi

Reputation: 1

For those still looking, there is currently no solution to the problem.

Currently, JuMP uses the syntax

model = Model(optimizer) set_optimizer_attribute(model, "attribue", value)

That would be the correct way to setting the "algorithm" = algorithm attribute for NLoptSolver.

However, the NLoptSolver package has not been updated to allow for loading the optimizer without the algorithm attribute, and so it is currently unable to use JuMP.

Source

Upvotes: 0

Related Questions