Development of an AI system for optimizing public transport routes
Urban transport is a system with constantly changing passenger flows. AI optimizes schedules and route networks based on real data, reducing wait times and increasing occupancy.
Passenger flow analysis
Data sources: - Turnstiles (AFC — Automated Fare Collection): exact entry/exit time, card type - GPS vehicle trackers: real location, deviation from schedule - Cameras in the cabin: CV-counting of passengers (YOLOv8 + tracking) - Mobile application: geolocation of users with consent
Passenger traffic forecast:
import pandas as pd
import numpy as np
from lightgbm import LGBMRegressor
class PassengerFlowPredictor:
"""Прогноз пассажиропотока на остановке по 15-минутным интервалам"""
def build_features(self, df):
df = df.copy()
df['hour'] = df['timestamp'].dt.hour
df['minute_bin'] = df['timestamp'].dt.minute // 15
df['dayofweek'] = df['timestamp'].dt.dayofweek
df['is_weekend'] = df['dayofweek'].isin([5, 6]).astype(int)
df['month'] = df['timestamp'].dt.month
# Лаги: те же интервалы в предыдущие периоды
for lag_days in [1, 7, 14]:
df[f'lag_{lag_days}d'] = df['passengers'].shift(lag_days * 96) # 96 интервалов/день
# Скользящее среднее
df['ma_7d'] = df['passengers'].rolling(7 * 96).mean()
return df
def train_and_predict(self, historical_df, forecast_horizon=96):
df = self.build_features(historical_df)
feature_cols = ['hour', 'minute_bin', 'dayofweek', 'is_weekend', 'month',
'lag_1d', 'lag_7d', 'lag_14d', 'ma_7d', 'is_holiday',
'weather_temp', 'weather_rain']
train = df.dropna(subset=feature_cols + ['passengers'])
model = LGBMRegressor(n_estimators=300, learning_rate=0.05, num_leaves=64)
model.fit(train[feature_cols], train['passengers'])
# Прогноз на следующие 24 часа
future = df.tail(forecast_horizon)[feature_cols]
return model.predict(future).clip(min=0)
Schedule optimization
Headway Optimization:
Objective: Determine the optimal departure interval (headway) for each route in each time period: - Minimize passenger waiting time (proportional to headway) - Minimize transport costs (proportional to frequency) - Constraint: capacity at peak demand ≤ 85% of seats
For each route and hour: headway* = sqrt(2 × vehicle_capacity × cycle_cost / (passenger_demand × vot))
Dynamic Schedule:
Unlike a fixed quarterly schedule, AI adjusts the frequency in real time: - Forecast peaks for the next 1-2 hours → increase frequency in advance - Vehicle failure → redistribution of intervals
Route network
Transit Network Design:
Optimization of the route network configuration is a meta-heuristic problem (Genetic Algorithm, Simulated Annealing): - Coverage: % of residents within walking distance of the stop (standard: 500 m) - Transfers: average number of transfers to the destination - Duplication: minimize parallel routes
Demand Responsive Transport (DRT):
On-demand minibuses (like Uber Pool for public transport): - Passenger requests trip A→B via app - Algorithm combines requests with overlapping routes - Real-time VRP solver → route for minibus - Used in sparsely populated areas where a fixed route is unprofitable
Fleet management
Depot allocation:
How many vehicles should be released from each depot to service the morning peak: - MILP optimization: minimizing empty runs to/from the depot - Accounting for the technical condition of each unit (maintenance schedule)
Electric fleet charging:
For electric buses (LiAZ 6274, Yutong E12): - Charge consumption forecast for each route - Charging optimization: cheap tariff at night + during the route intervals - Guarantee: sufficient charge at the start of each trip
Integration with city systems
- ATMS: traffic light priority for public transport (TSP — Transit Signal Priority) - GIS Moscow/cities: schedule publication via GTFS (General Transit Feed Specification) - Passenger applications (Yandex.Transport, 2GIS): real-time positions via API
Development time: 4–7 months for a platform with passenger flow forecasting, schedule optimization, and a DRT module.







