A real-time trajectory prediction method based on Markov process
By building a mathematical model based on Markov process, combining the user's historical trajectory data and real-time state, high-precision real-time trajectory prediction is achieved, solving the problem of insufficient prediction accuracy and real-time in the existing technology, and is suitable for Internet of Things devices.
Patent Information
- Application Number
- CN202210516209.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-12
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2042-05-12
AI Technical Summary
The existing real-time trajectory prediction methods have shortcomings in prediction accuracy and real-time performance, and deep neural network algorithms have high requirements for terminal equipment performance, making it difficult to deploy in IoT devices with low performance.
A real-time trajectory prediction method based on Markov process MP-RTP is proposed. By collecting historical trajectory data within long time intervals, the user's life routine and travel habits are extracted, and a mathematical model based on Markov process is constructed to perform real-time trajectory prediction. This method is divided into four steps: data collection, data preprocessing, construction of Markov models and real-time trajectory prediction.
While ensuring algorithm performance, it improves prediction accuracy and is suitable for deployment on IoT devices and can operate effectively in low-performance devices.
Smart Images

Figure CN114970331B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of mobile computing, and particularly relates to a real-time trajectory prediction method based on Markov process. Background Art
[0002] With the rapid development of Internet of Things technology, the Internet of Things has been widely used in many fields, such as mobile edge computing, intelligent transportation, autonomous driving, etc. Many applications or systems take trajectory prediction as a sub-module of their systems. For example, mobile edge computing uses trajectory prediction for service migration, and intelligent transportation systems use trajectory prediction to provide travel plans for users. In these systems, the accuracy of the trajectory prediction algorithm will greatly affect its service performance.
[0003] Currently, existing real-time trajectory prediction methods, such as real-time trajectory prediction methods based on Kalman filter and real-time trajectory prediction methods based on autoregressive model, etc., mostly predict based on the user's real-time state, real-time trajectory or historical trajectory within a short time interval, resulting in a large error between the predicted trajectory of the algorithm and the actual trajectory. And some real-time trajectory prediction algorithms based on deep neural network, although they have high prediction accuracy, have high requirements for the performance of terminal devices and are difficult to be deployed and applied in some Internet of Things devices with low performance. Summary of the Invention
[0004] Aiming at the deficiencies of the existing technology in terms of prediction accuracy and real-time performance, the present invention proposes a real-time trajectory prediction method MP-RTP (Realtime trajectory prediction based on MarkovProcess) based on Markov process. This method takes into account the user's historical trajectory, real-time trajectory and real-time state within a long time interval. By constructing a Markov process model to analyze the movement law of the user between different stay points within a long time interval, both real-time performance and prediction accuracy are considered during trajectory prediction.
[0005] The key point of the present invention is: by collecting the user's historical trajectory data within a long time interval, extracting the rules of the user's daily life and travel habits from it, and formally constructing a mathematical model based on Markov process with this rule, so as to use this model for real-time trajectory prediction. The MP-RTP method is divided into two stages: data collection stage and trajectory prediction stage. In the data collection stage, MP-RTP collects the user's historical trajectory data, performs data preprocessing and constructs a mathematical model based on Markov process. In the trajectory prediction stage, MP-RTP based on the pre-established mathematical model, according to the user's real-time trajectory, uses a prediction algorithm to predict the future user trajectory in real time. The MP-RTP method is divided into three major steps: data preprocessing, constructing a Markov model and trajectory prediction.
[0006] Step 1: Data preprocessing. Collect the historical trajectory data T of a certain user for about 1 month h , which is a sequence composed of several trajectory points, and the sampling interval is interval. P i =(t i , x i , y i ) represents a certain trajectory point, t i represents the sampling timestamp of this trajectory point, x i represents the latitude of P i , y i represents the longitude of P i . Due to the interference of the external environment, there is noise in the process of collecting the historical trajectory T h . Therefore, it is necessary to preprocess T h to reduce the impact of noise on the subsequent model construction. The specific steps are as follows:
[0007] Step (1.1): Speed calculation. Calculate the moving speeds corresponding to all trajectory points in the historical trajectory T h . Assume that the speed v0 of the user at the trajectory point P0 is 0, then the moving speed v i of the user at the trajectory point P i is as shown in Equation (1):
[0008]
[0009] where, t i - t i-1 represents the time difference between two trajectory points P i and P i-1 , dp(P i , P i-1 ) represents the actual geographical distance between the trajectory points P i and P i-1 , and this distance can be calculated by the Haversine formula, as shown in Equations (2) and (3):
[0010]
[0011]
[0012] where, R = 6371 km, representing the radius of the earth, and h is an intermediate variable.
[0013] Step (1.2): Outlier elimination. Set the speed threshold VT, and regard the trajectory points P h in the historical trajectory T where the speed v i is greater than VT as outliers, and remove this trajectory point P i and this trajectory point P iReplace it with the previous trajectory point P i-1 and the subsequent trajectory point P i+1 of the geometric midpoint.
[0014] Step 2: Construct a Markov model. Based on the historical trajectory T h Construct a Markov chain-based model (MCM, Markov Chain Model) to describe the user's travel movement pattern. The specific steps are as follows:
[0015] Step (2.1): Trajectory point classification. Divide all the trajectory points in the historical trajectory T h into two categories: stay trajectory points and moving trajectory points. Use c i to represent the type of the trajectory point P i , where c i = MOVE_POINT indicates that P i is a moving trajectory point, and c i = STAY_POINT indicates that P i is a stay trajectory point. The classification method is as follows: Set the initial classification information c i of all trajectory points to MOVE_POINT, and then perform two traversals: First, traverse all trajectory points. When a trajectory point with a speed of 0 is encountered, search forward for all trajectory points within the minimum stay time mst. If the speed values of these trajectory points are all 0, then classify these points as STAY_POINT. Then, traverse all trajectory points of type MOVE_POINT again. If the types of all trajectory points within the minimum moving time mmt in front of the current trajectory point are all MOVE_POINT, then the classification of these points remains unchanged; otherwise, classify these points as STAY_POINT. After the classification is completed, add the classification information c i of each trajectory point to P i , where P i = (t i , x i , y i , v i , c i ).
[0016] Step (2.2): Trajectory segment segmentation. According to the type information c i of P i after classification in step (2.1), divide T h into stay trajectory segments and moving trajectory segments. The process is as follows: First, divide adjacent trajectory points of the same type in the historical trajectory T h into the same trajectory segment according to the classification information of the trajectory points, and store the obtained trajectory segments in the trajectory segment list TL, where τ i = (PL i , type i) ∈ TL. Among them, τ i represents a trajectory segment, and PL i is the sequence of trajectory points in the trajectory segment τ i , and type i represents the type of the trajectory segment, and type i ∈ {STAY, MOVE}. When the value of type i is STAY, it means that τ i is a stay trajectory segment. When the value of type i is MOVE, it means that τ i is a moving trajectory segment. Then, for all the stay trajectory segments τ i in the trajectory segment list TL whose type i value is STAY, use the Geographic Midpoint algorithm to calculate its geographical center position coordinates τ (stay) .cp. Specifically, calculate its latitude coordinate τ (stay) .cp.x and longitude coordinate τ (stay) .cp.y.
[0017] Step (2.3): Classification of stay trajectory segments. First, traverse all the stay trajectory segments in the trajectory segment list TL, and use their corresponding geographical center positions as stay points and put them into the stay point list S. S k represents the stay point with index k in S. For each stay trajectory segment τ (stay) traversed, calculate the geographical distance between its corresponding geographical center position coordinates τ (stay) .cp and the coordinates of the existing stay points in the stay point list S. If the distance is less than the set threshold, calculate the geographical center of the two by the Geographic Midpoint algorithm to replace the stay point. Otherwise, add τ (stay) .cp as a new stay point to S. After the traversal is completed, the length of the stay point list S is represented by |S|. Then, according to the distances from the geographical center positions to all the stay points in S, classify all the stay trajectory segments in TL into |S| sets. The classification set Φ k corresponding to the stay point S k is defined as shown in Equation (4):
[0018]
[0019] Among them, dp(τ.cp, S k ) represents the geographical distance from the geographical center τ.cp of the trajectory segment τ to the stay point S k .
[0020] Step (2.4): Build a model. When a user is moving, they are always changing between two states: "staying at a dwelling point" and "moving between dwelling points". By modeling this pattern of user state changes as a Markov process model, we can predict user state changes and thus predict the user's movement trajectory. The process of building the model is as follows:
[0021] First, calculate the total number of user states \(M = |S|\) 2 +|S|, where the number of states of "staying at a dwelling point" is |S|, and the number of states of "moving between dwelling points" is |S| 2 . Use to represent the \(M\) user states, represents the user state of staying at dwelling point \(S\) k , represents the user state of moving between dwelling points \(S\) u and \(S\) v , \(m = 0, 1, \ldots, M - 1\).
[0022] Then, traverse each trajectory point in all trajectory segments in the trajectory segment list \(TL\), and add state information to the trajectory point \(P\) i When the trajectory segment to which the trajectory point \(P\) belongs is a stay trajectory segment, i it means the user is staying at dwelling point \(S\) ; when \(P\) k belongs to a movement trajectory segment, i it means the user is moving between dwelling points \(S\) and dwelling point \(S\) u and dwelling point \(S\) v .
[0023] Next, divide the time of a day into \(N\) time slots with a sampling interval of interval, and count the user state frequencies and user state transition frequencies in the historical trajectory \(T\) h . The frequency of the user state being in the \(n\)th time slot and the frequency of the user state transitioning from to between the \(n + 1\)th time slot are represented by the dictionaries \(F_0, F_1, \ldots, F\) N-1 to represent the statistical results.
[0024] Finally, based on the above statistical results, calculate the state transition probabilities and build a non-stationary Markov chain to describe the pattern of user state changes. The non-stationary Markov chain of the user at time slot \(n\) is denoted as \(Q\) n , \(Q\) n is an \(M\times M\) matrix. represents that at time slot \(n\), the current user state is In the case of, the user state in the next time slot changes to with a probability defined as shown in Equation (5):
[0025]
[0026] where \(i = 0, 1, \ldots, M - 1\) and \(j = 0, 1, \ldots, M - 1\).
[0027] Step 3: Real-time trajectory prediction. Based on the Markov process model constructed in Step 2 and the collected real-time trajectory \(T\) r predict the future user trajectory \(T\) p , and the specific steps are as follows:
[0028] Step (3.1): Current state determination. Collect the real-time trajectory \(T\) of the user in the past 5 minutes r , including \(|T|\) r real-time trajectory points. Determine the current user state as follows:
[0029] Calculate the speed information of all trajectory points in the real-time trajectory \(T\) r by the method in Step (1.1), and determine the user state type: if the number of trajectory points with a speed value of 0 exceeds \(0.5|T|\) r , then determine that the current user state type is the dwelling state; otherwise, it is the moving state. Then, further calculate the current user state value:
[0030] ① If the current user state type is the dwelling state, calculate the geographical center \(T.cp\) of all trajectory points in the real-time trajectory \(T\) r , compare the distance between \(T.cp\) and all dwelling points in the dwelling point list \(S\), and take the user state value \(q\) r .cp corresponding to the dwelling point \(S\) r .cp closest to \(T\) r as k the value of k .
[0031] ② If the current user state type is the moving state, obtain the last dwelling state before the user changes to the current moving state, and record the state value as Match the similarity between all trajectory segments of length \(|T|\) l starting from the dwelling point \(S\) in the trajectory segment list \(TL\) and the real-time trajectory \(T\) r r , and select the state value corresponding to the trajectory segment where the trajectory segment with the highest similarity is located as [1] the value of .
[0032] Step (3.2): State change prediction. Predict the list of state changes Ω of the user within the next |T p | time slots, Let the current time be t (now) , and obtain the current state of the user through step (3.1) and the Markov model Q constructed in step 2 n Predict the list of user state changes Ω. The specific process is as follows:
[0033] First, calculate the time slot index n corresponding to the current time t (now) : (now)
[0034]
[0035] where t (now) .h, t (now) .m, t (now) .s respectively represent the hour, minute, and second of the current time t (now) , interval is the sampling interval, and around means rounding to the nearest integer.
[0036] Then, transform the problem of predicting the list of state changes Ω into an optimization problem as shown in formula (7):
[0037]
[0038] The meaning of this optimization problem is: Search for all lists of state changes of length |T starting from state |, and find the list that maximizes the |T p |-step transition probability of the non-stationary Markov model as the value of Ω. p
[0039] Finally, use depth-first search to solve the above optimization problem.
[0040] Step (3.3): Future trajectory prediction. Predict the user trajectory T within the next |T p | time slots according to the list of states Ω obtained in step (3.2) p , and the specific process is as follows:
[0041] ① When the current state type of the user is the staying state, the prediction method is: First, obtain the state value q of the current state of the user according to step (3.2) k , and the corresponding staying point S k . Then, calculate the state values in the list of state changes Ω and the current state The number NS of the same states (NS ≤ |T p |). Since the dwelling state between adjacent time slots cannot change suddenly, that is, when the user changes from one dwelling state to another, at least one moving state must be passed through. Therefore, the state values between index 0 and NS–1 in the state change list Ω are the same as those of . The user will stay at the S k position within the next 0 to NS–1 time slots, and enter the moving state within the time slots from NS to |T p | - 1, and its state value is represented by q k→l . At the NSth time slot in the future, the most likely moving trajectory segment τ (b) that the user will pass through starting from the current dwelling point is:
[0042]
[0043] In summary, when the current state of the user is the dwelling state, the predicted future user trajectory T p is as shown in Equation (9):
[0044]
[0045] ② When the current state type of the user is the moving state, the prediction method is as follows: First, the state value q of l→g is obtained through step (3.2). Then, according to the current state and the real-time trajectory T r , the similarity matching [1] algorithm is used to find the most likely moving trajectory segment τ (m) where the user is currently located from the trajectory segment list TL. The starting index of the most similar path trajectory segment in the moving trajectory segment τ (m) is i max . Finally, calculate the number NS of states in the state change list Ω whose state values are the same as the current state (NS ≤ |T p |). Since the moving state between adjacent time slots cannot change suddenly, that is, when the user changes from one moving state to another, at least one dwelling state must be passed through. Therefore, the state values between index 0 and NS–1 in the state change list Ω are the same as those of . The user state within the next 0 to NS–1 time slots is the same as , indicating that the user will move on the τ (m) path; within the time slots from NS to |T p | - 1 in the future, the user will enter the dwelling state q g , and the corresponding dwelling point is Sg 。
[0046] In summary, when the current state of the user is in a moving state, the predicted future user trajectory T p is as shown in Equation (10):
[0047]
[0048] The present invention has the following advantages:
[0049] 1. In terms of algorithm performance: The prediction algorithm based on the Markov chain model constructed by the present invention has relatively lower time complexity and space complexity of the model and the prediction algorithm compared with the prediction algorithm based on the neural network. Therefore, it is suitable for deployment on Internet of Things devices, such as mobile terminals, embedded devices, etc.
[0050] 2. In terms of prediction accuracy: The present invention takes into account the user's historical trajectory, real-time trajectory and real-time state within a long time interval. By constructing a Markov process model to analyze the movement law of the user between different stay points within a long time interval, the prediction accuracy is improved while ensuring the algorithm performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 is a schematic diagram of trajectory segment segmentation;
[0052] Figure 2 is a schematic diagram of the trajectory segment after segmentation;
[0053] Figure 3 is a schematic diagram of the classification of trajectory segments;
[0054] Figure 4 is a schematic diagram of the user state and the statistical diagram of state transition frequencies;
[0055] Figure 5 is the prediction result of the user's movement trajectory in the embodiment. DETAILED DESCRIPTION OF THE INVENTION
[0056] All codes in the present invention are implemented using the Python language. The user's historical trajectory data is collected using a GPS recorder application installed on the user's smartphone. The GPS recorder application collects the user's GPS trajectory data in real time at a sampling interval of 10 seconds, that is, interval = 10 seconds, and saves the collected data with a time stamp in the csv (Comma-Separated Values, character-separated value file format).
[0057] Step 1: Data preprocessing.
[0058] First, use the read_csv function in the pandas library to read the historical trajectory data file and load it into memory in the form of a DataFrame object of the pandas library, that is, the user historical trajectory T h . Then, for each trajectory point P h in T i add the speed information v i . Finally, use a loop statement to traverse T h , and replace the trajectory points in T h with a speed greater than the threshold VT with the geometric midpoint of the two adjacent normal trajectory points. In this embodiment, the value of VT is 5.0, and the unit is m / s
[0059] Step 2: Build a Markov model
[0060] Step (2.1): Trajectory point classification. First, stipulate that the minimum stay time mst is 5 minutes and the minimum movement time mmt is 5 minutes. mst and mmt are variables of the pandas.Timedelta type. Then, Algorithm 1 is implemented in the form of a function named tp_class. Call the function with the user historical trajectory T h , the minimum stay time mst, the minimum movement time mmt, and the sampling time interval of 10 seconds as function parameters to obtain the classification information list c. c is a one-dimensional numpy array with the same length as the number of trajectory points in T h , and add the classification information to T h . After adding, the type of the trajectory point P h with index i in T i is c i .
[0061]
[0062]
[0063] Step (2.2): Build a list of trajectory segments. First, implement Algorithm 2 in the form of a function named separate_trajectory. As Figure 1 , Figure 2 shown, use the user historical trajectory T hAs input, call the function separate_trajectory to obtain a list of trajectory segments TL. TL is a Python list object, and each element in the object is a tuple, represented by (PL, type). PL is a trajectory segment of the DataFrame type, and type is a Python string used to mark the type of PL. Then, implement Algorithm 3 in the form of a function named geo_center. Traverse all the stay trajectory segments in TL. In each iteration, use the stay trajectory segment as input, call the geo_center function, calculate its geographical center point, and save it to TL.
[0064]
[0065]
[0066] Step (2.3): Extract stay points. First, implement Algorithm 4 in the form of a function named stay_point_extract. As Figure 3 shown, use the list of trajectory segments TL obtained in step (2.2) and the distance threshold DT (in this embodiment, DT is set to 7.5 meters) as input, call the function stay_point_extract to obtain a list of stay points S. S is a one-dimensional numpy array. Then, implement Algorithm 5 in the form of a function named sts_class. Use the list of trajectory segments TL and the list of stay points S as input, call the sts_class function to obtain a list TC = {Φ0, Φ1, …, Φ |S|-1}, TC is a Python list, with the same length as the list S. Each element Φ in the list is a Python set, and each element in the set is a stay trajectory segment of the DataFrame type.
[0067]
[0068]
[0069] Step (2.4): Build a model. First, define a status class named PointStatus. PointStatus contains an object of the string type to save the status value and an object of the boolean type to save the status type. Then, implement Algorithm 6 in the form of a function named add_status. Use the list of trajectory segments TL and the classification set TC = {Φ0, Φ1, …, Φ |S|-1} obtained in step (2.3) as input, call the add_status function to obtain a list PS is a Python list, with a length equal to the user's historical trajectory Th The number of trajectory points, and each element in the list is of the PointStatus type. The element at index i in PS corresponds to the status of the trajectory point at index i in T h . Finally, implement Algorithm 7 in the form of a function called freq_count. Take the historical trajectory dataset T h and the number of time slots N (the number of time slots is the same as the number of trajectory data points per day) as inputs, call the function freq_count, and obtain the statistical result FR = {F0, F1, …, F N-1}, FR is a Python list, and each element in FR is a Python dictionary. The element at index i represents the statistical result at time slot i. Finally, use FR to obtain the non-stationary Markov chain model Q, Q is a Python list of length N, and each element in the list is a state transition probability matrix.
[0070]
[0071]
[0072] Step 3: Real-time trajectory prediction.
[0073] Step (3.1) Determine the current user status. The application deployed on the mobile terminal device will collect the user's recent 5-minute movement trajectory in real time and save it as a DataFrame type, that is, the user's real-time trajectory T r . First, add speed information to all trajectory points in T r using the same method as adding speed information in Step 1. Then, determine the current user status type. If the current status type is the stay state, the method for calculating the current status value is as follows: First, use the geo_center function defined in Step (2.2) to calculate the geographical center T r of all trajectory points in T r .cp; then, use a loop statement to calculate the distances between T r .cp and all stay points in the S list, and obtain the stay point S r in S that is closest to T k .cp; finally, use the status value q k corresponding to this stay point as the current user status value It is an object of the PointStatus type. If the current status type is the moving state, the method for calculating the current status value is as follows: First, obtain the status value of the last stay state before the current moving state and the stay point S l ; then, use a loop statement to calculate the distances between T r and all points in the TL list starting from the stay point Sl For all trajectory segments of length |T in the starting trajectory r calculate the similarity, and save the state value corresponding to the trajectory segment with the highest similarity in each loop. Finally, use this state value as the current user state value after the loop ends is an object of type PointStatus
[0074] Step (3.2): Predict user state changes. First, implement Algorithm 8 and its sub-algorithm 8.1 in the form of a function named status_prediction. Then, use the current user state obtained in step (3.1) the time slot n corresponding to the current time (now) and predict the trajectory length |T p as inputs, call the function status_prediction to obtain the predicted status list Ω, where Ω is a Python list composed of objects of type PointStatus
[0075]
[0076]
[0077] Step (3.3): Predict the future user trajectory. If the type of the current user state is stay, the prediction process is as follows: First, obtain the stay point S corresponding to the stay state in step (3.1) k and its corresponding state value; then, use a loop statement to traverse the Ω list to count the number of states NS equal to the q k value. Finally, predict the future user trajectory T p T p is an object of type DataFrame. If the type of the current user state is moving, the prediction process is as follows: First, use a loop statement to match the most similar trajectory segment from the trajectory segments TL; then, use a loop statement to traverse the Ω list and count the number of states NS equal to the value. Finally, predict the future user trajectory
[0078] Figure 5 This is the effect diagram of real-time trajectory prediction for a certain user in this embodiment. Among them, (a) and (b) are the trajectory prediction effects when the user is in the stay state, and (c) and (d) are the trajectory prediction effects when the user is in the moving state. After calculation Figure 5 the root mean square error RMSE between the predicted trajectory and the real trajectory in is 9.4917×10 -5 , and the mean absolute error MAE is 6.9733×10-5 。
[0079] [1]Shang S,Chen L,Wei Z,et al.Trajectory similarity join in spatialnetworks[J].Proceedings of the VLDB Endowment,2017,10(11).
Claims
1. A real-time trajectory prediction method based on Markov process, characterized in that: Specifically, it includes the following steps: Step 1: Data preprocessing Collect the historical trajectory data T of the user within 1 month h , with a sampling interval of interval; P i =(t i ,x i ,y i ) represents a trajectory point in the historical trajectory T h ; t i represents the sampling timestamp of this trajectory point, x i represents the latitude of P i , and y i represents the longitude of P i ; The preprocessing steps are as follows: Step (1.1): Speed calculation Calculate the moving speeds corresponding to all trajectory points in the historical trajectory T h ; Assume that the speed v0 of the user at the trajectory point P0 is 0, then the moving speed v of the user at the trajectory point P i is as follows i as shown in Equation (1): where t i -t i-1 represents the time difference between two trajectory points P i and P i-1 , and dp(P i , P i-1 ) represents the actual geographical distance between trajectory points P i and P i-1 : Where R = 6371 km, representing the radius of the earth, and h is an intermediate variable; Step (1.2): Outlier elimination Set a speed threshold VT, and for the historical trajectory T h the speed v i in which is greater than VT, the trajectory points P i are regarded as abnormal points, and these trajectory points P i are replaced with the geometric midpoint of the trajectory point P i-1 before it and the trajectory point P i+1 after it; Step 2: Construct a Markov model Based on the historical trajectory T h Construct a Markov chain-based model to describe the user travel movement pattern. The specific steps are as follows: Step (2.1): Trajectory point classification Divide all the trajectory points in the historical trajectory T h into two categories: stay trajectory points and moving trajectory points. When c i = MOVE_POINT, it means that P i is a moving trajectory point; when c i = STAY_POINT, it means that P i is a stay trajectory point; First, set the initial classification information c i of all trajectory points to MOVE_POINT, then traverse all trajectory points. When a trajectory point with a speed of 0 is traversed, search for all trajectory points within the minimum stay time mst in the forward direction. If the speed values of these trajectory points are all 0, then classify these points as STAY_POINT; then traverse all trajectory points of type MOVE_POINT again. If the types of all trajectory points within the minimum moving time mmt in the forward direction of the current trajectory point are all MOVE_POINT, then the classification of these points remains unchanged, otherwise classify these points as STAY_POINT; After the classification is completed, add the classification information c i of each trajectory point to P i . P i = (t i , x i , y i , v i , c i ); Step (2.2): Trajectory segment segmentation After classification according to step (2.1), P i 's type information c i , the historical trajectory T h is segmented into a stay trajectory segment and a movement trajectory segment. According to the classification information of the trajectory points, the adjacent same-type trajectory points in the historical trajectory T h are divided into the same trajectory segment, and the obtained trajectory segments after segmentation are stored in the trajectory segment list TL, τ i =(PL i , type i )∈TL; where τ i represents a trajectory segment, PL i is the sequence of trajectory points in the trajectory segment τ i , type i represents the type of the trajectory segment, type i ∈{STAY, MOVE}; when the value of type i is STAY, it means that τ i is a stay trajectory segment, and when the value of type i is MOVE, it means that τ i is a movement trajectory segment; then, for all the stay trajectory segments τ i in the trajectory segment list TL whose type i value is STAY, use the Geographic Midpoint algorithm to calculate its geographical center position coordinates τ (stay) .cp, specifically calculate its latitude coordinate τ (stay) .cp.x and longitude coordinate τ (stay) .cp.y; Step (2.3): Classification of stay trajectory segments First, traverse all the stay trajectory segments in the trajectory segment list TL, and use their corresponding geographical center positions as stay points, and put them into the stay point list S; for each traversed stay trajectory segment τ (stay) , calculate the coordinates τ (stay) .cp of its corresponding geographical center position and the geographical distance from the coordinates of the existing stay points in the stay point list S. If the distance is less than the set threshold, calculate the geographical center of the two by the Geographic Midpoint algorithm to replace the stay point, otherwise use τ (stay) .cp as a new stay point and add it to the stay point list S; after the traversal is completed, the length of the stay point list S is |S|; Then, according to the distances from the geographical center location to all the stay points in S, all the stay track segments in TL are classified into |S| sets, and the stay point S k The corresponding classification set Φ k is defined as shown in Equation (4): where, dp(τ.cp,S k ) represents the geographical distance from the geographical center τ.cp of the trajectory segment τ to the stay point S k ; Step (2.4): Model construction When a user is moving, they are always changing between two states: "staying at a stay point" and "moving between stay points". By modeling this user state change pattern as a Markov process model, the user state change can be predicted, and thus the user's movement trajectory can be predicted. The process of constructing the model is as follows: First, calculate the total number of user states \(M = |S|\) 2 +|S|, where the number of states of "staying at the stationary point" is |S|, and the number of states of "moving between stationary points" is |S| 2 ; use to represent the \(M\) user states, \(\cup \{q\) u→v \(|0\leq u, v \lt |S| - 1\}\), represents that the user state is staying at the stationary point \(S\) k , represents that the user state is moving between the stationary points \(S\) u and \(S\) v , \(m = 0, 1, \ldots, M - 1\); Then, traverse each trajectory point in all trajectory segments in the trajectory segment list TL, and add status information for the trajectory point P i Add status information When the trajectory point P i belongs to a stay trajectory segment, it means that the user stays at the stay point S k ; when P i belongs to a moving trajectory segment, it means that the user moves between the stay point S u and the stay point S v ; Next, divide the time of one day into N time slots at a sampling interval of interval, and count the historical trajectory T h the frequency of user states and the frequency of user state transitions in it; the user state in the nth time slot is the frequency between the n+1th time slot, the user state changes from to the frequency Use dictionaries F0, F1, …, F N-1 to represent the statistical results; Finally, according to the above statistical results, calculate the state transition probability and construct a non-stationary Markov chain to describe the variation law of the user state; the non-stationary Markov chain of the user at time slot n is denoted as Q n , Q n is an M×M matrix; represents that at time slot n, when the current user state is , the probability that the user state in the next time slot changes to is defined as shown in Equation (5): Where i = 0, 1,..., M - 1, j = 0, 1,..., M - 1; Step 3: Real-time trajectory prediction The Markov process model constructed based on Step 2 and the collected real-time trajectory T r Predict the future user trajectory T p , and the specific steps are as follows: Step (3.1): Current state determination Collect the real-time trajectory T of the user in the past 5 minutes r , including |T r | real-time trajectory points; judge the current state of the user The process is as follows: Calculate the velocity information of all trajectory points in real-time trajectory T by the method of step (1.1), and determine the user state type: if the number of trajectory points with a velocity value of 0 exceeds 0.5|T r |, then determine that the current user state type is the residence state, otherwise it is the moving state; then, further calculate the current user state value: r |, then determine that the current user state type is the residence state, otherwise it is the moving state; then, further calculate the current user state value: ① If the current user status type is the residence status, calculate the geographical center T r of all the trajectory points in r .cp, and compare the distance between T r .cp and all the residence points in the residence point list S, and take the residence point S r with the closest distance to T k and use the corresponding user status value q k as the value; ② If the current user status type is the moving status, obtain the last resident status of the user before changing to the current moving status The status value is denoted as For all the trajectory segments in the trajectory segment list TL that start from the resident point S l departing, for all the trajectory segments with a length of |T r |, perform similarity matching with the real-time trajectory T r , and select the status value corresponding to the trajectory segment where the trajectory segment with the highest similarity is located as [1] the value of; Step (3.2): Prediction of state change Predict the user's state changes within the next |T p | list of state changes Ω in a time slot, Ω = [ω0, ω1, …, ω |Tp|-1 , Let the current time be t (now) , and obtain the user's current state through step (3.1) and the Markov model Q constructed in step 2 n Predict the user state change list Ω, and the specific process is as follows: First, calculate the current time t (now) The corresponding time slot index n (now) : Among them, t (now) .h, t (now) .m, t (now) .s respectively represent the hour, minute, and second of the current time t (now) , interval is the sampling interval, and around means rounding to the nearest integer; Then, the problem of the predicted state change list Ω is transformed into an optimization problem as shown in formula (7): The meaning of this optimization problem is: Search for all state change lists starting from state with a length of |T p |, and find the list that maximizes the |T p |-step transition probability of the non-stationary Markov model as the value of Ω; Finally, use depth-first search to solve the above optimization problem; Step (3.3): Future trajectory prediction Predict the future user trajectory \(T\) within \(|T|\) time slots based on the state list \(\Omega\) obtained in step (3.2). p Specifically, the process is as follows: p Predict the user trajectory \(T\) within \(|T|\) time slots ①When the current state type of the user is the dwelling state, the prediction method is as follows: First, the state value q of the user's current state is obtained according to step (3.2), k as well as the corresponding dwelling point S k ; Then, calculate the number NS of states in the state change list Ω whose state values are the same as the current state , where NS ≤ |T p |; Since the dwelling state between adjacent time slots cannot mutate, that is, for the user to change from one dwelling state to another dwelling state, at least one moving state must be passed through. Therefore, the state values between index 0 and NS - 1 in the state change list Ω are the same as the state value; The user will stay at the S k position within the next 0 to NS - 1 time slots, and enter the moving state within the time slots from NS to |T p | - 1, and its state value is represented by q k→l ; At the NSth time slot in the future, the most likely moving trajectory segment τ (b) that the user passes through starting from the current dwelling point is as follows: In summary, when the current state of the user is the resident state, the predicted future user trajectory T p is as shown in Equation (9): ②When the current state type of the user is the moving state, the prediction method is as follows: First, the state value q is obtained through step (3.2); l→g Then, according to the current state and the real-time trajectory T r , the similarity matching algorithm is used to find the moving trajectory segment τ (m) where the user is most likely to be located currently from the trajectory segment list TL. The starting index of the most similar path trajectory segment in the moving trajectory segment τ (m) is i max ; Finally, calculate the number NS (NS ≤ |T |) of states in the state change list Ω whose state values are the same as the current state p . Since the moving state cannot mutate between adjacent time slots, that is, when the user changes from one moving state to another moving state, at least one staying state must be passed through. Therefore, the state values between index 0 and NS - 1 in the state change list Ω are the same as the state value of ; In the next 0 to NS - 1 time slots, the user state is the same as , indicating that the user will move on the τ (m) path; In the next NS to |T p | - 1 time slots, the user will enter the staying state q g , and the corresponding staying point is S g ; In summary, when the current user state is in a moving state, the predicted future user trajectory T p is as shown in Equation (10):
2. The real-time trajectory prediction method based on Markov process according to claim 1, wherein: Set the sampling interval interval to 10 seconds.
3. The real-time trajectory prediction method based on the Markov process according to claim 1, characterized in that: During the data preprocessing in Step 1, set the speed threshold VT to 5 m / s.
4. The real-time trajectory prediction method based on Markov process according to claim 1, wherein: During the trajectory point classification process, set both the minimum stay time mst and the minimum movement time mmt to 5 minutes.