Applied Optimization with Julia
University of Hamburg
After this lecture, you will:
function keywordreturn to specify the output of a functionYou can create anonymous functions using the -> syntax for quick, one-off operations.
using Pkg to access package managementPkg.add("PackageName")] in the REPL to enter package mode and type add PackageNameusing PackageName or import PackageNameJuMP and HiGHSDataFrame constructorUse describe(df) to get a quick summary of your DataFrame.
CSV packageCSV.read("file.csv", DataFrame) to read a CSV file into a DataFrameCSV.write() to write a DataFrame to a CSV fileThe DataFrame is a required second argument of CSV.read() — it tells the function into which structure to read the file.
plot(), scatter(), bar()title, xlabel, ylabelExplore different plot types; later, different backends offer other output formats and interactivity.
You can ask questions anytime in class or via email!
Question: How do we get a model from paper into the computer?
Model and solver are separate: JuMP describes what to optimize, HiGHS figures out how to solve it.
In the first lecture, we formulated the transport problem:
\[ \begin{aligned} \text{Minimize} \quad F &= \sum_{i \in \mathcal{I}} \sum_{j \in \mathcal{J}} c_{i,j} \times X_{i,j} \\ \text{subject to:} \quad &\sum_{j \in \mathcal{J}} X_{i,j} \leq a_i \quad &&\forall i \in \mathcal{I} \\ &\sum_{i \in \mathcal{I}} X_{i,j} = b_j \quad &&\forall j \in \mathcal{J} \\ &X_{i,j} \geq 0 \quad &&\forall i \in \mathcal{I}, \forall j \in \mathcal{J} \end{aligned} \]
Let’s now solve it — live in JuMP!
Minimal costs: 225460.0 Euro
Don’t worry if not every line is clear yet — this week’s tutorials build up this pattern step by step.
And that’s it for this lecture!
The remaining time we will already start working on this week’s tutorials. From next week on, we will work on different optimization problems and topics that we will address together in the course.
Lauwens, B., & Downey, A. B. (2019). Think Julia: How to think like a computer scientist (First edition). O’Reilly®. Link to the free book website.
Kwon, C. (2019). Julia Programming for Operations Research (Second edition). Link to the book website.
For more interesting literature to learn more about Julia, take a look at the literature list of this course.
Lecture IV - Modelling with JuMP | Dr. Tobias Vlćek | Home