Skip to content

Commit

Permalink
added slides and fixed tuorials
Browse files Browse the repository at this point in the history
  • Loading branch information
beyondsimulations committed Jan 6, 2025
1 parent 6ea22c8 commit 7530ac6
Show file tree
Hide file tree
Showing 22 changed files with 586 additions and 79 deletions.
7 changes: 7 additions & 0 deletions 404.qmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
---
title: Page Not Found

html:
theme: [default, styles.scss]
highlight-style: breezedark
linkcolor: "#a60000"
---

# Page Not Found

Sorry, the page you requested cannot be found (perhaps it was moved or renamed).

You may want to try searching to find the page's new location.
2 changes: 1 addition & 1 deletion _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ website:

format:
html:
theme: [litera, ../styles.scss]
theme: [litera, styles.scss]
toc: true
highlight-style: arrow
linkcolor: "#a60000"
Expand Down
2 changes: 1 addition & 1 deletion general/cheatsheet-julia.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Julia Syntax Cheatsheet"
subtitle: "Applied Optimization with Julia"

html:
theme: litera
theme: [default, ../styles.scss]
highlight-style: breezedark
linkcolor: "#a60000"
code-copy: true
Expand Down
2 changes: 1 addition & 1 deletion general/faq.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Frequently Asked Questions"
subtitle: "Answers to common questions"

html:
theme: litera
theme: [default, ../styles.scss]
highlight-style: breezedark
linkcolor: "#a60000"
code-copy: true
Expand Down
2 changes: 2 additions & 0 deletions general/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<script defer data-domain="beyondsimulations.github.io/applied-optimization" src="https://plausible.io/js/script.file-downloads.outbound-links.js"></script>
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
2 changes: 1 addition & 1 deletion general/literature.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Literature and Resources"
subtitle: "Good books and resources to read"

html:
theme: litera
theme: [default, ../styles.scss]
code-copy: true
code-link: true
toc: true
Expand Down
2 changes: 1 addition & 1 deletion general/syllabus.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Syllabus"
subtitle: "This years course structure"

html:
theme: litera
theme: [default, ../styles.scss]
highlight-style: breezedark
linkcolor: "#a60000"
code-copy: true
Expand Down
File renamed without changes.
12 changes: 4 additions & 8 deletions create_pdf.py → helpers/create_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@
page.pdf(path=args.output, scale=1.5, prefer_css_page_size=True)

'''
python3 create_pdf.py _site/part-01/lecture-presentation.html pdf-slides/ao_lecture_01.pdf
python3 create_pdf.py _site/part-02/lecture-presentation.html pdf-slides/ao_lecture_02.pdf
python3 create_pdf.py _site/part-03/lecture-presentation.html pdf-slides/ao_lecture_03.pdf
python3 create_pdf.py _site/part-04/lecture-presentation.html pdf-slides/ao_lecture_04.pdf
python3 create_pdf.py _site/part-05/lecture-presentation.html pdf-slides/ao_lecture_05.pdf
python3 create_pdf.py _site/part-06/lecture-presentation.html pdf-slides/ao_lecture_06.pdf
python3 create_pdf.py _site/part-07/lecture-presentation.html pdf-slides/ao_lecture_07.pdf
decktape reveal _site/part-01/lecture-presentation.html pdf-slides/ao_lecture_01.pdf
decktape reveal _site/part-02/lecture-presentation.html pdf-slides/ao_lecture_02.pdf
decktape reveal _site/part-03/lecture-presentation.html pdf-slides/ao_lecture_03.pdf
Expand All @@ -34,4 +26,8 @@
decktape reveal _site/part-07/lecture-presentation.html pdf-slides/ao_lecture_07.pdf
decktape reveal _site/part-08/lecture-presentation.html pdf-slides/ao_lecture_08.pdf
decktape reveal _site/part-09/lecture-presentation.html pdf-slides/ao_lecture_09.pdf
decktape reveal _site/part-10/lecture-presentation.html pdf-slides/ao_lecture_10.pdf
decktape reveal _site/part-11/lecture-presentation.html pdf-slides/ao_lecture_11.pdf
decktape reveal _site/part-12/lecture-presentation.html pdf-slides/ao_lecture_12.pdf
decktape reveal _site/part-13/lecture-presentation.html pdf-slides/ao_lecture_13.pdf
'''
2 changes: 1 addition & 1 deletion index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Welcome to Applied Optimization with Julia!"
subtitle: "University of Hamburg - Fall 2024"

html:
theme: [litera, ../styles.scss]
theme: [default, styles.scss]
highlight-style: breezedark
linkcolor: "#a60000"
---
Expand Down
Binary file added part-02/tutorial-02-01-variables 2.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions part-06/lecture-ordersplit.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ As we don't need the customer order information, we only need to make a decision
```{julia}
#| eval: true
#| output: false
import Pkg; Pkg.add("SCIP")
using JuMP, SCIP # SCIP is a non-commercial MIQCP solver
warehouses = ["Hamburg", "Berlin"] # Add warehouses as a vector
Expand Down
Binary file renamed part-11/data/.DS_Store → part-11/.DS_Store
Binary file not shown.
8 changes: 0 additions & 8 deletions part-11/data/groups.csv

This file was deleted.

10 changes: 5 additions & 5 deletions part-11/lecture-distancing.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ You have 5 minutes to find a solution.
- $\mathcal{G}$ - Set of groups, indexed by $g$
- $\mathcal{R}$ - Set of rows, indexed by $r$
- $\mathcal{C}$ - Set of columns, indexed by $c$
- $\mathcal{C}_r$ - Available seats of row $r$, indexed by $c$
- $\mathcal{C}_{g,r}$ - Available seats of row $r$ for group $g$, indexed by $c$

. . .

Expand Down Expand Up @@ -310,7 +310,7 @@ Maximize the group values by filling the seating area given distancing regulatio
. . .

$$
\text{maximize} \quad \sum_{g \in \mathcal{G}} \sum_{r \in \mathcal{R}} \sum_{c\in \mathcal{C}_r} v_g \times X_{grc}
\text{maximize} \quad \sum_{g \in \mathcal{G}} \sum_{r \in \mathcal{R}} \sum_{c\in \mathcal{C}_{g,r}} v_g \times X_{g,r,c}
$$

# [Constraints]{.flow} {.title}
Expand Down Expand Up @@ -341,7 +341,7 @@ Ensure that each group is allocated only once in the entire seating area.
- $X_{g,r,c}$ - 1, if first left seat of $g$ is assigned to $r$ in $c$, else 0
- $\mathcal{G}$ - Set of groups, indexed by $g$
- $\mathcal{R}$ - Set of rows, indexed by $r$
- $\mathcal{C}_r$ - Set of columns of row $r$, indexed by $c$
- $\mathcal{C}_{g,r}$ - Set of columns of row $r$ for group $g$, indexed by $c$
:::

## Assign Each Group Only Once
Expand All @@ -351,7 +351,7 @@ Ensure that each group is allocated only once in the entire seating area.
. . .

$$
\sum_{r \in \mathcal{R}} \sum_{c \in \mathcal{C}_r} X_{g,r,c} \leq 1 \quad \forall g \in \mathcal{G}
\sum_{r \in \mathcal{R}} \sum_{c \in \mathcal{C}_{g,r}} X_{g,r,c} \leq 1 \quad \forall g \in \mathcal{G}
$$

. . .
Expand Down Expand Up @@ -384,7 +384,7 @@ Ensure that the number of groups in each row does not exceed the maximum allowed
. . .

$$
\sum_{g\in \mathcal{G}}\sum_{c\in \mathcal{C}} X_{g,r,c} \leq p_{r} \quad r \in \mathcal{R}
\sum_{g\in \mathcal{G}}\sum_{c\in \mathcal{C}_{g,r}} X_{g,r,c} \leq p_{r} \quad r \in \mathcal{R}
$$

. . .
Expand Down
137 changes: 137 additions & 0 deletions part-11/test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
using JuMP
using HiGHS

# Model
arena_model = Model(HiGHS.Optimizer)

# Sets
row_set = 1:10
col_set = 1:10

# Group data
groups = ["a", "b", "c", "d", "e", "f", "g"]
req_seats = Dict("a" => 1, "b" => 2, "c" => 2, "d" => 4, "e" => 4, "f" => 6, "g" => 6)
scores = Dict("a" => 1, "b" => 2, "c" => 4, "d" => 4, "e" => 5, "f" => 6, "g" => 12)
availability = Dict("a" => 3, "b" => 2, "c" => 3, "d" => 5, "e" => 2, "f" => 1, "g" => 1)

# Variables
@variable(arena_model, x[groups, row_set, col_set], Bin)

# Parameters
h = 1 # horizontal safety distance
b = 1 # vertical safety distance
p = 2 # max groups per row

# Objective
@objective(arena_model, Max, sum(scores[g] * x[g,r,c] for g in groups, r in row_set, c in col_set if c<=maximum(col_set)-req_seats[g]+1))

# Constraints
# Each group can only be assigned once
@constraint(arena_model, [g in groups],
sum(x[g,r,c] for r in row_set, c in col_set) <= availability[g])

# Maximum groups per row
@constraint(arena_model, [r in row_set],
sum(x[g,r,c] for g in groups, c in col_set) <= p)

# Horizontal and vertical social distancing
@constraint(arena_model, [r in row_set, c in col_set],
sum(x[g,rr,cc] for g in groups,
rr in max(1,r-b):r,
cc in max(1,c-req_seats[g]+1-h):c) <= 1)

# Define blocked seats (coordinates [row, column])
blocked_seats = [
(1, 1),(1, 2),(1,9),(1,10),
(6, 5),(6,6),
(7, 5),(7,6),
]

# Constraints to prevent assignments to blocked seats
@constraint(arena_model, [g in groups, (r,c) in blocked_seats],
x[g,r,c] == 0)

# Solve the model
optimize!(arena_model)

using Plots

# Create visualization of the solution
function visualize_seating(model)
# Get solution values
solution_matrix = fill("", 10, 10)

# Fill matrix with group assignments
for r in 1:10, c in 1:10
for g in groups
if value(model[:x][g,r,c]) > 0.5 # Using 0.5 to handle floating point
solution_matrix[r,c] = g
end
end
end

# Create color mapping for groups
color_map = Dict(
"" => :white, # Empty seats
"a" => :blue,
"b" => :green,
"c" => :red,
"d" => :purple,
"e" => :orange,
"f" => :yellow,
"g" => :pink
)

# Mark blocked seats
for (r,c) in blocked_seats
solution_matrix[r,c] = "" # Empty string for blocked seats
end

# Create plot
p = plot(
aspect_ratio=:equal,
xlims=(0.5,10.5),
ylims=(0.5,10.5),
yflip=true, # Flip y-axis to match traditional seating layout
legend=:outerright
)

# Plot seats
for r in 1:10, c in 1:10
group = solution_matrix[r,c]
if group != ""
group_length = req_seats[group]
for i in 1:group_length
if c+i-1 <= 10
println("Group $group in $r,$(c+i-1)")
scatter!([c+i-1], [r],
color=color_map[group],
label=nothing,
markersize=10,
markershape=:square)
end
end
else
# Plot empty or blocked seats
is_blocked = (r,c) in blocked_seats
if is_blocked
println("Blocked seat in $r,$c")
scatter!([c], [r],
color=is_blocked ? :gray : :white,
markersize=10,
markershape=:square,
label= nothing)
end
end
end

title!("Arena Seating Layout")
xlabel!("Column")
ylabel!("Row")

return p
end

# Display the visualization
p = visualize_seating(arena_model)
display(p)
Loading

0 comments on commit 7530ac6

Please sign in to comment.