Programming: Everyday Decision-Making Algorithms
Kühne Logistics University Hamburg - Winter 2024
Let’s solve this simple scheduling problem:
Goal: Minimize total time for washing and drying all loads
Question: An idea how to solve this?
Rule: To find the optimal solution:
Question: What’s the first scheduled task?
Question: What’s the next task?
Question: What’s the next task?
Now, we only have one task left!
Final sequence: B A D C
Optimal Solution: B A D C
Total time: 4 hours 20 minutes
Question: Is there a worse solution?
Suboptimal Solution: C D A B
Total time: 5 hours 10 minutes
Question: What’s the difference?
Question: Who knows what a Gantt Chart is?
Question: What properties can scheduled tasks have?
Question: What types of tasks do you deal with most often?
Question: What is different from before?
Order is Irrelevant
Under simple minimization of total processing time, order doesn’t matter!
Question: But is it that simple?
Order Matters
Order becomes crucial when we consider, Deadlines, Priorities and Dependencies!
Tasks with individual deadlines:
Goal: Minimize maximum deadline violation
Question: An idea how to solve this?
Rule: Sort the tasks by deadline.
Let’s visualize this!
Question: What’s the maximum delay here?
Instead of deadlines, we now have processing times.
Goal: Min. total waiting time
Question: Any ideas?
Rule: Always schedule the shortest remaining task
Rule: Always schedule the shortest remaining task. Choose random if multiple tasks are tied.
Question: What’s the order of scheduled tasks?
Rule: Always schedule the shortest remaining task. Choose random if multiple tasks are tied.
Final sequence: B E A D C or E B A D C
Optimal sequence:
Question: Where can we see the waiting time?
Total waiting time: 340 minutes
Question: Would this be applicable for your work?
Task Duration Revenue
A 20min €240
B 30min €200
C 60min €120
D 50min €70
E 30min €130
F 40min €120
G 20min €100
H 70min €110
I 50min €90
Question: Any ideas how to approach this?
Rule: Schedule by revenue per minute (descending)
Task Duration Revenue Revenue/Min Schedule
A 20min €240 12.0
B 30min €200 6.7
C 60min €120 2.0
D 50min €70 1.4
E 30min €130 4.3
F 40min €120 3.0
G 20min €100 5.0
H 70min €110 1.6
I 50min €90 1.8
Question: What’s the order of scheduled tasks?
Rule: Schedule by revenue per minute (descending)
Rule: Schedule by revenue per minute (descending)
Rule: Schedule by revenue per minute (descending)
Rule: Schedule by revenue per minute (descending)
Rule: Schedule by revenue per minute (descending)
Rule: Schedule by revenue per minute (descending)
Rule: Schedule by revenue per minute (descending)
Rule: Schedule by revenue per minute (descending)
Task Duration Revenue Revenue/Min Schedule
A 20min €240 12.0 1
B 30min €200 6.7 2
C 60min €120 2.0 6
D 50min €70 1.4 9
E 30min €130 4.3 4
F 40min €120 3.0 5
G 20min €100 5.0 3
H 70min €110 1.6 8
I 50min €90 1.8 7
Metric Priorities
Without revenues, we can use the same approach with metric priorities!
Question: How to handle with shortest processing time?
Question: What’s was earliest due date again?
Rule: We can use Lawler’s Algorithm (1968)
Task Duration Deadline Predecessor Schedule
A 40min 110min None
B 30min 90min D
C 60min 150min A
D 50min 70min None
E 30min 210min C
Question: What’s the schedule?
Task Duration Deadline Predecessor Schedule
A 40min 110min None 1
B 30min 90min D 3
C 60min 150min A 4
D 50min 70min None 2
E 30min 210min C 5
Successor Tasks
Note, how all tasks become tasks without successors at some point.
Predecessor Tasks
Predecessor tasks are tasks that must be completed before the current task can start. They are marked in grey in the chart.
Question: What’s the maximum delay?
Question: What have we missed so far?
Quick reminder
An earliest due date is a specific point in time by which a task must be completed. Under this objective, we want to minimize the maximum delay.
8:00-12:00 Schedule:
Task Duration Deadline
Email A 20min 9:00
Create PPT 60min 10:50
Investor call 10min 9:00
Email B 30min 10:20
Liquidity 40min 11:00
Email C 20min 11:20
Email D 40min 10:00
Question: Any ideas how to start with under the objective of the earliest due date?
Rule:
Equal Deadline
If a new task has the same deadline as the current task, you can choose either. But due to the cost of context switching, you might want to stick with the current task.
Question: What’s the maximum delay with this schedule?
Quick reminder
A shortest processing time is the task with the shortest duration. Under this objective, we want to minimize the total waiting time.
Question: Any ideas how to start here?
Rule:
Equal Duration
If a new task has the same duration as the current task, you can choose either. But due to the cost of context switching, you might again want to stick with the current task.
Question: Where can we see the waiting time?
Total waiting time: 260 minutes
Question: Have you ever experienced this?
Question: Any ideas how to prevent this?
Strategic
Strategic solutions focus on long-term changes to prevent thrashing.
Question: What strategies have worked for you?
Note
That’s it for todays lecture!
We now have covered a brief introduction into scheduling. Now, we can start with the tutorials! As we have now a good foundation, we can start to apply some algorithms on data sets in Python.
Note
Think Python is a great book to start with. It’s available online for free. Schrödinger Programmiert Python is a great alternative for German students, as it is a very playful introduction to programming with lots of examples.
For more interesting literature, take a look at the literature list of this course.
Lecture IV - Scheduling | Dr. Tobias Vlćek | Home