Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
home_test_julia [2017/02/07 10:13] antonello created |
home_test_julia [2017/02/07 10:14] antonello |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== A JuMP tutorial for GAMS users ====== | ||
- | |||
- | [[https:// | ||
- | It is developed by the MIT Operations Research Center and appeared in 2013 as an open source package of the relatively new Julia programming language. | ||
- | |||
- | [[http:// | ||
- | |||
- | This mini-tutorial is intended for gams users that want to try JuMP. There may be two reasons for someone to with to use JuMP instead of GAMS.\\ | ||
- | The most obvious one, even if often it isn't the key driver, is that GAMS is a commercial software while JuMP being open-source is free both as freedom and as a free beer.\\ | ||
- | While for GAMS a licence for the underlying solver engine is often included with a particular version of GAMS, JuMP would still require the user to buy a licence to use a specific commercial solvers. However JuMP interfaces with both [[https:// | ||
- | The second reason (and, to me, the most important one) resides in the language features and in the availability of development environments. GAMS uses a VERY ODD syntax, somehow derived from the Cobol language, that is very distant from any programming language in use nowadays. For example a macro mechanism to provide an elementary way to structure the code in reusable components has been introduced only in GAMS 22.9. | ||
- | Its own editor is also very terrible, but as most text editors do not provide a GAMS syntax highlighting, | ||
- | |||
- | JuMP, at the opposite, is both open source and it allow to write the model in a powerful general-purpose language like Julia\\ | ||
- | You have plenty of development environment to choose from (e.g. Jupiter, Juno), a clear modern language, the possibility to interface your model with third party libraries.. all of this basically for free.\\ | ||
- | It is also, at least for my user case, much faster than GAMS. Aside the preparation of the model to pass to the solver, where it is roughly equivalent, in the solver execution I can benefit of having on my system a version of IPOPT compiled with the much more performing ma27 linear solver, while for GAMS I would have to rely on the embedded version that is compiled with the MUMPS linear solver. That's part of the flexibility you gain in using JuMP in place of GAMS. | ||
- | That's said, for people that don't need such flexibility, | ||
- | |||
- | |||
- | So let's start. We will see how to code the trasnport.gms problem, the one that ship as default example in GAMS((yes, the default GAMS example is named " | ||
- | GAMS equivalent code is inserted as single-dash comments. The original GAMS code needs slightly different ordering of the commands and it's available at [[http:// | ||
- | |||
===== Installation ===== | ===== Installation ===== | ||
Line 30: | Line 8: | ||
Run, only once, the following code to install JuMP language and a couple of open source solvers: | Run, only once, the following code to install JuMP language and a couple of open source solvers: | ||
- | < | + | <code julia> |
Pkg.update() | Pkg.update() | ||
Pkg.add(" | Pkg.add(" | ||
Line 44: | Line 22: | ||
You will need to import as a minima the '' | You will need to import as a minima the '' | ||
- | < | + | <code julia> |
# Import of the JuMP and DataFrames modules (the latter one just to import the data from a header-based table, as in the original trasnport example in GAMS | # Import of the JuMP and DataFrames modules (the latter one just to import the data from a header-based table, as in the original trasnport example in GAMS | ||
using JuMP, DataFrames | using JuMP, DataFrames |