Applied Optimization with Julia
University of Hamburg - Fall 2024
Question: Anybody an idea what a central library is?
Question: What decisions can the library make for tours?
Question: What is the impact of the decisions?
Have you heard of
this problem before?
Question: What could be the objective for central libraries?
Question: What could we try to model?
Minimization of the travel time while supplying all libraries in the state and adhering to the vehicle capacities and driving time restrictions.
Capacitated
Vehicle Routing
(CVRP)
Note
There are many variants of the VRP! E.g., with time windows, periodic deliveries, allowing for pickups or deliveries, and much more!
Let’s visualize
the problem!
Question: What could be the sets here?
Question: What are possible parameters?
Tip
\(t\) is the maximal duration of each tour, not the travel time on an arc or an index!
We have the following sets:
Our objective is to:
Minimize the total travel time while supplying all customers and adhering to the vehicle capacities and duration restrictions.
Question: What could be our decision variable/s?
Variable Domain
\(X_{i,j,k}\) is a binary variable, as it can only take values 0 or 1. But most likely, you will already have spotted that!
Question: Why this might make the problem difficult?
We have the following sets:
Our objective is to:
Minimization of the travel time (or driving distance), while supplying all customers and adhering to the vehicle capacities and duration restrictions. Hint: Even with many vehicles, each arc can maximally be passed once!
Question: What could be our decision variable/s?
Only possible under certain conditions!
Only possible, if time and capacity constraints are equal for all vehicles!
Our objective is to:
Minimization of the travel time (or driving distance), while supplying all customers and adhering to the vehicle capacities and duration restrictions.
Question: What could be our objective function?
We need the following variable:
We need the following parameters:
\[\text{minimize} \quad \sum_{(i,j) \in \mathcal{A}} c_{i,j} \times X_{i,j}\]
Question: What does \((i,j) \in \mathcal{A}\) under the sum mean?
Question: What constraints do we need?
Subtours
In addition, we have to prevent subtours!
What is a
subtour?
The goal of these constraints is to:
Ensure that each customer is visited exactly once. Essentially, we could also say that each node has to be entered and left exactly once.
We need the following sets and variables:
Question: What could the constraint look like?
\[ \sum_{i \in \mathcal{V}} X_{i,j} = 1 \quad \forall j \in \mathcal{V} \setminus \{0\}, i \neq j \]
\[ \sum_{j \in \mathcal{V}} X_{i,j} = 1 \quad \forall i \in \mathcal{V} \setminus \{0\}, i \neq j \]
Question: Why for all nodes except the depot?
The depot is the only node that is visited multiple times!
The goal of these constraints is to:
Ensure that each vehicle enters and leaves the depot exactly \(|\mathcal{K}|\) times, as we have \(|\mathcal{K}|\) vehicles and each vehicle has to return to the depot.
We need the following sets and variables:
Question: What could the constraint look like?
\[ \sum_{i \in \mathcal{V}} X_{i,0} = |\mathcal{K}| \]
\[ \sum_{j \in \mathcal{V}} X_{0,j} = |\mathcal{K}| \]
Are all constraints necessary?
No, theoretically we could also say that we only have to leave or enter the depot exactly \(|\mathcal{K}|\) times, as the other constraint is already enforced by the “visit each customer once constraint”.
The next ones are
a little bit tricky.
Note
You don’t need to guess these constraints, as they are quite tricky!
We need the following sets, parameters, and variables:
\[ U_i - U_j + b \times X_{i,j} \leq b - d_j \quad \forall i,j \in \mathcal{V} \setminus \{0\}, i \neq j \]
\[ d_i \leq U_i \leq b \quad \forall i \in \mathcal{V} \setminus \{0\} \]
Too
complicated?
Question: Why is it binding?
Question: Do you get the idea?
Question: What about the capacity?
Question: Anybody an idea?
We need the following sets and variables:
\[ T_i - T_j + t \times X_{i,j} \leq t - c_{i,j} \quad \forall i,j \in \mathcal{V} \setminus \{0\}, i \neq j \]
\[ 0 \leq T_{i} \leq t \quad \forall i \in \mathcal{V} \setminus \{0\} \]
Any questions?
\[ \text{minimize} \quad \sum_{(i,j) \in \mathcal{A}} c_{i,j} \times X_{i,j} \]
The goal of the objective function is to:
Minimize the total travel distance.
\[ \sum_{i \in \mathcal{V}} X_{i,j} = 1 \quad \forall j \in \mathcal{V} \setminus \{0\}, i \neq j \]
\[ \sum_{j \in \mathcal{V}} X_{i,j} = 1 \quad \forall i \in \mathcal{V} \setminus \{0\}, i \neq j \]
Our constraints ensure:
Each customer is visited exactly once.
\[ \sum_{i \in \mathcal{V}} X_{i,0} = |\mathcal{K}| \]
\[ \sum_{j \in \mathcal{V}} X_{0,j} = |\mathcal{K}| \]
Our constraints ensure:
The depot is visited by exactly \(|\mathcal{K}|\) vehicles. Note, that we could remove one of the constraints and the solution would still be optimal.
\[ U_i - U_j + b \times X_{i,j} \leq b - d_j \quad \forall i,j \in \mathcal{V} \setminus \{0\}, i \neq j \]
\[ d_i \leq U_i \leq b \quad \forall i \in \mathcal{V} \setminus \{0\} \]
Our constraints ensure:
The capacity limit is respected and subtours are eliminated.
\[ T_i - T_j + t \times X_{i,j} \leq t - c_{i,j} \quad \forall i,j \in \mathcal{V} \setminus \{0\}, i \neq j \]
\[ 0 \leq T_i \leq t \quad \forall i \in \mathcal{V} \setminus \{0\} \]
Our constraints ensure:
The time limit is respected (and subtours are eliminated).
\[ X_{i,j} \in \{0,1\} \quad \forall i,j \in \mathcal{V} \]
\[ d_i \leq U_i \leq b \quad \forall i \in \mathcal{V} \setminus \{0\} \]
\[ 0 \leq T_i \leq t \quad \forall i \in \mathcal{V} \setminus \{0\} \]
The variable domains make sure that:
The binary setup variable is either 0 or 1 and the new variables are below the time and capacity limit.
Questions: On model characteristics
Questions: On model assumptions
Questions: What extensions do you know?
Can our formulation
solve the problem
on a real-world instance?
No, although we can find
solutions within one hour,
the gap is still very large
with 40%-45%.
Note
We won’t go deeper into this, but feel free to ask me!
Can we do
anything to solve
the model?
Tip
For problems with 100+ locations, heuristics are often the only practical choice.
Logistics & Delivery
Service Industries
Question: Can you think of other applications?
And that’s it for todays lecture!
We now have covered the Capacitated Vehicle Routing Problem and are ready to start solving some tasks in the upcoming tutorial.
Questions?
For more interesting literature to learn more about Julia, take a look at the literature list of this course.
Lecture VII - Library Routing Optimization | Dr. Tobias Vlćek | Home