A trajectory data encoding and querying method and system, a terminal device, and a medium

By optimizing the splitting dimension of the index tree through semantic encoding and reinforcement learning algorithms, the efficiency and semantic encoding deficiencies of existing index structures in high-dimensional trajectory data querying are resolved, thus achieving efficient and accurate trajectory data querying.

CN121301495BActive Publication Date: 2026-03-27HUNAN NORMAL UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-10
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing index structures are inefficient when processing high-dimensional trajectory data, have poor multidimensional query performance, lack effective encoding of semantic information, have low load sensitivity, and cannot adapt to query hot areas or time periods.

Method used

Semantic coding rules are used to encode trajectory points, an index tree based on reinforcement learning algorithm is constructed, and a semantic pruning mechanism is introduced to dynamically select the split dimension of the index tree, optimize the index depth, and improve query efficiency.

Benefits of technology

It improves the efficiency of querying spatiotemporal semantic information of trajectory data, enhances the accuracy and speed of queries, reduces storage overhead, and adapts to dynamic changes in query load.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121301495B_ABST
    Figure CN121301495B_ABST
Patent Text Reader

Abstract

The application provides a trajectory data encoding and query method, system, terminal device and medium, comprising: obtaining trajectory data; performing semantic encoding on each trajectory point by using a semantic encoding rule to obtain semantic trajectory data; constructing an index tree based on a reinforcement learning algorithm according to the semantic trajectory data, and introducing a semantic pruning mechanism to optimize the index depth of the index tree to obtain an optimized index tree; receiving or responding to a query request, performing a space-time query on the optimized index tree, and returning a trajectory query result matched with the query request. The application can improve the space-time semantic information query efficiency of trajectories.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of intelligent transportation, and particularly relates to a trajectory data coding and querying method and system, a terminal device and a medium. BACKGROUND

[0002] With the popularity of global positioning system (GPS) and smart mobile devices, massive spatio-temporal trajectory data is continuously generated, and the great value behind it makes efficient trajectory data management and querying technology a research hotspot. Early trajectory indexing technology mainly focuses on solving the query efficiency problem in the spatio-temporal dimension, but to truly understand user intent and behavior patterns behind the trajectory, semantic information must be introduced. Thus, semantic trajectory query emerges as the times require, aiming to more deeply mine data value. In the field of semantic trajectory query, some researches are dedicated to processing complex user requirements that integrate space, time and semantics. For example, the STKST-I method proposed by researchers in the related field aims to efficiently retrieve trajectories that are close to the user's location and most relevant in semantics and time. The method proposes a similarity measurement model integrating the three dimensions of space, time and semantics, and constructs a novel multi-dimensional hybrid index structure (STS-I). The innovation lies in the use of a hierarchical semantic tree (LM-Tree) to measure the deep semantic relationship between keywords and geographic entities, surpassing traditional string matching, so as to more accurately capture user intent. Some other researches by researchers in the related field propose a time-space index data structure model named DSTree, which is specifically used for geographic information query in distributed networks. The model adopts a two-layer tree structure design: the top layer uses an interval tree to handle time queries, and the bottom layer uses a quadtree to handle space queries. The model provides a new solution for managing and querying large-scale spatio-temporal data in distributed networks, and is particularly suitable for sensor data, crime data and other log-based time series data processing. At the same time, when the scale of trajectory data reaches billions or even higher, the efficiency of the underlying index structure becomes a core bottleneck. To this end, the BT-Tree index structure proposed by some other researchers in the related field provides a new solution for range query and K-NN query processing of large-scale historical trajectory data. It breaks the rigid partitioning strategy of traditional indexes that adopts "space-first" or "time-first", and can dynamically select any dimension (space or time) and any position for recursive partitioning of data space according to the characteristics of data and historical query load. To achieve optimal partitioning, the method either adopts a carefully designed cost function for greedy decision (CFBM), or trains an agent model that can make globally optimal decisions through reinforcement learning.

[0003] The main defects of the current method are:

[0004] 1. Low efficiency of multi-dimensional query: Traditional index structures (such as R-tree, quad-tree) face severe challenges in processing high-dimensional trajectory data containing spatial, temporal and semantic information. Many existing indexes adopt a rigid "space-first" strategy, i.e., the top layer is a spatial index and the bottom layer is a temporal index. This structure will significantly deteriorate the performance when processing queries with strong time selectivity, because the top layer spatial index cannot effectively prune data, resulting in a large number of irrelevant data partitions being accessed.

[0005] 2. Lack of semantics: The behavior semantics of trajectory points are not effectively encoded into the index structure, resulting in full-scan data for semantic filtering.

[0006] 3. Low load sensitivity: Static or rigid index structures are usually constructed only according to the distribution of data itself, ignoring the skewness of query load in actual applications, i.e., query requests are often unevenly distributed in geographical space and time, with obvious hot regions or time periods. SUMMARY

[0007] The technical problem to be solved by the present application is to provide a trajectory data encoding and query method, system, terminal device and medium to improve the efficiency of spatio-temporal semantic information query of trajectories.

[0008] In a first aspect, the present application provides a trajectory data encoding and query method, which comprises the following steps:

[0009] Obtaining trajectory data; the trajectory data includes multiple trajectories, and each trajectory includes at least two trajectory points;

[0010] Encoding each trajectory point using a semantic encoding rule to obtain semantic trajectory data; wherein each trajectory point is encoded into a string, and the string includes a key point type field for indicating whether the trajectory point changes the topological relationship of a geographical element, a geographical element type field for indicating the type of the geographical element where the trajectory point is located, a position type field for indicating the position of the trajectory point in the geographical element, a geographical element identifier field, a trajectory point identifier field, a trajectory identifier field, and a topological semantic encoding field; the topological semantic encoding field is used to describe the behavior pattern of the moving object, including a first field for describing the predecessor state of the trajectory point, a second field for describing the position of the key point, and a third field for describing the successor state of the trajectory point;

[0011] According to the semantic trajectory data, an index tree based on a reinforcement learning algorithm is constructed, and a semantic pruning mechanism is introduced to optimize the index depth of the index tree, to obtain an optimized index tree; wherein the reinforcement learning algorithm is designed to dynamically select the split dimension of each tree node in the index tree according to the data distribution and the query load; the semantic pruning mechanism is designed to control the splitting degree of the nodes in the index tree according to the trajectory semantic similarity between each trajectory point in each tree node and a preset threshold; the trajectory semantic similarity is obtained by string calculation;

[0012] Receiving or responding to a query request, performing a spatio-temporal query on the optimized index tree, and returning a trajectory query result matching the query request.

[0013] Optionally, according to the semantic trajectory data, an index tree based on a reinforcement learning algorithm is constructed, and a semantic pruning mechanism is introduced to optimize the index depth of the index tree, to obtain an optimized index tree, comprising:

[0014] Step I, taking the semantic trajectory data as the root node;

[0015] Step II, recursively splitting the root node until a preset splitting termination condition is met, to obtain an optimized index tree; wherein,

[0016] Before performing the splitting, the trajectory semantic similarity is calculated according to the string of each trajectory point in the current tree node, and the number of semantic similar pairs in the current tree node is determined according to the trajectory semantic similarity and a preset similarity threshold; if the number of semantic similar pairs is less than a preset number threshold, the splitting is performed; otherwise, the splitting is not performed, and the current tree node is taken as a leaf node;

[0017] In the splitting process, the reinforcement learning algorithm is used to determine the splitting dimension of the current tree node; the splitting dimension is the longitude dimension, the latitude dimension or the timestamp dimension; the state space of the reinforcement learning algorithm includes the query skew reduction amount, the segment increase amount, the normalized node boundary and the normalized depth, the query skew reduction amount is used to evaluate the query load balancing benefit brought by the current tree node in each splitting dimension, the segment increase amount is used to evaluate the I / O overhead introduced by the splitting operation, the normalized node boundary is used to indicate the spatial range information of the current tree node, and the normalized depth is used to indicate the hierarchical information of the current tree node in the index tree; the reinforcement learning algorithm is designed to follow Policy selection splitting action; the reward function of the reinforcement learning algorithm is designed to minimize the I / O overhead, and the reward function includes local reward and global reward, the local reward is used to evaluate the query skew reduction amount and the segment increase amount caused by the execution of the splitting action, and the global reward represents the performance improvement degree of the current index tree relative to a preset baseline index tree.

[0018] Optionally, the calculation expression of the query skew reduction amount is:

[0019]

[0020] wherein, denotes the query skew reduction amount, denotes the number of queries intersecting with the current tree node before splitting, denotes the number of queries intersecting with the left child node of the current tree node after splitting, denotes the number of queries intersecting with the right child node of the current tree node after splitting.

[0021] The calculation expression of the segment increase amount is:

[0022]

[0023] wherein, denotes the segment increase amount, denotes the number of child nodes containing trajectory points after splitting the current tree node, denotes the current tree node before splitting, and the segment number is 1.

[0024] Optionally, the expression of the reward function is:

[0025]

[0026]

[0027]

[0028] wherein, denotes the total reward value, denotes the local reward, denotes the global reward, denotes the weight of the local reward value, denotes the weight of the global reward, denotes the weight of the I / O overhead, denotes the weight of the query skew reduction amount, denotes the weight of the segment increase amount, denotes the depth penalty factor, , denotes the hierarchical information, denotes the total I / O overhead of the current index tree, denotes the total I / O overhead of the preset baseline index tree.

[0029] Optionally, the trajectory semantic similarity is used to measure the scene similarity and behavior semantic similarity between the trajectory points in the current tree node.

[0030] Optionally, the calculation expression of the trajectory semantic similarity is:

[0031]

[0032]

[0033]

[0034] wherein, represents a trajectory semantic similarity, represents a trajectory point and a trajectory point between the scene similarity, represents a weight coefficient, represents a behavior semantic similarity, represents a field weight, respectively represent a key point type field weight, a geographic feature type field weight, a position type field weight, a geographic feature identification field weight and a trajectory identification field weight, represents an encoding matching function, , represent a TF-IDF vector of a behavior semantic description of a trajectory point A, represent a TF-IDF vector of a behavior semantic description of a trajectory point B, and respectively represent and vector lengths.

[0035] Optionally, according to the trajectory semantic similarity and a preset similarity threshold, a number of semantic similar pairs in the current tree node is determined, comprising:

[0036] by a calculation formula:

[0037]

[0038] a preset similarity threshold is obtained; wherein, represents an initial threshold, represents a decay rate;

[0039] if the trajectory semantic similarity between two trajectory points in the current tree node is greater than or equal to , the two trajectory points are determined as a semantic similar pair;

[0040] all semantic similar pairs in the current tree node are counted to obtain the number of semantic similar pairs.

[0041] In a second aspect, the present application provides a trajectory data encoding and query system, comprising:

[0042] a data acquisition module, configured to acquire trajectory data; the trajectory data comprises multiple trajectories, and each trajectory comprises at least two trajectory points;

[0043] The semantic encoding module is configured to encode each trajectory point according to a semantic encoding rule to obtain semantic trajectory data, wherein each trajectory point is encoded into a string, and the string includes a key point type field used to indicate whether the trajectory point changes the topological relationship of a geographic element, a geographic element type field used to indicate the type of the geographic element where the trajectory point is located, a position type field used to indicate the position of the trajectory point in the geographic element, a geographic element identifier field, a trajectory point identifier field, a trajectory identifier field, and a topological semantic encoding field; the topological semantic encoding field is used to describe the behavior pattern of the moving object, and includes a first field used to describe the predecessor state of the trajectory point, a second field used to describe the position of the key point, and a third field used to describe the successor state of the trajectory point.

[0044] The index construction module is configured to construct an index tree based on a reinforcement learning algorithm according to the semantic trajectory data, and introduce a semantic pruning mechanism to optimize the index depth of the index tree to obtain an optimized index tree; wherein the reinforcement learning algorithm is designed to dynamically select the split dimension of each tree node in the index tree according to the data distribution and the query load; the semantic pruning mechanism is designed to control the split degree of the nodes in the index tree according to the trajectory semantic similarity between each trajectory point in each tree node and a preset threshold; the trajectory semantic similarity is obtained by string calculation.

[0045] The trajectory query module is configured to receive or respond to a query request, perform a spatio-temporal query on the optimized index tree, and return a trajectory query result matched with the query request.

[0046] In a third aspect, the present application provides a terminal device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the above method when executing the computer program.

[0047] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the above method.

[0048] The present application has at least the following beneficial effects:

[0049] The semantic trajectory data is obtained by performing semantic coding on each trajectory point according to a semantic coding rule, which can capture rich semantic information in the trajectory, is beneficial to construction of a structured index tree and improvement of query efficiency, and is beneficial to improvement of query accuracy; the reinforcement learning algorithm dynamically selects a split dimension of each tree node in the index tree according to data distribution and query load, can adaptively change a dynamic query workload, and improves query efficiency; and the semantic pruning mechanism is designed to control a split degree of nodes in the index tree according to trajectory semantic similarity between each trajectory point in each tree node and a preset threshold, can reduce unnecessary index depth, reduce storage overhead, speed up query, and improve query efficiency. BRIEF DESCRIPTION OF DRAWINGS

[0050] The accompanying drawings are used to provide a further understanding of the technical solutions of the present application, and constitute a part of the specification, and are used to explain the technical solutions of the present application together with the embodiments of the present application, and do not constitute a limitation on the technical solutions of the present application.

[0051] Figure 1 A flowchart of a trajectory data coding and query method in one of the embodiments of the present application;

[0052] Figure 2 A structural schematic diagram of a trajectory data coding and query system in one of the embodiments of the present application;

[0053] Figure 3 A structural schematic diagram of a terminal device in one of the embodiments of the present application. DETAILED DESCRIPTION

[0054] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the scope of protection of the present application.

[0055] Traditional trajectory query methods mainly rely on static indexes such as R-trees and quad-trees, adopt a fixed splitting strategy of "space first", and can only efficiently process basic spatio-temporal range queries. The core defects are as follows: one-dimension dominant, performance drops sharply when processing queries with strong time or semantic constraints; semantic missing, unable to understand behavior intentions such as "enter" and "leave", and need to be filtered after full-scan, which is inefficient; load insensitive, static structure cannot adapt to query hotspots. The present application dynamically constructs an index tree through reinforcement learning, so that the index structure is adaptive to data and load distribution; topological semantic coding and pruning mechanisms are innovatively introduced, behavior semantics are deeply embedded in the index, and original efficient support for complex semantic queries is realized, which fundamentally overcomes the limitations of traditional methods.

[0056] Embodiment 1

[0057] For the convenience of understanding, the trajectory data encoding and query method provided by the present application is described in the embodiment of the present application taking a vehicle as a mobile object. It should be noted that this is only for the convenience of example and does not limit the mobile object.

[0058] As shown in Figure 1 The trajectory data encoding and query method provided by the present application includes the following steps:

[0059] Step 11, obtaining trajectory data.

[0060] In the embodiment of the present application, the trajectory data includes multiple trajectories, and each trajectory includes at least two trajectory points.

[0061] For example, the vehicle trajectory data is the basis for subsequent traffic state analysis, path planning or driving behavior analysis. This data can be obtained from various sources, such as sensors (such as cameras, radars) deployed on the roadside, vehicle-mounted GPS terminals, smart phone APPs or urban traffic data centers.

[0062] In a feasible implementation, the vehicle trajectory includes a timestamp, latitude and longitude coordinates, instantaneous speed, driving direction angle and road link. Among them, the timestamp accurately records the time of data collection (usually accurate to seconds), which is used to determine the time sequence relationship of the trajectory points; the latitude and longitude coordinates are obtained by GPS or other positioning systems, which are used to determine the accurate position of the vehicle in the geographical space; the unit of instantaneous speed is usually kilometers per hour (km / h), which is used to analyze the traffic flow state (such as congestion, smoothness); the driving direction angle is usually in degrees, 0° represents north, 90° represents east, which is used to judge the driving direction of the vehicle; the road link can be associated to a specific road section in the digital road network through map matching technology by the original latitude and longitude coordinates.

[0063] It should be noted that in specific implementation, after obtaining the original vehicle trajectory data, data preprocessing is usually needed to ensure data quality. Specifically, the original vehicle trajectory data needs to be cleaned to remove obviously erroneous trajectory points (such as latitude and longitude exceeding the reasonable range, points with abnormally high speed); for the missing trajectory points caused by signal loss, reasonable interpolation processing is performed; Kalman filtering is used to smooth the taxi data.

[0064] Step 12, performing semantic encoding on each trajectory point using semantic encoding rules to obtain semantic trajectory data.

[0065] Each trajectory point is encoded as a string, and the string comprises a key point type field used for indicating whether the trajectory point changes the topological relation of a geographic element, a geographic element type field used for indicating the type of the geographic element where the trajectory point is located, a position type field used for indicating the position of the trajectory point in the geographic element, a geographic element identifier field, a trajectory point identifier field, a trajectory identifier field and a topological semantic encoding field. The topological semantic encoding field is used for describing the behavior mode of the moving object, and comprises a first field used for describing the precursor state of the trajectory point, a second field used for describing the position of the key point and a third field used for describing the successor state of the trajectory point.

[0066] In an implementable embodiment, the string of each trajectory point comprises seven parts A to G:

[0067] A represents the key point type field: A takes the value 1 to represent a non-key point, and A takes the value 2 to represent a key point. The key point refers to a point where the topological relation changes in the moving process of the moving object;

[0068] B represents the geographic element type field: B takes the value 1 to represent an area, and B takes the value 2 to represent a road;

[0069] C indicates the position type field: C takes the value 1 to represent a boundary, and C takes the value 2 to represent an interior;

[0070] D is a 10-bit geographic element identifier field, which is a unique identifier of the geographic element;

[0071] E is a 7-bit trajectory point identifier field, which is a unique identifier of the trajectory point;

[0072] F is a 4-bit trajectory identifier field, which is a unique identifier of the trajectory.

[0073] G encoding (the topological semantic encoding field) is the core of the semantic encoding rule, and comprises three parts X1 (the first field), X2 (the second field) and X3 (the third field). X1 describes the position condition of the precursor trajectory point of the key point: X1 takes the value 0 to represent that there is no precursor point, X1 takes the value 1 to represent that the precursor point is not on the current element, X1 takes the value 2 to represent that the precursor point is on the current element and the directions are the same, and X1 takes the value 3 to represent that the precursor point is on the current element and the directions are opposite. X2 describes the position condition of the key point: is the start point (0) of the road, the end point (1) or neither (2). X3 is similar to X1, and describes the position condition of the successor trajectory point of the key point. According to the form of G encoding, the corresponding semantic behavior is defined.

[0074] In the embodiment of the application, the mapping relationship between the value of the topological semantic encoding field G and the semantic behavior comprises at least one of the following:

[0075] X1X2X3=102: from node 1 (road segment start point) into and along the road segment;

[0076] X1X2X3 = 113: Enter from node 2 (end of road segment) and move along the road segment;

[0077] X1X2X3 = 123: Enter from road segment and move towards node 1 (start of road segment);

[0078] X1X2X3 = 122: Enter from road segment and move towards node 2 (end of road segment);

[0079] X1X2X3 = 101: Pass through node 1 (start of road segment) without entering other geographic elements;

[0080] X1X2X3 = 111: Pass through node 2 (end of road segment) without entering other geographic elements;

[0081] X1X2X3 = 121: Pass inside the road segment;

[0082] X1X2X3 = 221: Move along the road segment towards node 2 (end of road) and leave the road segment;

[0083] X1X2X3 = 321: Move along the road segment towards node 1 (start of road) and leave the road segment.

[0084] Step 13, according to the semantic trajectory data, an index tree based on a reinforcement learning algorithm is constructed, and a semantic pruning mechanism is introduced to optimize the index depth of the index tree, and an optimized index tree is obtained.

[0085] Wherein, the reinforcement learning algorithm is designed to dynamically select the splitting dimension of each tree node in the index tree according to the data distribution and query load. The semantic pruning mechanism is designed to control the degree of splitting of nodes in the index tree according to the trajectory semantic similarity between each trajectory point in each tree node and the preset threshold. The trajectory semantic similarity is calculated by string.

[0086] In the embodiment of the application, step 13 specifically comprises steps I to step II.

[0087] Step I, taking semantic trajectory data as a root node.

[0088] Step II, recursively split the root node until the preset splitting termination condition is met, and obtain the optimized index tree; wherein, before performing the splitting, the trajectory semantic similarity is calculated according to the string of each trajectory point in the current tree node, and the number of semantic similar pairs in the current tree node is determined according to the trajectory semantic similarity and the preset similarity threshold; if the number of semantic similar pairs is less than the preset number threshold, the splitting is performed; otherwise, the splitting is not performed, and the current tree node is taken as a leaf node.

[0089] In the execution of the splitting process, a reinforcement learning algorithm is used to determine the splitting dimension of the current tree node; the splitting dimension is a longitude dimension, a latitude dimension, or a timestamp dimension; the state space of the reinforcement learning algorithm includes a query skew reduction amount, a segment increase amount, a normalized node boundary, and a normalized depth, the query skew reduction amount is used to evaluate the query load balancing benefits brought by the current tree node in each splitting dimension, the segment increase amount is used to evaluate the I / O overhead introduced by the splitting operation, the normalized node boundary is used to indicate the spatial range information of the current tree node, and the normalized depth is used to indicate the hierarchical information of the current tree node in the index tree; the reinforcement learning algorithm is designed to follow Policy to select a splitting action; the reward function of the reinforcement learning algorithm is designed to minimize the I / O overhead, and the reward function includes a local reward and a global reward, the local reward is used to evaluate the query skew reduction amount and the segment increase amount caused by the execution of the splitting action, and the global reward represents the performance improvement degree of the current index tree relative to the preset baseline index tree.

[0090] In an embodiment of the present application, the construction of the index tree starts from the root node (containing all trajectory point data) and recursively performs splitting. For each node to be processed, the system follows a strict decision-making process. In a feasible implementation, the construction process of the optimized index tree includes stages 1 to 4.

[0091] Stage 1:

[0092] First, the preprocessed semantic trajectory data is obtained. Each data record contains longitude, latitude, timestamp, and a 27-bit semantic code. The system constructs sub-ranges for each dimension (longitude, latitude, and timestamp) to ensure that each sub-range contains approximately the same number of data points, laying the foundation for building a balanced tree structure. At the same time, the following key instances are initialized:

[0093] LearningAgent: Reinforcement learning agent, whose network structure and hyperparameters are pre-configured;

[0094] SemanticPruner: Semantic pruning device, configured with weight parameters of scene similarity and behavior semantic similarity;

[0095] BPAD (baseline model): As a performance comparison benchmark, used to calculate the global reward.

[0096] Stage 2:

[0097] First, determine whether the preset splitting termination condition is met. In a feasible implementation, the preset splitting termination condition is: ① the number of trajectory points in the current tree node is lower than the preset minimum capacity threshold (such as 100 points); ② the current tree node has reached the preset maximum tree depth (such as 20 layers).

[0098] If the preset split termination condition is met, the tree node is immediately marked as a leaf node and will not split further. If the basic condition is not met, proceed to stage 3.

[0099] Phase 3:

[0100] The semantic similarity of the trajectory is calculated based on the strings of each trajectory point in the current tree node, and the number of semantically similar pairs in the current tree node is determined based on the semantic similarity of the trajectory and the preset similarity threshold. If the number of semantically similar pairs is less than the preset threshold, then splitting is performed and the process proceeds to stage 4. Otherwise, splitting is not performed, and the current tree node is treated as a leaf node.

[0101] In this embodiment of the invention, trajectory semantic similarity is used to measure the scene similarity and behavioral semantic similarity between trajectory points in the current tree node.

[0102] In one feasible implementation, the expression for calculating trajectory semantic similarity is:

[0103]

[0104]

[0105]

[0106] in, Indicates the semantic similarity of trajectories. Represents trajectory points With trajectory points Scene similarity between them Indicates the weighting coefficient. Indicates semantic similarity of behaviors. Indicates field weight. These represent the weights of the key point type field, the geographic feature type field, the location type field, the geographic feature identifier field, and the trajectory identifier field, respectively. This represents the encoding matching function. , The TF-IDF vector representing the behavioral semantic description of trajectory point A. The TF-IDF vector representing the behavioral semantic description of trajectory point B. and They represent and The length of the vector.

[0107] The following describes the process of determining the number of semantically similar pairs in the current tree node based on trajectory semantic similarity and a preset similarity threshold, specifically including steps a to c.

[0108] Step a, through calculation formula

[0109]

[0110] obtaining a preset similarity threshold ; wherein, denotes an initial threshold value, denotes a decay rate.

[0111] Step b, if the trajectory semantic similarity between the two trajectory points in the current tree node is greater than or equal to , the two trajectory points are determined as a semantic similar pair.

[0112] Step c, count all semantic similar pairs in the current tree node to obtain the number of semantic similar pairs.

[0113] Phase 4:

[0114] The reinforcement learning agent first perceives the state of the current tree node (query skew reduction amount, segment increase amount, normalized node boundary and normalized depth). For each dimension, the query skew reduction state contains the maximum query skew reduction amount that can be achieved by splitting in this dimension, reflecting the potential of the current node to solve the query coverage problem in different dimensions. The calculation expression of the query skew reduction amount is:

[0115]

[0116] wherein, denotes the query skew reduction amount, denotes the number of queries intersecting with the current tree node before splitting, denotes the number of queries intersecting with the left child node of the current tree node after splitting, denotes the number of queries intersecting with the right child node of the current tree node after splitting.

[0117] Corresponding to each dimension, the state contains the segment increase amount accompanied by the maximum query skew reduction. This reflects the I / O overhead that the splitting operation may introduce. The calculation expression of the segment increase amount is:

[0118]

[0119] wherein, denotes the segment increase amount, denotes the number of child nodes containing trajectory points after splitting of the current tree node, denotes the current tree node before splitting, and the segment number is 1.

[0120] Subsequently, the reinforcement learning agent predicts the Q value of splitting in the longitude, latitude and timestamp dimensions according to the state vector of the current tree node through the Q network. The reinforcement learning agent follows Policy selects an action A (i.e. split dimension). At the beginning of training, high values encourage exploration of different dimensions; as training proceeds, diminish, the reinforcement learning agent is more inclined to select known high Q-value actions. After the split dimension is selected, all possible split points in this dimension are traversed, and the point that maximizes the local reward is selected for splitting, dividing the data of the current node into two subsets and creating corresponding left and right child nodes.

[0121] In an embodiment of the present application, the expression of the reward function is:

[0122]

[0123]

[0124]

[0125] wherein, represents the total reward value, represents the local reward, represents the global reward, represents the weight of the local reward value, represents the weight of the global reward, represents the weight of I / O overhead, represents the weight of query skew reduction amount, represents the weight of segment increase amount, represents the depth penalty factor, , represents the hierarchical information, represents the total I / O overhead of the current index tree, represents the total I / O overhead of the preset baseline index tree.

[0126] It should be noted that the local reward is calculated immediately after each split action is completed. The local reward takes into account the immediate benefits (query skew reduction) and costs (segment increase) of splitting, and applies a depth penalty to encourage the construction of a shallower tree. After the end of a training cycle (all query workloads run once), the system calculates the total I / O cost of the current index tree processing all queries, and compares it with the total I / O cost of the BPAD baseline to calculate the global reward. After the total reward value is calculated based on the local reward and the global reward, the parameters of the Q network are updated through reinforcement learning algorithms such as DQN. This enables the reinforcement learning agent to learn the splitting strategy that is optimal for long-term query performance.

[0127] When all nodes have been processed (i.e. all branches reach the leaf nodes), an optimized index tree is constructed.

[0128] Step 14, performing spatio-temporal query on the optimized index tree in response to the query request, and returning the trajectory query result matching the query request.

[0129] In an embodiment of the present application, the trajectory query result includes trajectory points and their associated time information.

[0130] In a feasible implementation, a semantic trajectory query method is used to obtain the trajectory query result. The method is used to respond to natural language queries such as "When did trajectory 2 enter the 'Via Nazionale' road?" and specifically includes steps S101 to S105.

[0131] Step S101: parsing the query request to generate structured parameters.

[0132] The received natural language query is input into the large language model DeepSeek. From the output of the large language model, structured query parameters are extracted and generated, including: target trajectory identifier; target road name; behavior keyword; and optional time range constraint.

[0133] Step S102: converting the road name and behavior keyword into index-matching identifiers.

[0134] The target road name is converted into the corresponding geographic feature identifier by querying the pre-stored road semantic mapping table. The behavior keyword is converted into one or more corresponding topological semantic codes by querying the pre-stored semantic behavior mapping table.

[0135] Step S103: traversing the BT-Tree index to obtain a candidate trajectory point set.

[0136] Traversing starts from the root node of the index tree. At each internal node, the following sub-steps are performed:

[0137] S1031: obtaining the split dimension and split value of the node;

[0138] S1032: judging the overlap relationship between the query range and each subspace of the node according to the spatio-temporal constraints in the structured parameters;

[0139] S1033: recursively traversing only those child nodes that have an overlap with the query range.

[0140] Finally, one or more leaf nodes are reached, and the trajectory data points stored in all reached leaf nodes are loaded into memory to form a candidate trajectory point set.

[0141] Step S104: performing multi-level semantic filtering on the candidate trajectory point set.

[0142] For each trajectory point in the candidate set, the following filtering judgments are performed in sequence:

[0143] S1041 (Trajectory Filtering): Analyze the trajectory identifier field of the trajectory point, and determine whether it matches the target trajectory identifier.

[0144] S1042 (Road Filtering): Analyze the geographic feature identifier field of the trajectory point, and determine whether it matches the converted geographic feature identifier.

[0145] S1043 (Behavior Filtering): Analyze the topological semantic encoding field of the trajectory point, and determine whether it belongs to the converted topological semantic encoding set.

[0146] Only keep the trajectory points that pass the above three levels of filtering simultaneously as the accurate query result.

[0147] Step S105: Generate and return the final query result.

[0148] Extract the timestamp information from the accurate query result and arrange it in chronological order. Output a list containing all matching time points and their total number.

[0149] In another possible implementation, the K-nearest neighbor query method is used to obtain the trajectory query result. This method is used to respond to queries such as "find the 5 nearest trajectory points to a certain center point", and specifically includes steps S201 to S205.

[0150] Step S201: Analyze the query request and generate KNN query parameters.

[0151] The following parameters are obtained by analysis: the latitude and longitude coordinates of the query center point; the number of nearest neighbors K.

[0152] Step S202: Initialize the priority queue and start traversal.

[0153] Initialize a minimum heap as the priority queue, whose priority is determined by the minimum possible distance from the query center point to the minimum bounding rectangle of the tree node. Add the root node of the index tree to the priority queue.

[0154] Step S203: Perform best-first search based on the priority queue.

[0155] Loop the following operations until the priority queue is empty or all K nearest neighbors have been confirmed:

[0156] S2031: Pop out the node N with the highest priority (i.e. the smallest minimum possible distance) from the queue.

[0157] S2032: Determine the type of node N:

[0158] If N is an internal node: Calculate the minimum possible distance from the query center point to the minimum bounding rectangle of each child node of N. Add all child nodes to the priority queue with their corresponding minimum possible distance values.

[0159] If N is a leaf node: Traverse each trajectory point Pi in N. If the timestamp of Pi is within the specified time range, perform step S204.

[0160] Step S204: Calculate the distance and maintain the nearest neighbor result set.

[0161] For each trajectory point Pi in the leaf node that meets the time constraint, calculate the Haversine actual distance from the query center point to Pi. Maintain a maximum heap of size K to store the K nearest points found so far and their distances. Compare the current point Pi and its distance with the top element of the maximum heap. If the distance of Pi is smaller, replace the top element and adjust the heap structure.

[0162] Step S205: Generate and return the final query result.

[0163] When the search loop ends, output all trajectory points in the maximum heap as the final result. The output result includes the latitude and longitude coordinates, timestamp, and actual distance from the query center point of each point.

[0164] Embodiment 2

[0165] In the embodiments of the present application, the trajectory data encoding and query method provided by the present application is compared with the traditional method, and the comparison results are shown in Table 1.

[0166] Table 1

[0167]

[0168] As can be seen from Table 1, the index tree constructed by the trajectory data encoding and query method provided by the present application has advantages in index memory usage, average semantic query time, and relative I / O cost compared with the index tree constructed by the traditional method, especially in the relative I / O cost, which is far ahead of other methods.

[0169] In summary, the trajectory data encoding and query method provided by the application encodes each trajectory point by using a semantic encoding rule to obtain semantic trajectory data, which can capture rich semantic information in the trajectory of a moving object, is conducive to the construction of a structured index tree and improves query efficiency, and is conducive to improving the accuracy of trajectory query of a moving object; the reinforcement learning algorithm dynamically selects the split dimension of each tree node in the index tree according to data distribution and query load, can adapt to dynamic changes in query work load, and improves query efficiency; the semantic pruning mechanism is designed to control the split degree of nodes in the index tree according to the trajectory semantic similarity between each trajectory point in each tree node and a preset threshold, can reduce unnecessary index depth, reduce storage overhead, and speed up query, thereby improving query efficiency.

[0170] Embodiment 3

[0171] In the embodiments of the application, a trajectory data encoding and query system is disclosed, and each module in the trajectory data encoding and query system cooperates with each other to realize the trajectory data encoding and query method in Embodiment 1.

[0172] As shown in Figure 2 The trajectory data encoding and query system 200 includes the following modules:

[0173] The data acquisition module 201 is configured to acquire trajectory data; the trajectory data includes multiple trajectories, and each trajectory includes at least two trajectory points;

[0174] The semantic encoding module 202 is configured to encode each trajectory point by using a semantic encoding rule to obtain semantic trajectory data; each trajectory point is encoded into a string, and the string includes a key point type field used to indicate whether a topological relationship of a geographical element of the trajectory point is changed, a geographical element type field used to indicate a geographical element type in which the trajectory point is located, a position type field used to indicate a position of the trajectory point in the geographical element, a geographical element identifier field, a trajectory point identifier field, a trajectory identifier field, and a topological semantic encoding field; the topological semantic encoding field is used to describe a behavior mode of a moving object, and includes a first field used to describe a predecessor state of the trajectory point, a second field used to describe a key point position, and a third field used to describe a successor state of the trajectory point;

[0175] The index construction module 203 is configured to construct an index tree based on a reinforcement learning algorithm according to the semantic trajectory data, and introduce a semantic pruning mechanism to optimize the index depth of the index tree to obtain an optimized index tree; the reinforcement learning algorithm is designed to dynamically select the split dimension of each tree node in the index tree according to data distribution and query load; the semantic pruning mechanism is designed to control the split degree of nodes in the index tree according to the trajectory semantic similarity between each trajectory point in each tree node and a preset threshold; the trajectory semantic similarity is calculated by using a string.

[0176] The trajectory query module 204 is configured to receive or respond to a query request, perform a spatio-temporal query on the optimized index tree, and return a trajectory query result matching the query request.

[0177] It should be noted that the information interaction between the above modules, the execution process, and the like, are based on the same concept as the method embodiments of the present application, and the specific functions and technical effects brought about can be referred to the method embodiments part. Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above functional units and modules is taken as an example for illustration, and in actual applications, the above functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiments can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit, and the integrated unit can be realized in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for easy distinction, and do not limit the protection scope of the present application. The specific working process of the units and modules in the above system can refer to the corresponding process in the method embodiments, which will not be repeated here.

[0178] As shown in FIG. 1, the embodiment of the present application provides a terminal device. Figure 3 As shown in FIG. 1, the embodiment of the present application provides a terminal device. Figure 3 The terminal device D10 of the embodiment includes at least one processor D100 (only one processor is shown in the figure), a memory D101, and a computer program D102 stored in the memory D101 and executable on the at least one processor D100, wherein the processor D100 implements the steps in any of the above method embodiments when executing the computer program D102. Figure 3

[0179] ​Specifically, the processor D100 executes the computer program D102 to obtain trajectory data, encode each trajectory point by using a semantic encoding rule to obtain semantic trajectory data, construct an index tree based on a reinforcement learning algorithm according to the semantic trajectory data, introduce a semantic pruning mechanism to optimize the index depth of the index tree, obtain an optimized index tree, receive or respond to a query request, perform a spatio-temporal query on the optimized index tree, and return a trajectory query result matched with the query request. The semantic trajectory data obtained by encoding each trajectory point by using the semantic encoding rule can capture rich semantic information of the trajectory, which is conducive to the construction of a structured index tree, improves the query efficiency, and improves the accuracy of the trajectory query. The reinforcement learning algorithm dynamically selects the split dimension of each tree node in the index tree according to the data distribution and the query load, which can adapt to the dynamic changes of the query work load and improve the query efficiency. The semantic pruning mechanism is designed to control the split degree of the nodes in the index tree according to the trajectory semantic similarity between each trajectory point in each tree node and a preset threshold, which can reduce unnecessary index depth, reduce storage overhead, speed up the query, and improve the query efficiency.

[0180] The processor D100 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or can also be any conventional processor.

[0181] The storage D101 can be an internal storage unit of the terminal device D10, such as a hard disk or a memory of the terminal device D10, in some embodiments. The storage D101 can also be an external storage device of the terminal device D10, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device D10, in other embodiments. Further, the storage D101 can include both an internal storage unit and an external storage device of the terminal device D10. The storage D101 is used to store an operating system, an application program, a boot loader, data, and other programs, such as program codes of the computer program, etc. The storage D101 can also be used to temporarily store data that has been output or is to be output.

[0182] The embodiments of the present application further provide a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to implement the steps in the above method embodiments.

[0183] The embodiments of the present application provide a computer program product. When the computer program product is run on a terminal device, the terminal device is caused to implement the steps in the above method embodiments.

[0184] Those skilled in the art should understand that the discussion of the above any embodiment is only exemplary, and is not intended to imply that the protection scope of the present application is limited to these examples; the above embodiments or technical features in different embodiments can also be combined, the steps can be implemented in any order, and there are many other changes of different aspects of one or more embodiments of the present application as described above. In order to be brief, they are not provided in details.

[0185] One or more embodiments of the present application are intended to cover all such alternatives, modifications and variations falling within the broad scope of the present application. Therefore, any omission, modification, equivalent replacement, improvement, etc. made in the spirit and principle of one or more embodiments of the present application should be included in the protection scope of the present application.

Claims

1. A method for encoding and querying trajectory data, characterized in that, include: Acquire trajectory data; the trajectory data includes multiple trajectory segments, each of which includes at least two trajectory points; Semantic coding rules are used to semantically encode each trajectory point to obtain semantic trajectory data. Each trajectory point is encoded as a string, which includes a keypoint type field indicating whether the trajectory point changes the topological relationship of geographic features, a geographic feature type field indicating the type of geographic feature the trajectory point is located in, a location type field indicating the position of the trajectory point within the geographic feature, a geographic feature identifier field, a trajectory point identifier field, a trajectory identifier field, and a topological semantic coding field. The topological semantic coding field describes the behavior pattern of the moving object, including a first field describing the preceding state of the trajectory point, a second field describing the keypoint position, and a third field describing the succeeding state of the trajectory point. Based on the semantic trajectory data, an index tree based on a reinforcement learning algorithm is constructed, and a semantic pruning mechanism is introduced to optimize the index depth of the index tree, resulting in an optimized index tree. The reinforcement learning algorithm is designed to dynamically select the split dimension of each tree node in the index tree based on data distribution and query load. The semantic pruning mechanism is designed to control the degree of splitting of nodes in the index tree based on the trajectory semantic similarity between trajectory points in each tree node and a preset threshold. The trajectory semantic similarity is calculated using the string. Upon receiving or responding to a query request, a spatiotemporal query is performed on the optimized index tree, and the trajectory query result matching the query request is returned.

2. The trajectory data encoding and query method according to claim 1, characterized in that, The step of constructing an index tree based on a reinforcement learning algorithm using the semantic trajectory data, and introducing a semantic pruning mechanism to optimize the index depth of the index tree to obtain an optimized index tree, includes: Step 1: Use the semantic trajectory data as the root node; Step II: Recursively split the root node until a preset splitting termination condition is met, thus obtaining the optimized index tree; wherein, Before splitting, the semantic similarity of the trajectory is calculated based on the strings of each trajectory point in the current tree node, and the number of semantically similar pairs in the current tree node is determined based on the semantic similarity of the trajectory and a preset similarity threshold; if the number of semantically similar pairs is less than the preset threshold, then splitting is performed; otherwise, splitting is not performed, and the current tree node is treated as a leaf node. During the splitting process, the reinforcement learning algorithm is used to determine the splitting dimension of the current tree node; the splitting dimension can be a longitude dimension, a latitude dimension, or a timestamp dimension; the state space of the reinforcement learning algorithm includes query skew reduction, segment increment, normalized node boundary, and normalized depth. The query skew reduction is used to evaluate the query load balancing benefit brought by the current tree node in each splitting dimension, the segment increment is used to evaluate the I / O overhead introduced by the splitting operation, the normalized node boundary is used to indicate the spatial range information of the current tree node, and the normalized depth is used to indicate the level information of the current tree node in the index tree; the reinforcement learning algorithm is designed to follow... The strategy selects the split action; the reward function of the reinforcement learning algorithm is designed to minimize I / O overhead. The reward function includes local rewards and global rewards. The local rewards are used to evaluate the reduction in query skew and the increase in segmentation caused by executing the split action. The global rewards characterize the performance improvement of the current index tree relative to the preset baseline index tree.

3. The trajectory data encoding and query method according to claim 2, characterized in that, The expression for calculating the reduction in query skewness is: in, This indicates a reduction in query skew. This represents the number of queries that intersected with the current tree node before the split. This represents the number of queries that intersect with the left child node after the current tree node is split. This indicates the number of queries that intersect with the right child node after the current tree node is split; The expression for calculating the segmented increase is: in, Indicates the increment in segments. This indicates the number of child nodes containing the trajectory point after the current tree node is split. This represents the current tree node before the split, with a segment count of 1.

4. The trajectory data encoding and query method according to claim 3, characterized in that, The expression for the reward function is: in, Represents the total reward value. Indicates a partial reward. Indicates global reward. This indicates the weight of the local reward. This indicates the weight of the global reward. Indicates the weight of I / O overhead. This indicates a reduction in the weight of query skew. This indicates the increase in weight for each segment. Indicates the depth penalty factor. , This indicates the hierarchical information. This represents the total I / O cost of the current index tree. This indicates the total I / O overhead of the preset baseline index tree.

5. The trajectory data encoding and query method according to claim 4, characterized in that, The trajectory semantic similarity is used to measure the scene similarity and behavioral semantic similarity between trajectory points in the current tree node.

6. The trajectory data encoding and query method according to claim 5, characterized in that, The expression for calculating the trajectory semantic similarity is: in, Indicates the semantic similarity of trajectories. Represents trajectory points With trajectory points Scene similarity between them Indicates the weighting coefficient. Indicates semantic similarity of behaviors. Indicates field weight. These represent the weights of the key point type field, the geographic feature type field, the location type field, the geographic feature identifier field, and the trajectory identifier field, respectively. This represents the encoding matching function. , The TF-IDF vector representing the behavioral semantic description of trajectory point A. The TF-IDF vector representing the behavioral semantic description of trajectory point B. and They represent and The length of the vector.

7. The trajectory data encoding and query method according to claim 6, characterized in that, The step of determining the number of semantically similar pairs in the current tree node based on the trajectory semantic similarity and a preset similarity threshold includes: Through calculation formula The preset similarity threshold is obtained. ;in, Indicates the initial threshold. Indicates the attenuation rate; If the semantic similarity of the trajectories between two trajectory points in the current tree node is greater than or equal to If so, then the two trajectory points are identified as a semantically similar pair; Count all semantically similar pairs in the current tree node to obtain the number of semantically similar pairs.

8. A trajectory data encoding and query system, characterized in that, include: The data acquisition module is used to acquire trajectory data; the trajectory data includes multiple trajectory segments, and each trajectory segment includes at least two trajectory points. A semantic encoding module is used to semantically encode each trajectory point using semantic encoding rules to obtain semantic trajectory data. Each trajectory point is encoded as a string, which includes a keypoint type field indicating whether the trajectory point changes the topological relationship of a geographic feature, a geographic feature type field indicating the type of geographic feature the trajectory point is located in, a location type field indicating the position of the trajectory point within the geographic feature, a geographic feature identifier field, a trajectory point identifier field, a trajectory identifier field, and a topological semantic encoding field. The topological semantic encoding field describes the behavior pattern of the moving object, including a first field describing the preceding state of the trajectory point, a second field describing the keypoint position, and a third field describing the succeeding state of the trajectory point. An index building module is used to construct an index tree based on a reinforcement learning algorithm according to the semantic trajectory data, and to introduce a semantic pruning mechanism to optimize the index depth of the index tree, resulting in an optimized index tree. The reinforcement learning algorithm is designed to dynamically select the split dimension of each tree node in the index tree based on data distribution and query load. The semantic pruning mechanism is designed to control the degree of splitting of nodes in the index tree based on the trajectory semantic similarity between trajectory points in each tree node and a preset threshold. The trajectory semantic similarity is calculated from the string. The trajectory query module is used to receive or respond to query requests, perform spatiotemporal queries on the optimized index tree, and return trajectory query results that match the query request.

9. A terminal 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, it implements the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Hot spot identification method and system for trajectory data

    CN118427457A

  • Track representation enhancement method based on dynamic subgraph

    CN120316196A