# MILP optimization using Gurobi gives error related to Attribute MathOptInterface

**URL:** https://discourse.julialang.org/t/milp-optimization-using-gurobi-gives-error-related-to-attribute-mathoptinterface/39700
**Category:** Optimization (Mathematical)
**Created:** [May 18, 2020, 2:56pm UTC](https://discourse.julialang.org/t/milp-optimization-using-gurobi-gives-error-related-to-attribute-mathoptinterface/39700 "2020-05-18T14:56:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mamuniut09](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mamuniut09/32/9991_2.png) [@mamuniut09](https://discourse.julialang.org/u/mamuniut09)
#### Post date: [May 18, 2020, 2:56pm UTC](https://discourse.julialang.org/t/milp-optimization-using-gurobi-gives-error-related-to-attribute-mathoptinterface/39700/1 "2020-05-18T14:56:15Z")

</div>

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.

```julia
using JuMP, Ipopt, DataFrames, LinearAlgebra, Gurobi, Complementarity
x0=[-1 1 3]
y0=zeros(3);
for i=1:3
    y0[i]=(x0[i]-1)^2+5
end

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])
optimize!(m)

```

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

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [May 18, 2020, 3:32pm UTC](https://discourse.julialang.org/t/milp-optimization-using-gurobi-gives-error-related-to-attribute-mathoptinterface/39700/2 "2020-05-18T15:32:48Z")

</div>

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.
