Constraints of type MathOptInterface.ScalarNonlinearFunction-in-MathOptInterface.LessThan{Float64} are not supported by the solver

I am working on an optimization problem and build a model using Gurobi Optimizer with JuMP. It has some nonlinear constraints:
@constraint(model, f[i] + func(qe[i])<= M1 * (1 - x[(i, j)]) + f[j])
where f, qe, x are nonnegative variables, and func is a function:
function func(q)
return (10 + q)^(3 / 2)
end

The weird thing is that it worked before today. I reinstalled julia, ran it and got an error:
Constraints of type MathOptInterface.ScalarNonlinearFunction-in-MathOptInterface.LessThan{Float64} are not supported by the solver.
:sob:

Did you test with a nonlinear solver, like Ipopot?

(post deleted by author)

Test with the solver to Ipopt.Optimizer, got this:
ERROR: MathOptInterface.UnsupportedConstraint{MathOptInterface.VariableIndex, MathOptInterface.ZeroOne}(“”)

The versions I use:
julia 1.11.2
gurobi 9.5.2
Is it because of version incompatibility?

Ipopt does not support binary variables (x[(i, j)]). Why do you not write the polynomial function func within the constraint instead of defining a function?

Hi @leonie25, welcome to the forum :smile:

Gurobi’s support for nonlinear constraints is a very recent feature. You need to install Gurobi v12.

You can check which version of Gurobi you are running with

import Gurobi
Gurobi._GUROBI_VERSION

We should be able to automatically install Gurobi v12, so do:

import Pkg
Pkg.update()

then restart Julia.

If that doesn’t work, please run

import Pkg
Pkg.status()

and let me know what the output is.