Knowledge Graph-Based Travel Time Prediction Method and Device

By constructing a traffic knowledge graph based on knowledge graph, using the Neo4j graph database and dynamic mapping matrix, the accuracy of the itinerary time prediction of urban road network is solved, and more efficient itinerary time prediction is achieved, suitable for complex and changeable urban traffic environments.

CN119622273BActive Publication Date: 2025-06-27湖南工商大学
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510147594.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-11
Publication Date
2025-06-27
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

The traffic knowledge graph is used to construct a traffic knowledge graph, and the entities, relationships and attributes are stored through the Neo4j graph database, real-time traffic data is obtained and input into the knowledge graph for prediction. Dynamic mapping matrix and low-dimensional embedding vector are used for knowledge storage and reasoning to improve the accuracy of travel time prediction.

Benefits of technology

By taking into account temporary or periodic changes caused by traffic events and integrating them into the knowledge graph, 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 CN119622273B_ABST
    Figure CN119622273B_ABST
Patent Text Reader

Abstract

The present invention discloses a travel time prediction method and device based on a knowledge graph, including: constructing a traffic knowledge graph, where the data layer in the traffic knowledge graph is stored using a Neo4j graph database. The traffic knowledge graph includes entities, relationships, and attributes. Among them, the entities include at least one of road conditions, road sections, intersections, and road grades. The relationships include the connections between the various entities, and the attributes include travel time and traffic events; obtaining real-time traffic data and inputting the real-time traffic data into the traffic knowledge graph for prediction to obtain the predicted travel time. The present invention takes into account the temporary or periodic changes caused by traffic events and incorporates this information into the knowledge graph, thereby improving the accuracy of travel time prediction.
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 particularly to a travel time prediction method and device based on a knowledge graph. Background Art

[0002] During 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 path navigation, road congestion control, optimal scheduling, and traffic accident detection. Urban road network travel time prediction is a crucial task in the intelligent transportation system, which is directly related to the efficiency of daily travel planning, logistics transportation management, traffic congestion mitigation, and emergency rescue. In a complex and changeable 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, making it difficult to predict urban road network travel time.

[0003] Existing methods use statistical models for travel time prediction, such as linear regression models, ARIMA models and variants, and methods based on Kalman filters. However, the inventor found in the process of implementing the present invention that the data designed by existing statistical models tend to be linear data, and it is difficult to represent 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 to be solved urgently at present. Summary of the Invention

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

[0006] To solve the above technical problems, an embodiment of the present application provides a travel time prediction method based on a knowledge graph, including:

[0007] Construct a traffic knowledge graph, where the data layer in the traffic knowledge graph is stored using a Neo4j graph database. The traffic knowledge graph includes entities, relationships, and attributes. Among them, the entities include at least one of road conditions, road segments, intersections, and road grades. The relationships include the connections between the entities, and the attributes include travel time and traffic events;

[0008] Obtain real-time traffic data, and input the real-time traffic data into the traffic knowledge graph for prediction to obtain the predicted travel time.

[0009] Optionally, the construction of the traffic knowledge graph includes:

[0010] Define the static part of the knowledge graph as , where (h, r, t) indicates 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;

[0011] For the dynamic part, define , representing the road condition, represents the attributes corresponding to the road condition, where M and N respectively represent the total numbers of road conditions and attributes;

[0012] Use to represent any one of the attributes owned by the road condition, hasTime represents the event time, hasincident represents the event identifier has = {hasTime, hasincident};

[0013] Classify the road condition set into the entity set: , obtaining the representation of the traffic knowledge graph:

[0014] ,

[0015] where .

[0016] Optionally, the construction of the traffic knowledge graph further includes:

[0017] Construct a first vector and a second vector, where the first vector represents an entity or a relationship, and the second vector is a projection vector;

[0018] Use the second vector to construct a dynamic mapping matrix, combine it with the first vector, and encode the entity into a low-dimensional embedding vector in the relationship space;

[0019] Use the low-dimensional embedding vector for knowledge storage and knowledge reasoning to obtain the traffic knowledge graph.

[0020] Optionally, using the second vector to construct a dynamic mapping matrix, combining it with the first vector, and encoding the entity into a low-dimensional embedding vector in the relationship space includes:

[0021] Each of the dynamic mapping matrices is initialized with an identity matrix, and vector operations are used instead of matrix multiplication operations, expressed as:

[0022] ;

[0023] Project the entity vector into the relationship space and embed it, expressed as:

[0024] ;

[0025] For the triple The relational vector r in it serves as the head entity vector and the tail entity vector translation vector, and the embedding vector of the head entity and the embedding vector of the relational vector in the embedding space sum up to the embedding vector of the tail entity .

[0026] Optionally, before constructing the traffic knowledge graph, the travel time prediction method based on the knowledge graph further includes:

[0027] Obtaining historical data, where the historical data includes historical travel time data and historical traffic event data;

[0028] Dividing the historical travel time data according to a preset time period, taking each time period as a time point, and obtaining M time points;

[0029] Matching the historical traffic event data in the time dimension to determine event matching information;

[0030] The matching information includes historical traffic event data, the time point when the historical traffic event data occurs, and the end time point;

[0031] Taking the event matching information and the historical data as the original data for constructing the traffic knowledge graph.

[0032] To solve the above technical problems, an embodiment of the present application further provides a travel time prediction device based on a knowledge graph, including:

[0033] A knowledge graph construction module for constructing a traffic knowledge graph, where the data layer in the traffic knowledge graph is stored using a Neo4j graph database. The traffic knowledge graph includes entities, relationships, and attributes. Among them, the entities include at least one of road conditions, road sections, intersections, and road grades. The relationships include the connections between various entities, and the attributes include travel time and traffic events;

[0034] A real-time data acquisition module for acquiring real-time traffic data and inputting the real-time traffic data into the traffic knowledge graph for prediction to obtain a predicted travel time.

[0035] Optionally, the knowledge graph construction module includes:

[0036] A first definition unit for defining the static part of the knowledge graph as , where (h, r, t) in it indicates 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;

[0037] A second definition unit for defining, for the dynamic part, , representing the road condition, representing the attributes corresponding to the road condition, where M and N respectively represent the total numbers of road conditions and attributes;

[0038] A third definition unit for using to represent any one of the attributes of the road condition, has = {hasTime, hasincident}, hasTime represents the event time, and hasincident represents the event identifier;

[0039] A graph spectrum representation unit for classifying the road condition set into the entity set: , to obtain the representation of the traffic knowledge graph:

[0040] ,

[0041] where .

[0042] Optionally, the knowledge graph construction module further includes:

[0043] A vector construction unit for constructing a first vector and a second vector, where the first vector represents an entity or a relationship, and the second vector is a projection vector;

[0044] An encoding unit for constructing a dynamic mapping matrix using the second vector, and combining the first vector to encode the entity into a low-dimensional embedding vector in the relationship space;

[0045] An inference unit for performing knowledge storage and knowledge inference using the low-dimensional embedding vector to obtain the traffic knowledge graph.

[0046] Optionally, the encoding unit includes:

[0047] An initialization subunit for initializing each of the dynamic mapping matrices with an identity matrix and replacing matrix multiplication operations with vector operations, expressed as:

[0048] ;

[0049] An embedding subunit for projecting and embedding the entity vector into the relationship space, expressed as:

[0050] ;

[0051] An encoding subunit for using the relationship vector r in the triple as the translation vector between the head entity vector and the tail entity vector , and the embedding vector of the head entity and the relationship vector in the embedding space The sum of the embedding vectors is equal to the embedding vector of the tail entity 。

[0052] Optionally, the travel time prediction device based on the knowledge graph further includes:

[0053] A data acquisition module for acquiring historical data, where the historical data includes historical travel time data and historical traffic event data;

[0054] A time period division module for dividing the historical travel time data according to a preset time period, taking each time period as a time point, and obtaining M time points;

[0055] A matching module for matching the historical traffic event data in the time dimension to determine event matching information, where the matching information includes historical traffic event data, the time point when the historical traffic event data occurs, and the end time point;

[0056] An original data determination module for using the event matching information and the historical data as the original data for constructing the traffic knowledge graph.

[0057] To solve the above technical problems, an embodiment of the present application further provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above travel time prediction method based on the knowledge graph are implemented.

[0058] To solve the above technical problems, an embodiment of the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above travel time prediction method based on the knowledge graph are implemented.

[0059] The travel time prediction method, device, computer device, and storage medium provided by the embodiments of the present invention construct a traffic knowledge graph. The data layer in the traffic knowledge graph is stored using a Neo4j graph database. The traffic knowledge graph includes entities, relationships, and attributes. Among them, the entities include at least one of road conditions, road sections, intersections, and road grades. The relationships include the connections between the entities, and the attributes include travel time and traffic events; real-time traffic data is acquired and 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. Description of the Drawings

[0060] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments of the present invention. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0061] Figure 1 is an exemplary system architecture diagram to which the present application can be applied;

[0062] Figure 2 is a flowchart of an embodiment of the travel time prediction method based on a knowledge graph of the present application;

[0063] Figure 3 is a schematic diagram of the schema layer of the traffic knowledge graph of the present application;

[0064] Figure 4 is a schematic structural diagram of an embodiment of the travel time prediction device based on a knowledge graph according to the present application;

[0065] Figure 5 is a schematic structural diagram of an embodiment of the computer device according to the present application. Detailed Embodiments

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

[0067] Referring to "embodiment" herein means that a specific feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of this application. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those of ordinary skill in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.

[0068] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0069] Please refer to Figure 1 , as Figure 1 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 fiber optic cables, etc.

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

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

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

[0073] It should be noted that the travel time prediction method based on the knowledge graph provided in the embodiments of the present application is executed by the server. Correspondingly, the travel time prediction device based on the knowledge graph is set in the server.

[0074] It should be understood that Figure 1 the numbers of the terminal devices, the network, and the server in

[0075] are merely illustrative. According to the implementation requirements, there may be any number of terminal devices, networks, and servers. The terminal devices 101, 102, 103 in the embodiments of the present application may specifically correspond to the application systems in actual production.

[0075] Please refer to Figure 2 , Figure 2 which shows a travel time prediction method based on the knowledge graph provided by the embodiments of the present invention. Taking the application of this method in the Figure 1 server as an example for illustration, the details are as follows:

[0076] S201: Construct a traffic knowledge graph. The data layer in the traffic knowledge graph is stored using the Neo4j graph database. The traffic knowledge graph includes entities, relationships, and attributes. Among them, the entities include at least one of road conditions, road segments, intersections, and road grades. The relationships include the connections between various entities, and the attributes include travel time and traffic events.

[0077] The prediction of future travel time is related to temporal features and traffic event features. In a specific example, therefore, traffic data is aggregated every 5 minutes to define time attributes. Set time label vectors S1=(0, 1, …, 287), S2=(0, 1, …, 6), and S3=(0, 1) to represent the time of day, day of the week, and whether it is a working day (0: non - working day), respectively.

[0078] To capture the mutation phenomenon in actual traffic and improve the prediction accuracy, a knowledge graph is constructed to extract traffic event data features. The prediction problem in this embodiment is defined as follows: For the current moment , using the historical observations of the previous time steps, the time attribute vector, and the traffic event feature vector to predict the future time steps of the travel time of the road segment . Among them, is the actual value at time t, and is the predicted value at the next time step t + 1. To verify the single - step and multi - step prediction capabilities of the prediction model, the travel times of the road segments for the next 5, 15, 30 minutes (i.e., = 1, 3, 6) are predicted respectively.

[0079] In a specific alternative implementation, before step S201, that is, before constructing the traffic knowledge graph, the travel time prediction method based on the knowledge graph further includes:

[0080] Obtain historical data, where the historical data includes historical travel time data and historical traffic event data;

[0081] For the historical travel time data, divide it according to a preset time period, and take each time period as a time point to obtain M time points;

[0082] Match the historical traffic event data in the time dimension to determine the event matching information;

[0083] The matching information includes the historical traffic event data, the time point when the historical traffic event data occurred, and the end time point;

[0084] Take the event matching information and the historical data as the original data for constructing the traffic knowledge graph.

[0085] Specifically, the basic road network data, section travel time data, and traffic event data are obtained from the Amap API through web crawler technology. The web crawler automatically grabs and downloads target information from the website using a uniform resource locator (URL), which improves efficiency and saves time. The specific descriptions of the basic road network and section data sets are shown in Table 1:

[0086] Table 1 Description of Basic Road Network and Section Data

[0087]

[0088] The specific description of the traffic event data set is shown in Table 2. According to the event occurrence characteristics, 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.

[0089] Table 2 Description of Traffic Event Data

[0090]

[0091] Preprocess the historical travel time data and traffic event data, extract the target data, and eliminate invalid and error data to improve the data quality. For the travel time data, divide the 24 hours of a day into 288 time points at intervals of 5 minutes, i.e., {00:00; 00:05; …; 23:50; 23:55}. Calculate the average travel time for each time period as the travel time required for that period.

[0092] 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 relatively complex, and it is impossible to achieve an absolute match with the time granularity in the above data set. In this embodiment, the following three matching strategies are adopted for the obtained traffic event data:

[0093] 1) If the start time and end time of the traffic event exactly match the divided time points, the time is matched to the corresponding moment.

[0094] 2) If the start time of the traffic event cannot match the time point, select the previous time point corresponding to the start time. 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 considered due to the time delay generated during the traffic event detection and upload process.

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

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

[0097] In this embodiment, first, traffic event data is obtained; second, data obtained from different sources is subjected to knowledge extraction to obtain entities, relationships, and attributes in the knowledge graph; then, according to the existing data and professional knowledge in the traffic field, the schema layer of the knowledge graph is designed and completed, that is, an ontology in the traffic field 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.

[0098] Furthermore, this embodiment constructs a knowledge graph in the urban traffic field by a top-down method. This study considers road segments, intersections, and road grades, and adds static data such as monitoring points and vehicle information as entities, and dynamic data such as travel time and traffic events in road conditions as attributes, and enriches the relationships between various entities and attributes. Define the static part of the knowledge graph as , where (h, r, t) indicates 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 , representing road conditions, representing the attributes corresponding to road conditions, where M and N respectively represent the total numbers of road conditions and attributes. Use to represent any attribute of road conditions, has = {hasTime, hasincident}, hasTime represents the event time, and hasincident represents the event identifier. We classify the road condition set into the entity set: , then the overall traffic knowledge graph can be represented by . Among them . Finally, establish the schema layer of the traffic knowledge graph, as shown in Figure 3 . The solid line part represents entities, and the dashed line part represents attributes.

[0099] Furthermore, the graph database Neo4j supports massive data storage. 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.

[0100] In a specific optional implementation, constructing a traffic knowledge graph includes:

[0101] Define the static part of the knowledge graph as , where (h, r, t) indicates that the head entity h and the tail entity t have a relationship r, E represents the entity set, and R represents the relationship set;

[0102] For the dynamic part, define , representing the road condition, representing the attributes corresponding to the road condition, where M and N respectively represent the total numbers of road conditions and attributes;

[0103] Use to represent any one of the attributes of the road condition, has = {hasTime, hasincident}, hasTime represents the event time, and hasincident represents the event identifier;

[0104] Classify the road condition set into the entity set: , obtaining the traffic knowledge graph representation:

[0105] ,

[0106] where .

[0107] In a specific optional implementation, constructing a traffic knowledge graph further includes:

[0108] Construct a first vector and a second vector, where the first vector represents an entity or a relationship, and the second vector is a projection vector;

[0109] Use the second vector to construct a dynamic mapping matrix, and combine it with the first vector to encode the entity into a low-dimensional embedding vector in the relationship space;

[0110] Use the low-dimensional embedding vector for knowledge storage and knowledge reasoning to obtain the traffic knowledge graph.

[0111] In a specific optional implementation, using the second vector to construct a dynamic mapping matrix and combining it with the first vector to encode the entity into a low-dimensional embedding vector in the relationship space includes:

[0112] Each dynamic mapping matrix is initialized with an identity matrix, and vector operations are used instead of matrix multiplication operations, which is expressed as:

[0113] ;

[0114] Project the entity vector into the relational space and embed it, which is expressed as:

[0115] ;

[0116] Take the relational vector r in the triple (h, r, t) as the translation vector between the head entity vector and the tail entity vector . The embedding vector of the head entity plus the embedding vector of the relational vector in the embedding space is equal to the embedding vector of the tail entity .

[0117] Preferably, this embodiment uses the TransD model to process time attribute and traffic event data. Its main idea is to use the dynamic mapping matrix constructed by the projection vector to encode the entity into a low-dimensional embedding vector in the relational space. At the same time, 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.

[0118] The TransD model uses two vectors to represent each entity and relation. The first vector represents the actual meaning of the entity or relation, and the second vector, called the projection vector, is used to construct the mapping matrix. The mapping matrix is jointly determined by the projection vector of the entity and the relation. Entities can be mapped from the entity space to the vector space. Each mapping matrix is initialized with an identity matrix, and vector operations are used instead of matrix multiplication operations, effectively reducing the computational complexity.

[0119] ;

[0120] Project the entity vector into the relational space and embed it as:

[0121] ;

[0122] TransD takes the relational vector r in the triple (h, r, t) as the translation vector between the head entity vector and the tail entity vector . That is to say, the embedding vector of the head entity plus the embedding vector of the relational vector in the embedding space is equal to the embedding vector of the tail entity . Therefore, a scoring function based on the L2 Euclidean distance can be defined to measure the distance between these two vectors:

[0123] ;

[0124] The model adds an L2 norm constraint to the vector, which can make the relevant parameters of the model smaller, avoid overfitting of the model, and improve the generalization ability of the model. We implemented the following constraints:

[0125] ;

[0126] For correct triples, the higher the expected score, the better; at the same time, for incorrect triples, the smaller the score, the better. Therefore, a margin-based ranking loss function is defined, as shown in Equation (7), and minimizing the loss function value is used as the training objective of the model.

[0127] ;

[0128] where is a hyperparameter, representing the maximum margin between correct triples and negative triples, [x]+ = max(0, x), represents the set of correct triples, represents the set of constructed negative triples.

[0129] Since there are only correct triples in the knowledge graph, incorrect triples need to be constructed as negative samples. The method used by the TransE model is to randomly select an entity from all the entity sets of correct triples and replace the head or tail entity of the original triple to obtain a new incorrect 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 of constructing negative samples introduces many false negative example samples, that is, false negatives.

[0130] Considering different types of relationships, when replacing the head or tail entity in a triple, the probability that a smaller entity is replaced by a larger entity. For example, when the relationship is one-to-many, that is, one head entity corresponds to multiple tail entities, the probability that the head entity is replaced is greater. When the relationship is many-to-one, that is, multiple head entities correspond to one tail entity, the probability that the tail entity is replaced is greater. For all relationship triples, the following numbers will be calculated:

[0131] The average number of tail entities associated with each head entity is recorded as ;

[0132] The average number of head entities associated with each tail entity is recorded as .

[0133] ;

[0134] Random variable Takes only two values, 0 and 1, with corresponding probabilities as follows:

[0135] ;

[0136] ;

[0137] Finally, the construction of negative samples follows a Bernoulli distribution with parameter and the distribution law of the random variable is as follows:

[0138] ;

[0139] For a correct triple of a given relationship, the probability of generating a negative triple by replacing the head entity is , and the probability of generating a negative triple by replacing the tail entity is .

[0140] In addition, the constraint type of a relationship is represented by defining the types of entities that should be associated with it. Using the prior knowledge of the relationship type, the relationship determines which entities to replace. For example, the definition of a relationship type like marriage is only associated with individuals. Define the following variables:

[0141] Relationship type The ordered indices of all entities in the domain constraint;

[0142] In the relationship type The ordered indices of all entities within the range constraint.

[0143] For a triple of a given relationship , when constructing negative triples, the probability of replacing the head or tail entity is calculated according to the Bernoulli distribution. If replacing the head entity, it is selected from the subset of entities in the domain of the relationship type, and if replacing the tail entity, it is selected from the subset of entities within the range of the relationship type, as shown in Equation (12).

[0144] ;

[0145] Using the prior knowledge of the relationship type improves the probability of extracting the correct entity type to replace the original triple when constructing negative samples.

[0146] Furthermore, the model in this embodiment uses the mini - batch gradient descent (MBGD) method to update the parameters to obtain the minimum value of the loss function. During training, a small batch of positive samples is randomly selected and the corresponding negative samples are constructed. After batch processing, the gradients are calculated and the model parameters are updated. The model continuously updates the parameters through iteration until the loss value converges or the maximum number of iterations is reached. After training is completed, the embedding representations of entities and relationships are obtained.

[0147] GRU is a variant of the Recurrent Neural Network (RNN). Similar to the LSTM (Long Short-Term Memory) network, it aims to address the problems of vanishing gradients or exploding gradients encountered by traditional RNNs when dealing with long-term dependencies. The GRU structure consists of gating mechanisms that can control the flow of information, enabling the model to better capture long-term dependencies in time series data. The main difference between GRU and LSTM is that it combines the hidden state and the memory cell into a single hidden state, and it has only two gate structures: the Reset Gate and the Update Gate. The Reset Gate determines how to combine the new input 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.

[0148] In this embodiment, the dynamic changes in travel time have obvious non-linear and non-stationary characteristics. By reducing the attention to other information and filtering out irrelevant information, the problem of information overload is solved, and the efficiency and accuracy of task prediction are improved. Therefore, in this embodiment, an attention mechanism is introduced based on the existing GRU model, that is, the Attention-enhanced Gated Recurrent Unit (A-GRU) is adopted, thereby improving the ability of the GRU model to capture effective features of historical data. In order to deeply reveal the influence degree of different time nodes on travel time prediction, the attention mechanism enhancement method is adopted. The deep learning model based on the attention mechanism can extract important features at different time points in the prediction process by calculating the influence degree of each time node on the prediction target.

[0149] In the A-GRU model of this embodiment, these attention coefficients will be used as weighting factors during the prediction process, giving higher weights to the time nodes that have a greater impact on the prediction result. The input is the historical observation values of the previous time steps after preprocessing, which are represented as . These inputs will enter the GRU model. After being calculated by the GRU model, the corresponding outputs , , …, will be obtained. Then, Attention is introduced in the hidden layer to calculate the attention probability distribution values of each input , , …, . Further, the time attribute features are extracted to predict the link travel time of the future time steps . Among them, the calculation formula of the Attention mechanism is as follows:

[0150] ;

[0151] ;

[0152] ;

[0153] wherein, represents the attention probability distribution value determined by the hidden layer state vector at the moment, and represents the weight coefficient matrix at the moment, and represents the corresponding offset at the moment. Through the above formula, the final feature vector including time attributes can be calculated . The input of the output layer is the output of the previous Attention layer. Finally, the function is used to perform corresponding calculations on the input of the output layer, so as to predict the travel time. The calculation formula is as follows:

[0154] ;

[0155] wherein: 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.

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

[0157] In this embodiment, a traffic knowledge graph is constructed. The data layer in the traffic knowledge graph is stored using the Neo4j graph database. The traffic knowledge graph includes entities, relationships, and attributes. Among them, the entities include at least one of road conditions, road segments, intersections, and road grades. The relationships include the connections between the entities, and the attributes include travel time and traffic events; obtain real-time traffic data, and input the real-time traffic data 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.

[0158] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.

[0159] Figure 4The principle block diagram of a travel time prediction device based on a knowledge graph corresponding to the above-mentioned travel time prediction method based on a knowledge graph is shown. As Figure 4 shown, the travel time prediction device based on a knowledge graph includes a knowledge graph construction module 31 and a real-time data acquisition module 32. The detailed description of each functional module is as follows:

[0160] The knowledge graph construction module 31 is used to construct a traffic knowledge graph. The data layer in the traffic knowledge graph is stored using a Neo4j graph database. The traffic knowledge graph includes entities, relationships, and attributes. Among them, the entities include at least one of road conditions, road segments, intersections, and road grades. The relationships include the connections between the entities, and the attributes include travel time and traffic events;

[0161] 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.

[0162] Optionally, the knowledge graph construction module 31 includes:

[0163] The first definition unit is used to define the static part of the knowledge graph as , where (h, r, t) indicates 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;

[0164] The second definition unit is used to define, for the dynamic part, , representing road conditions, representing the attributes corresponding to the road conditions, where M and N respectively represent the total numbers of road conditions and attributes;

[0165] The third definition unit is used to use to represent any one of the attributes of the road conditions. has = {hasTime, hasincident}, hasTime represents the event time, and hasincident represents the event identifier;

[0166] The graph representation unit is used to classify the road condition set into the entity set: , to obtain the traffic knowledge graph representation:

[0167] ;

[0168] where .

[0169] Optionally, the knowledge graph construction module 31 further includes:

[0170] The vector construction unit is 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;

[0171] An encoding unit, which is used to construct a dynamic mapping matrix by using a second vector, combine with a first vector, and encode an entity into a low-dimensional embedding vector in a relational space;

[0172] An inference unit, which is used to perform knowledge storage and knowledge inference by using the low-dimensional embedding vector to obtain a traffic knowledge graph.

[0173] Optionally, the encoding unit includes:

[0174] An initialization subunit, which is used to initialize each dynamic mapping matrix with an identity matrix, replace matrix multiplication operations with vector operations, and is expressed as:

[0175] ;

[0176] An embedding subunit, which is used to project an entity vector into a relational space and embed it, and is expressed as:

[0177] ;

[0178] An encoding subunit, which is used to use the relational vector r in the triple (h, r, t) as the translation vector of the head entity vector and the tail entity vector , and the sum of the embedding vector of the head entity and the embedding vector of the relational vector in the embedding space is equal to the embedding vector of the tail entity .

[0179] Optionally, the travel time prediction device based on the knowledge graph further includes:

[0180] A data acquisition module, which is used to acquire historical data, and the historical data includes historical travel time data and historical traffic event data;

[0181] A time period division module, which is used to divide the historical travel time data according to a preset time period, take each time period as a time point, and obtain M time points;

[0182] A matching module, which is used to match the historical traffic event data in the time dimension to determine event matching information, and the matching information includes the historical traffic event data, the time point when the historical traffic event data occurs, and the end time point;

[0183] An original data determination module, which is used to use the event matching information and historical data as the original data for constructing the traffic knowledge graph.

[0184] For the specific limitations of the travel time prediction device based on the knowledge graph, reference can be made to the limitations of the travel time prediction method based on the knowledge graph in the above text, which will not be elaborated here. Each module in the above travel time prediction device based on the knowledge graph can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.

[0185] To solve the above technical problems, the embodiments of the present application also provide a computer device. For details, please refer to Figure 5 , Figure 5 which is the basic structural block diagram of the computer device in this embodiment.

[0186] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are communicatively connected to each other through a system bus. It should be noted that only the computer device 4 with components connected to the memory 41, the processor 42, and the network interface 43 is shown in the figure. However, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Among them, those skilled in the art of the present technology 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 (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0187] The computer device can be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The computer device can interact with the user through a keyboard, a mouse, a remote control, a touchpad, or a voice control device.

[0188] The memory 41 includes at least one type of readable storage medium, which includes flash memory, hard disk, multimedia card, card-type memory (such as 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, magnetic disk, optical disc, etc. In some embodiments, the memory 41 may be an internal storage unit of the computer device 4, such as the hard disk or memory of the computer device 4. In other embodiments, the memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc., equipped on the computer device 4. Of course, the memory 41 may also include both the internal storage unit and the external storage device of the computer device 4. 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. In addition, the memory 41 may also be used to temporarily store various data that have been output or will be output.

[0189] In some embodiments, the processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. 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.

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

[0191] The present application also provides another implementation manner, that is, to provide a computer-readable storage medium storing an interface display program, and the interface display program can be executed by at least one processor to enable the at least one processor to execute the steps of the travel time prediction method based on the knowledge graph as described above.

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

[0193] Obviously, the above-described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The drawings show preferred embodiments of the present application, but 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 disclosed content of the present application more thorough and comprehensive. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments or equivalently replace some of the technical features. Any equivalent structure directly or indirectly using the content of the specification and drawings of the present application in other related technical fields is similarly within the scope of the patent protection of the present 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 the connections between entities, and the attributes include travel time and traffic events, and an attention-enhanced gated recurrent unit is used to extract important features of different time points in the prediction process by calculating the degree of influence of each time node on the travel time prediction; Acquire real-time traffic data, and input the real-time traffic data into the traffic knowledge graph for prediction to obtain predicted travel time; Wherein, 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: , the traffic knowledge graph representation is obtained: , in ; Wherein, 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.

2. The travel time prediction method based on knowledge graph according to claim 1, 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 The relationship between the embedding vector and the embedding space The sum of the embedding vectors is approximately equal to the tail entity The embedding vector of .

3. The travel time prediction method based on knowledge graph according to claim 1 or 2, 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.

4. A travel time prediction device based on knowledge graph, characterized in that: The travel time prediction method based on knowledge graph according to any one of claims 1 to 3 is adopted, wherein the device comprises: 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 and attributes. The entity includes at least one of road conditions, road sections, intersections, and road grades. The attributes include travel time and traffic events. An attention-enhanced gated recurrent unit is used to extract important features of different time points in the prediction process by calculating the influence of each time node on the travel time prediction. 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.

5. The travel time prediction device based on knowledge graph according to claim 4, 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.

6. The travel time prediction device based on knowledge graph according to claim 5, 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.

7. 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 3 is implemented.

8. 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 3 is implemented.

Citation Information

Patent Citations

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

    CN114969263A

  • Navigation system

    JP2006090887A