Differences
This shows you the differences between two versions of the page.
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:24] antonello [Declaration of the model] |
||
---|---|---|---|
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() | + | using Pkg # Load the package manager |
- | Pkg.add(" | + | Pkg.update() |
- | Pkg.add(" | + | Pkg.add(" |
- | Pkg.add(" | + | Pkg.add(" |
- | Pkg.add(" | + | Pkg.add(" |
+ | Pkg.add(" | ||
+ | Pkg.add(" | ||
</ | </ | ||
Line 42: | Line 44: | ||
==== Importing the libraries ==== | ==== Importing the libraries ==== | ||
- | You will need to import as a minima the '' | + | You will need to import as a minima the '' |
< | < | ||
- | # Import of the JuMP and DataFrames modules (the latter | + | # Import of the JuMP, GLPK, CSV and DataFrames modules (the latter |
- | using JuMP, DataFrames | + | using CSV, DataFrames, GLPK, JuMP |
</ | </ | ||
Line 94: | Line 96: | ||
# seattle | # seattle | ||
# san-diego | # san-diego | ||
- | d_table = wsv""" | + | d_table = CSV.read(IOBuffer(""" |
plants | plants | ||
seattle | seattle | ||
san_diego | san_diego | ||
- | """ | + | """ |
d = Dict( (r[: | d = Dict( (r[: | ||
# Here we are converting the table in a " | # Here we are converting the table in a " | ||
Line 130: | Line 132: | ||
Here we declare a JuML optimisation model and we give it a name. This name will be then passed as first argument to all the subsequent operations, like creation of variables, constraints and objective function.\\ | Here we declare a JuML optimisation model and we give it a name. This name will be then passed as first argument to all the subsequent operations, like creation of variables, constraints and objective function.\\ | ||
- | We can, if we wish, works with several models at the same time.\\ | + | The solver engine to use is given as argument of the '' |
- | If we do not specify a solver, we let JuML use a suitable solver for the type of problem. Aside to specify the solver, we can also pass it solver-level options, e.g.: | + | We could pass solver-specific |
- | '' | + | '' |
<code julia> | <code julia> | ||
# Model declaration (transport model) | # Model declaration (transport model) | ||
- | trmodel = Model() | + | trmodel = Model(GLPK.Optimizer) |
</ | </ | ||