Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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://github.com/JuliaOpt/JuMP.jl|JuMP]] (Julia for Mathematical Optimization) is an Algebraic Modelling Language (AML) that allows to write optimisation problems using a concise mathematical formulation, acting as interface to the specific solver engine API. For non-linear optimisation problems it allows to keep a high-level approach that doesn't require the modeller to compute the Jacobian or the Hessian.\\ 
-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://www.gams.com/|GAMS]] (The General Algebraic Modeling System) does more or less the same things and appeared in the '70s as a project of the World Bank. GAMS is hence a very mature project (maybe //too// mature) with a lot of followers in the economic domain, where it is used mainly to solve equilibria problems. 
- 
-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://www.gnu.org/software/glpk/|GLPK]] (for linear and mixed-integer programming) and [[https://projects.coin-or.org/Ipopt|IPOPT]] (for non-linear optimisation) open-source solvers, both of which are top on their classes, leaving the necessity to acquire a licence for a commercial solver to niche cases.\\ 
-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, it's still the most common way to code in GAMS.\\ 
- 
-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, the package automatically install a local pre-compiled version of the solver, so just adding the package relative to the solver is enough to start writing the model. Even more, for people that doesn't care too much about performances, there is a service on [[https://juliabox.com|JuliaBox.com]] that allows to run Julia/JuMP scripts for free in the browser, without anything to install on the local computer.    
- 
- 
-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 "tra//sn//port" )), using JuMP. For a fictions product, there are three canning plants and three markets and the objective of the model is to find the optimal allocation of products between plants and markets that minimises the (transport) costs.\\ 
-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://www.gams.com/mccarl/trnsport.gms]] 
- 
 ===== 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 lang="julia">+<code julia>
 Pkg.update()                        # To refresh the list of newest packages Pkg.update()                        # To refresh the list of newest packages
 Pkg.add("JuMP"                    # The mathematical optimisation library Pkg.add("JuMP"                    # The mathematical optimisation library
Line 44: Line 22:
 You will need to import as a minima the ''JuMP'' module. If you wish to specify a solver engine rather than letting JuMP select a suitable one, you will need to import also the module relative to the solver, e.g. ''Ipopt'' or  ''GLPKMathProgInterface'' You will need to import as a minima the ''JuMP'' module. If you wish to specify a solver engine rather than letting JuMP select a suitable one, you will need to import also the module relative to the solver, e.g. ''Ipopt'' or  ''GLPKMathProgInterface''
  
-<code  lang="julia">+<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
home_test_julia.txt · Last modified: 2018/06/18 15:11 (external edit)
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0