Applied Optimization with Julia
University of Hamburg
Question: Have you ever heard of the Hajj?
After this lecture, you will be able to:
Ramy al-Jamarat ritual
Pilgrims throw pebbles against three pillars, which symbolize the temptations of the devil. They repeat this ritual with small variations on four consecutive days.
Question: What could become a problem?
Uncoordinated access within confined area can escalate into crowd disasters!
Question: What could we do to prevent this?
How is Hajj pedestrian
traffic different from the
regular urban pedestrian
traffic in cities?



Question: What is the most dangerous type here?
Multi-directional and intersecting flows are the most dangerous type!
General idea
Adhere to one-way flow systems and define path options for each camp under consideration of a unidirectional flow system.
Question: What could be the objective?
Question: How can we try to model this?
Question: Where is the goal conflict?
Each camp has a set of feasible one-way paths that include the stoning ritual.
A path may contain one or more bottlenecks, regarded as resources subject to a capacity.
Pilgrims depart from a camp at a time \(t\) and pass through the bottleneck later.
Our model should assign one of the feasible paths to a camp on all four ritual days.
These bottlenecks should not be overcrowded at any time during the Hajj.
How can we model
time preferences?
Group time preferences
May be computed, i.e., down-sampled given a distribution of pilgrims over time.
Question: What could become a problem?
Question: Any idea how we can do that later?
Question: What could be the sets here?
A scheduling group is a group of pilgrims from one camp on one specific ritual day. One model thus covers all four days at once.
But we further need subsets!
That looks
complicated…
Question: Why use subsets?
A smaller problem size reduces the solution space and helps the solver in finding the optimal solution faster!
Question: What could be possible parameters?
Our first goal is to:
Satisfy time preferences of the pilgrims as much as possible under the consideration of infrastructure bottleneck flow capacities by assigning “something” to a time slot.
We need the following sets:
Question: What could be our decision variable?
Question: Do you get the idea here?
It’s a binary assignment of a group to a time slot and a path.
Our second goal (more a constraint):
For the sake of simplicity and safety, pilgrims coming from one camp will always have to be assigned the same path.
We need the following sets:
Question: What could be our second variable?
Question: Does anyone remember the third part?
Our third goal (again, more a constraint):
We need to keep track of the relative utilization of each resource to restrict the fluctuations between periods to ensure a safer event.
We need the following sets:
Question: What could be our third variable?
Question: What does relative utilization mean?
Let’s start with our
objective function!
Our main objective is to:
Satisfy time preferences of the pilgrims as much as possible under the consideration of infrastructure bottleneck flow capacities by assigning “something” to a time slot. Hint: We thus could aim to minimize the total dissatisfaction with the timetable.
Question: How could we minimize the total dissatisfaction?
We need the following parameters and variables:
Question: What could be our objective function?
\[ \text{Minimize} \quad \sum_{s \in \mathcal{S}}\sum_{t \in \mathcal{T}_s}\sum_{p \in \mathcal{P}_s} f_{s,t} \times X_{s,t,p} \]
Note how we use the subsets \(\mathcal{T}_s\) and \(\mathcal{P}_s\) to keep the model small.
Question: Is our objective function linear?
Question: Any idea why?
Question: Which constraints do we need?
The goal of this constraint is to:
Assign one path to each camp over the entire time horizon.
We need the following variables:
Question: What could be the constraint?
\[ \sum_{p \in \mathcal{P}_c} Y_{c,p} = 1 \quad \forall c \in \mathcal{C} \]
The goal of this constraint is to:
Assign one time slot to each group over the entire time horizon using the same path we have assigned to the camp in the previous constraint.
We need the following variables:
Question: What could be the constraint?
\[ \sum_{t \in \mathcal{T}_s} X_{s,t,p} = Y_{c,p} \quad \forall c \in \mathcal{C}, p \in \mathcal{P}_c, s \in \mathcal{S}_c \]
We use the following sets:
Each group can use all feasible paths of its camp: \(\mathcal{P}_s = \mathcal{P}_c\) for all \(s \in \mathcal{S}_c\).
Question: We wanted one path and one time slot per group. Where are these two constraints?
Sum the last constraint over all paths of a camp:
\[ \sum_{p \in \mathcal{P}_c} \sum_{t \in \mathcal{T}_s} X_{s,t,p} = \sum_{p \in \mathcal{P}_c} Y_{c,p} = 1 \quad \forall c \in \mathcal{C}, s \in \mathcal{S}_c \]
The goal of this constraint is to:
Compute the relative utilization of each resource while also ensuring that the utilization does not exceed the capacity limit. This one is very tricky!
Difficulties:
We need the following:
Question: What could be the constraint?
\[ \sum_{p \in \mathcal{P}_r}\sum_{s \in \mathcal{S}_p} n_s \times X_{s,t-a_{p,r},p} = b_{r,t}\times U_{r,t} \quad \forall r \in \mathcal{R}, t \in \mathcal{T} \]
Convention
Terms where the shifted period \(t - a_{p,r}\) lies outside of \(\mathcal{T}_s\) are simply dropped, as no group can be scheduled for stoning there.
Question: We promised a capacity limit, but there is no “\(\leq\) capacity” constraint. Why does it still hold?
A variable domain and a constraint can combine into a constraint that is never written down explicitly.
Let’s pause!
Have you understood
this part?
The goal of this constraint is to:
Keep the relative utilization of each resource within bounds to ensure a safer event.
We need the following:
Question: What could be the constraint?
\[ U_{r,t} - U_{r,t-1} \leq \sigma_r \quad \forall r \in \mathcal{R}, t \in \mathcal{T}: t > 1 \]
\[ U_{r,t-1} - U_{r,t} \leq \sigma_r \quad \forall r \in \mathcal{R}, t \in \mathcal{T}: t > 1 \]
Question: Can somebody explain why this works?
\[\begin{align*} \text{Minimize} \quad \sum_{s\in \mathcal{S}}\sum_{t \in \mathcal{T}_s}\sum_{p \in \mathcal{P}_s} f_{s,t} \times X_{s,t,p} \end{align*}\]
subject to:
\[\begin{align*} & \sum_{p \in \mathcal{P}_c} Y_{c,p} = 1 && \forall c \in \mathcal{C} \\ & \sum_{t \in \mathcal{T}_s} X_{s,t,p} = Y_{c,p} && \forall c \in \mathcal{C}, p \in \mathcal{P}_c, s \in \mathcal{S}_c \end{align*}\]
\[\begin{align*} & \sum_{p \in \mathcal{P}_r}\sum_{s \in \mathcal{S}_p} n_s \times X_{s,t-a_{p,r},p} = b_{r,t}\times U_{r,t} && \forall r \in \mathcal{R}, t \in \mathcal{T} \\ & U_{r,t} - U_{r,t-1} \leq \sigma_r && \forall r \in \mathcal{R}, t \in \mathcal{T}: t > 1 \\ & U_{r,t-1} - U_{r,t} \leq \sigma_r && \forall r \in \mathcal{R}, t \in \mathcal{T}: t > 1 \end{align*}\]
Restricting the relative utilization of each resource to a certain bound.
\[\begin{align*} & X_{s,t,p} \in \{0,1\} && \forall s \in \mathcal{S}, t \in \mathcal{T}_s, p \in \mathcal{P}_s \\ & Y_{c,p} \in \{0,1\} && \forall c \in \mathcal{C}, p \in \mathcal{P}_c \\ & U_{r,t} \in [0,1] && \forall r \in \mathcal{R}, t \in \mathcal{T} \end{align*}\]
All variables, except for \(U_{r,t}\), are binary.
Questions: On model characteristics
Questions: On model assumptions
Capacities are hard limits: if demand exceeds them, the model becomes infeasible and refuses to produce an unsafe plan. This is a feature, not a bug!
Can this be
applied?
Optimization was part of a project by Knut Haase and his team (Haase et al. 2016).
And that’s it for today’s lecture!
We now have covered a scheduling problem based on a real-world application and are ready to start solving some new tasks in the upcoming tutorial.
Questions?
To learn more about the project and crowd management during the Hajj, take a look at Haase et al. (2016) and the literature list of this course.
Lecture IX - Safety Planning for the Islamic Pilgrimage | Dr. Tobias Vlćek | Home