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
Previous revision
Next revision Both sides next revision
personal:blog:2017:0203_jump_for_gams_users [2023/12/22 11:12]
antonello [Complete script]
personal:blog:2017:0203_jump_for_gams_users [2023/12/22 11:20]
antonello [Definition of the "parameters"]
Line 31: Line 31:
 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> <code julia>
-Pkg.update()                        # To refresh the list of newest packages +using Pkg               # Load the package manager 
-Pkg.add("JuMP"                    # The mathematical optimisation library +Pkg.update()            # To refresh the list of newest packages 
-Pkg.add("GLPKMathProgInterface"   # A lineaqr and MIP solver +Pkg.add("CSV"         # A library to work with Comma Separated Values 
-Pkg.add("Ipopt"                   # A non-linear solver +Pkg.add("DataFrames"  # A library to deal with dataframes (R like tabular data) 
-Pkg.add("DataFrames"              # A library to deal with dataframes (R like tabular data)+Pkg.add("JuMP"        # The mathematical optimisation library 
 +Pkg.add("GLPK"        # A linear and MIP solver 
 +Pkg.add("Ipopt"       # A non-linear solver (not needed in this example)
 </code> </code>
  
Line 42: Line 44:
 ==== Importing the libraries ==== ==== Importing the libraries ====
  
-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 and a suitable solver. In this case the problem is linear, so we can use ''GLPK'' (''HiGHS'' is another popular alternative). If the problem would have been non-linear, you could have used the ''Ipopt'' solver/package
  
 <code  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, GLPK, CSV and DataFrames modules (the latter twos just to import the data from a header based table, as in the original trasnport example in GAMS  
-using JuMP, DataFrames+using CSV, DataFrames, GLPK, JuMP
 </code> </code>
  
Line 94: Line 96:
 #      seattle          2.5           1.7          1.8 #      seattle          2.5           1.7          1.8
 #      san-diego        2.5           1.8          1.4  ; #      san-diego        2.5           1.8          1.4  ;
-d_table = wsv"""+d_table = CSV.read(IOBuffer("""
 plants     new_york  chicago  topeka plants     new_york  chicago  topeka
 seattle    2.5       1.7      1.8 seattle    2.5       1.7      1.8
 san_diego  2.5       1.8      1.4 san_diego  2.5       1.8      1.4
-"""+"""), DataFrame, delim=" ", ignorerepeated=true,copycols=true)
 d = Dict( (r[:plants],m) => r[Symbol(m)] for r in eachrow(d_table), m in markets) d = Dict( (r[:plants],m) => r[Symbol(m)] for r in eachrow(d_table), m in markets)
 # Here we are converting the table in a "(plant, market) => distance" dictionary # Here we are converting the table in a "(plant, market) => distance" dictionary
personal/blog/2017/0203_jump_for_gams_users.txt · Last modified: 2023/12/22 11:39 by antonello
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0