MathOptInterface not supported by solvers

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]))
solution_summary(model; verbose=true)

Thank you in advance!

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.

1 Like

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 :smiling_face_with_tear: ).

Could you please explain more in detail this:

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

Thank you very much for your response!

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, 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)’.

1 Like