Trouble importing Nonlinear constraints to Gurobi models
Awaiting user inputI am trying to import JuMP or MathOpt Models to Gurobi recognized model formats (.mps, .rew, .lp). All seem to throw the same error during conversion:
MathOptInterface.UnsupportedConstraint{MathOptInterface.ScalarNonlinearFunction, MathOptInterface.EqualTo{Float64}}: `MathOptInterface.ScalarNonlinearFunction`-in-`MathOptInterface.EqualTo{Float64}` constraint is not supported by the model.
I tried enabling "NonConvex" parameter as well, even though according to latest documentation it's enabled by default.
Is there a way to overcome this issue? I can serialize the model to .json as well.
-
Hi Harsh,
Thanks for posting here! Where exactly does this error occur, can you share a code snippet? It seems to be on the JuMP side so I'm wondering if the error is Gurobi-related or not.
Kind regards,
Ronald0 -
Thanks Ronald, for the quick response.
This error first occurred when I tried integrating Gurobi Optimizer with JuMP models via Gurobi.jl module.
Later on, to circumvent the problem I tried to serialize my JuMP model to a different format and faced the same error.
I would agree that this problem might not be Gurobi related but would appreciate any insight you might have why all the Gurobi recognized formats (.mps, .rew, .lp) have the same limitation. I am able to work with .nl files with other solvers for the same JuMP model.
Really appreciate your support.
Sincerely,
Harsh
0 -
Hi Harsh,
Thanks a lot for the additional background info! Most likely, the reason is the following. Gurobi v11 supports univariate non-linear expressions. Trees of expressions (e.g. z = sin(y + exp(x))) can be constructed by building the expression in steps using multiple constraints. This will improve in a future Gurobi release.
Because of this, I believe Gurobi.jl does not support non-linear types. One workaround is to use the C API directly as suggested here. Once the Gurobi API for non-linear expressions becomes more flexible, this will also open the door to third-party frameworks to integrate with Gurobi more easily for such expressions.
Kind regards,
Ronald0
Please sign in to leave a comment.
Comments
3 comments