Travel time prediction method and device based on knowledge graph

By constructing a traffic knowledge graph and combining real-time traffic data, the problem of inaccurate prediction of urban road network trip time in the existing technology is solved, and higher prediction accuracy is achieved, and suitable for complex and changeable urban traffic environments.

CN119622273AActive Publication Date: 2025-03-14湖南工商大学
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510147594.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-11
Publication Date
2025-03-14
Estimated Expiration
2045-02-11

AI Technical Summary

Technical Problem

It is difficult for the existing technology to achieve accurate prediction of the itinerary time of the urban road network, especially in the complex and changing urban traffic environment. Various dynamics and interrelated factors affect the itinerary time, resulting in poor prediction results of existing statistical models.

Method used

Using a knowledge graph-based method, a traffic knowledge graph is constructed, including entities, relationships and attributes, stored using Neo4j graph database, and knowledge storage and reasoning are performed through dynamic mapping matrix and low-dimensional embedding vectors, and travel time prediction is performed in combination with real-time traffic data.

Benefits of technology

By considering temporary or periodic changes caused by traffic events, the accuracy of itinerary time prediction is improved, and a variety of influencing factors in complex urban traffic environments can be more effectively dealt with.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119622273A_ABST
    Figure CN119622273A_ABST
Patent Text Reader

Abstract

The invention discloses a travel time prediction method and equipment based on a knowledge graph, and the method comprises the steps: building a traffic knowledge graph, storing a data layer in the traffic knowledge graph through employing a Neo4j graph database, enabling the traffic knowledge graph to comprise entities, relationships and attributes, enabling the entities to comprise at least one of a road condition, a road section, an intersection and a road grade, and enabling the relationships to be stored in the Neo4j graph database; the relationship comprises the relationship among the entities, and the attributes comprise travel time and traffic events; and acquiring real-time traffic data, and inputting the real-time traffic data into the traffic knowledge graph for prediction to obtain predicted travel time. According to the method, temporary or periodic changes caused by traffic events are considered, and the information is incorporated into the knowledge graph, so that the travel time prediction accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of traffic prediction, and in particular to a travel time prediction method and device based on a knowledge graph. Background Art

[0002] In daily travel, travel time is one of the most important traffic information for users. Travel time prediction can provide useful information for applications such as dynamic route navigation, road congestion control, optimal scheduling and traffic accident detection. Urban road network travel time prediction is a crucial task in intelligent transportation systems. It is directly related to daily travel planning, logistics and transportation management, traffic congestion relief and the efficiency of emergency rescue. In the complex and changing urban traffic environment, many factors such as traffic accidents, road construction, vehicle failures, weather changes and special events may affect travel time. These factors are often dynamic and interrelated, and there are abnormal fluctuations under different traffic conditions, which makes it difficult to predict the travel time of urban road networks.

[0003] Existing methods use statistical models to predict travel time, such as linear regression models, ARIMA models and variants, and methods based on Kalman filters. However, the inventors found in the process of implementing the present invention that the data designed by the existing statistical models tend to be linear data, and it is difficult to express the prediction algorithm for urban road network travel time with an accurate equation.

[0004] Therefore, how to provide a traffic travel time data processing method to achieve accurate prediction of urban road network travel time has become a technical problem that needs to be solved urgently. Summary of the invention

[0005] Embodiments of the present invention provide a travel time prediction method, apparatus, computer equipment and storage medium based on a knowledge graph to improve the accuracy of travel time prediction.

[0006] In order to solve the above technical problems, the present application embodiment provides a travel time prediction method based on a knowledge graph, including: Constructing a traffic knowledge graph, wherein the data layer in the traffic knowledge graph is stored in a Neo4j graph database, and the traffic knowledge graph includes entities, relationships, and attributes, wherein the entities include at least one of road conditions, road sections, intersections, and road grades, the relationships include connections between entities, and the attributes include travel time and traffic events; Real-time traffic data is obtained, and the real-time traffic data is input into the traffic knowledge graph for prediction to obtain a predicted travel time.

[0007] Optionally, the constructing of a traffic knowledge graph includes: Define the static part of the knowledge graph as , where (h, r, t) means that there is a relationship r between the head entity h and the tail entity t, E represents the entity set, and R represents the relationship set; For the dynamic part, define , indicating road conditions, Indicates the attributes corresponding to the road conditions, where M and N represent the total number of road conditions and attributes respectively; use Represents any attribute of the traffic condition, hasTime represents the event time, hasincident represents the event identifier has={hasTime,hasincident}; Classify the traffic condition set into the entity set: , the traffic knowledge graph representation is obtained: , in .

[0008] Optionally, the construction of the traffic knowledge graph further includes: Constructing a first vector and a second vector, wherein the first vector represents an entity or a relationship, and the second vector is a projection vector; The second vector is used to construct a dynamic mapping matrix, which is combined with the first vector to encode the entity into a low-dimensional embedding vector in the relational space; The low-dimensional embedding vector is used for knowledge storage and knowledge reasoning to obtain the traffic knowledge graph.

[0009] Optionally, using the second vector to construct a dynamic mapping matrix, combining the first vector, and encoding the entity into a low-dimensional embedding vector in the relational space includes: Each of the dynamic mapping matrices is initialized with the identity matrix, and the matrix multiplication operation is replaced by vector operation, which is expressed as: ; The entity vector is projected into the relation space and embedded, expressed as: ; The triple The relation vector r in is used as the head entity vector With the tail entity vector The translation vector of the head entity and the relationship vector in the embedding space The sum of the embedding vectors of the tail entity is equal to the embedding vector of .

[0010] Optionally, before constructing the traffic knowledge graph, the travel time prediction method based on the knowledge graph further includes: Acquiring historical data, wherein the historical data includes historical travel time data and historical traffic event data; The historical travel time data is divided according to preset time periods, and each time period is taken as a time point to obtain M time points; Matching the historical traffic event data in a time dimension to determine event matching information; The matching information includes historical traffic event data, the time point when the historical traffic event data occurred and the time point when the historical traffic event data ended; The event matching information and the historical data are used as raw data for constructing a traffic knowledge graph.

[0011] In order to solve the above technical problems, the embodiment of the present application further provides a travel time prediction device based on a knowledge graph, comprising: A knowledge graph construction module is used to construct a traffic knowledge graph. The data layer in the traffic knowledge graph is stored in a Neo4j graph database. The traffic knowledge graph includes entities, relationships and attributes. The entities include at least one of road conditions, road sections, intersections and road grades. The relationships include connections between entities. The attributes include travel time and traffic events. The real-time data acquisition module is used to acquire real-time traffic data and input the real-time traffic data into the traffic knowledge graph for prediction to obtain the predicted travel time.

[0012] Optionally, the knowledge graph construction module includes: The first definition unit is used to define the static part of the knowledge graph as , where (h, r, t) means that there is a relationship r between the head entity h and the tail entity t, E represents the entity set, and R represents the relationship set; The second definition unit is used to define, for the dynamic part, , indicating road conditions, Indicates the attributes corresponding to the road conditions, where M and N represent the total number of road conditions and attributes respectively; The third definition unit is used to Represents any attribute of the traffic condition, has={hasTime,hasincident}, hasTime represents the event time, hasincident represents the event identifier; Graph representation unit, used to classify the road condition set into the entity set: , the traffic knowledge graph representation is obtained: , in .

[0013] Optionally, the knowledge graph construction module further includes: A vector construction unit, used to construct a first vector and a second vector, wherein the first vector represents an entity or a relationship, and the second vector is a projection vector; An encoding unit, configured to construct a dynamic mapping matrix using the second vector, and combine the first vector to encode the entity into a low-dimensional embedding vector in the relational space; The reasoning unit is used to use the low-dimensional embedding vector to perform knowledge storage and knowledge reasoning to obtain the traffic knowledge graph.

[0014] Optionally, the encoding unit includes: The initialization subunit is used to initialize each of the dynamic mapping matrices with the identity matrix, and replace the matrix multiplication operation with a vector operation, which is expressed as: ; The embedding subunit is used to project the entity vector into the relation space and embed it, which is expressed as: ; Encoding subunit, used to convert triples The relation vector r in is used as the head entity vector With the tail entity vector The translation vector of the head entity and the relationship vector in the embedding space The sum of the embedding vectors of the tail entity is equal to the embedding vector of .

[0015] Optionally, the travel time prediction device based on knowledge graph further includes: A data acquisition module, used to acquire historical data, wherein the historical data includes historical travel time data and historical traffic event data;

[0016] A time period division module is used to divide the historical travel time data according to preset time periods, taking each time period as a time point, and obtaining M time points; A matching module, used to match the historical traffic event data in a time dimension to determine event matching information, wherein the matching information includes the historical traffic event data, the time point at which the historical traffic event data occurs, and the time point at which the historical traffic event data ends; The original data determination module is used to use the event matching information and the historical data as the original data for constructing a traffic knowledge graph.

[0017] In order to solve the above technical problems, an embodiment of the present application also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned knowledge graph-based travel time prediction method when executing the computer program.

[0018] In order to solve the above technical problems, an embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of the above-mentioned travel time prediction method based on the knowledge graph.

[0019] The travel time prediction method, device, computer equipment and storage medium based on the knowledge graph provided by the embodiment of the present invention construct a traffic knowledge graph. The data layer in the traffic knowledge graph is stored in the Neo4j graph database. The traffic knowledge graph includes entities, relationships and attributes, wherein the entity includes at least one of the road conditions, road sections, intersections and road grades, the relationship includes the connection between the entities, and the attribute includes the travel time and traffic events; real-time traffic data is obtained, and the real-time traffic data is input into the traffic knowledge graph for prediction to obtain the predicted travel time. By considering the temporary or periodic changes caused by traffic events and incorporating this information into the knowledge graph, the accuracy of travel time prediction is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0021] Figure 1 is an exemplary system architecture diagram to which the present application may be applied; Figure 2 is a flowchart of an embodiment of a travel time prediction method based on a knowledge graph of the present application; Figure 3 It is a schematic diagram of the traffic knowledge graph model layer of this application; Figure 4 It is a structural schematic diagram of an embodiment of a travel time prediction device based on a knowledge graph according to the present application; Figure 5 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION

[0022] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application are only for the purpose of describing specific embodiments, not for limiting the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0023] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0024] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0025] See also Figure 1 ,like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0026] Users can use terminal devices 101 , 102 , 103 to interact with server 105 via network 104 to receive or send messages, etc.

[0027] The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players, laptop computers, desktop computers, and the like.

[0028] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .

[0029] It should be noted that the travel time prediction method based on the knowledge graph provided in the embodiment of the present application is executed by a server, and accordingly, the travel time prediction device based on the knowledge graph is arranged in the server.

[0030] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. According to the implementation requirements, there may be any number of terminal devices, networks and servers. The terminal devices 101, 102, 103 in the embodiment of the present application may specifically correspond to application systems in actual production.

[0031] See also Figure 2 , Figure 2 A travel time prediction method based on knowledge graph provided by an embodiment of the present invention is shown. The method is applied in Figure 1 The server in is used as an example to illustrate the details as follows: S201: Construct a traffic knowledge graph. The data layer in the traffic knowledge graph is stored in the Neo4j graph database. The traffic knowledge graph includes entities, relationships, and attributes. The entities include at least one of road conditions, road sections, intersections, and road grades. The relationships include the connections between entities. The attributes include travel time and traffic events.

[0032] Future travel time prediction is related to time series features and traffic event features. In a specific example, traffic data is aggregated every 5 minutes to define time attributes. Time label vectors S1 = (0, 1, ..., 287), S2 = (0, 1, ..., 6) and S3 = (0, 1) are set to represent the time of day, week and whether it is a working day (0: non-working day).

[0033] In order to capture the sudden changes in actual traffic and improve the prediction accuracy, a knowledge graph is constructed to extract the characteristics of traffic event data. The prediction problem in this embodiment is defined as follows: , before using Historical observations at time steps , time attribute vector and traffic event feature vector to predict the future The travel time of the road segment in time steps .in, is the actual value at time t, is the predicted value at the next time step t+1. In order to verify the single-step and multi-step prediction capabilities of the prediction model, the next 5, 15, and 30 minutes (i.e., =1, 3, 6) to predict the travel time of the road sections.

[0034] In a specific optional implementation, before step S201, that is, before constructing the traffic knowledge graph, the travel time prediction method based on the knowledge graph further includes: Obtain historical data, including historical travel time data and historical traffic event data; For the historical travel time data, divide it according to the preset time periods, take each time period as a time point, and get M time points; Match historical traffic event data in the time dimension to determine event matching information; The matching information includes historical traffic event data, the time point at which the historical traffic event data occurred, and the time point at which the historical traffic event data ended; Event matching information and historical data are used as raw data for building the traffic knowledge graph.

[0035] Specifically, the basic road network data, road segment travel time data, and traffic event data are obtained from the Amap API through Internet crawler technology. The web crawler uses a unified resource locator URL to automatically crawl and download target information from the website, which improves efficiency and saves time. The specific description of the basic road network and road segment data set is shown in Table 1: Table 1 Description of basic road network and road section data

[0036] The specific description of the traffic event dataset is shown in Table 2. According to the characteristics of the events, the events are divided into repetitive traffic events and non-repetitive traffic events. Repetitive traffic events refer to periodic congestion events that occur during the morning and evening rush hours in daily commuting, while non-repetitive traffic events are random and are usually caused by other road events such as sudden traffic accidents.

[0037] Table 2 Traffic incident data description

[0038] Preprocess the historical travel time data and traffic event data, extract the target data, remove invalid and erroneous data, and improve the data quality. For the travel time data, divide the 24 hours of a day into 5-minute periods, which is divided into 288 time points, namely {00:00; 00:05; ...; 23:50; 23:55}. Calculate the average travel time of each period as the travel time required for that period.

[0039] Preferably, for traffic event data, due to the randomness and unpredictability of its occurrence time, the data matching of traffic event data in the time dimension is more complicated and cannot achieve absolute matching with the time granularity in the above data set. In this embodiment, the following three matching strategies are adopted for the acquired traffic event data: 1) If the start time and end time of the traffic event can match the divided time points, the time will be matched to the corresponding moment.

[0040] 2) If the start time of a traffic event cannot be matched with a time point, the previous time point corresponding to the start time is selected. For example, if the event start time is 10:12, its time point is matched to 10:10. The "forward selection" strategy for the start time is mainly to take into account the time delay generated during the detection and upload of traffic events.

[0041] 3) If the end time of the traffic event cannot be matched with the time point, the next time point corresponding to the end time is selected. For example, if the event ends at 17:36, the time point is matched to 17:40. The "backward selection" strategy for the end time mainly considers the time delay for traffic flow to return to normal after the traffic event occurs.

[0042] Specifically, the process of constructing a knowledge graph is essentially a process of obtaining the required data, organizing this data into a whole in an appropriate form and method, and continuously iterating and updating it.

[0043] In this embodiment, first, traffic event data is obtained; second, knowledge is extracted from data obtained from different sources to obtain entities, relationships and attributes in the knowledge graph; then, based on the existing data and professional knowledge in the traffic field, the model layer of the knowledge graph is designed and completed, that is, the traffic field ontology is constructed; then, the data layer of the knowledge graph is stored in the graph database Neo4j; finally, the traffic knowledge graph is enriched and updated through knowledge reasoning.

[0044] Furthermore, this embodiment adopts a top-down approach to construct a knowledge graph in the field of urban transportation. This study considers road sections, intersections, and road levels, and adds static data such as monitoring points and vehicle information as entities, dynamic data such as travel time and traffic events in road conditions as attributes, and enriches the relationships between entities and attributes. The static part of the knowledge graph is defined as , where (h, r, t) means that the head entity h has a relationship r with the tail entity t, E represents the entity set, and R represents the relationship set. For the dynamic part, define , indicating road conditions, Represents the attributes corresponding to the road conditions, where M and N represent the total number of road conditions and attributes respectively. Any attribute representing the traffic condition, has={hasTime,hasincident}, hasTime represents the event time, hasincident represents the event identifier. We classify the traffic condition set into the entity set: , then the overall traffic knowledge graph can be used Indicates. Finally, the traffic knowledge graph model layer is established, such as Figure 3 As shown in the figure, the solid line represents the entity and the dotted line represents the attribute.

[0045] Furthermore, the graph database Neo4j supports the storage of massive data. In Neo4j, data is organized into a series of nodes and relationships, which can directly represent various entities and the connections between them, making data management simpler and more intuitive. At the same time, Neo4j uses the Cypher graph query language to provide association queries and graph algorithms, which is more conducive to data query and value mining. Therefore, this study uses the Neo4j graph database for knowledge storage.

[0046] In a specific optional implementation, constructing a traffic knowledge graph includes: Define the static part of the knowledge graph as , where (h, r, t) means that there is a relationship r between the head entity h and the tail entity t, E represents the entity set, and R represents the relationship set; For the dynamic part, define , indicating road conditions, Indicates the attributes corresponding to the road conditions, where M and N represent the total number of road conditions and attributes respectively; use Represents any attribute of the traffic condition, has={hasTime,hasincident}, hasTime represents the event time, hasincident represents the event identifier; Classify the traffic condition set into the entity set: , we get the traffic knowledge graph representation: , in .

[0047] In a specific optional implementation, constructing a traffic knowledge graph further includes: Construct a first vector and a second vector, wherein the first vector represents an entity or a relationship, and the second vector is a projection vector; The second vector is used to construct a dynamic mapping matrix, which is combined with the first vector to encode the entity into a low-dimensional embedding vector in the relational space; Low-dimensional embedding vectors are used for knowledge storage and knowledge reasoning to obtain a traffic knowledge graph.

[0048] In a specific optional implementation, using the second vector to construct a dynamic mapping matrix, combining the first vector, and encoding the entity into a low-dimensional embedding vector in the relational space includes: Each dynamic mapping matrix is ​​initialized with the identity matrix, and the matrix multiplication operation is replaced by vector operation, which is expressed as: ; The entity vector is projected into the relation space and embedded, expressed as: ; Take the relation vector r in the triple (h, r, t) as the head entity vector With the tail entity vector The translation vector of the head entity and the relationship vector in the embedding space The sum of the embedding vectors of the tail entity is equal to the embedding vector of .

[0049] Preferably, this embodiment uses the TransD model to process time attributes and traffic event data. The main idea is to use the dynamic mapping matrix constructed by projection vectors to encode entities into low-dimensional embedding vectors in the relational space. Considering that entities and relations have different types and attributes, different types of relations define different semantic spaces, and different attributes focus on different entities under different relations.

[0050] The TransD model uses two vectors to represent each entity and relationship. The first vector represents the actual meaning of the entity or relationship, and the second vector is called the projection vector, which is used to construct the mapping matrix. The mapping matrix is ​​determined by the projection vector of the entity and the relationship. The entity can be mapped from the entity space to the vector space. Each mapping matrix is ​​initialized with the identity matrix, and the matrix multiplication operation is replaced by the vector operation, which effectively reduces the amount of calculation.

[0051] ; The entity vector is projected into the relation space and embedded as: ; TransD uses the relation vector r in the triple (h, r, t) as the head entity vector With the tail entity vector That is, the embedding vector of the head entity and the relationship vector in the embedding space The sum of the embedding vectors of the tail entity is equal to the embedding vector of Therefore, we can define a score function based on the L2 Euclidean distance to measure the distance between the two vectors: ; This model adds L2 norm constraints to the vector, which can reduce the relevant parameters of the model, avoid overfitting of the model, and improve the generalization ability of the model. We implemented the following constraints: ; For the correct triples, the higher the expected score, the better; at the same time, for the wrong triples, the smaller the score, the better. Therefore, a margin-based ranking loss function is defined, as shown in formula (7), and minimizing the loss function value is used as the training objective of the model.

[0052] ; in is a hyperparameter, indicating the maximum interval between the correct triple and the negative triple, [x]+=max(0,x), represents the set of correct triples, Represents the set of constructed negative triples.

[0053] Since there are only correct triples in the knowledge graph, it is necessary to construct the wrong triples as negative samples. The method used by the TransE model is to randomly select an entity from the set of all entities in the correct triples, replace the head or tail entity of the original triple, and obtain a new wrong triple, that is, a negative triple. However, due to the existence of one-to-many, many-to-one, and many-to-many relationships, this random sampling method for constructing negative samples introduces many false negative samples, that is, false negatives.

[0054] Taking into account different types of relations, when replacing the head or tail entity in a triple, the probability of the entity with a smaller number being replaced with a larger one. For example, when the relation is one-to-many, i.e. one head entity corresponds to multiple tail entities, the probability of the head entity being replaced is greater. When the relation is many-to-one, i.e. multiple head entities correspond to one tail entity, the probability of the tail entity being replaced is greater. For all relation triples, the following numbers are calculated: The average number of tail entities associated with each head entity is recorded as ; The average number of head entities associated with each tail entity is recorded as .

[0055] ; random variable Only two values, 0 and 1, are taken, and the corresponding probabilities are: ; ; The final negative sample is constructed according to the parameters Bernoulli distribution, random variable The distribution law is: ; For a correct triplet of a given relation, the probability of generating a negative triplet by replacing the head entity is , the probability of replacing the tail entity to generate a negative triple is .

[0056] Additionally, the type of constraint on a relationship is expressed by defining the entity types that should be associated with it. Using prior knowledge of the relationship type, the relationship determines which entities to replace. For example, the definition of a relationship type such as Marriage is associated only with individuals. Define the following variables: Relationship Type The ordered index of all entities in the domain constraint; In the relationship type The ordered indices of all entities within the scope constraint.

[0057] For a given relationship When constructing negative triples, the probability of replacing the head or tail entity is calculated according to the Bernoulli distribution. If the head entity is replaced, it is selected from the entity subset in the relation type domain. If the tail entity is replaced, it is selected from the entity subset within the relation type range, as shown in formula (12).

[0058] ; By utilizing the prior knowledge of relation types, the probability of extracting the correct entity type to replace the original triples when constructing negative samples is improved.

[0059] Furthermore, the model of this embodiment uses the mini-batch gradient descent (MBGD) method to update the parameters to obtain the minimum value of the loss function. During the training process, small batches of positive samples are randomly selected and corresponding negative samples are constructed. After batch processing, the gradient is calculated and the model parameters are updated. The model updates the parameters through continuous iteration until the loss value converges or the maximum number of iterations is reached. After the training is completed, the embedded representation of the entity and relationship is obtained.

[0060] GRU is a variant of a recurrent neural network (RNN), similar to the LSTM (Long Short-Term Memory) network, designed to solve the gradient vanishing or gradient exploding problems encountered by traditional RNNs when dealing with long-term dependency problems. The GRU structure consists of gating mechanisms that control the flow of information, allowing the model to better capture long-term dependencies in time series data. The main difference between GRU and LSTM is that it merges the hidden state and memory cells into a single hidden state, and it has only two gate structures: the reset gate and the update gate. The reset gate determines how the new input is combined with the previous hidden state, while the update gate controls the extent to which the information of the previous hidden state is passed to the current state.

[0061] In this embodiment, the dynamic change of travel time has obvious nonlinear and non-stationary characteristics. Reduce the attention to other information and filter out irrelevant information, thereby solving the problem of information overload and improving the efficiency and accuracy of task prediction. Therefore, this embodiment introduces an attention mechanism based on the existing GRU model, that is, an attention-enhanced gated recurrent unit (Attention-enhanced GRU, A-GRU) is used to improve the ability of the GRU model to capture effective features of historical data. In order to deeply reveal the influence of different time nodes on travel time prediction, an attention mechanism enhancement method is adopted. The deep learning model based on the attention mechanism can extract important features of different time points in the prediction process by calculating the influence of each time node on the prediction target.

[0062] In the A-GRU model of this embodiment, these attention coefficients will be used as weighting factors in the prediction process to give higher weights to time nodes that have a greater impact on the prediction results. The historical observations of time steps are represented , these inputs will enter the GRU model, and after calculation by the GRU model, the corresponding output will be obtained , , …, , then introduce Attention in the hidden layer to calculate the attention probability distribution value of each input , , …, , further extracting time attribute features to predict the future The travel time of the road segment in time steps Among them, the calculation formula of the Attention mechanism is as follows: ; ; ; in, Indicates Hidden state vector at time The determined attention probability distribution value, and Indicates The weight coefficient matrix at time, Indicates The corresponding offset at the moment. The above formula can be used to calculate the final feature vector containing the time attribute The input of the output layer is the output of the previous Attention layer. The function performs corresponding calculations on the input of the output layer to predict the travel time. The calculation formula is as follows: ; in: Represents the weight coefficient matrix to be trained from the Attention mechanism layer to the output layer, Represents the corresponding bias to be trained, is the predicted label of the output.

[0063] S202: Acquire real-time traffic data, and input the real-time traffic data into the traffic knowledge graph for prediction to obtain predicted travel time.

[0064] In this embodiment, a traffic knowledge graph is constructed, and the data layer in the traffic knowledge graph is stored in a Neo4j graph database. The traffic knowledge graph includes entities, relationships, and attributes, wherein entities include at least one of road conditions, road sections, intersections, and road grades, relationships include the connection between entities, and attributes include travel time and traffic events; real-time traffic data is obtained, and the real-time traffic data is input into the traffic knowledge graph for prediction to obtain predicted travel time. By considering temporary or periodic changes caused by traffic events and incorporating this information into the knowledge graph, the accuracy of travel time prediction is improved.

[0065] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0066] Figure 4 The principle block diagram of the travel time prediction device based on the knowledge graph is shown in one-to-one correspondence with the travel time prediction method based on the knowledge graph in the above embodiment. Figure 4 As shown, the travel time prediction device based on knowledge graph includes a knowledge graph construction module 31 and a real-time data acquisition module 32. Each functional module is described in detail as follows: The knowledge graph construction module 31 is used to construct a traffic knowledge graph. The data layer in the traffic knowledge graph is stored in a Neo4j graph database. The traffic knowledge graph includes entities, relationships and attributes. The entities include at least one of road conditions, road sections, intersections and road grades. The relationships include the connections between entities. The attributes include travel time and traffic events. The real-time data acquisition module 32 is used to acquire real-time traffic data and input the real-time traffic data into the traffic knowledge graph for prediction to obtain the predicted travel time.

[0067] Optionally, the knowledge graph construction module 31 includes: The first definition unit is used to define the static part of the knowledge graph as , where (h, r, t) means that there is a relationship r between the head entity h and the tail entity t, E represents the entity set, and R represents the relationship set; The second definition unit is used to define, for the dynamic part, , indicating road conditions, Indicates the attributes corresponding to the road conditions, where M and N represent the total number of road conditions and attributes respectively; The third definition unit is used to Represents any attribute of the traffic condition, has={hasTime,hasincident}, hasTime represents the event time, hasincident represents the event identifier; Graph representation unit, used to classify the road condition set into the entity set: , we get the traffic knowledge graph representation: ; in .

[0068] Optionally, the knowledge graph construction module 31 further includes: A vector construction unit, used to construct a first vector and a second vector, the first vector represents an entity or a relationship, and the second vector is a projection vector; An encoding unit, configured to construct a dynamic mapping matrix using the second vector, concatenating the first vector, and encoding the entity into a low-dimensional embedding vector in the relational space; The reasoning unit is used to use low-dimensional embedding vectors for knowledge storage and knowledge reasoning to obtain a traffic knowledge graph.

[0069] Optionally, the encoding unit includes: The initialization subunit is used to initialize each dynamic mapping matrix with the identity matrix, and the matrix multiplication operation is replaced by the vector operation, which is expressed as: ; The embedding subunit is used to project the entity vector into the relation space and embed it, which is expressed as: ; The encoding subunit is used to take the relation vector r in the triple (h, r, t) as the head entity vector With the tail entity vector The translation vector of the head entity and the relationship vector in the embedding space The sum of the embedding vectors of the tail entity is equal to the embedding vector of .

[0070] Optionally, the travel time prediction device based on the knowledge graph further includes: A data acquisition module is used to acquire historical data, including historical travel time data and historical traffic event data; The time period division module is used to divide the historical travel time data according to the preset time periods, taking each time period as a time point to obtain M time points; A matching module is used to match the historical traffic event data in the time dimension and determine the event matching information, the matching information includes the historical traffic event data, the time point when the historical traffic event data occurs and the time point when the historical traffic event data ends; The raw data determination module is used to use event matching information and historical data as raw data for constructing a traffic knowledge graph.

[0071] For the specific limitations of the travel time prediction device based on the knowledge graph, please refer to the limitations of the travel time prediction method based on the knowledge graph above, which will not be repeated here. Each module in the above-mentioned travel time prediction device based on the knowledge graph can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0072] To solve the above technical problems, the present application also provides a computer device. Figure 5 , Figure 5 This is a basic structural block diagram of the computer device in this embodiment.

[0073] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components connected to the memory 41, the processor 42, and the network interface 43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0074] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0075] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or D interface display memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. equipped on the computer device 4. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as the program code of the travel time prediction method based on the knowledge graph, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.

[0076] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run the program code stored in the memory 41 or process data, such as running the program code of the travel time prediction method based on the knowledge graph.

[0077] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0078] The present application also provides another embodiment, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores an interface display program, and the interface display program can be executed by at least one processor so that the at least one processor performs the steps of the travel time prediction method based on the knowledge graph as described above.

[0079] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0080] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to replace some of the technical features therein with equivalents. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.

Claims

1. A travel time prediction method based on knowledge graph, characterized in that: include: Constructing a traffic knowledge graph, wherein the data layer in the traffic knowledge graph is stored in a Neo4j graph database, and the traffic knowledge graph includes entities, relationships, and attributes, wherein the entities include at least one of road conditions, road sections, intersections, and road grades, the relationships include connections between entities, and the attributes include travel time and traffic events; Real-time traffic data is obtained, and the real-time traffic data is input into the traffic knowledge graph for prediction to obtain a predicted travel time.

2. The travel time prediction method based on knowledge graph according to claim 1, characterized in that: The construction of the traffic knowledge graph includes: Define the static part of the knowledge graph as , where (h, r, t) means that there is a relationship r between the head entity h and the tail entity t, E represents the entity set, and R represents the relationship set; For the dynamic part, define , indicating road conditions, Indicates the attributes corresponding to the road conditions, where M and N represent the total number of road conditions and attributes respectively; use Represents any attribute of the traffic condition, has={hasTime,hasincident}, hasTime represents the event time, hasincident represents the event identifier; Classify the traffic condition set into the entity set: , the traffic knowledge graph representation is obtained: , in .

3. The travel time prediction method based on knowledge graph according to claim 2, characterized in that: The construction of the traffic knowledge graph further includes: Constructing a first vector and a second vector, wherein the first vector represents an entity or a relationship, and the second vector is a projection vector; The second vector is used to construct a dynamic mapping matrix, which is combined with the first vector to encode the entity into a low-dimensional embedding vector in the relational space; The low-dimensional embedding vector is used for knowledge storage and knowledge reasoning to obtain the traffic knowledge graph.

4. The travel time prediction method based on knowledge graph according to claim 3, characterized in that: The step of using the second vector to construct a dynamic mapping matrix, combining the first vector, and encoding the entity into a low-dimensional embedding vector in the relational space comprises: Each of the dynamic mapping matrices is initialized with the identity matrix, and the matrix multiplication operation is replaced by vector operation, which is expressed as: ; The entity vector is projected into the relation space and embedded, expressed as: ; The triple The relation vector r in is used as the head entity vector With the tail entity vector The translation vector of the head entity and the relationship vector in the embedding space The sum of the embedding vectors of the tail entity is equal to the embedding vector of .

5. The travel time prediction method based on knowledge graph according to any one of claims 1 to 4, characterized in that: Before constructing the traffic knowledge graph, the travel time prediction method based on the knowledge graph further includes: Acquiring historical data, wherein the historical data includes historical travel time data and historical traffic event data; The historical travel time data is divided according to preset time periods, and each time period is taken as a time point to obtain M time points; Matching the historical traffic event data in a time dimension to determine event matching information; The matching information includes historical traffic event data, the time point when the historical traffic event data occurred and the time point when the historical traffic event data ended; The event matching information and the historical data are used as raw data for constructing a traffic knowledge graph.

6. A travel time prediction device based on knowledge graph, characterized in that: include: A knowledge graph construction module is used to construct a traffic knowledge graph. The data layer in the traffic knowledge graph is stored in a Neo4j graph database. The traffic knowledge graph includes entities, relationships and attributes. The entities include at least one of road conditions, road sections, intersections and road grades. The relationships include connections between entities. The attributes include travel time and traffic events. The real-time data acquisition module is used to acquire real-time traffic data and input the real-time traffic data into the traffic knowledge graph for prediction to obtain the predicted travel time.

7. The travel time prediction device based on knowledge graph according to claim 6, characterized in that: The knowledge graph construction module also includes: A vector construction unit, used to construct a first vector and a second vector, wherein the first vector represents an entity or a relationship, and the second vector is a projection vector; An encoding unit, configured to construct a dynamic mapping matrix using the second vector, and combine the first vector to encode the entity into a low-dimensional embedding vector in the relational space; The reasoning unit is used to use the low-dimensional embedding vector to perform knowledge storage and knowledge reasoning to obtain the traffic knowledge graph.

8. The travel time prediction device based on knowledge graph according to claim 7, characterized in that: The travel time prediction device based on the knowledge graph also includes: A data acquisition module, used to acquire historical data, wherein the historical data includes historical travel time data and historical traffic event data; A time period division module is used to divide the historical travel time data according to preset time periods, taking each time period as a time point, and obtaining M time points; A matching module, used to match the historical traffic event data in a time dimension to determine event matching information, wherein the matching information includes the historical traffic event data, the time point at which the historical traffic event data occurs, and the time point at which the historical traffic event data ends; The original data determination module is used to use the event matching information and the historical data as the original data for constructing a traffic knowledge graph.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the travel time prediction method based on the knowledge graph as described in any one of claims 1 to 5 is implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the travel time prediction method based on the knowledge graph as described in any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Urban traffic knowledge graph construction method, construction device and application

    CN114969263A

  • Travel recommendation method based on knowledge graph and traffic speed prediction

    CN118262513A

  • Traffic decision-making method and device based on time sequence knowledge graph

    CN118736822A

  • Navigation system

    JP2006090887A