# MathOptInterface not supported by solvers

**URL:** https://discourse.julialang.org/t/mathoptinterface-not-supported-by-solvers/98376
**Category:** Optimization (Mathematical)
**Tags:** question
**Created:** [May 5, 2023, 10:49am UTC](https://discourse.julialang.org/t/mathoptinterface-not-supported-by-solvers/98376 "2023-05-05T10:49:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Gianmarco\_Montillo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gianmarco_montillo/32/49458_2.png) [@Gianmarco\_Montillo](https://discourse.julialang.org/u/Gianmarco_Montillo)
#### Post date: [May 5, 2023, 10:49am UTC](https://discourse.julialang.org/t/mathoptinterface-not-supported-by-solvers/98376/1 "2023-05-05T10:49:22Z")

</div>

I am trying to solve a model using constraints of type **MOI** , but every solver I try out, results in a error stating

> Constraints of type MathOptInterface.ScalarQuadraticFunction{Float64}-in-MathOptInterface.EqualTo{Float64} are not supported by the solver.

Maybe I am writing something in the wrong way, i leave the code here for any suggestion on syntax or improvement:

> model = Model(GLPK.Optimizer)  
> @variable(model, x[1:9])  
> nx = length(x)  
> @variable(model, y[1:7])  
> ny = length(y)  
> @variable(model, z[1:10])  
> nz = length(z)  
> @variable(model, i[1:3, 1:max(nx, ny, nz)], Bin)  
> @constraint(model, sum(x’\*i[1,1:nx]) == 450)  
> @constraint(model, sum(y’\*i[2,1:ny]) == 800)  
> @constraint(model, sum(z’\*i[3,1:nz]) == 650)  
> @constraint(model, sum(x’\*i[1,1:nx]) + sum(y’\*i[2,1:ny]) + sum(z’\*i[3,1:nz]) \<= 1600)  
> @objective(model, Max, sum(x’\*i[1,1:nx]) + sum(y’\*i[2,1:ny]) + sum(z’\*i[3,1:nz]))  
> optimize!(model)  
> solution\_summary(model; verbose=true)

Thank you in advance!

---

<div class="post-metadata">

### Author: ![mike\_k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_k/32/211864_2.png) [@mike\_k](https://discourse.julialang.org/u/mike_k)
#### Post date: [May 5, 2023, 12:00pm UTC](https://discourse.julialang.org/t/mathoptinterface-not-supported-by-solvers/98376/2 "2023-05-05T12:00:09Z")

</div>

GLPK can solve (mixed integer) **linear** programs. Your constraints, and the objective function is non-linear because you defined `x, y, z`, and `i` as variables and multiply them with each other. This is essentially what the error message says, i.e., GLPK does not support quadratic functions.

There is also some redundancy in the constraints and the objective function. The dot product, e.g., `x' * y`, is already a sum of the products of the coordinates of vectors `x` and `y`. Thus, you could skip the `sum()` functions.

---

<div class="post-metadata">

### Author: ![Gianmarco\_Montillo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gianmarco_montillo/32/49458_2.png) [@Gianmarco\_Montillo](https://discourse.julialang.org/u/Gianmarco_Montillo)
#### Post date: [May 5, 2023, 12:14pm UTC](https://discourse.julialang.org/t/mathoptinterface-not-supported-by-solvers/98376/3 "2023-05-05T12:14:40Z")

</div>

Hi @mike_k, thank you for your answer.  
You are right, GLPK is not ok with this approach, I tried also other solvers, such as MadNLP, but I get an error upon the creation of Binary variables “i”:

> Constraints of type MathOptInterface.VariableIndex-in-MathOptInterface.ZeroOne are not supported by the solver.

However with Alpine for example it works without errors (even if it still does not work properly 🥲 ).

Could you please explain more in detail this:

> [@mike\_k](#):
>
> There is also some redundancy in the constraints and the objective function. The dot product, e.g., `x' * y`, is already a sum of the products of the coordinates of vectors `x` and `y`. Thus, you could skip the `sum()` functions.

If I try to remove **’** or **sum()** I get other errors.

Thank you very much for your response!

---

<div class="post-metadata">

### Author: ![mike\_k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_k/32/211864_2.png) [@mike\_k](https://discourse.julialang.org/u/mike_k)
#### Post date: [May 5, 2023, 12:29pm UTC](https://discourse.julialang.org/t/mathoptinterface-not-supported-by-solvers/98376/4 "2023-05-05T12:29:35Z")

</div>

Variables `i` are defined as binary (i.e., integer), and MadNLP does not support that. Thus, you need a solver which supports solving mixed integer non-linear programs ((MI)NLPs) such as Alpine. See the list of [solvers supported by JuMP](https://jump.dev/JuMP.jl/stable/installation/#Supported-solvers), and pick an appropriate one. I have never used MINLP solvers and therefore cannot recommend one.

Btw: you are more likely to receive help if you move your post into the category ‘Optimization (Mathematical)’.
