I have been using GAMS for several years, and I would like to do my new research in Python programming language. It is simple to do coding stuff in GAMS, however, it takes much time in complex optimization models.

I usually do NLP and MILP.

  • $\begingroup$ Welcome to ORSE. Would you say please, what you mean by it takes much time in complex optimization models? You should be aware that, GAMS and Pyomo are two optimization frameworks and what really solves the models is a specific solver. Indeed, there are some tricks on both to accelerate preprocessing phase of the solving process, but GAMS is really fast for working on a large data set. Also, it has still very nice facilities to exchange data between databases and its environment than Pyomo. $\endgroup$
    – A.Omidi
    Aug 17 at 16:52
  • $\begingroup$ Please, noted that many of the hard optimization models can be solved in a reasonable amount of time by using a State of the art models. Have you tried that? $\endgroup$
    – A.Omidi
    Aug 17 at 16:53
  • $\begingroup$ Rather than ask "is it better", you might want to ask what are the pros and cons of using GAMS v. Python. Also, you might want to indicate whether the question is specific to GAMS and Python, or whether you are interested in other modeling languages besides GAMS and/or other programming languages besides Python. $\endgroup$
    – prubin
    Aug 17 at 19:58
  • $\begingroup$ Hello, when I was solving different kinds TSP problems with very much decision variables, I had waited nearly 1 hour to complete the tours in the algorithm. Besides, I had some troubles to define subsets in summations while I was writing the constraints. $\endgroup$
    – dozgunay
    Aug 17 at 21:28

3 Answers 3


Python is a programming language that needs a library to model problems. Pyomo is a good option. Here is a good comparison between modeling in Pyomo and GAMS: http://yetanothermathprogrammingconsultant.blogspot.com/2021/08/a-network-model-pyomo-vs-gams.html. Which is better is something a bit subjective, and it will depend on what your research is about.


Disclaimer: I work for Gurobi.

GAMS itself is a modeling language, while Python is a programming language. This means you need a way to write your model using an API. In Python, you actually have two flavors of APIs:

Modeling frameworks

These are solver-agnostic ways of writing optimization models, similar to what you already have in GAMS. The most popular ones are:

Personally, I think that python-mip is the best, closely followed by cvxpy.

Solver-specific APIs

Modeling frameworks offer you solver independence, but there are two potential drawbacks (these may apply to you or not):

  • Most modeling frameworks only offer a subset of the functionalities that a solver has to offer. For example, Gurobi allows you to formulate general constraints (e.g. absolute value), but these specialized elements are not available in modeling frameworks.
  • Since modeling frameworks cater to several different solvers, they tend to be slower (but not always!) in the model building part compared to solver-specific APIs.

An alternative to modeling frameworks are APIs that the various solvers (Gurobi, Xpress etc.) have to offer. Depending on what your licensing situation is, i.e. whether you have consistent access to a commercial solver, this may be a good alternative.


GAMS is an Algebraic Modeling Language (AML) whereas python is a General Purpose Language (GPL)

Optimization (aka prescriptive analytics) : Should we write the model in a modeling language or a general programming language ?

Plus here you will see the same very tiny example both in python and GAMS.


[from docplex.mp.model import Model

mdl = Model(name='buses')
nbbus40 = mdl.integer_var(name='nbBus40')
nbbus30 = mdl.integer_var(name='nbBus30')
mdl.add_constraint(nbbus40*40 + nbbus30*30 >= 300, 'kids')
mdl.minimize(nbbus40*500 + nbbus30*400)


for v in mdl.iter_integer_vars():
    print(v," = ",v.solution_value)][3]


 cost;Integer Variables
 nbbus40, nbbus30;Equations
 obj, c1;obj.. cost =e= 500 * nbbus40 + 400 * nbbus30;
c1..  40 * nbbus40 + 30 * nbbus30 =g= 300;option optcr = 1e-3;
Model buses / all /;
Solve buses using MIP minimizing cost;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.