0

I am new to JuMP, Julia. I am running a very basic example and I get a weird error.

using JuMP 
using NLopt

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

@variable(m1, x, start = 0.0) 
@variable(m1, y, start = 0.0)
@NLobjective(m1, Min, (1-x)^2 + 100(y-x^2)^2)
solve(m1)
println("x = ", getvalue(x), " y = ", getvalue(y))

#adding a (linear) constraint
@constraint(m1, x + y == 10) 
solve(m1) 
println("x = ", getvalue(x), " y = ", getvalue(y))
chupa_kabra
  • 465
  • 2
  • 5
  • 15

1 Answers1

1

You are using a solver that does not support equality constraints. Change your model setup to e.g.:

m1 = Model(solver=NLoptSolver(algorithm=:LD_AUGLAG))

and all should work.

Here https://nlopt.readthedocs.io/en/latest/NLopt_Algorithms/ you have a review of algorithms available in NLopt.

Bogumił Kamiński
  • 66,844
  • 3
  • 80
  • 107