Lecture


In [4]:
using JuMP

m = Model()

@variables m begin
    r>=0
    g>=0
end

@constraints m begin
    r + g <= 8
    r     >= 1
        g >= 1
    r     <= 5
        g <= 6
end

@objective(m, Max, 3r+2g)

solve(m)

println(getobjectivevalue(m))
writeLP(m, "costs.lp")


21.0

Changing Kernel to Execute Shell Command


In [1]:
!less "costs.lp"


Maximize
 obj: 3 VAR1 + 2 VAR2
Subject To
 c1: 1 VAR1 + 1 VAR2 <= 8
 c2: 1 VAR1 >= 1
 c3: 1 VAR2 >= 1
 c4: 1 VAR1 <= 5
 c5: 1 VAR2 <= 6
Bounds
 0 <= VAR1 <= +inf
 0 <= VAR2 <= +inf
General
End

In [3]:
!glpsol --cpxlp costs.lp --ranges costs.sen


GLPSOL: GLPK LP/MIP Solver, v4.60
Parameter(s) specified in the command line:
 --cpxlp costs.lp --ranges costs.sen
Reading problem data from 'costs.lp'...
5 rows, 2 columns, 6 non-zeros
13 lines were read
GLPK Simplex Optimizer, v4.60
5 rows, 2 columns, 6 non-zeros
Preprocessing...
1 row, 2 columns, 2 non-zeros
Scaling...
 A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00
Problem data seem to be well scaled
Constructing initial basis...
Size of triangular part is 1
*     0: obj =   5.000000000e+00 inf =   0.000e+00 (2)
*     2: obj =   2.100000000e+01 inf =   0.000e+00 (0)
OPTIMAL LP SOLUTION FOUND
Time used:   0.2 secs
Memory used: 0.0 Mb (40416 bytes)
Write sensitivity analysis report to 'costs.sen'...

In [4]:
!less "costs.sen"


GLPK 4.60 - SENSITIVITY ANALYSIS REPORT                                                                         Page   1

Problem:    
Objective:  obj = 21 (MAXimum)

   No. Row name     St      Activity         Slack   Lower bound       Activity      Obj coef  Obj value at Limiting
                                          Marginal   Upper bound          range         range   break point variable
------ ------------ -- ------------- ------------- -------------  ------------- ------------- ------------- ------------
     1 c1           NU       8.00000        .               -Inf        6.00000      -2.00000      17.00000 c3
                                           2.00000       8.00000       11.00000          +Inf      27.00000 c5

     2 c2           BS       5.00000      -4.00000       1.00000        2.00000      -1.00000      16.00000 c4
                                            .               +Inf        5.00000          +Inf          +Inf

     3 c3           BS       3.00000      -2.00000       1.00000         .           -2.00000      15.00000 c1
                                            .               +Inf        6.00000       1.00000      24.00000 c4

     4 c4           NU       5.00000        .               -Inf        2.00000      -1.00000      18.00000 c5
                                           1.00000       5.00000        7.00000          +Inf      23.00000 c3

     5 c5           BS       3.00000       3.00000          -Inf        1.00000      -2.00000      15.00000 c1
                                            .            6.00000        7.00000       1.00000      24.00000 c4

GLPK 4.60 - SENSITIVITY ANALYSIS REPORT                                                                         Page   2

Problem:    
Objective:  obj = 21 (MAXimum)

   No. Column name  St      Activity      Obj coef   Lower bound       Activity      Obj coef  Obj value at Limiting
                                          Marginal   Upper bound          range         range   break point variable
------ ------------ -- ------------- ------------- -------------  ------------- ------------- ------------- ------------
     1 VAR1         BS       5.00000       3.00000        .             2.00000       2.00000      16.00000 c4
                                            .               +Inf        5.00000          +Inf          +Inf

     2 VAR2         BS       3.00000       2.00000        .             1.00000        .           15.00000 c1
                                            .               +Inf        6.00000       3.00000      24.00000 c4

End of report

In [ ]:
Pkg.add("Plots")


INFO: Cloning cache of ColorTypes from https://github.com/JuliaGraphics/ColorTypes.jl.git
INFO: Cloning cache of Colors from https://github.com/JuliaGraphics/Colors.jl.git
INFO: Cloning cache of FixedPointNumbers from https://github.com/JuliaMath/FixedPointNumbers.jl.git
INFO: Cloning cache of FixedSizeArrays from https://github.com/SimonDanisch/FixedSizeArrays.jl.git

In [2]:
%%julia

println("Hello from Julia!\n")
[1:10]


ERROR: Cell magic `%%julia` not found.

In [ ]: