MILP optimization using Gurobi gives error related to Attribute MathOptInterface

Hello all,
I was trying to optimize an MILP problem using Gurobi. However, I am getting the below error.
MathOptInterface.UnsupportedAttribute{MathOptInterface.NLPBlock}: Attribute MathOptInterface.NLPBlock() is not supported by the model.

The code is given below.

using JuMP, Ipopt, DataFrames, LinearAlgebra, Gurobi, Complementarity
x0=[-1 1 3]
for i=1:3

m = Model(with_optimizer(Gurobi.Optimizer))
@variable(m, -1<=x<=3)
@variable(m, g[1:2, 1])
@variable(m, u[i=1:2],Bin) 
@constraint(m, sum(u[j] for j=1:2) ==1) 
@complements(m, g[1,1] == y0[1]+(x-x0[1])*(y0[1]-y0[2])/(x0[1]-x0[2]), -1<=x<=1)
@complements(m, g[2,1] == y0[2]+(x-x0[2])*(y0[2]-y0[3])/(x0[2]-x0[3]), 1<=x<=3)
@objective(m, Min, u[1]*g[1,1]+u[2]*g[2,1])

I would appreciate if anybody could explain the error and give possible way to resolve this issue. Thank you.

Your problem is not a MILP because it has complementarity constraints, and Gurobi cannot handle complementarity constraints.

You should just reformulate this as a standard MILP.

p.s. I’ve moved your post to the Optimization (Mathematical) category.

1 Like