Method and apparatus for constructing vehicle routes with time windows

CN122414958BActive Publication Date: 2026-10-09HUNAN ELECTRICAL COLLEGE OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610805302.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-06-05
Publication Date
2026-10-09
Estimated Expiration
2046-06-05

AI Technical Summary

Technical Problem

传统精确算法(如分支定界)在大规模实例上计算成本过高;元启发式算法(如禁忌搜索、蜂群算法)虽速度尚可,但难以保证解质量;基于深度强化学习的神经构造方法通过训练学习路径模式,推理速度快,但现有方法在时间窗约束的架构设计和约束处理策略上存在明显缺陷

Benefits of technology

[0015]Based on the aforementioned vehicle path construction method with time windows, a path problem with capacity and time window constraints for the target vehicle is obtained. The encoder encodes customer nodes and warehouse nodes, obtaining node embedding vectors and global mean embeddings for each node. The decoder concatenates and projects the node embedding vector of the current node, the remaining capacity of the target vehicle, the arrival time of the target vehicle, and the speed of the target vehicle to obtain a time-aware query vector. The selection probability of each customer node is determined based on the time-aware query vector, thus identifying the target customer node. Explicit time status updates are performed on the target customer node, obtaining its updated current arrival time, updated used capacity, and updated current position. After traversing all customer nodes, the vehicle path solution is output. Thus, by combining explicit time-aware status with time window information for path planning, the accuracy of path planning can be improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122414958B_ABST
    Figure CN122414958B_ABST
Patent Text Reader

Abstract

The application provides a vehicle path construction method and device with a time window. The method comprises the following steps: obtaining a path problem with a capacity and a time window constraint of a target vehicle; encoding customer nodes and warehouse nodes based on an encoder to obtain node embedding vectors and a global mean embedding; determining a time-aware query vector based on a decoder according to a node embedding vector of a current node, a remaining capacity, a time of arriving at the current node, and a target vehicle speed; determining a selection probability of each customer node according to the time-aware query vector to obtain a target customer node; performing explicit time state updating on the target customer node to obtain an updated current arrival time of the target customer node, an updated used capacity of the target vehicle, and an updated current position of the target vehicle; and outputting a vehicle path scheme after traversing all the customer nodes. By combining an explicit time-aware state and time window information for path planning, the accuracy of path planning can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of route planning technology, and more specifically to a method and apparatus for constructing vehicle routes with time windows. Background Technology

[0002] With the rapid expansion of e-commerce and the express delivery industry, large-scale delivery networks have created an urgent need for path planning systems to simultaneously meet the triple requirements of "near-optimal solution quality, real-time response, and complex constraint handling." Traditional exact algorithms (such as branch and bound) are computationally too expensive on large-scale instances; metaheuristic algorithms (such as tabu search and bee colony optimization) are relatively fast, but struggle to guarantee solution quality; neural construction methods based on deep reinforcement learning learn path patterns through training, resulting in fast inference speeds, but existing methods have significant shortcomings in the architectural design of time window constraints and constraint handling strategies. Summary of the Invention

[0003] This application aims to provide a method and apparatus for constructing vehicle routes with time windows to improve the accuracy of vehicle route planning.

[0004] Firstly, a method for constructing vehicle paths with time windows is provided, the method comprising: The path problem with capacity and time window constraints is used to obtain the target vehicle. The path problem with capacity and time window constraints includes customer nodes and warehouse nodes. The customer nodes and warehouse nodes are encoded based on the encoder to obtain the node embedding vector and global mean embedding of each node. Based on the decoder, the node embedding vector of the current node, the remaining capacity of the target vehicle, the time when the target vehicle arrives at the current node, and the speed of the target vehicle are stitched together and projected to obtain the time-aware query vector. The selection probability of each customer node is determined based on the time-aware query vector to obtain the target customer node; Explicitly update the time status of the target customer node to obtain the updated current arrival time of the target customer node, the updated used capacity of the target vehicle, and the updated current location of the target vehicle. After traversing all customer nodes, output the vehicle routing plan.

[0005] Optionally, the customer node includes five-dimensional original features, which include coordinate information, demand, time window start time, and time window end time.

[0006] Optionally, customer nodes and warehouse nodes are encoded based on the encoder to obtain the node embedding vector and global mean embedding for each node, including: The five-dimensional original features of each node are mapped to the initial embedding of the target dimension through a linear projection layer; Multi-head self-attention computation is performed based on the initial embedding to obtain the multi-head concatenation output; The multi-head splicing output is combined with the initial embedding and then residually connected and normalized to obtain the node's embedding vector. The global mean embedding is obtained by averaging the embedding vectors of each node.

[0007] Optionally, the time-aware query vector is represented as:

[0008] in, Represents a time-aware query vector. This indicates global mean embedding. This represents the learnable projection matrix, used to project the concatenated multidimensional vector back to the target dimension. This represents the embedding vector of the current node. Indicates the remaining capacity of the target vehicle. Indicates the current arrival time. Indicates the speed of the target vehicle.

[0009] Optionally, the target customer node is explicitly updated with its time status to obtain the updated current arrival time, the updated used capacity of the target vehicle, and the updated current location of the target vehicle, including: The driving distance is determined based on the coordinates of the target customer node and the coordinates of the current node; The updated current arrival time is determined based on the travel distance, current arrival time, and the target vehicle's speed. The updated used capacity of the target vehicle is determined by the sum of the used capacity of the target vehicle and the demand of the target customer node. The current location of the target customer node is determined as the updated current location of the target vehicle.

[0010] Optionally, the updated current arrival time is determined based on the travel distance, current arrival time, and target vehicle speed, including: The ratio of the travel distance to the target vehicle's speed is defined as the target time. If the sum of the current arrival time and the target time is less than the start time of the time window corresponding to the target customer node, the start time of the time window corresponding to the target customer node will be determined as the updated current arrival time. If the sum of the current arrival time and the target time is greater than or equal to the start time of the time window corresponding to the target customer node, the sum will be determined as the updated current arrival time.

[0011] Secondly, a vehicle path construction device with a time window is provided, characterized in that the device comprises: The acquisition module is used to acquire the path problem with capacity and time window constraints for the target vehicle. The path problem with capacity and time window constraints includes customer nodes and warehouse nodes. The encoding module is used to encode customer nodes and warehouse nodes based on the encoder to obtain the node embedding vector and global mean embedding of each node. The decoding module is used to stitch and project the node embedding vector of the current node, the remaining capacity of the target vehicle, the time when the target vehicle arrives at the current node, and the speed of the target vehicle based on the decoder to obtain the time-aware query vector. The determination module is used to determine the selection probability of each customer node based on the time-aware query vector, thereby obtaining the target customer node. The update module is used to explicitly update the time status of the target customer node, and obtain the updated current arrival time of the target customer node, the updated used capacity of the target vehicle, and the updated current location of the target vehicle. The output module is used to output the vehicle routing scheme after traversing all customer nodes.

[0012] Thirdly, an electronic device is provided, comprising: The memory is configured to store instructions; The processor is configured to retrieve instructions from memory and, when executing the instructions, to implement the time-windowed vehicle path construction method provided in the first aspect of the embodiments of this application.

[0013] Fourthly, a machine-readable storage medium is provided, on which instructions are stored, which cause a machine to execute the vehicle path construction method with time window described above.

[0014] Fifthly, a computer program product is provided, wherein when the instructions in the computer program product are executed by the processor of an electronic device, the electronic device performs the vehicle path construction method with time window as described above.

[0015] Based on the aforementioned vehicle path construction method with time windows, a path problem with capacity and time window constraints for the target vehicle is obtained. The encoder encodes customer nodes and warehouse nodes, obtaining node embedding vectors and global mean embeddings for each node. The decoder concatenates and projects the node embedding vector of the current node, the remaining capacity of the target vehicle, the arrival time of the target vehicle, and the speed of the target vehicle to obtain a time-aware query vector. The selection probability of each customer node is determined based on the time-aware query vector, thus identifying the target customer node. Explicit time status updates are performed on the target customer node, obtaining its updated current arrival time, updated used capacity, and updated current position. After traversing all customer nodes, the vehicle path solution is output. Thus, by combining explicit time-aware status with time window information for path planning, the accuracy of path planning can be improved. Attached Figure Description

[0016] Figure 1 This is a flowchart illustrating the vehicle path construction method with time windows provided in the embodiments of this application; Figure 2 This is a schematic diagram of the vehicle path construction device with time window provided in the embodiments of this application; Figure 3 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0017] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0018] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0019] The method and apparatus for constructing vehicle paths with time windows provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.

[0020] Please see Figure 1 This is a flowchart illustrating a vehicle path construction method with a time window provided in an embodiment of this application. This method is applied to electronic devices. Figure 1 As shown, the vehicle path construction method with time window includes the following steps S100 to S600.

[0021] Step S100: Obtain the path problem with capacity and time window constraints for the target vehicle. The path problem with capacity and time window constraints includes customer nodes and warehouse nodes.

[0022] In this embodiment, the Capacitated Vehicle Routing Problem with Time Windows (CVRPTW) is a core optimization problem in logistics and delivery scenarios. It requires planning the optimal delivery route for a group of vehicles while satisfying the maximum capacity of each vehicle and the time window for each customer service. CVRPTW consists of n customer nodes and one warehouse node. Each customer node contains 5-dimensional features: 2D coordinates (x, y), demand quantity d, and the start time of the time window. and the end time of the time window .

[0023] Step S200: Encode the customer node and warehouse node based on the encoder to obtain the node embedding vector and global mean embedding of each node.

[0024] In this embodiment, the encoder adopts a standard Transformer encoder architecture to encode the features of the input nodes, obtaining the node embedding vectors and global mean embeddings for each node. The five-dimensional original features of each node are mapped to initial embeddings of the target dimension through a linear projection layer. Multi-head self-attention calculation is performed based on the initial embeddings to obtain a multi-head concatenation output. The multi-head concatenation output is then residually connected to the initial embeddings and normalized to obtain the node embedding vectors. The global mean embedding is obtained by averaging the embedding vectors of each node.

[0025] Step S300: Based on the decoder, the node embedding vector of the current node, the remaining capacity of the target vehicle, the time when the target vehicle arrives at the current node, and the speed of the target vehicle are stitched together and projected to obtain the time-aware query vector.

[0026] In this embodiment, the decoder employs an explicit time-aware decoder. At each decision step, the decoder explicitly maintains the following state variable: current arrival time (the actual time the target vehicle arrives at the current node). target vehicle speed Remaining capacity of the target vehicle The node embedding vector of the current node Global mean embedding of all nodes This application adds a time-aware decoder to the decoder state by employing an explicit time-aware decoder. and This allows the decoder to directly query the current time at each decision step, without having to backtrack to calculate from historical sequences.

[0027] Specifically, except and In addition, this application can add more time status variables, such as the cumulative number of time window violations for the current path and the expiration time of the time window closest to the current vehicle's service, to further enrich the time status information.

[0028] The decoder constructs a time-aware query vector, explicitly concatenates spatial, capacity, and temporal information, and then projects it to obtain: ,in, Represents a time-aware query vector. This is a learnable projection matrix used to project the concatenated multidimensional vector back to its initial dimensions.

[0029] Then, the glimpse vector is calculated using multi-head attention to obtain: .

[0030] in, Represents a glimpse vector. This represents the linear transformation matrix on the query side. This represents the linear transformation matrix on the key side. Let f represent the linear transformation matrix on the Value side, and let f represent the embedding vector matrix of all nodes output by the encoder.

[0031] Step S400: Determine the selection probability of each customer node based on the time-aware query vector to obtain the target customer node.

[0032] In the embodiments of this application, using For the query, calculate the attention score for each node and convert it into a selection probability: , ; ; ; Where q represents the final query vector used for node selection. This represents the Query weight matrix of the decoder selection layer. This represents the key vector corresponding to the i-th node. This represents the key weight matrix of the decoder selection layer. This represents the node embedding vector of the i-th node output by the encoder. Let represent the original attention score of the i-th node, and C represent the scaling factor. Represents the query vector q and the key vector dot product, Indicates the scaling factor. This represents the current set of feasible nodes (unvisited and with sufficient capacity). C=10 compresses the score to [ To achieve better exploration results within a range of 10,10, infeasible nodes are... The mask ensures a zero probability. This represents the normalization of the attention scores o of all nodes to obtain the selection probability distribution of each node, where X represents the original feature set of all nodes, i.e., the input of the encoder. Indicates the first t Step 1: The selected node sequence, i.e., the historical path.

[0033] After obtaining the selection probability of each node, the target customer node can be determined based on the selection probability. Specifically, it can be based on greedy selection, choosing the node with the highest probability as the target customer node; or it can be based on sampling selection, randomly selecting a node as the target customer node according to probability.

[0034] Step S500: Explicitly update the time status of the target customer node to obtain the updated current arrival time of the target customer node, the updated used capacity of the target vehicle, and the updated current location of the target vehicle.

[0035] In this embodiment, the travel distance of the target vehicle can be determined based on the coordinates of the target customer node and the coordinates of the current node. The updated arrival time can be determined based on the travel distance, the current arrival time, and the target vehicle's speed. The updated used capacity of the target vehicle is then determined by summing the used capacity of the target vehicle with the demand of the target customer node. The used capacity of the target vehicle can be determined by subtracting its remaining capacity from its rated capacity. Finally, the current position of the target customer node is determined as the updated current position of the target vehicle.

[0036] Step S600: After traversing all customer nodes, output the vehicle route plan.

[0037] Through steps S100-S600, a path problem with capacity and time window constraints for the target vehicle is obtained. Customer nodes and warehouse nodes are encoded using an encoder to obtain node embedding vectors and global mean embeddings for each node. The current node's node embedding vector, the target vehicle's remaining capacity, the target vehicle's arrival time at the current node, and the target vehicle's speed are concatenated and projected using a decoder to obtain a time-aware query vector. The selection probability of each customer node is determined based on the time-aware query vector to obtain the target customer node. Explicit time status updates are performed on the target customer node to obtain its updated current arrival time, updated used capacity, and updated current position. After traversing all customer nodes, the vehicle path plan is output. Thus, by combining explicit time-aware status with time window information for path planning, the accuracy of path planning can be improved.

[0038] In some implementations, the client nodes and warehouse nodes are encoded based on the encoder to obtain the node embedding vector and global mean embedding for each node, including: The five-dimensional original features of each node are mapped to the initial embedding of the target dimension through a linear projection layer; Multi-head self-attention computation is performed based on the initial embedding to obtain the multi-head concatenation output; The multi-head splicing output is combined with the initial embedding and then residually connected and normalized to obtain the node's embedding vector. The global mean embedding is obtained by averaging the embedding vectors of each node.

[0039] Specifically, the five-dimensional original features of each node In this embodiment, the target dimension d can be 128 dimensions, mapped to an initial embedding of the target dimension through a linear projection layer. Let represent the original feature vector of the i-th node. This represents the horizontal coordinate of the i-th node. Represents the vertical coordinate of the i-th node. This represents the demand for the i-th node. This represents the start time of the time window for the i-th node. This represents the end time of the time window for the i-th node.

[0040] In this embodiment, a three-layer multi-head self-attention module (8 attention heads per layer) is used, and each attention head calculates: Query, Key, and Value.

[0041] in, This represents the query vector of the i-th node at the h-th attention head. This represents the Query weight matrix for the h-th attention head. Let represent the initial embedding vector of the i-th node. This represents the key vector of the i-th node at the h-th attention head. This represents the Key weight matrix of the h-th attention head. This represents the value vector of the i-th node at the h-th attention head. Let represent the Value weight matrix for the h-th attention head. , d represents the initial embedding dimension of the node, and H represents the total number of attention heads. This represents the output dimension of each attention head. In this embodiment, d=128, H=8. The association weights between nodes are then calculated using scaled dot product attention. Here, softmax(·) represents normalizing each row of the similarity matrix to obtain the attention weights of each node to other nodes. This represents the dot product between the query and the key, and calculates the similarity matrix between nodes. This represents the scaling factor, used to prevent the dot product result from becoming too large, which could cause the softmax function to enter the gradient saturation region. The output feature matrix of the h-th attention head is obtained by weighting the Value matrix with the attention weight matrix and summing the features of each node that incorporate global information.

[0042] After obtaining the output feature matrix of the attention head, multi-head output concatenation is performed: .

[0043] in, This represents the final output of the multi-head self-attention module. This represents the concatenation of the output feature matrices from all H attention heads. This represents the projection weight matrix of the multi-head output.

[0044] Finally, after two layers of residual connections and batch normalization, we obtain the node embedding vectors and global mean embeddings for each node.

[0045]

[0046]

[0047] Where BN represents batch normalization, Let represent the initial embedding vector of node i. This represents the output feature vector of node i after passing through the multi-head self-attention module. Let FF represent the intermediate feature vector of node i after passing through the multi-head self-attention module, residual connection, and batch normalization. This represents the final node embedding vector of node i after passing through the entire encoder layer (multi-head attention, feedforward network, and two residual and normalization operations). The encoder outputs the node embedding vector for each node. and global mean embedding .

[0048] In some implementations, the target customer node is explicitly updated with its time status to obtain the updated current arrival time, the updated used capacity of the target vehicle, and the updated current location of the target vehicle, including: The driving distance is determined based on the coordinates of the target customer node and the coordinates of the current node; The updated current arrival time is determined based on the travel distance, current arrival time, and the target vehicle's speed. The updated used capacity of the target vehicle is determined by the sum of the used capacity of the target vehicle and the demand of the target customer node. The current location of the target customer node is determined as the updated current location of the target vehicle.

[0049] Specifically, the driving distance is determined based on the coordinates of the target customer node and the coordinates of the current node;

[0050] The updated current arrival time is then determined based on the travel distance, current arrival time, and target vehicle speed. First, the target travel time is determined by the ratio of travel distance to target vehicle speed. If the sum of the current arrival time and the target time is less than the start time of the time window corresponding to the target customer node, the start time of the time window corresponding to the target customer node can be used as the updated current arrival time; that is, if the target vehicle arrives early, a wait is required. If the sum of the current arrival time and the target time is greater than or equal to the start time of the time window corresponding to the target customer node, the sum is used as the updated current arrival time; that is, if the target vehicle arrives on time or late, the actual arrival time is used as the updated current arrival time. The updated used capacity of the target vehicle can be determined by the sum of the target vehicle's used capacity and the target customer node's demand; the updated current location of the target customer node can be used as the updated current location of the target vehicle.

[0051] In a specific embodiment of this application, in addition to splicing projection to obtain the time-aware query vector, additive fusion can be used instead of splicing, cross-attention mechanism can be used to allow the time state vector to interact with the node embedding, and a small MLP encoder can be designed separately for the time state, and its output can be gated and fused with the spatial embedding.

[0052] In a specific embodiment of this application, in addition to using the timeout amount as a penalty, the number of timeout customers can be used instead of the timeout duration, a quadratic function of the timeout amount can be used as a penalty, or an adaptive penalty coefficient can be used.

[0053] In one specific embodiment of this application, the feasibility judgment condition of the hard mask during the inference phase can also introduce a more relaxed reachability judgment, considering the possible waiting after arrival and the chain reaction effect of subsequent nodes (forward constraint propagation), and preemptively eliminating nodes that are currently reachable but would cause all subsequent nodes to become unreachable, thereby reducing deadlocks during inference. Alternatively, a "predicted timeout probability" can be used instead of a deterministic mask, imposing a soft penalty on nodes with a high predicted timeout probability instead of completely masking them, thus making a smoother trade-off between feasibility assurance and solution quality.

[0054] In a specific embodiment of this application, in addition to greedy and sampling decoding strategies, beam search, active search, and a combination of local search can also be used.

[0055] In a specific embodiment of this application, in addition to REINFORCE + rolling baseline, the training algorithm may also employ proximal policy optimization (PPO), the actor-critic method, and multi-start point optimization algorithms.

[0056] In this embodiment, the time window processing logic can be divided into early arrival and on-time / late arrival. When arriving early, wait until the time window opens (no penalty is incurred). When arriving on time or late, record the actual arrival time. If the actual arrival time is greater than the end time of the time window, the timeout amount (the difference between the actual arrival time and the end time of the time window) is included in the penalty item of the hybrid cost (allowed during training, but if a hard mask is enabled during inference, this node will be masked in advance).

[0057] In the embodiments of this application, different constraint processing modes are adopted in the training phase and the inference phase, which solves the contradiction between training flexibility and deployment feasibility in existing methods.

[0058] Soft constraints with theoretically derived penalty coefficients are used during the training phase. A hybrid cost function is used as the optimization objective during training.

[0059] Wherein, it means, This represents the total path length of the j-th vehicle. This represents the sum of timeouts for all customers in path j. This represents the time window violation penalty coefficient, which is the equivalent path length penalty coefficient corresponding to a unit timeout.

[0060] Penalty coefficient ,in, Indicates the length of working time. This represents the average single-vehicle path length in the initial planning solution of the problem instance. This represents the dimensionless penalty scaling factor.

[0061] If a customer is late by a full business day, the penalty should be increased in conjunction with the increased path length. This ensures that the time and space objectives are comparable in terms of scale by using equal quantities. In one example, this could be achieved by... This means that a one-working-day timeout is equivalent to a three-fold increase in path length. This derivation method eliminates the need to re-search for the penalty coefficient for each problem size, significantly reducing hyperparameter tuning costs. By not using hard masks for time windows during training, the policy is allowed to explore near-feasible regions, learning a trade-off strategy of "accepting short timeouts for a better global path."

[0062] During the inference phase, a hard mask can be enabled, and the feasible node set can be selected. Defined as:

[0063] in, This indicates the used capacity of the target vehicle. Let C represent the demand at node i, and let C represent the rated capacity of the target vehicle. This indicates that the target vehicle has arrived at the current node. Time, This represents the Euclidean distance from the current position to node i, and v represents the speed of the target vehicle. This indicates the end time of the time window for node i. This indicates a small tolerance (to prevent floating-point errors from causing misjudgment of boundary nodes).

[0064] Nodes that do not meet the above conditions are set to -1 in the attention score calculation. After softmax, the probability is zero, so it will never be selected, thus ensuring that the output path 100% satisfies the capacity constraint and time window constraint.

[0065] In the embodiments of this application, two decoding strategies are provided during inference: greedy mode and sampling mode.

[0066] Greedy mode (ETHC-VRC(G)): Selects the feasible node with the highest probability in each step, which has the advantages of fast speed (about 3 seconds for 100 node instances); Sampling mode (ETHC-VRC(S)): The same instance is sampled independently 1280 times from the policy distribution (adjustable), and the optimal solution is selected from the candidate solutions. It has the advantage of higher quality (about 49 minutes for 100 nodes).

[0067] The two modes can be used for different application scenarios: the greedy mode is used for latency-sensitive scenarios, and the sampling mode is used for quality-sensitive scenarios.

[0068] In this embodiment, the REINFORCE policy gradient algorithm combined with a rolling baseline is used during the training process:

[0069] in, The loss function L represents the policy network parameters. The gradient of , where s represents the current state of the problem (such as customer node characteristics, vehicle initial state, etc.). This represents the expectation of the path distribution. This represents a complete path generated by the model sampling. Representing a path The cost, Baseline cost, determined by the frozen baseline strategy. Greedy expansion yields results. This represents the gradient of the logarithm of the path probability.

[0070] At the end of each round, evaluate the current policy on the validation set. and baseline strategy Perform a paired t-test; if the current strategy is significantly better, update the baseline. .

[0071] In one specific embodiment, the training configuration can be: Optimizer: Adam, learning rate: ; Batch size: 512; Training epochs: 100 epochs, 2500 steps per epoch; Training data for each scale: 1,280,000 randomly generated instances; Soft constraints are used throughout the training process, and hard masks are not enabled for time windows, allowing the policy to explore near-feasible regions.

[0072] The specific values ​​mentioned above are only shown as specific embodiments of this application and do not limit the specific parameters in the solution of this application.

[0073] In this application embodiment, the experiment follows the standard benchmark of Deep Reinforcement Learning (DRL) path: Node coordinates: (x,y) ~ U[0,1]*U[0,1]; Demand: d~U[1,9] (uniform integer distribution); Time window: Based on an 8-hour workday, [0,1] is divided into 4 equal segments. The time window width is fixed at 0.25, defined as ~U{0,0.25,0.5,0.75}. Problem size: n {20, 30, 50, 70, 100} corresponds to vehicle capacity C. {30,35,40,45,50}.

[0074] This application employs an explicit time-aware state representation. The vehicle's current arrival time and speed are explicitly introduced as first-level state variables into the state vector of the Transformer decoder, and then projected onto the context vector, expanding the context vector from its original (d+1) dimensions to (d+3) dimensions. Combined with a dedicated time-state update algorithm, these two time variables are maintained and updated in real time at each decision step, improving constraint verification efficiency. Furthermore, the attention mechanism can directly utilize [the relevant technology] when calculating node selection probabilities. Inferring whether accessing distant nodes will time out, rather than relying on the model implicitly learning temporal patterns from historical sequences, reduces the learning difficulty and improves the accuracy of constraint awareness. Explicit temporal states capture scale-independent spatiotemporal coordination patterns, independent of distributional statistics of a specific scale. This allows models trained on small-scale data to better transfer to large-scale test instances, enhancing cross-scale generalization capabilities.

[0075] This application employs a hybrid constraint strategy that separates training and inference, proposing a constraint processing framework that decouples the training and inference phases: during training, penalty-based soft constraints are used, allowing time window violations and incorporating the violation amount into the objective function; during inference, hard masks can be selectively enabled to forcibly mask nodes that do not meet capacity or time window constraints, ensuring 100% feasibility. The soft constraints during training allow the model to explore the solution space near the constraint boundaries and learn better path strategies; the hard masks during inference ensure absolute feasibility in safety-critical scenarios. Existing methods can only choose one, while this method can achieve both simultaneously. This improves the balance between training flexibility and deployment feasibility. The theoretical derivation of the penalty coefficient proposed in this application eliminates the cost of hyperparameter search. The penalty dimension is determined from the temporal structure of the problem, eliminating the need for separate hyperparameter grid searches for different problem sizes. This application uses dual-mode decoding to meet different deployment requirements. Greedy decoding supports real-time decision-making scenarios, while sampling decoding provides high-quality solutions close to the global optimum.

[0076] This application's embodiments directly encode customer time window features as node features using an encoder, while the decoder maintains the vehicle's time status in real time. This achieves joint modeling of capacity constraints and time window constraints, rather than processing them independently. It allows customer location, demand, and time windows to be jointly displayed within the same embedding space, avoiding the information fragmentation problem caused by treating time windows as independent constraint modules, preventing the model from getting trapped in local optima, and avoiding information fragmentation. This application's solution does not rely on any manually designed constraint rules or heuristic initialization, but entirely utilizes an end-to-end learning path strategy based on reinforcement learning signals. A single trained model in this application can directly generalize to unseen problem scales, achieving multi-scale coverage with a single model.

[0077] Please see Figure 2 This is a schematic diagram of the structure of a vehicle path construction device with a time window provided in an embodiment of this application. A second aspect of this application provides a vehicle path construction device with a time window, the device comprising: The acquisition module is used to acquire the path problem with capacity and time window constraints for the target vehicle. The path problem with capacity and time window constraints includes customer nodes and warehouse nodes. The encoding module is used to encode customer nodes and warehouse nodes based on the encoder to obtain the node embedding vector and global mean embedding of each node. The decoding module is used to stitch and project the node embedding vector of the current node, the remaining capacity of the target vehicle, the time when the target vehicle arrives at the current node, and the speed of the target vehicle based on the decoder to obtain the time-aware query vector. The determination module is used to determine the selection probability of each customer node based on the time-aware query vector, thereby obtaining the target customer node. The update module is used to explicitly update the time status of the target customer node, and obtain the updated current arrival time of the target customer node, the updated used capacity of the target vehicle, and the updated current location of the target vehicle. The output module is used to output the vehicle routing scheme after traversing all customer nodes.

[0078] The vehicle path construction apparatus with time window provided in the second aspect of the present application can realize the various processes implemented in the above method embodiments and achieve the same beneficial effects. To avoid repetition, it will not be described again here.

[0079] Please see Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. A third aspect of this application provides an electronic device 3000, including a processor 3100 and a memory 3200. The memory 3200 stores machine-executable instructions that can be executed by the processor 3100. The processor 3100 can execute the machine-executable instructions to implement the above-mentioned vehicle path construction method with time window.

[0080] A fourth aspect of this application provides a machine-readable storage medium storing instructions that, when executed by a processor, cause the processor to implement the above-described vehicle path construction method with time windows.

[0081] In some embodiments, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the time-windowed vehicle path construction method according to the above embodiments.

[0082] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0083] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 The computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The functions specified in one or more boxes. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable apparatus for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0084] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0085] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0086] Computer-readable media include both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic tape, disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0087] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0088] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

[0089] Furthermore, various different embodiments of the present invention can be combined in any way, as long as they do not violate the spirit of the present invention, they should also be regarded as the content disclosed by the present invention.

Claims

1. A method for constructing vehicle paths with time windows, characterized in that the method... include: The path problem with capacity and time window constraints is used to obtain the target vehicle. The path problem with capacity and time window constraints includes customer nodes and warehouse nodes. The customer nodes and warehouse nodes are encoded based on the encoder to obtain the node embedding vector and global mean embedding of each node. Based on the decoder, the node embedding vector of the current node, the remaining capacity of the target vehicle, the time of arrival of the target vehicle at the current node, and the speed of the target vehicle are stitched together and projected to obtain the time-aware query vector, which is represented as: in, Represents a time-aware query vector. This indicates global mean embedding. This represents the learnable projection matrix, used to project the concatenated multidimensional vector back to the target dimension. This represents the embedding vector of the current node. Indicates the remaining capacity of the target vehicle. Indicates the current arrival time. Indicates the speed of the target vehicle; The selection probability of each customer node is determined based on the time-aware query vector, and the target customer node is obtained based on greedy selection or sampling selection. Explicitly update the time status of the target customer node to obtain the updated current arrival time of the target customer node, the updated used capacity of the target vehicle, and the updated current location of the target vehicle, including: The driving distance is determined based on the coordinates of the target customer node and the coordinates of the current node; The updated current arrival time is determined based on the travel distance, current arrival time, and target vehicle speed; the ratio of travel distance to target vehicle speed is determined as the target time; if the sum of the current arrival time and the target time is less than the start time of the time window corresponding to the target customer node, the start time of the time window corresponding to the target customer node is determined as the updated current arrival time; if the sum of the current arrival time and the target time is greater than or equal to the start time of the time window corresponding to the target customer node, the sum is determined as the updated current arrival time. After traversing all customer nodes, output the vehicle routing plan.

2. The vehicle path construction method with time window according to claim 1, characterized in that, The customer node includes five original features, which include coordinate information, demand, time window start time, and time window end time.

3. The vehicle path construction method with time window according to claim 2, characterized in that, Based on the encoder, customer nodes and warehouse nodes are encoded to obtain the node embedding vector and global mean embedding for each node, including: The five-dimensional original features of each node are mapped to the initial embedding of the target dimension through a linear projection layer; Multi-head self-attention computation is performed based on the initial embedding to obtain the multi-head concatenation output; The multi-head splicing output is combined with the initial embedding and then residually connected and normalized to obtain the node's embedding vector. The global mean embedding is obtained by averaging the embedding vectors of each node.

4. The vehicle path construction method with time window according to claim 1, characterized in that, Explicitly update the time status of the target customer node to obtain the updated current arrival time of the target customer node, the updated used capacity of the target vehicle, and the updated current location of the target vehicle, including: The updated used capacity of the target vehicle is determined by the sum of the used capacity of the target vehicle and the demand of the target customer node. The current location of the target customer node is determined as the updated current location of the target vehicle.

5. A vehicle path construction device with a time window, characterized in that, The apparatus for implementing the vehicle routing method with time window as described in any one of claims 1 to 4 includes: The acquisition module is used to acquire the path problem with capacity and time window constraints for the target vehicle. The path problem with capacity and time window constraints includes customer nodes and warehouse nodes. The encoding module is used to encode customer nodes and warehouse nodes based on the encoder to obtain the node embedding vector and global mean embedding of each node. The decoding module is used to stitch and project the node embedding vector of the current node, the remaining capacity of the target vehicle, the time when the target vehicle arrives at the current node, and the speed of the target vehicle based on the decoder to obtain the time-aware query vector. The determination module is used to determine the selection probability of each customer node based on the time-aware query vector, thereby obtaining the target customer node. The update module is used to explicitly update the time status of the target customer node, and obtain the updated current arrival time of the target customer node, the updated used capacity of the target vehicle, and the updated current location of the target vehicle. The output module is used to output the vehicle routing scheme after traversing all customer nodes.

6. An electronic device, characterized in that, include: The memory is configured to store instructions; The processor is configured to retrieve instructions from memory and, when executing the instructions, to implement the vehicle path construction method with time window as described in any one of claims 1 to 4.

7. A machine-readable storage medium, characterized in that, The machine-readable storage medium stores instructions for causing the machine to perform the vehicle path construction method with time window as described in any one of claims 1 to 4.

8. A computer program product, characterized in that, When the instructions in the computer program product are executed by the processor of the electronic device, the electronic device causes the electronic device to perform the vehicle path construction method with time window as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Multi-constraint vehicle path planning method based on attention mechanism and deep reinforcement learning

    CN115759915A

  • Heterogeneous vehicle type vehicle path planning method and system based on deep reinforcement learning

    CN118608021A