Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid solvers for GAMS writer #3359

Open
tk3016 opened this issue Aug 21, 2024 · 2 comments
Open

Valid solvers for GAMS writer #3359

tk3016 opened this issue Aug 21, 2024 · 2 comments

Comments

@tk3016
Copy link

tk3016 commented Aug 21, 2024

Hi Pyomo development team,

The recent versions of GAMS (v46+) incorporate GUROBI v11 which support solution of NLP/MINLP models directly. However, invoking GUROBI through GAMS in Pyomo results in 'ValueError: GAMS writer passed solver (gurobi) unsuitable for model type (nlp)' when trying to solve a NLP/MINLP.

Many thanks for your support.

Best wishes,
Tanuj

@tk3016 tk3016 added the bug label Aug 21, 2024
@bernalde
Copy link
Contributor

Hey Tanuj,
You can specify the model type to the GAMS writer as follows:

import pyomo.environ as pe
solver = pe.SolverFactory('gams')
solver.options['mtype']= "miqcp"

or whichever model type you have according to https://www.gams.com/latest/docs/UG_ModelSolve.html#UG_ModelSolve_ModelClassificationOfModels
Also, AFAIK the feature of solving arbitrary NLP problems with Gurobi was only released recently and both GAMS (https://www.gams.com/latest/docs/S_GUROBI.html) and Pyomo have not currently fully implemented that capability. You can still solve quadratic programs in both.
Finally, since you require a standalone installation of Gurobi to use it on GAMS, why not classing it directly with Pyomo?

@tk3016
Copy link
Author

tk3016 commented Aug 21, 2024

Dear David,

Many thanks for your prompt response.
It is possible to solve general NLP/MINLP problems with GUROBI via GAMS since v46 which was released in February this year.
Please see the release notes for v46 here:
https://www.gams.com/46/docs/RN_46.html#g4610_GUROBI

Since then any general NLP/MINLP models can be solved. As far as I understand, GUROBI v11 can only accept univariate nonlinear functions currently. Please see the links below:

  1. https://www.gams.com/47/docs/S_GUROBI.html#GUROBI_NONLINEAR_PROGRAMMING
  2. https://www.gurobi.com/documentation/11.0/refman/general_constraints.html

To allow any general MINLPs to be solved by GUROBI, GAMS has an option nlreform which is active by default to reformulate a nonlinear constraint which conforms to the univariate form required by GUROBI. Please see the link below:
https://www.gams.com/47/docs/S_GUROBI.html#GUROBInlreform

I am aware that Pyomo's interface with GUROBI currently does not support general nonlinear constraints and an issue is open currently (#3249).

Hence, in the meantime I wanted to work around this and use GUROBI to solve my nonlinear model.
Ofcourse, I can simply use the GAMS writer to convert my Pyomo model into the equivalent GAMS file and then solve the model in GAMS using GUROBI, but this is cumbersome and I want to avoid this.
Unfortunately, my model is not a MIQCP so I cannot use that option to solve it with GUROBI.

I hope this clarifies my situation further.

Best wishes,
Tanuj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants