PhD Thesis: Julia code in Chapter 1

Throughout my thesis I use JuMP, a modeling language for mathematical optimization embedded in Julia. On this page I present the code for two examples that I use in the introduction of my thesis. The material below is free to use in other lectures or programs with reference to the original source.

Julia code (click to download):

The raw code from the small robust optimization example is also given below to copy-paste.

# Models for introduction thesis Frans de Ruiter, 2017 CC.

# Load packages JuMP and wrapper for Gurobi
using JuMP, Gurobi

ro = Model(solver=GurobiSolver())           # Define robust optimization model with solver
@variable(ro, x[1:2] >= 0)                  # Add variable
@objective(ro, Max, 5*x[1] + x[2])          # Add objective
@constraint(ro, 21.94174*x[1] + 4.38476*x[2]
 + 1/sqrt(2)*norm(x) <= 200)                # Add (robust counterpart) constraint
solve(ro)                                   # Solve the model
obj_ro  = getobjectivevalue(ro)             # Obtain the objective value and solution
x_ro    = getvalue(x)

# The same as above, but now for the nominal model
nom = Model(solver=GurobiSolver())          # Define nominal optimization model with solver
@variable(nom, xnom[1:2] >= 0)              # Add variable
@objective(nom, Max, 5*xnom[1] + xnom[2])   # Add objective
@constraint(nom, 21.94174*xnom[1] +
4.38476*xnom[2] <= 200)                     # Add nominal constraint
solve(nom)                                  # Solve the model
obj_nom  = getobjectivevalue(nom)           # Obtain the objective value and solution
x_nom    = getvalue(xnom)
For questions, see contact details on the homepage.