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.
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.
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.
python:
[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(nbbus4040 + nbbus3030 >= 300, 'kids')
mdl.minimize(nbbus40500 + nbbus30400)
mdl.solve(log_output=True,)
for v in mdl.iter_integer_vars():
print(v," = ",v.solution_value)][3]
GAMS:
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;
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. – A.Omidi Aug 17 '22 at 16:52