How to evaluate MathProgBase functions of a JuMP model

I have a JuMP model and I want to evaluate the following functions for this model: MathProgBase.eval_f(), MathProgBase.eval_g(), MathProgBase.jac_structure(), MathProgBase.eval_grad_f(). The model is as the following:

Min (x[1] ^ 2.0 + x[2] ^ 2.0 + x[3] ^ 2.0) + x[4] + x[5]
Subject to
 x[1] + x[2] + x[3] + x[4] + x[5] <= 50
 (x[1] ^ 2.0 + x[2] ^ 2.0 + x[3] ^ 2.0 + x[4] ^ 2.0 + x[5] ^ 2.0) - 100.0 <= 0
 (x[1] ^ 2.0 + x[2] ^ 2.0 + x[3] ^ 2.0) - 50.0 <= 0
 -100 <= x[i] <= 100 for all i in {1,2,3,4,5}

The julia code for the JuMP (version 0.18) model is the following:

using JuMP
using MathProgBase
using Ipopt
model=Model(solver=IpoptSolver())
@variable(model, -100 <= x[1:5] <=100)
@NLconstraint(model, sum(x[i]^2 for i in 1:5) <= 100)
@NLconstraint(model, sum(x[i]^2 for i in 1:5) <= 100)
@constraint(model, sum(x[i] for i in 1:5) <= 50)
@NLconstraint(model, sum(x[i]^2 for i in 1:3) <= 50)
@NLobjective(model, Min, sum(x[i]^2 for i in 1:3)+x[4]+x[5])

I need a guideline so that I can execute the above mentioned functions for the NLP model. Thank you.

See Nonlinear Modeling — JuMP -- Julia for Mathematical Optimization 0.18 documentation.

1 Like

This link helps. Thank you @miles.lubin.