pyomo icon indicating copy to clipboard operation
pyomo copied to clipboard

Valid solvers for GAMS writer

Open tk3016 opened this issue 1 year ago • 2 comments

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 avatar Aug 21 '24 08:08 tk3016

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?

bernalde avatar Aug 21 '24 17:08 bernalde

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

tk3016 avatar Aug 21 '24 18:08 tk3016