Understanding Elevator Algorithms
Elevator algorithms are fascinating examples of everyday optimization problems. They need to balance multiple competing factors:
- Minimize average waiting time
- Minimize total travel distance
- Provide fair service to all floors
- Handle peak usage patterns efficiently
Common Algorithms
1. FCFS (First Come, First Served)
- Simplest approach: serve requests in order of arrival
- Can lead to inefficient “ping-pong” patterns
- Poor performance under heavy load
2. SCAN (Elevator Algorithm)
- Move in one direction until no more requests in that direction
- Then reverse direction and repeat
- Better handling of multiple requests
- Can lead to some requests waiting longer
3. LOOK
- Similar to SCAN but only goes as far as the last request
- More efficient than SCAN for most scenarios
- Default choice for many real implementations
Interactive Simulation
This simulation features an automated request generation system that simulates real-world elevator traffic patterns:
Traffic Patterns
- Morning Rush: Heavy upward flow from ground floor
- Lunch Time: Mixed traffic between all floors
- Evening Rush: Heavy downward flow to ground floor
- Random: Uniformly distributed requests
Simulation Controls
- Start/Stop the simulation
- Select traffic pattern
- Adjust request rate (15-120 requests/minute)
- Choose scheduling algorithm
- Max Capacity: Elevators have a maximum capacity of 8 passengers.
- Floor Pause: A brief pause at each floor to simulate door opening and closing.
Simulation Controls
Algorithm:
0
↑0
↓0
0
1
↑0
↓0
0
2
↑0
↓0
0
3
↑0
↓0
0
4
↑0
↓0
0
5
↑0
↓0
0
6
↑0
↓0
0
7
↑0
↓0
0
0
0
↑0
↓0
0
1
↑0
↓0
0
2
↑0
↓0
0
3
↑0
↓0
0
4
↑0
↓0
0
5
↑0
↓0
0
6
↑0
↓0
0
7
↑0
↓0
0
0
System Metrics
Average Wait:
0s
Total Distance:
0 floors
Longest Wait:
0s
Requests Served:
0 / 0
Pending Requests:
0
Pending Requests
From | To | Wait Time |
---|