An Online LSTM Prediction Method for Bus Arrival Time Based on Multi-Source Data

By using an online prediction method based on multi-source data LSTM, and combining GPS, network and passenger information to reconstruct the spatiotemporal map, and utilizing the LSTM neural network model, the problem of multi-source data fusion and dynamic response in bus arrival time prediction is solved, achieving high-precision and robust arrival time prediction and meeting the real-time requirements of intelligent bus systems.

CN121789456BActive Publication Date: 2026-07-31DALIAN MARITIME UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
DALIAN MARITIME UNIVERSITY
Filing Date
2025-12-26
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing methods for predicting bus arrival times fail to fully integrate multi-source heterogeneous data, lack dynamic response capabilities, and ignore the differences in operating modes between different bus routes, resulting in insufficient practicality and reliability of the prediction results.

Method used

An online prediction method based on multi-source data using LSTM is adopted. The spatiotemporal map is reconstructed using GPS information, network information, bus schedule information and passenger QR code scanning information. Combined with the LSTM neural network model, the arrival time of buses is predicted in real time. The long short-term memory is controlled by forget gate, input gate and output gate. Combined with the real-time status information of the vehicles, the model's response capability and prediction accuracy are improved.

Benefits of technology

It significantly improves the robustness and accuracy of bus arrival time prediction, can maintain high-precision prediction in the event of sudden traffic incidents, and is suitable for concurrent calls from multiple terminals such as mobile APP and electronic bus stop signs, meeting the real-time needs of smart bus systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121789456B_ABST
    Figure CN121789456B_ABST
Patent Text Reader

Abstract

This invention provides an online LSTM prediction method for bus arrival time based on multi-source data, comprising: preprocessing bus GPS trajectory data and passenger card swipe data, removing abnormal GPS points and compensating for missing points, finding the nearest station segment to the vehicle, and determining the vehicle's position in real time; matching the preprocessed bus GPS trajectory data with the bus route station sequence to obtain the arrival time of each bus at each station, forming a historical bus schedule runtime spacetime map; using the historical bus schedule runtime spacetime map, constructing and training an LSTM neural network model to learn the mapping relationship between multi-dimensional features of route-bus-station-time-environment and arrival time; during the real-time operation of the vehicle, obtaining the current GPS position and speed of the bus, and combining the trained LSTM neural network model to predict the arrival time of subsequent stations online.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of urban public transport operation cycle and arrival time prediction technology, and more particularly to an online prediction method for bus arrival time based on multi-source data using LSTM. Background Technology

[0002] As a crucial carrier of urban commuting, the operational efficiency and service quality of public transportation systems directly impact the overall effectiveness of the urban transportation system. In the context of intelligent transportation development, real-time arrival time prediction for public buses has become a core technological aspect for improving operational service quality. However, the complex influence of multiple dynamic factors, including road conditions, passenger volume variations, weather conditions, and traffic light timings, on conventional bus operations presents significant challenges to establishing accurate prediction models. Currently, a multi-source data system based on GPS positioning systems, smart card transaction systems, and vehicle-to-everything (V2X) technology provides the foundation for constructing data-driven prediction methods. Vehicle trajectory data, passenger boarding and alighting records, and road network topology data constitute the main input dimensions of the prediction model.

[0003] Existing methods for predicting bus arrival times mainly fall into three categories: traditional methods based on statistical modeling (such as Kalman filtering and Markov chains), machine learning methods based on instance learning (such as support vector machines and K-nearest neighbors), and modern methods based on deep neural networks. Although temporal neural networks, represented by LSTM, have shown advantages in capturing spatiotemporal features, existing research still has significant limitations: First, most models rely on a single data source (such as using only GPS trajectory data or card swipe data), failing to fully integrate the complementary value of multi-source heterogeneous data; second, existing methods lack the dynamic response capability to the real-time operating status of vehicles, leading to significantly increased prediction bias when encountering sudden traffic events; third, model construction often ignores the differences in operating modes between different bus routes, resulting in insufficient accuracy in capturing periodic features. These technical deficiencies directly restrict the practicality and reliability of the prediction results, making it difficult to meet the high-precision real-time prediction requirements of intelligent public transportation systems. Summary of the Invention

[0004] To address the aforementioned technical issues and improve the timeliness and accuracy of dynamic bus arrival prediction, this paper proposes an online LSTM-based bus arrival time prediction method using multi-source data. This method first utilizes multi-source data, including GPS information, route network information, bus schedule information, and passenger QR code scanning information, to reconstruct historical arrival times of bus routes, thus obtaining a spatiotemporal map of the vehicles. Based on this spatiotemporal map, a Long Short-Term Memory (LSTM) network is used to mine the operational patterns of each route and vehicle on different road segments at different times. During real-time prediction, an LSTM neural network model is used as the foundation, combined with real-time vehicle status information, to predict the arrival times of subsequent stops.

[0005] The technical means employed in this invention are as follows: An online LSTM prediction method for bus arrival times based on multi-source data includes: S1. Preprocess the GPS trajectory data of buses and passenger card swipe data, remove abnormal GPS points and compensate for missing points, find the nearest station and road segment to the vehicle, and determine the vehicle's location in real time. S2. Match the preprocessed GPS trajectory data of buses with the bus route stop sequence to obtain the arrival time of each bus at each stop, forming a historical bus time space map. S3. Using the historical schedule time-space map, construct and train an LSTM neural network model to learn the mapping relationship between multi-dimensional features of route-schedule-station-time-environment and arrival time. S4. During the real-time operation of the vehicle, obtain the current GPS location and speed of the bus, and combine it with the trained LSTM neural network model to predict the arrival time of subsequent stops online.

[0006] Further, step S1 includes: S11. For the GPS trajectory data of the bus, calculate the time difference and location information of adjacent GPS points to obtain the vehicle's speed. S12. If the calculated driving speed is greater than the set threshold, the GPS point is determined to be an abnormal point and is removed. S13. Under the premise of meeting the speed constraint, calculate the deviation distance between the vehicle position and the bus route. If the deviation distance exceeds the set threshold, the GPS point is determined to be an abnormal point and is removed. S14. For the missing parts of the trajectory after removing abnormal points, perform a compensation operation for missing GPS points to ensure the integrity of the GPS trajectory.

[0007] Further, step S2 includes: S21, Considering Bus routes at each station , The latitude and longitude coordinates of each station are denoted as follows: ; S22. Obtain GPS data of the bus operating on the bus route in step S21. , The latitude and longitude position at the time is ; S23. Define the directed segment between two adjacent stations as the directed segment of the line, denoted as... ; S24. Define the directed road segment between two adjacent GPS data points as the vehicle travel segment, denoted as... ; S25. Search for the GPS point closest to the station and in the same direction along the entire trajectory. As the arrival time of the vehicle :

[0008] in, Latitude and longitude location for each station and Latitude and longitude position at any time Euclidean distance, For directed sections of the route Road section with vehicles The angle between the planes, , , ; S26. Determine the GPS point based on the relationship between the vehicle's direction of travel and the route direction. Let these be the points before or after the station along the route, assuming the vehicle's stop time at each station is fixed. It is estimated that the bus will arrive at the station. Time:

[0009] Where, vector , GPS point The vehicle speed; S27. Perform the above matching and time estimation for all stations in sequence to obtain the arrival time sequence of the train at each station, thus forming the historical runtime space map of the train.

[0010] Further, step S3 includes: S31. Construct a training sample dataset by selecting public transportation operation data over a period of time, including information such as routes, dates, weeks, holidays, departure times, weather, stops, and arrival times. Arrival time is the output variable, and the others are input variables. S32. Divide a 24-hour day into multiple time periods (e.g., 0:00-5:30, 5:30-6:30, ..., 22:00-24:00) and label them. At the same time, label the weather conditions for each time period (e.g., sunny, light rain, moderate rain, heavy rain, light snow, moderate snow, heavy snow, etc.). S33. Construct an LSTM neural network model for arrival time. The LSTM neural network model selects and passes states by setting input gates, forget gates, output gates, and memory units, including: By combining the current arrival time of the bus with prior memory, and through... A function is used to determine the degree to which the previous state is retained, with a value ranging from 0 to 1. A forget gate is set as follows:

[0011] in, The weight matrix represents the forget gate. This represents the state variable passed from the previous station. The bias matrix represents the forget gate. The input variable representing each set of data in the historical data; Compare the current arrival time with the previous state variables. After combination, through The function controls the degree to which input variables are retained. The input gate is set as follows:

[0012] in, This represents the weight matrix of the input gate. The bias matrix representing the input gate; The memory unit is configured by combining the previous state and the current arrival time, and then activated by a function. Get the current state :

[0013] in, The weight matrix represents the memory unit. The bias matrix representing the memory unit; Forget the control variables Acts on the previous memory unit The current state control variable Acts on the current state Together, new memory units are generated. :

[0014] The output gate is set by both the previous state and the current state:

[0015] in, This represents the weight matrix of the output gate. The bias matrix represents the output gate; Combined with output control variables Memory units in the current state Through activation function Output predictor variables :

[0016] in, express Arrival time at the station.

[0017] Furthermore, to improve the prediction accuracy of the model, the LSTM neural network model training process in step S3 also includes: Input variables for each set of data in the historical data and output variables Standardization process:

[0018]

[0019] in, The mean of each independent variable in the training data. Let be the variance of the independent variable matrix.

[0020] Further, step S4 includes: S41. Obtain the real-time GPS location of buses, determine the current station interval of the vehicle, and mark the next station as... ; S42. Determine if the bus has passed a stop. If it has, obtain the arrival time at the previous stop and, based on the arrival times at the previous stops, use the LSTM neural network model to calculate the arrival time at the next stop. The arrival time is recorded as ; S43. Calculate the station based on the vehicle's current speed and historical speed. Arrival time based on speed is denoted as Taking into account historical speed, current speed, and driving habits of the LSTM neural network model, the station is obtained. Predicted arrival time :

[0021] in, These are the weighting coefficients corresponding to the predicted speed values. These are the weight coefficients corresponding to the predicted values ​​of the LSTM neural network model. S44. The subsequent stations are repeatedly fed into the LSTM neural network model for prediction, that is: .

[0022] Furthermore, for multiple vehicles on different routes, parallel computing is employed, and the calculation process is as follows: Step 1: Obtain GPS information of all vehicles within a set time (5 seconds). For each vehicle that receives GPS information, if the previous status was not in operation and the current status is in operation, proceed to Step 2; if the previous status was in operation, proceed to Step 3. Step 2: Determine whether the vehicle is in operation based on the schedule information. If it is in operation, determine the vehicle's location and complete the set of arrival times for the vehicle's preceding stops. Then, obtain the predicted arrival times for the following stops using the LSTM neural network model. If the vehicle is not in operation, skip it. Step 3: Determine whether the shift has ended based on the GPS status returned by the vehicle. If it has ended, update the vehicle status to "not running". If the vehicle status is "in operation", determine the vehicle's location and then use the LSTM neural network model to give the arrival time of the next station, while updating the vehicle status.

[0023] Compared with the prior art, the present invention has the following advantages: 1. This invention provides an online prediction method for bus arrival time based on multi-source data using LSTM. In the offline stage, it integrates heterogeneous data from multiple sources such as GPS, IC cards, route topology, weather, and holidays to reconstruct a spatiotemporal map of "station-time" for each bus, thus overcoming the shortcomings of traditional methods with their single information dimension. In the online stage, it integrates the long-term patterns output by LSTM with real-time GPS streams, enabling the model to not only remember historical patterns but also retain the ability to respond to sudden disturbances, significantly improving the overall prediction robustness.

[0024] 2. The present invention provides an online prediction method for bus arrival time based on multi-source data using LSTM. It introduces the angle constraint between the directed road segment and the vehicle travel segment to eliminate mismatches of the reverse road segment. Combined with geometric judgment before / after the station and acceleration / deceleration compensation, it significantly reduces the estimation deviation of single-station arrival time and provides reliable labels for subsequent modeling.

[0025] 3. The present invention provides an online prediction method for bus arrival time based on multi-source data using LSTM. This method embeds multi-dimensional information such as route, bus number, station, date, week, holidays, discrete time period, and weather category into the same input space, so that the network can automatically learn the time offset pattern under various scenarios during the training phase without the need for manual additional segmentation rules.

[0026] 4. The present invention provides an online prediction method for bus arrival time based on multi-source data using LSTM. Its LSTM neural network model uses a forget gate, input gate, and output gate to jointly control long-term memory, solving the memory shortening problem caused by gradient vanishing in traditional RNNs. The cross-validation mechanism prevents the model from overfitting to specific time periods or routes, so that the prediction results remain robust across different routes and seasons.

[0027] 5. The present invention provides an online prediction method for bus arrival time based on multi-source data using LSTM, which transforms the matching, prediction, and update steps into batch parallel computing, so that a single vehicle can complete the output of the arrival time of all remaining stations in a single forward propagation, meeting the concurrent call requirements of multiple terminals such as mobile APP, electronic bus stop signs, and signal priority. Attached Figure Description

[0028] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0029] Figure 1 This is a flowchart of the method of the present invention.

[0030] Figure 2 This is a schematic diagram of vehicle movement and station matching provided in an embodiment of the present invention.

[0031] Figure 3 This is a schematic diagram illustrating the relationship between vehicles and stations provided in an embodiment of the present invention.

[0032] Figure 4 The diagram shows the structure of the LSTM neural network model provided in this embodiment of the invention.

[0033] Figure 5 A bus distribution map of Liuzhou City provided for an embodiment of the present invention.

[0034] Figure 6 The route map of bus route 24 provided for an embodiment of the present invention.

[0035] Figure 7 The spatiotemporal diagram of bus route 24 during weekdays and non-weekdays is provided for an embodiment of the present invention.

[0036] Figure 8 The average operating time for different shifts during different time periods is provided in the embodiments of the present invention.

[0037] Figure 9 This is a comparison chart of arrival errors provided in an embodiment of the present invention. Detailed Implementation

[0038] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0039] It should be noted that the terms "comprising" and "having" and any variations thereof in the specification, claims and accompanying drawings of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such processes, methods, products or devices.

[0040] like Figure 1 As shown, this invention provides an online LSTM prediction method for bus arrival times based on multi-source data, including: S1. Preprocess the GPS trajectory data of buses and passenger card swipe data, remove abnormal GPS points and compensate for missing points, find the nearest station and road segment to the vehicle, and determine the vehicle's location in real time. S2. Match the preprocessed GPS trajectory data of buses with the bus route stop sequence to obtain the arrival time of each bus at each stop, forming a historical bus time space map. S3. Using the historical schedule time-space map, construct and train an LSTM neural network model to learn the mapping relationship between multi-dimensional features of route-schedule-station-time-environment and arrival time. S4. During the real-time operation of the vehicle, obtain the current GPS location and speed of the bus, and combine it with the trained LSTM neural network model to predict the arrival time of subsequent stops online.

[0041] In a specific implementation, as a preferred embodiment of the present invention, step S1 includes: S11. For the GPS trajectory data of the bus, calculate the time difference and location information of adjacent GPS points to obtain the vehicle's speed. S12. If the calculated driving speed is greater than the set threshold, the GPS point is determined to be an abnormal point and is removed. S13. Under the premise of meeting the speed constraint, calculate the deviation distance between the vehicle position and the bus route. If the deviation distance exceeds the set threshold, the GPS point is determined to be an abnormal point and is removed. S14. For the missing parts of the trajectory after removing abnormal points, perform a compensation operation for missing GPS points to ensure the integrity of the GPS trajectory.

[0042] In this embodiment, the time interval between the current GPS location of the bus and the previous GPS location is first calculated. If the time interval exceeds the time interval threshold, the vehicle's travel direction must be determined when determining the vehicle's location. If the time interval does not exceed the time interval threshold, there are two cases: crossing at most one station or crossing two or more stations. If the adjacent GPS location does not cross any stations or only crosses one station, the travel direction is not considered, and only the shortest distance to the road segment is considered. Otherwise, both the travel direction and distance are considered to filter out abnormal GPS locations that have shifted in the online data.

[0043] In a specific implementation, as a preferred embodiment of the present invention, step S2 includes: S21, Considering Bus routes at each station , The latitude and longitude coordinates of each station are denoted as follows: ; S22. Obtain GPS data of the bus operating on the bus route in step S21. , The latitude and longitude position at the time is ; S23. Define the directed segment between two adjacent stations as the directed segment of the line, denoted as... ; S24. Define the directed road segment between two adjacent GPS data points as the vehicle travel segment, denoted as... ; S25. Search for the GPS point closest to the station and in the same direction along the entire trajectory. As the arrival time of the vehicle :

[0044] in, Latitude and longitude location for each station and Latitude and longitude position at any time Euclidean distance, For directed sections of the route Road section with vehicles The angle between the planes, , , In this embodiment, to verify the necessity of further explaining the determination of the included angle, the following is provided: Figure 2 . Figure 2The curves in the diagram represent bus routes and their directions, with the dashed lines indicating the direction of vehicle travel. a, b, c, d, and e represent different stops. The diagram shows that this is a round-trip route, with stop b being the closest to the vehicle. In stop matching, if only the distance between the vehicle and the stop is considered, the closest stop is e. However, if both the vehicle's direction of travel and the route direction are considered, the closest stop is b. Therefore, stop matching requires considering the angle between the vehicle's travel segment and the limited segment of the route.

[0045] S26. Determine the GPS point based on the relationship between the vehicle's direction of travel and the route direction. Let these be the points before or after the station along the route, assuming the vehicle's stop time at each station is fixed. (e.g., 0.5 minutes) Estimate the arrival time of the bus at the stop. Time:

[0046] Where, vector , GPS point The vehicle speed; in this embodiment, the formula in step S25 discusses the angle between the vehicle travel segment formed by adjacent GPS points and the station segment formed by adjacent stations, such as Figure 3 Zhongzhan section GPS section The angle formed by the station and the directed line segment formed by the station and GPS. The formula in step S26 discusses the angle between the station road segment and the directed line segment formed by the station and GPS, such as... Figure 3 middle and The angle between the GPS point and the station. The formula in step S25 is used to find the GPS point closest to the station along the entire GPS path. At this point, it is essential to ensure that the vehicle's travel direction is consistent with the station's direction; otherwise, it may match a station in the opposite direction. Therefore, the angle must be less than 90 degrees. The formula in step S26, based on the formula in step S25, determines the relative position of the GPS point to the station. If... and If the angle between the two points is greater than 90 degrees, it means the vehicle has not yet arrived at the station. If )and If the angle between the points is less than 90 degrees, it indicates that the vehicle has left the station. In the above formula, if the matched GPS point is a point before the station, the vehicle arrives at the station by deceleration; if it is a point after the station, the vehicle leaves the station by acceleration. Considering the effects of acceleration and deceleration, we take the average speed. This method can perform offline computation and store and update the results as a training set. It should be noted that data quality has a certain impact on arrival time estimation, such as the topology of the bus network, the density and accuracy of GPS data collection, and station dwell times. The bus network may have significant directional changes, directly affecting the matching of vehicle direction with route direction. The latitude and longitude of bus routes can be increased based on the actual route map, ensuring that the route direction remains relatively stable before and after each stop. Furthermore, if computational speed allows, the GPS data collection density can be increased and pre-cleaned. In addition, vehicle dwell time estimation can also be calculated separately using historical data.

[0047] S27. Perform the above matching and time estimation for all stations in sequence to obtain the arrival time sequence of the train at each station, thus forming the historical runtime space map of the train.

[0048] In this embodiment, it is assumed that the GPS data for this trip already includes passenger card swipe records, which can be processed using interpolation. To estimate the arrival time of the vehicle at each stop, the coordinate point in the GPS data that is aligned with the road segment direction and closest to the stop is selected as the vehicle's arrival time. The arrival time is then corrected using information such as speed and stop time. For simplicity, Euclidean distance is used as the standard for measuring the distance of the vehicle from the road segment.

[0049] In a specific implementation, as a preferred embodiment of the present invention, step S3 includes: S31. Construct a training sample dataset by selecting public transportation operation data over a period of time, including information such as routes, dates, weeks, holidays, departure times, weather, stops, and arrival times. Arrival time is the output variable, and the others are input variables. S32. Divide a 24-hour day into multiple time periods (e.g., 0:00-5:30, 5:30-6:30, ..., 22:00-24:00) and label them. At the same time, label the weather conditions for each time period (e.g., sunny, light rain, moderate rain, heavy rain, light snow, moderate snow, heavy snow, etc.). S33. Construct an LSTM neural network model for arrival time. The LSTM neural network model selects and passes states by setting input gates, forget gates, output gates, and memory units, including: By combining the current arrival time of the bus with prior memory, and through... A function is used to determine the degree to which the previous state is retained, with a value ranging from 0 to 1. A forget gate is set as follows:

[0050] in, The weight matrix represents the forget gate. This represents the state variable passed from the previous station. The bias matrix represents the forget gate. The input variable representing each set of data in the historical data; Compare the current arrival time with the previous state variables. After combination, through The function controls the degree to which input variables are retained. The input gate is set as follows:

[0051] in, This represents the weight matrix of the input gate. The bias matrix representing the input gate; The memory unit is configured by combining the previous state and the current arrival time, and then activated by a function. Get the current state :

[0052] in, The weight matrix represents the memory unit. The bias matrix representing the memory unit; Forget the control variables Acts on the previous memory unit The current state control variable Acts on the current state Together, new memory units are generated. :

[0053] The output gate is set by both the previous state and the current state:

[0054] in, This represents the weight matrix of the output gate. The bias matrix represents the output gate; Combined with output control variables Memory units in the current state Through activation function Output predictor variables :

[0055] in, express Arrival time at the station.

[0056] The public transportation system contains a large amount of multi-source data, including vehicle GPS data, route data, and bus schedule data. However, there is no correlation between these various data sources. Therefore, in this embodiment, it is necessary to extract vehicle travel patterns from the multi-source data. First, by processing the multi-source data, a historical spatiotemporal map of vehicle routes is obtained. Based on this historical spatiotemporal map, a bus arrival line prediction is implemented using an LSTM neural network model. This model extracts vehicle travel patterns from different time periods, different vehicles, and different road segments within the historical routes. Figure 4 The overall structure of the LSTM neural network model is presented. It involves preprocessing multi-source data, reconstructing the historical vehicle travel spatiotemporal map using estimation methods, and finally inputting the spatiotemporal map into the LSTM model for training. During real-time prediction, when station arrival times change, the LSTM neural network model intervenes to provide the arrival time for subsequent stations. Furthermore, during travel between stations, arrival times are corrected based on the real-time vehicle status.

[0057] In a specific implementation, as a preferred embodiment of the present invention, in order to improve the prediction accuracy of the model, the LSTM neural network model training process in step S3 further includes: Input variables for each set of data in the historical data and output variables Standardization process:

[0058]

[0059] in, The mean of each independent variable in the training data. Let be the variance of the independent variable matrix. In this embodiment, to prevent the LSTM neural network model from overfitting, the following is used during training: The cross-validation method is used to train the LSTM neural network model, dividing the dataset into... Group, among which Group 1 is used for training, the first group The group is used for testing, and the test set is constantly changed to cross-validate each other.

[0060] In a specific implementation, as a preferred embodiment of the present invention, step S4 includes: S41. Obtain the real-time GPS location of buses, determine the current station interval of the vehicle, and mark the next station as... ; S42. Determine if the bus has passed a stop. If it has, obtain the arrival time at the previous stop and, based on the arrival times at the previous stops, use the LSTM neural network model to calculate the arrival time at the next stop. The arrival time is recorded as ; S43. Calculate the station based on the vehicle's current speed and historical speed. Arrival time based on speed is denoted as Taking into account historical speed, current speed, and driving habits of the LSTM neural network model, the station is obtained. Predicted arrival time :

[0061] in, These are the weighting coefficients corresponding to the predicted speed values. These are the weight coefficients corresponding to the predicted values ​​of the LSTM neural network model. S44. The subsequent stations are repeatedly fed into the LSTM neural network model for prediction, that is: .

[0062] In a specific implementation, as a preferred embodiment of the present invention, parallel computing is used for multiple vehicles on different routes, and the calculation process is as follows: Step 1: Obtain GPS information of all vehicles within a set time (5 seconds). For each vehicle that receives GPS information, if the previous status was not in operation and the current status is in operation, proceed to Step 2; if the previous status was in operation, proceed to Step 3. Step 2: Determine whether the vehicle is in operation based on the schedule information. If it is in operation, determine the vehicle's location and complete the set of arrival times for the vehicle's preceding stops. Then, obtain the predicted arrival times for the following stops using the LSTM neural network model. If the vehicle is not in operation, skip it. Step 3: Determine whether the shift has ended based on the GPS status returned by the vehicle. If it has ended, update the vehicle status to "not running". If the vehicle status is "in operation", determine the vehicle's location and then use the LSTM neural network model to give the arrival time of the next station, while updating the vehicle status.

[0063] Example The programming language used in this embodiment is Python, the machine CPU is an i7-7700, and the memory is 16GB. This embodiment is based on real public transportation data for Liuzhou City from Shanghai Liangla Company. This company focuses on MaaS service design and therefore has strict requirements for dynamic bus arrival time prediction. The dynamic data provided by the company includes real-time vehicle location information transmitted by onboard GPS, passenger card swipe information obtained by onboard POS machines, and passenger QR code swipe information via mobile APP. The Liuzhou City public transportation system includes 142 routes and 4525 stops. A schematic diagram of route coverage and stop distribution is shown below. Figure 5As shown. Taking bus route 24 as an example, this route starts from Que'ershan Park, passes by the railway station, the municipal party committee, Liuzhou Museum, and other places, and finally returns to Que'ershan Park. Figure 6 As shown.

[0064] Vehicle operation history spatiotemporal diagram In the process of historical spatiotemporal map reconstruction, the original data is first cleaned to obtain accurate and usable GPS information, and then the spatiotemporal map reconstruction method given in section 1.1 is used to reconstruct the historical driving data. For example... Figure 7 The image shows the time and location of bus route 24 on weekdays (Thursdays) and weekends (Saturdays). The horizontal axis represents time, the vertical axis represents stops, a smaller slope indicates slower speed, and intersections of different segments indicate overtaking. Figure 7 It can be seen that the travel patterns of most bus routes are relatively regular, with relatively smooth routes. However, some sections of the route showed congestion at certain times. For example, between 4 PM and 8 PM on November 5th, the time-space curves between stations 9 and 12, and between stations 22 and 24, were relatively gentle. Map observation revealed that these two sections are adjacent to densely populated areas such as Liuzhou No. 3 Middle School and the Municipal Party Committee, indicating a large number of commuter passengers. Subsequent card-swipe data analysis showed that vehicles in these sections also had relatively high passenger numbers. Compared to the time-space curve of Thursday, the time-space curve of Saturday was even smoother, without showing obvious travel peaks or congestion.

[0065] To further compare vehicle operation patterns during different time periods on weekdays and non-weekdays, we used spatiotemporal maps to calculate the average operating time of each shift on Thursdays and Saturdays, such as... Figure 8 As shown. The operating time of a service is determined by both the number of passengers and road conditions. The longer the service time, the more passengers there are, or the more congested the road conditions are during that time period. Figure 8 The red line in the graph represents the average operating time of each bus service on Thursday. The graph clearly shows morning and evening peak hours: the morning peak is from 6:00 AM to 9:00 AM, and the evening peak is from 3:00 PM to 8:00 PM. Compared to the morning peak, the evening peak lasts longer and is more congested (with longer average bus times). This congestion is closely related to factors such as private car travel. Saturday, unlike Thursday, does not show a clear morning or evening peak. However, travel is concentrated after 8:00 AM, and the number of travelers gradually increases over time (leading to longer bus times), reaching a peak around 5:00 PM, although this peak is lower than Thursday's evening peak. The analysis reveals that travel on non-working days is smoother than on working days, and vehicle operating conditions vary across different time periods. Therefore, an LSTM model is used to mine the operational patterns of the vehicle spatiotemporal map.

[0066] Arrival Prediction Performance Analysis After obtaining the reconstructed historical spatiotemporal map of the vehicles, multi-dimensional data such as arrival time, station number, vehicle number, day of the week, and time of day are acquired for each station and processed into a multi-dimensional tensor input layer. This data is then fed into a four-layer LSTM model with 5, 128, 24, and 1 neurons per layer for training, outputting the arrival time of the next station. During training, the learning rate is set to 0.01, and the Mean Square Error (MSE) is used as the loss function. The formula for calculating the MSE function is as follows:

[0067] in, For the site Observed arrival times.

[0068] Table 1. Comparison of Prediction Performance of Different Models (Unit: seconds)

[0069] To verify the effectiveness of the LSTM algorithm, we compared it with four other common prediction methods: historical mean prediction, KNN prediction, KNN+Calmen prediction, and SVM. The simplest prediction method is historical mean prediction. Its advantages are simplicity and ease of operation, but its disadvantage is that it cannot accurately reflect the spatiotemporal patterns of the route. In KNN prediction, we used the nearest neighbor matching method, that is, selecting the nearest stations the vehicle passes through... Similar to historical schedules at each station The number of trips was used for fitting, and the test selected... , In the Kalman filter, the values ​​for measurement noise and process noise were set to 10 and 29, respectively. Furthermore, an SVM model was introduced, employing a Gaussian kernel function. Timetables for 2489 trips were reconstructed from 32 stops across route 24, and the data was divided into two groups based on peak and off-peak hours for testing. 80% of the data was used as the training set, and 20% as the test set. The minimum error, average error, maximum error, and root mean square error (RMSE) for each method were obtained. The formula for calculating RMSE is as follows:

[0070] Table 1 shows the RMSE, minimum error, average error, maximum error, running time, and other parameters for different models. Gap Value, of which GapThe value represents the percentage difference between the RMSE values ​​of other models and the LSTM model. The experimental results show that the LSTM model's RMSE value is significantly lower than the other models, indicating relatively high prediction accuracy. Furthermore, since the predicted values ​​for all subsequent stations are given every 15 seconds, and these predictions are dynamically adjusted over time, the minimum error values ​​of all models are close to 0. In addition, the LSTM model has the smallest average and maximum errors among the five methods, further reflecting the accuracy and stability of its prediction results. Regarding prediction time, the KNN model takes longer because it needs to compare historical data line by line; its speed depends on the amount of historical data—the larger the data volume, the longer the time. The LSTM model is the fastest among the five models because it only needs to input the known parameters into the trained model to obtain the arrival times of subsequent stations. In actual testing, the LSTM model processed data from 427 buses simultaneously in just 21 seconds, effectively meeting the real-time requirements of public transportation.

[0071] To verify the effectiveness of the method of this invention, a comparison was made with the prediction results of a certain dynamic bus arrival time prediction software. The prediction results of the dynamic bus software were retrieved every 15 seconds via an API interface. Taking a single bus route 24 between 6:00 AM and 7:20 AM as an example, the average prediction error for each stop within that route was calculated, and the results are shown in Table 2. The prediction error based on LSTM is denoted as... E 1. The prediction error of a certain software is marked as... E 2, E 1 and E The smaller values ​​in section 2 are indicated in bold black. From the results, we can see that 26 out of a total of 31 sites had better predictions than the software, a superiority rate of 83.87%.

[0072] Table 2 Comparison of average prediction errors at various stations (unit: seconds)

[0073] also, Figure 9 The predicted arrival times for the 10th station and the final station are given at different times. The red line represents the actual arrival time, the blue curve represents the predicted value based on LSTM-spatiotemporal graph at different times, and the green curve represents the predicted value of a certain software at different times. Figure 9 Figure (a) shows the predicted arrival time of the 10th station at different times. As can be seen from the figure, both predictions have similar peaks, but the LSTM-based prediction is closer to the actual arrival time and therefore more accurate. Figure 9As shown in (b), the LSTM-based predictions have a large error during the initial operation phase of the vehicle. As time progresses, the predictions are dynamically adjusted based on the current vehicle status, gradually approaching the actual arrival time. Furthermore, the predicted time we provide fluctuates less, with the terminal station error within 5 minutes.

[0074] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for online prediction of bus arrival time based on multi-source data using LSTM, characterized in that, include: S1. Preprocess the GPS trajectory data of buses and passenger card swipe data, remove abnormal GPS points and compensate for missing points, find the nearest station and road segment to the vehicle, and determine the vehicle's location in real time. S2. Match the preprocessed GPS trajectory data of buses with the bus route stop sequence to obtain the arrival time of each bus at each stop, forming a historical bus time space map. S3. Using the historical schedule time-space map, construct and train an LSTM neural network model to learn the mapping relationship between multi-dimensional features of route-schedule-station-time-environment and arrival time. Step S3 includes: S31. Construct a training sample dataset by selecting public transportation operation data over a period of time, including information on routes, dates, weeks, holidays, departure times, weather, stops, and arrival times. Arrival time is the output variable, and the others are input variables. S32. Divide a 24-hour day into multiple time periods and label them, and label the weather conditions for each time period; S33. Construct an LSTM neural network model for arrival time. The LSTM neural network model selects and passes states by setting input gates, forget gates, output gates, and memory units, including: By combining the current arrival time of the bus with prior memory, and through... A function is used to determine the degree to which the previous state is retained, with a value ranging from 0 to 1. A forget gate is set as follows: in, The weight matrix represents the forget gate. This represents the state variable passed from the previous station. The bias matrix represents the forget gate. The input variable representing each set of data in the historical data; Compare the current arrival time with the previous state variables. After combination, through The function controls the degree to which input variables are retained. The input gate is set as follows: in, This represents the weight matrix of the input gate. The bias matrix representing the input gate; The memory unit is configured by combining the previous state and the current arrival time, and then activated by a function. Get the current state : in, The weight matrix represents the memory unit. The bias matrix representing the memory unit; Forget the control variables Acts on the previous memory unit The current state control variable Acts on the current state Together, new memory units are generated. : The output gate is set by both the previous state and the current state: in, This represents the weight matrix of the output gate. The bias matrix represents the output gate; Combined with output control variables Memory units in the current state Through activation function Output predictor variables : in, express Arrival time at the station; S4. During real-time vehicle operation, obtain the current GPS location and speed of the bus, and combine this with the trained LSTM neural network model to predict the arrival time of subsequent stops online; Step S4 includes: S41. Obtain the real-time GPS location of buses, determine the current station interval of the vehicle, and mark the next station as... ; S42. Determine if the bus has passed a stop. If it has, obtain the arrival time at the previous stop and, based on the arrival times at the previous stops, use the LSTM neural network model to calculate the arrival time at the next stop. The arrival time is recorded as ; S43. Calculate the station based on the vehicle's current speed and historical speed. Arrival time based on speed is denoted as Taking into account historical speed, current speed, and driving habits of the LSTM neural network model, the station is obtained. Predicted arrival time : in, These are the weighting coefficients corresponding to the predicted speed values. These are the weight coefficients corresponding to the predicted values ​​of the LSTM neural network model. S44. The subsequent stations are repeatedly fed into the LSTM neural network model for prediction, that is: 。 2. The online prediction method for bus arrival time based on multi-source data using LSTM as described in claim 1, characterized in that, Step S1 includes: S11. For the GPS trajectory data of the bus, calculate the time difference and location information of adjacent GPS points to obtain the vehicle's speed. S12. If the calculated driving speed is greater than the set threshold, the GPS point is determined to be an abnormal point and is removed. S13. Under the premise of meeting the speed constraint, calculate the deviation distance between the vehicle position and the bus route. If the deviation distance exceeds the set threshold, the GPS point is determined to be an abnormal point and is removed. S14. For the missing parts of the trajectory after removing abnormal points, perform a compensation operation for missing GPS points to ensure the integrity of the GPS trajectory.

3. The online prediction method for bus arrival time based on multi-source data using LSTM as described in claim 1, characterized in that, Step S2 includes: S21, Considering Bus routes at each station , The latitude and longitude coordinates of each station are denoted as follows: ; S22. Obtain GPS data of the bus operating on the bus route in step S21. , The latitude and longitude position at the time is ; S23. Define the directed segment between two adjacent stations as the directed segment of the line, denoted as... ; S24. Define the directed road segment between two adjacent GPS data points as the vehicle travel segment, denoted as... ; S25. Search for the GPS point closest to the station and in the same direction along the entire trajectory. As the arrival time of the vehicle : in, Latitude and longitude location for each station and Latitude and longitude position at any time Euclidean distance, For directed sections of the route Road section with vehicles The angle between the planes, , , ; S26. Determine the GPS point based on the relationship between the vehicle's direction of travel and the route direction. Let these be the points before or after the station along the route, assuming the vehicle's stop time at each station is fixed. It is estimated that the bus will arrive at the station. Time: Where, vector , GPS point The vehicle speed; S27. Perform the above matching and time estimation for all stations in sequence to obtain the arrival time sequence of the train at each station, thus forming the historical runtime space map of the train.

4. The online prediction method for bus arrival time based on multi-source data using LSTM as described in claim 1, characterized in that, To improve the prediction accuracy of the model, the LSTM neural network model training process in step S3 also includes: Input variables for each set of data in the historical data and output variables Standardization process: in, The mean of each independent variable in the training data. Let be the variance of the independent variable matrix.

5. The online prediction method for bus arrival time based on multi-source data using LSTM as described in claim 1, characterized in that, For multiple vehicles on different routes, parallel computing is used, and the calculation process is as follows: Step 1: Obtain GPS information for all vehicles within a set time period. For each vehicle that receives GPS information, if the previous status was "not in operation" and the current status is "in operation", proceed to Step 2. If the previous state was "running", then proceed to step 3; Step 2: Determine whether the vehicle is in operation based on the schedule information. If it is in operation, determine the vehicle's location and complete the set of arrival times for the vehicle's previous stops. Then, obtain the predicted arrival times for the next stops based on the LSTM neural network model. If the vehicle is not in operation, skip it. Step 3: Determine whether the shift has ended based on the GPS status returned by the vehicle. If it has ended, update the vehicle status to "not running". If the vehicle status is "in operation", determine the vehicle's location and then use the LSTM neural network model to give the arrival time of the next station, while updating the vehicle status.