A method for recommending a travel route based on spatial relationship enhanced self-supervised trajectory learning
By employing a self-supervised trajectory learning method enhanced with spatial relationships, this approach addresses the limitations of existing models in complex spatial relationship modeling and sparse data scenarios. It enables efficient and personalized travel route recommendations, generating travel routes that meet the actual needs of users.
Patent Information
- Application Number
- CN202511807949.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-03
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2045-12-03
AI Technical Summary
Existing travel route recommendation models struggle to effectively capture user behavior patterns and preferences, especially in complex spatial relationship modeling. They also fail to adapt to changes in feature importance across different scenarios, neglecting geographical coherence and temporal rationality, resulting in recommendation results that do not align with users' actual travel habits.
We employ a self-supervised trajectory learning method based on spatial relationship enhancement. By constructing a multi-type data decoupling and fusion module, a context-aware encoding module, a spatial relationship-aware encoder, and a trajectory generator, and combining data augmentation strategies and self-attention mechanisms, we dynamically adjust feature weights to capture the spatiotemporal dependencies between user trajectories and generate efficient and personalized travel routes.
It improves the accuracy and personalization of travel route recommendations, overcomes the limitations of existing models in sparse data scenarios, and can proactively avoid repeated visits and long-distance jumps, generating travel routes that meet the actual needs of users.
Smart Images

Figure QLYQS_3 
Figure QLYQS_18 
Figure QLYQS_20
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, specifically to a self-supervised trajectory learning method for recommending travel routes based on spatial relationship enhancement. Background Technology
[0002] As consumers gain more travel experience and their consumption concepts mature, their demands for personalized travel products and services are increasing. Therefore, intelligent travel route recommendations have emerged. The rise of location-based social networks (LBSNs) such as Foursquare and Meituan has greatly facilitated the sharing of location information among individuals. The widespread use of smartphones, smartwatches, and other smart devices has further promoted the sharing of personal location information. A large amount of information, including photos tagged with geographic and time information, is accessible online, providing a solid data foundation for the rise of intelligent travel route recommendations and greatly promoting their development. The core objective of travel route recommendations is to utilize artificial intelligence technology to mine users' potential preferences and behavioral patterns from large-scale data, automatically generating efficient, personalized, and realistic travel routes. Therefore, how to fully utilize users' historical trajectory information, combining the spatiotemporal relationships and transition probabilities within those historical trajectories, and better capturing the relationship between users' check-in order and their potential transition preferences, becomes crucial to improving the accuracy of recommendation results.
[0003] Traditional methods for travel route recommendations mostly focus on historical sequential behavior between Points of Interest (POIs), designed based on statistical characteristics of the data or user-item relationships. For example, early collaborative filtering and Markov models modeled user movement behavior by analyzing interactions between users and POIs. These methods generally have high requirements for data quality; in situations where travel data is sparse, they may even provide recommendations that deviate from tourists' true travel intentions. These methods only explicitly analyze users' historical trajectories, and these processes may fail to capture the diversity and transitional patterns of human needs, posing challenges to the accuracy of recommendations.
[0004] With the development of deep learning, deep learning-based models such as recurrent neural networks and generative adversarial networks (GANs) are widely used to capture user behavior sequence patterns and use users' personalized preferences and historical trajectory information to recommend future travel routes for users. These methods can improve the accuracy of predictions to a certain extent.
[0005] While the methods described above have played a positive role in route recommendation tasks, current research still faces several key challenges. First, most existing models focus on historical sequential behavior along trajectories, simplifying rich geospatial relationships into simple sequence transitions. This over-reliance on implicit pattern learning makes it difficult to effectively model long-distance spatial dependencies between origin and destination points. Furthermore, the uncertainty in spatial relationship modeling limits its performance in complex spatial relationships. Therefore, effectively capturing both local and global spatial relationships has become a new challenge. Second, existing models typically extract trajectory information by simply concatenating different features (such as POI, time, and location) and then evenly distributing weights across different types of information. This leads to interference between different types of information when processing different features, making the model unable to adapt to changes in feature importance across different scenarios. Additionally, existing models generally neglect the crucial geographical coherence and temporal rationality in tourism planning, failing to proactively avoid recommending repeatedly visited POIs or generating long-distance skipping trajectories. However, in practical applications, these shortcomings clearly do not align with users' actual travel habits and expectations. Summary of the Invention
[0006] To overcome the shortcomings of the above technologies, this invention provides a more effective method for capturing user behavior patterns and preferences, thereby providing a more accurate self-supervised trajectory learning travel route recommendation method based on spatial relationship enhancement.
[0007] The technical solution adopted by this invention to overcome its technical problems is:
[0008] A self-supervised trajectory learning-based tourism route recommendation method based on spatial relationship enhancement includes:
[0009] S1. Obtain Each POI, its category, latitude and longitude information, and the user. The set of trajectories, A set of POI points consists of several POI points. , ,in For the first The POI point, the ... The categories corresponding to each POI are: The category set is , , No. The latitude and longitude information corresponding to each POI point is: Latitude and longitude information set , , No. The trajectory set of each user is , ,in For the first The first user's A sequence of trajectories, , For the first Number of user trajectories ,in For the first The first user's The first of the trajectories A check-in location, , For the first The first user's The number of locations visited in each trajectory, the number of times the first location was checked in. The number of users accessing the first The first trajectory Each check-in location The time is , No. The number of users accessing the first The time set of each trajectory is , ;
[0010] S2. Utilizing latitude and longitude information sets Construct the distance matrix ;
[0011] S3. According to the first The trajectory sets of each user yield enhanced sequences view1, view2, and trajectory sequences. ;
[0012] S4. Establish a self-supervised model for spatial relationship enhancement, consisting of a multi-type data decoupling and fusion module, a context-aware encoding module, a spatial relationship-aware encoder, and a trajectory generator;
[0013] S5. Enhance the sequence view1, view2, and trajectory sequence. Category set Time set Trajectory Sequence The data is input into the multi-type data decoupling and fusion module of the self-supervised model for spatial relationship enhancement, and the output is fused feature representation fused_emb, fused feature representation fused_emb_v1, and fused feature representation fused_emb_v2.
[0014] S6. Input the fused feature representations fused_emb, fused_emb_v1, and fused_emb_v2 into the context-aware encoding module of the self-supervised model for spatial relation enhancement, and output a unified representation E.
[0015] S7. Input the unified representation E into the spatial relation-aware encoder of the self-supervised model for spatial relation enhancement, and output the guided representation E'.
[0016] S8. Input the guided representation E' and the user's current POI into the trajectory generator of the spatial relationship enhancement self-supervised model, and output the recommended trajectory route.
[0017] Furthermore, in step S1, data is obtained from the Weeplaces dataset. Each POI, its category, latitude and longitude information, and the user. The set of trajectories.
[0018] Furthermore, in step S2, the Haversine formula is used to calculate the first... Points of Interest (POIs) With the Points of Interest (POIs) Distance between Distance matrix have OK Columns, distance matrix The Middle Line number The elements of the column are , .
[0019] Furthermore, step S3 includes the following steps:
[0020] S3-1. The first The trajectory set of each user is All of them Each trajectory undergoes initial data augmentation using random insertion, random deletion, random masking, or random truncation. The data augmented after the first data augmentation... The trajectories constitute the enhanced sequence view1;
[0021] S3-2. The first The trajectory set of each user is All of them Each trajectory undergoes a second data augmentation using random insertion, random deletion, random masking, or random truncation. This second data augmentation differs from the first. The resulting data after the second augmentation... The trajectories constitute the enhanced sequence view2;
[0022] S3-3. In the... User trajectory set The first trajectory With the A trajectory Select 15-30% of the intermediate points, replace 80% of the selected intermediate points with the [MASK] marker, and replace the check-in locations in the trajectory of the remaining 10% of the selected intermediate points with a set of POI points. For any POI point, add a [CLS] marker at the beginning and a [SEP] marker at the end of the trajectory of the 10% selected intermediate points, completing the first step. User trajectory set The masking operation yields the trajectory sequence. .
[0023] Furthermore, step S5 includes the following steps:
[0024] S5-1. The multi-type data decoupling and fusion module of the self-supervised model for spatial relationship enhancement consists of a first embedding layer, a second embedding layer, a third embedding layer, a position embedding layer of the Transformer model, a linear layer, and a Sigmoid activation function;
[0025] S5-2. Trajectory Sequence The enhanced sequences view1 and view2 are respectively input into the first embedding layer of the multi-type data decoupling and fusion module, and the POI embedding sequences E_s, E_v1, and E_v2 are respectively output.
[0026] S5-3. Class Set The input is fed into the second embedding layer of the multi-type data decoupling and fusion module, and the output is the category embedding representation E_c;
[0027] S5-4. Time Set The input is fed into the third embedding layer of the multi-type data decoupling and fusion module, and the output is the time embedding representation E_t;
[0028] S5-5. Trajectory Sequence The input is fed into the position embedding layer of the Transformer model in the multi-type data decoupling and fusion module, and the output is the position code E_p;
[0029] S5-6. After concatenating the POI embedding sequence E_s with the class embedding representation E_c, the concatenation is input into the linear layer of the multi-type data decoupling and fusion module, and the output is the POI-class joint representation E_pc. The POI-class joint representation E_pc, the temporal embedding representation E_t, and the position code E_p are then input into the Sigmoid activation function of the multi-type data decoupling and fusion module, and the outputs are the gate weights. Gating weights Gating weights Through formula Weighted fusion is performed to calculate the fused feature representation fused_emb;
[0030] S5-7. After concatenating the POI embedding sequence E_v1 with the class embedding representation E_c, the concatenation is input into the linear layer of the multi-type data decoupling and fusion module, and the output is the POI-class joint representation E_pc1. The POI-class joint representation E_pc1, the temporal embedding representation E_t, and the position code E_p are then input into the Sigmoid activation function of the multi-type data decoupling and fusion module, and the outputs are the POI-class gating weights. Time-gating weights Location gating weights Through formula The fused feature representation fused_emb_v1 is calculated.
[0031] S5-8. After concatenating the POI embedding sequence E_v2 with the class embedding representation E_c, the concatenation is input into the linear layer of the multi-type data decoupling and fusion module, and the output is the POI-class joint representation E_pc2. The POI-class joint representation E_pc2, the temporal embedding representation E_t, and the position code E_p are then input into the Sigmoid activation function of the multi-type data decoupling and fusion module, and the outputs are the POI-class gating weights. Time-gating weights Location gating weights Through formula The fused feature representation fused_emb_v2 is calculated.
[0032] Furthermore, step S6 includes the following steps:
[0033] S6-1. The context-aware encoding module of the self-supervised model for enhancing spatial relationships consists of a Transformer encoder, a linear layer, a GELU activation function, a normalization layer, a first projection head, a second projection head, a cross-attention layer, a gated fusion layer, and a layer normalization layer.
[0034] S6-2. Input the fused feature representation fused_emb, fused feature representation fused_emb_v1, and fused feature representation fused_emb_v2 into the Transformer encoder of the context-aware coding module, and output the context-aware sequence representation Hu, the encoding identifier CLS1 of the augmented view, and the encoding identifier CLS2 of the augmented view, respectively.
[0035] S6-3. Input the context-aware sequence representation Hu into the linear layer, GELU activation function, and normalization layer of the context-aware coding module in sequence, and output a stable representation Hm;
[0036] S6-4. The first projection head of the context-aware encoding module consists of a linear transformation layer, a ReLU activation function, and a normalization layer. The encoding identifier CLS1 of the enhanced view is input into the first projection head, and the normalized representation Hp1 is output.
[0037] S6-5. The second projection head of the context-aware encoding module consists of a linear transformation layer, a ReLU activation function, and a normalization layer. The encoding identifier CLS2 of the enhanced view is input into the second projection head, and the normalized representation Hp2 is output.
[0038] S6-6. Through formula The uniform trajectory representation Hc is calculated, where... These are learnable fusion weights;
[0039] S6-7. The cross-attention layer of the context-aware coding module is composed of a multi-head attention mechanism, which concatenates the stable representation Hm with the unified trajectory representation Hc to obtain the fused representation Hu'. The fused representation Hu' is then input into the cross-attention layer of the context-aware coding module, and the weighted representation Ha of the attention is output.
[0040] S6-8. The gated fusion layer of the context-aware coding module consists of a linear transformation layer and a sigmoid activation function. The attention-weighted representation Ha is concatenated with the stable representation Hm to obtain the feature H_concat. The feature H_concat is input into the linear transformation layer of the gated fusion layer, and the output is the gate score g. The gate score g is input into the sigmoid activation function of the gated fusion layer, and the output is the gate weight gate.
[0041] S6-9. Through formula The preliminary unified representation H_p is obtained by calculation, where To perform element-wise multiplication, the initial unified representation H_p is added to the stable representation Hm and then input into the layer normalization layer of the context-aware coding module, and the unified representation E is output.
[0042] Furthermore, step S7 includes the following steps:
[0043] S7-1. The spatial relationship-aware encoder of the self-supervised model for spatial relationship enhancement consists of a first embedding layer, a second embedding layer, a third embedding layer, K linear layers, and an average pooling layer.
[0044] S7-2. The first The first user's A trajectory sequence The first place to check in As start_id, the first The first user's A trajectory sequence The last place to check in As end_id, it forms the anchor pair (start_id, end_id);
[0045] S7-3. Input the anchor point pair (start_id, end_id) into the first embedding layer of the spatial relationship-aware encoder, and output the anchor point representation Ai;
[0046] S7-4. From the... The first user's A trajectory sequence Except for the first check-in location and the last place to check in Arbitrarily select a check-in location and input it into the second embedding layer of the spatial relationship-aware encoder to obtain a positive sample representation. ;
[0047] S7-5. From the... Trajectory set of individual users Except for the first A trajectory sequence In any chosen trajectory sequence Each check-in location will The locations visited during each check-in are input into the third embedding layer of the spatial relationship-aware encoder, and the output is a sequence of negative sample representations. , ,in For the first One negative sample represents, ;
[0048] S7-6. Through formula The offset vector of the positive sample is calculated. Through formula The average value of the negative samples was calculated. Through formula The offset vector of the negative sample is calculated. ;
[0049] S7-7. The offset vector of the positive samples offset vector of negative samples After the stitching operation, the data are input into the K linear layers of the spatial relationship-aware encoder, and the output yields K relationship perspectives. ,in This is the relational perspective output by the k-th linear layer. Stacking all K relational perspectives yields a 3D relational tensor. ;
[0050] S7-8. Through formula The query matrix of the multi-head attention mechanism is calculated. In the formula These are learnable parameters; obtained through formulas The key matrix of the multi-head attention mechanism is calculated. In the formula These are learnable parameters; obtained through formulas The value matrix of the multi-head attention mechanism was calculated. In the formula These are learnable parameters;
[0051] S7-9. Through formula Calculate the attention weights In the formula The Softmax activation function is used. To transpose, use the formula Calculate the output ;
[0052] S7-10. Output The input is fed into the average pooling layer of the spatial relation-aware encoder, and the output is a fused relation vector. ;
[0053] S7-11. Through formula The guided representation E' is calculated.
[0054] Furthermore, step S8 includes the following steps:
[0055] S8-1. The trajectory generator of the self-supervised model with enhanced spatial relationships consists of an embedding layer, a first linear layer, a GELU activation function, a second linear layer, a normalization layer, and a Softmax function.
[0056] S8-2. Input the user's current POI point into the embedding layer of the trajectory generator, outputting the POI point's embedding vector. Concatenate the POI point's embedding vector with the guided representation E' to obtain the initial input representation. ;
[0057] S8-3. Represent the initial input The input is fed into the first linear layer of the trajectory generator, and the output is a high-dimensional hidden representation h. The high-dimensional hidden representation h is then fed into the GELU activation function of the trajectory generator, and the output is a vector h'. The vector h' is then fed into the second linear layer and the normalization layer of the trajectory generator, and the output is a score vector Z. The score vector Z is then fed into the Softmax function of the trajectory generator, and the output is the set of POIs from the user's current location to the POIs. Probability distribution of each POI point ;
[0058] S8-4. Probability distribution of each POI point After selecting the POI with the highest probability value to replace the POI where the user is located in step S8-2, repeat steps S8-2 to S8-3 until the probability distribution of each POI is obtained. The POI with the highest probability value is the user's target destination.
[0059] S8-5. The recommended trajectory route is formed by the user's current POI, the user's destination, and the POIs with the highest probability values between the user's current POI and the user's destination.
[0060] Furthermore, it also includes using the Adam optimizer to train a spatial relation-enhanced self-supervised model with a total loss L_total, resulting in an optimized spatial relation-enhanced self-supervised model.
[0061] Furthermore, through the formula The total loss L_total is calculated, where For cross-entropy loss, For InfoNCE losses, and All of these are hyperparameters.
[0062] The beneficial effects of this invention are:
[0063] This paper employs a self-supervised trajectory learning method with spatial relationship enhancement, using four different data augmentation strategies to increase data diversity and address the potential problem of sparsity in check-in data. A decoupling and fusion mechanism for different data types is designed, enabling the model to intelligently integrate multi-source heterogeneous data such as POI geographic information, user access categories, time features, and location encoding, and dynamically adjust the weights of different feature types through a gating mechanism. A self-attention mechanism is used to enable the model to deeply integrate spatiotemporal context information, generating semantically rich trajectory vector representations. A masking task is designed to enhance the model's ability to represent complex trajectory contexts, allowing it to uncover deeper spatiotemporal dependencies between POIs. Subsequently, through comparative learning of dual views, the model can automatically learn highly discriminative and robust trajectory semantic representations from massive amounts of unlabeled trajectory data, effectively capturing the similarity relationships between trajectories and the essential features of user movement patterns. To address the problem that traditional sequence models rely solely on implicit learning and struggle to effectively model long-distance spatial relationships between origin and destination, a spatial relationship encoder is designed to capture global spatial relationships through anchor point offset calculation and attention aggregation. Simultaneously, in the downstream recommendation task, the model combines the origin and destination information provided by the user to recommend complete travel routes. Detailed Implementation
[0064] The present invention will be further described below.
[0065] A self-supervised trajectory learning-based tourism route recommendation method based on spatial relationship enhancement includes:
[0066] S1. Obtain Each POI, its category, latitude and longitude information, and the user. The set of trajectories, A set of POI points consists of several POI points. , ,in For the first The POI point, the ... The categories corresponding to each POI are: The category set is , , No. The latitude and longitude information corresponding to each POI point is: Latitude and longitude information set , , No. The trajectory set of each user is , ,in For the first The first user's A sequence of trajectories, , For the first Number of user trajectories ,in For the first The first user's The first of the trajectories A check-in location, , For the first The first user's The number of locations visited in each trajectory, the number of times the first location was checked in. The number of users accessing the first The first trajectory Each check-in location The time is , No. The number of users accessing the first The time set of each trajectory is , .
[0067] S2. Utilizing latitude and longitude information sets Construct the distance matrix .
[0068] S3. According to the first The trajectory sets of each user yield enhanced sequences view1, view2, and trajectory sequences. .
[0069] S4. Establish a self-supervised model for spatial relationship enhancement, consisting of a multi-type data decoupling and fusion module, a context-aware encoding module, a spatial relationship-aware encoder, and a trajectory generator.
[0070] S5. Enhance the sequence view1, view2, and trajectory sequence. Category set Time set Trajectory Sequence The input is fed into the multi-type data decoupling and fusion module of the self-supervised model for spatial relationship enhancement, and the output is fused feature representation fused_emb, fused feature representation fused_emb_v1, and fused feature representation fused_emb_v2.
[0071] S6. Input the fused feature representations fused_emb, fused_emb_v1, and fused_emb_v2 into the context-aware encoding module of the spatial relation enhancement self-supervised model, and output the unified representation E.
[0072] S7. Input the unified representation E into the spatial relation-aware encoder of the self-supervised model for spatial relation enhancement, and output the guided representation E'.
[0073] S8. Input the guided representation E' and the user's current POI into the trajectory generator of the spatial relationship enhancement self-supervised model, and output the recommended trajectory route.
[0074] This effectively addresses the limitations of existing models that over-rely on implicit learning sequence transfer patterns, lack global space modeling capabilities, and struggle to effectively handle sparse data scenarios, providing an innovative solution for the development of travel route recommendation systems.
[0075] In one embodiment of the present invention, step S1 involves obtaining data from the Weeplaces dataset. Each POI, its category, latitude and longitude information, and the user. The set of trajectories.
[0076] In one embodiment of the present invention, step S2 uses the Haversine formula to calculate the first... Points of Interest (POIs) With the Points of Interest (POIs) Distance between Distance matrix have OK Columns, distance matrix The Middle Line number The elements of the column are , .
[0077] In one embodiment of the present invention, step S3 includes the following steps:
[0078] S3-1. The first The trajectory set of each user is All of them Each trajectory undergoes initial data augmentation using random insertion, random deletion, random masking, or random truncation. The data augmented after the first data augmentation... The trajectories constitute the enhanced sequence view1. This significantly increases the diversity of training samples.
[0079] S3-2. The first The trajectory set of each user is All of them Each trajectory undergoes a second data augmentation using random insertion, random deletion, random masking, or random truncation. This second data augmentation differs from the first. The resulting data after the second augmentation... The trajectories constitute the enhanced sequence view2.
[0080] S3-3. In the... User trajectory set The first trajectory With the A trajectory Select 15-30% of the intermediate points, replace 80% of the selected intermediate points with the [MASK] marker, and replace the check-in locations in the trajectory of the remaining 10% of the selected intermediate points with a set of POI points. For any POI point, add a [CLS] marker at the beginning and a [SEP] marker at the end of the trajectory of the 10% selected intermediate points, completing the first step. User trajectory set The masking operation yields the trajectory sequence. .
[0081] In one embodiment of the present invention, step S5 includes the following steps:
[0082] S5-1. The multi-type data decoupling and fusion module of the self-supervised model for spatial relationship enhancement consists of a first embedding layer, a second embedding layer, a third embedding layer, a position embedding layer of the Transformer model, a linear layer, and a Sigmoid activation function.
[0083] S5-2. Trajectory Sequence The enhanced sequences view1 and view2 are input into the first embedding layer of the multi-type data decoupling and fusion module, respectively, to convert the discrete POI IDs into a dense vector representation with fixed dimensions, and output the POI embedding sequences E_s, E_v1, and E_v2 respectively.
[0084] S5-3. Class Set The data is input into the second embedding layer of the multi-type data decoupling and fusion module, mapped to a dimension-reduced vector space, and transformed from the original time dimension to the target dimension to obtain the category embedding representation E_c.
[0085] S5-4. Time Set The input is fed into the third embedding layer of the multi-type data decoupling and fusion module, and the output is the time embedding representation E_t.
[0086] S5-5. Trajectory Sequence The input is fed into the position embedding layer of the Transformer model in the multi-type data decoupling and fusion module, and the output is the position code E_p.
[0087] S5-6. After concatenating the POI embedding sequence E_s with the class embedding representation E_c, the concatenation is input into the linear layer of the multi-type data decoupling and fusion module, and the output is the POI-class joint representation E_pc. The POI-class joint representation E_pc, the temporal embedding representation E_t, and the position code E_p are then input into the Sigmoid activation function of the multi-type data decoupling and fusion module, and the outputs are the gating weights in the 0-1 interval. Gating weights Gating weights Through formula Weighted fusion is performed to calculate the fused feature representation fused_emb.
[0088] S5-7. After concatenating the POI embedding sequence E_v1 with the class embedding representation E_c, the concatenation is input into the linear layer of the multi-type data decoupling and fusion module, and the output is the POI-class joint representation E_pc1. The POI-class joint representation E_pc1, the temporal embedding representation E_t, and the position code E_p are then input into the Sigmoid activation function of the multi-type data decoupling and fusion module, and the outputs are the POI-class gating weights. Time-gating weights Location gating weights Through formula The fusion feature representation fused_emb_v1 is calculated.
[0089] S5-8. After concatenating the POI embedding sequence E_v2 with the class embedding representation E_c, the concatenation is input into the linear layer of the multi-type data decoupling and fusion module, and the output is the POI-class joint representation E_pc2. The POI-class joint representation E_pc2, the temporal embedding representation E_t, and the position code E_p are then input into the Sigmoid activation function of the multi-type data decoupling and fusion module, and the outputs are the POI-class gating weights. Time-gating weights Location gating weights Through formula The fused feature representation fused_emb_v2 is calculated.
[0090] In one embodiment of the present invention, step S6 includes the following steps:
[0091] S6-1. The context-aware encoding module of the self-supervised model for enhancing spatial relationships consists of a Transformer encoder, a linear layer, a GELU activation function, a normalization layer, a first projection head, a second projection head, a cross-attention layer, a gated fusion layer, and a layer normalization layer.
[0092] S6-2. The fused feature representations fused_emb, fused_emb_v1, and fused_emb_v2 are input into the Transformer encoder of the context-aware coding module, respectively. The Transformer encoder calculates the attention weights of all position pairs in the sequence. Each attention head captures the contextual dependencies of the sequence from different subspaces and outputs the context-aware sequence representation Hu, the encoding identifier CLS1 of the augmented view, and the encoding identifier CLS2 of the augmented view, respectively.
[0093] S6-3. The context-aware sequence representation Hu is sequentially input into the linear layer, GELU activation function, and normalization layer of the context-aware encoding module, and a stable representation Hm is output. The linear layer projects the context representation at each position onto a high-dimensional feature space, the GELU activation function performs a nonlinear transformation to enhance the model's expressive power, and the normalization layer stabilizes the numerical distribution.
[0094] S6-4. The first projection head of the context-aware encoding module consists of a linear transformation layer, a ReLU activation function, and a normalization layer. The encoded identifier CLS1 of the enhanced view is input into the first projection head, and the normalized representation Hp1 is output. The linear transformation layer maps the input to a hidden space of the same dimension, and the ReLU activation function performs a non-linear transformation.
[0095] S6-5. The second projection head of the context-aware encoding module consists of a linear transformation layer, a ReLU activation function, and a normalization layer. The encoded identifier CLS2 of the enhanced view is input into the second projection head, and the normalized representation Hp2 is output. The linear transformation layer maps the input to a hidden space of the same dimension, and the ReLU activation function performs a non-linear transformation.
[0096] S6-6. Through formula The uniform trajectory representation Hc is calculated, where... These are learnable fusion weights.
[0097] S6-7. The cross-attention layer of the context-aware coding module is composed of a multi-head attention mechanism. The stable representation Hm is concatenated with the unified trajectory representation Hc to obtain the fused representation Hu'. The fused representation Hu' is input into the cross-attention layer of the context-aware coding module, and the weighted representation Ha of the attention is output.
[0098] S6-8. The gated fusion layer of the context-aware coding module consists of a linear transformation layer and a sigmoid activation function. The attention-weighted representation Ha is concatenated with the stable representation Hm to obtain the feature H_concat. The feature H_concat is input into the linear transformation layer of the gated fusion layer, and the output is the gate score g. The gate score g is input into the sigmoid activation function of the gated fusion layer, and the output is the gate weight gate.
[0099] S6-9. Through formula The preliminary unified representation H_p is obtained by calculation, where To perform element-wise multiplication, the initial unified representation H_p is added to the stable representation Hm and then input into the layer normalization layer of the context-aware coding module, and the unified representation E is output.
[0100] In one embodiment of the present invention, step S7 includes the following steps:
[0101] S7-1. The spatial relation perception encoder of the self-supervised model for spatial relation enhancement consists of a first embedding layer, a second embedding layer, a third embedding layer, K linear layers, and an average pooling layer.
[0102] S7-2. The first The first user's A trajectory sequence The first place to check in As start_id, the first The first user's A trajectory sequence The last place to check in As end_id, it forms the anchor pair (start_id, end_id).
[0103] S7-3. Input the anchor point pair (start_id, end_id) into the first embedding layer of the spatial relationship-aware encoder, and output the anchor point representation Ai.
[0104] S7-4. From the... The first user's A trajectory sequence Except for the first check-in location and the last place to check in Arbitrarily select a check-in location and input it into the second embedding layer of the spatial relationship-aware encoder to obtain a positive sample representation. .
[0105] S7-5. From the... Trajectory set of individual users Except for the first A trajectory sequence In any chosen trajectory sequence Each check-in location will The locations visited during each check-in are input into the third embedding layer of the spatial relationship-aware encoder, and the output is a sequence of negative sample representations. , ,in For the first One negative sample represents, .
[0106] S7-6. Through formula The offset vector of the positive sample is calculated. Through formula The average value of the negative samples was calculated. Through formula The offset vector of the negative sample is calculated. .
[0107] S7-7. The offset vector of the positive samples offset vector of negative samples After the stitching operation, the data are input into the K linear layers of the spatial relationship-aware encoder, and the output yields K relationship perspectives. ,in This is the relational perspective output by the k-th linear layer. Stacking all K relational perspectives yields a 3D relational tensor. .
[0108] S7-8. Through formula The query matrix of the multi-head attention mechanism is calculated. In the formula These are learnable parameters; obtained through formulas The key matrix of the multi-head attention mechanism is calculated. In the formula These are learnable parameters; obtained through formulas The value matrix of the multi-head attention mechanism was calculated. In the formula These are learnable parameters.
[0109] S7-9. Through formula Calculate the attention weights In the formula The Softmax activation function is used. To transpose, use the formula Calculate the output .
[0110] S7-10. Output The input is fed into the average pooling layer of the spatial relation-aware encoder, and the output is a fused relation vector. .
[0111] S7-11. Through formula The guided representation E' is calculated.
[0112] In one embodiment of the present invention, step S8 includes the following steps:
[0113] S8-1. The trajectory generator of the self-supervised model with enhanced spatial relationships consists of an embedding layer, a first linear layer, a GELU activation function, a second linear layer, a normalization layer, and a softmax function.
[0114] S8-2. Input the user's current POI point into the embedding layer of the trajectory generator, outputting the POI point's embedding vector. Concatenate the POI point's embedding vector with the guided representation E' to obtain the initial input representation. .
[0115] S8-3. Represent the initial input The input is fed into the first linear layer of the trajectory generator, and the output is a high-dimensional hidden representation h. The high-dimensional hidden representation h is then fed into the GELU activation function of the trajectory generator, and the output is a vector h'. The vector h' is then fed into the second linear layer and the normalization layer of the trajectory generator, and the output is a score vector Z. The score vector Z is then fed into the Softmax function of the trajectory generator, and the output is the set of POIs from the user's current location to the POIs. Probability distribution of each POI point The first linear layer expands the dimensions to obtain a high-dimensional hidden representation h, enhancing the model's expressive power. Then, a non-linear transformation using the GELU activation function is applied, causing some neurons to be suppressed with a certain probability, thus enhancing the model's generalization ability. Finally, a second linear layer compresses the dimensions back to the original dimensions, unifying the input and output dimensions.
[0116] S8-4. Probability distribution of each POI point After selecting the POI with the highest probability value to replace the POI where the user is located in step S8-2, repeat steps S8-2 to S8-3 until the probability distribution of each POI is obtained. The POI with the highest probability value is the user's target destination.
[0117] S8-5. The recommended trajectory route is formed by the user's current POI, the user's destination, and the POIs with the highest probability values between the user's current POI and the user's destination.
[0118] In one embodiment of the present invention, the method further includes using the Adam optimizer to train a self-supervised model for spatial relation enhancement with a total loss L_total, thereby obtaining an optimized self-supervised model for spatial relation enhancement.
[0119] In this embodiment, through the formula The total loss L_total is calculated, where For cross-entropy loss, For InfoNCE losses, and All of these are hyperparameters.
[0120] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention 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 embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A self-supervised trajectory learning tourism route recommendation method based on spatial relationship enhancement, characterized in that, include: S1. Obtain Each POI, its category, latitude and longitude information, and the user. The set of trajectories, A set of POI points consists of several POI points. , ,in For the first The POI point, the ... The categories corresponding to each POI are: The category set is , , No. The latitude and longitude information corresponding to each POI point is: Latitude and longitude information set , , No. The trajectory set of each user is , ,in For the first The first user's A sequence of trajectories, , For the first Number of user trajectories ,in For the first The first user's The first of the trajectories A check-in location, , For the first The first user's The number of locations visited in each trajectory, the number of times the first location was checked in. The number of users accessing the first The first trajectory Each check-in location The time is , No. The number of users accessing the first The time set of each trajectory is , ; S2. Utilizing latitude and longitude information sets Construct the distance matrix ; S3. According to the first The trajectory sets of each user yield enhanced sequences view1, view2, and trajectory sequences. ; S4. Establish a self-supervised model for spatial relationship enhancement, consisting of a multi-type data decoupling and fusion module, a context-aware encoding module, a spatial relationship-aware encoder, and a trajectory generator; S5. Enhance the sequence view1, view2, and trajectory sequence. Category set Time set Trajectory Sequence The data is input into the multi-type data decoupling and fusion module of the self-supervised model for spatial relationship enhancement, and the output is fused feature representation fused_emb, fused feature representation fused_emb_v1, and fused feature representation fused_emb_v2. S6. Input the fused feature representations fused_emb, fused_emb_v1, and fused_emb_v2 into the context-aware encoding module of the self-supervised model for spatial relation enhancement, and output a unified representation E. S7. Input the unified representation E into the spatial relation-aware encoder of the self-supervised model for spatial relation enhancement, and output the guided representation E'. S8. Input the guided representation E' and the user's current POI into the trajectory generator of the spatial relationship enhancement self-supervised model, and output the recommended trajectory route.
2. The self-supervised trajectory learning tourism route recommendation method based on spatial relationship enhancement according to claim 1, characterized in that: In step S1, obtain from the Weeplaces dataset Each POI, its category, latitude and longitude information, and the user. The set of trajectories.
3. The self-supervised trajectory learning tourism route recommendation method based on spatial relationship enhancement according to claim 1, characterized in that: In step S2, the Haversine formula is used to calculate the first... Points of Interest (POIs) With the Points of Interest (POIs) Distance between Distance matrix have OK Columns, distance matrix The Middle Line number The elements of the column are , .
4. The self-supervised trajectory learning tourism route recommendation method based on spatial relationship enhancement according to claim 1, characterized in that, Step S3 includes the following steps: S3-1. The first The trajectory set of each user is All of them Each trajectory undergoes initial data augmentation using random insertion, random deletion, random masking, or random truncation. The data augmented after the first data augmentation... The trajectories constitute the enhanced sequence view1; S3-2. The first The trajectory set of each user is All of them Each trajectory undergoes a second data augmentation using random insertion, random deletion, random masking, or random truncation. This second data augmentation differs from the first. The resulting data after the second augmentation... The trajectories constitute the enhanced sequence view2; S3-3. In the... User trajectory set The first trajectory With the A trajectory Select 15-30% of the intermediate points, replace 80% of the selected intermediate points with the [MASK] marker, and replace the check-in locations in the trajectory of the remaining 10% of the selected intermediate points with a set of POI points. For any POI point, add a [CLS] marker at the beginning and a [SEP] marker at the end of the trajectory of the 10% selected intermediate points, completing the first step. User trajectory set The masking operation yields the trajectory sequence. .
5. The self-supervised trajectory learning tourism route recommendation method based on spatial relationship enhancement according to claim 1, characterized in that, Step S5 includes the following steps: S5-1. The multi-type data decoupling and fusion module of the self-supervised model for spatial relationship enhancement consists of a first embedding layer, a second embedding layer, a third embedding layer, a position embedding layer of the Transformer model, a linear layer, and a Sigmoid activation function; S5-2. Trajectory Sequence The enhanced sequences view1 and view2 are respectively input into the first embedding layer of the multi-type data decoupling and fusion module, and the POI embedding sequences E_s, E_v1, and E_v2 are respectively output. S5-3. Class Set The input is fed into the second embedding layer of the multi-type data decoupling and fusion module, and the output is the category embedding representation E_c; S5-4. Time Set The input is fed into the third embedding layer of the multi-type data decoupling and fusion module, and the output is the time embedding representation E_t; S5-5. Trajectory Sequence The input is fed into the position embedding layer of the Transformer model in the multi-type data decoupling and fusion module, and the output is the position code E_p; S5-6. After concatenating the POI embedding sequence E_s with the class embedding representation E_c, the concatenation is input into the linear layer of the multi-type data decoupling and fusion module, and the output is the POI-class joint representation E_pc. The POI-class joint representation E_pc, the temporal embedding representation E_t, and the position code E_p are then input into the Sigmoid activation function of the multi-type data decoupling and fusion module, and the outputs are the POI-class gating weights. Time-gating weights Location gating weights Through formula Weighted fusion is performed to calculate the fused feature representation fused_emb; S5-7. After concatenating the POI embedding sequence E_v1 with the class embedding representation E_c, the concatenation is input into the linear layer of the multi-type data decoupling and fusion module, and the output is the POI-class joint representation E_pc1. The POI-class joint representation E_pc1, the temporal embedding representation E_t, and the position code E_p are then input into the Sigmoid activation function of the multi-type data decoupling and fusion module, and the outputs are the POI-class gating weights. Time-gating weights Location gating weights Through formula The fused feature representation fused_emb_v1 is calculated. S5-8. After concatenating the POI embedding sequence E_v2 with the class embedding representation E_c, the concatenation is input into the linear layer of the multi-type data decoupling and fusion module, and the output is the POI-class joint representation E_pc2. The POI-class joint representation E_pc2, the temporal embedding representation E_t, and the position code E_p are then input into the Sigmoid activation function of the multi-type data decoupling and fusion module, and the outputs are the POI-class gating weights. Time-gating weights Location gating weights Through formula The fused feature representation fused_emb_v2 is calculated.
6. The self-supervised trajectory learning tourism route recommendation method based on spatial relationship enhancement according to claim 1, characterized in that, Step S6 includes the following steps: S6-1. The context-aware encoding module of the self-supervised model for enhancing spatial relationships consists of a Transformer encoder, a linear layer, a GELU activation function, a normalization layer, a first projection head, a second projection head, a cross-attention layer, a gated fusion layer, and a layer normalization layer. S6-2. Input the fused feature representation fused_emb, fused feature representation fused_emb_v1, and fused feature representation fused_emb_v2 into the Transformer encoder of the context-aware coding module, and output the context-aware sequence representation Hu, the encoding identifier CLS1 of the augmented view, and the encoding identifier CLS2 of the augmented view, respectively. S6-3. Input the context-aware sequence representation Hu into the linear layer, GELU activation function, and normalization layer of the context-aware coding module in sequence, and output a stable representation Hm; S6-4. The first projection head of the context-aware encoding module consists of a linear transformation layer, a ReLU activation function, and a normalization layer. The encoding identifier CLS1 of the enhanced view is input into the first projection head, and the normalized representation Hp1 is output. S6-5. The second projection head of the context-aware encoding module consists of a linear transformation layer, a ReLU activation function, and a normalization layer. The encoding identifier CLS2 of the enhanced view is input into the second projection head, and the normalized representation Hp2 is output. S6-6. Through formula The uniform trajectory representation Hc is calculated, where... These are learnable fusion weights; S6-7. The cross-attention layer of the context-aware coding module is composed of a multi-head attention mechanism, which concatenates the stable representation Hm with the unified trajectory representation Hc to obtain the fused representation Hu'. The fused representation Hu' is then input into the cross-attention layer of the context-aware coding module, and the weighted representation Ha of the attention is output. S6-8. The gated fusion layer of the context-aware coding module consists of a linear transformation layer and a sigmoid activation function. The attention-weighted representation Ha is concatenated with the stable representation Hm to obtain the feature H_concat. The feature H_concat is input into the linear transformation layer of the gated fusion layer, and the output is the gate score g. The gate score g is input into the sigmoid activation function of the gated fusion layer, and the output is the gate weight gate. S6-9. Through formula The preliminary unified representation H_p is obtained by calculation, where To perform element-wise multiplication, the initial unified representation H_p is added to the stable representation Hm and then input into the layer normalization layer of the context-aware coding module, and the unified representation E is output.
7. The self-supervised trajectory learning tourism route recommendation method based on spatial relationship enhancement according to claim 1, characterized in that, Step S7 includes the following steps: S7-1. The spatial relationship-aware encoder of the self-supervised model for spatial relationship enhancement consists of a first embedding layer, a second embedding layer, a third embedding layer, K linear layers, and an average pooling layer. S7-2. The first The first user's A trajectory sequence The first place to check in As start_id, the first The first user's A trajectory sequence The last place to check in As end_id, it forms the anchor pair (start_id, end_id); S7-3. Input the anchor point pair (start_id, end_id) into the first embedding layer of the spatial relationship-aware encoder, and output the anchor point representation Ai; S7-4. From the... The first user's A trajectory sequence Except for the first check-in location and the last place to check in Arbitrarily select a check-in location and input it into the second embedding layer of the spatial relationship-aware encoder to obtain a positive sample representation. ; S7-5. From the... Trajectory set of individual users Except for the first A trajectory sequence In any chosen trajectory sequence Each check-in location will The locations visited during each check-in are input into the third embedding layer of the spatial relationship-aware encoder, and the output is a sequence of negative sample representations. , ,in For the first One negative sample represents, ; S7-6. Through formula The offset vector of the positive sample is calculated. Through formula The average value of the negative samples was calculated. Through formula The offset vector of the negative sample is calculated. ; S7-7. The offset vector of the positive samples offset vector of negative samples After the stitching operation, the data are input into the K linear layers of the spatial relationship-aware encoder, and the output yields K relationship perspectives. ,in This is the relational perspective output by the k-th linear layer. Stacking all K relational perspectives yields a 3D relational tensor. ; S7-8. Through formula The query matrix of the multi-head attention mechanism is calculated. In the formula These are learnable parameters; obtained through formulas The key matrix of the multi-head attention mechanism is calculated. In the formula These are learnable parameters; obtained through formulas The value matrix of the multi-head attention mechanism was calculated. In the formula These are learnable parameters; S7-9. Through formula Calculate the attention weights In the formula The Softmax activation function is used. To transpose, use the formula Calculate the output ; S7-10. Output The input is fed into the average pooling layer of the spatial relation-aware encoder, and the output is a fused relation vector. ; S7-11. Through formula The guided representation E' is calculated.
8. The self-supervised trajectory learning tourism route recommendation method based on spatial relationship enhancement according to claim 1, characterized in that, Step S8 includes the following steps: S8-1. The trajectory generator of the self-supervised model with enhanced spatial relationships consists of an embedding layer, a first linear layer, a GELU activation function, a second linear layer, a normalization layer, and a Softmax function. S8-2. Input the user's current POI point into the embedding layer of the trajectory generator, outputting the POI point's embedding vector. Concatenate the POI point's embedding vector with the guided representation E' to obtain the initial input representation. ; S8-3. Represent the initial input The input is fed into the first linear layer of the trajectory generator, and the output is a high-dimensional hidden representation h. The high-dimensional hidden representation h is then fed into the GELU activation function of the trajectory generator, and the output is a vector h'. The vector h' is then fed into the second linear layer and the normalization layer of the trajectory generator, and the output is a score vector Z. The score vector Z is then fed into the Softmax function of the trajectory generator, and the output is the set of POIs from the user's current location to the POIs. Probability distribution of each POI point ; S8-4. Probability distribution of each POI point After selecting the POI with the highest probability value to replace the POI where the user is located in step S8-2, repeat steps S8-2 to S8-3 until the probability distribution of each POI is obtained. The POI with the highest probability value is the user's target destination. S8-5. The recommended trajectory route is formed by the user's current POI, the user's destination, and the POIs with the highest probability values between the user's current POI and the user's destination.
9. The self-supervised trajectory learning tourism route recommendation method based on spatial relationship enhancement according to claim 1, characterized in that: It also includes using the Adam optimizer to train a self-supervised model with enhanced spatial relations using the total loss L_total, resulting in an optimized self-supervised model with enhanced spatial relations.
10. The self-supervised trajectory learning tourism route recommendation method based on spatial relationship enhancement according to claim 9, characterized in that: Through formula The total loss L_total is calculated, where For cross-entropy loss, For InfoNCE losses, and All of these are hyperparameters.
Citation Information
Patent Citations
POI recommendation method fusing social relation network and spatio-temporal context information
CN119691292A
Regional perception dynamic hypergraph and double-layer modeling-based interest point recommendation method
CN120429503A