Bird
0
0
LLDsystem_design~7 mins

Multiple elevator coordination in LLD - System Design Guide

Choose your learning style9 modes available
Problem Statement
When multiple elevators operate independently without coordination, they can cause inefficient service such as multiple elevators responding to the same floor request, long wait times, and uneven load distribution. This leads to passenger frustration and wasted energy as elevators travel unnecessarily.
Solution
Multiple elevator coordination assigns elevator requests intelligently to the best-suited elevator based on current position, direction, and load. It uses a centralized or distributed controller to optimize elevator movements, minimizing wait times and avoiding duplicate responses. This coordination ensures elevators serve requests efficiently and fairly.
Architecture
Floor Request
Elevator Coordinator
Elevator 2

This diagram shows floor requests sent to a central elevator coordinator, which assigns tasks to multiple elevators based on their state and location.

Trade-offs
✓ Pros
Reduces passenger wait times by assigning the closest or most suitable elevator.
Prevents multiple elevators from responding to the same request, improving efficiency.
Balances load among elevators to avoid overuse of a single elevator.
Improves energy efficiency by minimizing unnecessary elevator movements.
✗ Cons
Requires a centralized or distributed coordination system, adding complexity.
Coordination logic can become complex with many elevators and floors.
Potential single point of failure if centralized coordinator is not redundant.
Use when a building has multiple elevators serving overlapping floors and experiences high passenger traffic, typically more than 3 elevators and 10 floors.
Avoid when the building has only one elevator or very low traffic where coordination overhead outweighs benefits.
Real World Examples
Otis Elevator Company
Uses group supervisory control systems to coordinate multiple elevators in skyscrapers, reducing wait times and improving energy efficiency.
Thyssenkrupp
Implements AI-based elevator coordination to optimize elevator dispatching in busy office buildings.
KONE
Employs destination control systems that coordinate multiple elevators by grouping passengers going to the same floors.
Code Example
The before code shows elevators handling requests independently, which can cause inefficiency. The after code introduces an ElevatorCoordinator that assigns each floor request to the closest elevator, improving efficiency and reducing wait times.
LLD
### Before: Independent elevator handling requests
class Elevator:
    def __init__(self, id):
        self.id = id
        self.current_floor = 0
        self.requests = []

    def add_request(self, floor):
        self.requests.append(floor)

    def move(self):
        if self.requests:
            next_floor = self.requests.pop(0)
            self.current_floor = next_floor

# No coordination: multiple elevators may respond to same request

### After: Coordinated elevator system
class Elevator:
    def __init__(self, id):
        self.id = id
        self.current_floor = 0
        self.direction = None
        self.requests = []

    def assign_request(self, floor):
        self.requests.append(floor)

    def move(self):
        if self.requests:
            next_floor = self.requests.pop(0)
            self.current_floor = next_floor

class ElevatorCoordinator:
    def __init__(self, elevators):
        self.elevators = elevators

    def assign_request(self, floor):
        best_elevator = None
        min_distance = float('inf')
        for elevator in self.elevators:
            distance = abs(elevator.current_floor - floor)
            if distance < min_distance:
                min_distance = distance
                best_elevator = elevator
        if best_elevator:
            best_elevator.assign_request(floor)

# Usage
elevators = [Elevator(1), Elevator(2)]
coordinator = ElevatorCoordinator(elevators)
coordinator.assign_request(5)
coordinator.assign_request(3)
for elevator in elevators:
    elevator.move()
OutputSuccess
Alternatives
Independent Elevator Control
Each elevator operates autonomously without coordination, responding only to its own requests.
Use when: Use in small buildings with one or two elevators where coordination complexity is unnecessary.
Destination Control System
Passengers input their destination floor before entering the elevator, allowing the system to group passengers and assign elevators efficiently.
Use when: Use in high-traffic buildings where grouping passengers reduces stops and travel time.
Summary
Uncoordinated elevators cause inefficiency by duplicating responses and increasing wait times.
Coordinating elevators assigns requests to the best elevator based on position and state, improving service.
Coordination adds complexity but is essential for buildings with multiple elevators and high traffic.