Is it possible to add user-defined nonlinear functions as constraints in JuMP? I couldn’t find any documentation about a case like this nor any examples where someone would have done this.
I mean something like this:
Yes of course I’ve tried my example @odow , but it didn’t work, probably because my variable was a vector. However I now figured how it can be done:
f(x) = x[1]^2+2*x[2]+3
g(x) = x[1]^3+x[2]^2
JuMP.register(m, :f, 2, f, autodiff=true)
JuMP.register(m, :g, 2, g, autodiff=true)
JuMP.setNLobjective(m, :Min, :(f($(x...)))
JuMP.addNLconstraint(m, :(g($(x...))<=10))) # This line is the one I had trouble with
Interesting that similar examples really don’t exist anywhere in JuMP’s documentation.