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.
Operations Research Stack Exchange is a question and answer site for operations research and analytics professionals, educators, and students. It only takes a minute to sign up.Sign up to join this community
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:
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.
Modeling frameworks offer you solver independence, but there are two potential drawbacks (these may apply to you or not):
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)
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) mdl.solve(log_output=True,) for v in mdl.iter_integer_vars(): print(v," = ",v.solution_value)]
Variable 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;