Dynamic task optimization method based on knowledge graph
By constructing a knowledge graph and an improved dynamic time regularization algorithm, combining historical optimal solutions and dynamic weight adjustment, the problem of inefficiency of traditional algorithms in dynamic task scenarios is solved, and efficient and robust task optimization and scheduling is achieved.
Patent Information
- Application Number
- CN202510237375.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-02
- Publication Date
- 2025-07-25
AI Technical Summary
Traditional optimization algorithms are difficult to effectively deal with changes in dynamic task scenarios, especially when real-time changes in task locations, time windows or constraints, and lack of full utilization of historical information, resulting in low optimization efficiency and insufficient robustness.
By constructing a knowledge graph to store task scenario information, initialize the differential evolution algorithm population using historical optimal solutions of similar scenarios, and combining dynamic weight adjustment strategies, update knowledge graph nodes and relationships in real time, apply improved dynamic time regularization algorithms to cluster and trace similarity of task scenarios, and dynamically adjust the weight of mutation strategy.
It improves the efficiency and robustness of dynamic task optimization, can quickly respond to task scenario changes, and significantly enhances the performance and resource utilization efficiency of dynamic task scheduling.
Smart Images

Figure CN120373583A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the fields of intelligent optimization and dynamic path planning, and relates to a dynamic task optimization method based on a knowledge graph, aiming to achieve efficient optimization and rapid response of tasks in dynamic scenarios. Background Art
[0002] The problem of dynamic task optimization widely exists in practical applications. Traditional optimization algorithms are difficult to effectively cope with the dynamic changes in task scenarios, such as real-time changes in task locations, time windows, or constraint conditions. When facing these problems, existing methods often lack sufficient utilization of historical information, resulting in low optimization efficiency and insufficient robustness.
[0003] As a structured knowledge management technology, a knowledge graph can efficiently store and retrieve historical information in task scenarios, providing support for the optimization of dynamic scenarios. The dynamic time warping (DTW) algorithm performs well in time series similarity analysis. By combining the knowledge graph and the improved DTW algorithm, fast clustering and traceability of task scenarios can be achieved, improving the adaptability and optimization performance of the algorithm.
[0004] The present invention provides a dynamic task optimization method based on a knowledge graph, which stores task scenario information by constructing a knowledge graph, initializes the population with the historical optimal solutions of similar scenarios, and combines a dynamic weight adjustment strategy to achieve efficient optimization. Summary of the Invention
[0005] The present invention provides a dynamic task optimization method based on a knowledge graph, aiming to quickly respond to the dynamic changes in task scenarios and improve the task optimization efficiency and robustness. The present invention realizes dynamic task optimization through the following steps:
[0006] The method steps of the present invention are as follows:
[0007] Step 1: Set the goals of the task vehicle path optimization problem, including minimizing the number of vehicles used and the total driving time. Optimize the distribution path while satisfying the load limit and time window constraints.
[0008] Step 2: Knowledge graph construction.
[0009] Step 2.1: Data node construction.
[0010] Read the task scenario information from the dataset. For each record, check whether the task scenario is valid (non-empty and not an empty string);
[0011] If the task scenario is valid, create a task scenario node and store the unique identifier of the task scenario with the scenario_id attribute;
[0012] Create longitude sequence nodes and store longitude values as the Longitude attribute; construct the HAS_LONGITUDE_SEQUENCE relationship between the task scenario node and the longitude sequence nodes to represent the longitude sequence included in the task scenario;
[0013] Create latitude sequence nodes and store latitude values as the Latitude attribute; construct the HAS_LATITUDE_SEQUENCE relationship between the task scenario node and the latitude sequence nodes to represent the latitude sequence included in the task scenario;
[0014] Create left time window nodes and store the time window values as the LeftTimeWindow attribute;
[0015] Construct the HAS_LEFT_TIME_WINDOW relationship between the task scenario node and the left time window nodes to represent the left time window information corresponding to the task scenario;
[0016] Create right time window nodes and store the time window values as the RightTimeWindow attribute; construct the HAS_RIGHT_TIME_WINDOW relationship between the task scenario node and the right time window nodes to represent the right time window information corresponding to the task scenario;
[0017] Create population mutation strategy nodes, store the strategy information as the info attribute, and associate them with the task scenario; construct the HAS_MUTATION_STRATEGY relationship between the task scenario node and the population mutation strategy nodes to represent the population mutation strategy information corresponding to the task scenario;
[0018] Create population information nodes, store the information as the info attribute, and associate them with the task scenario; construct the HAS_POPULATION_INFO relationship between the task scenario node and the population information nodes to represent the population information corresponding to the task scenario.
[0019] Step 2.2: Dynamic update.
[0020] When the order location, time window, or constraints change, update the node and relationship information in real time to maintain the accuracy of the knowledge graph.
[0021] Step 3: Improvement and application of the dynamic time warping algorithm.
[0022] Step 3.1: Task similarity calculation.
[0023] Define the distance calculation method for time window and geographical location information:
[0024] Based on the DTW algorithm, the time window distance, geographical distance, and weight factor are improved, and the improved DTW distance is defined by the formula:
[0025]
[0026] where α and β are weight factors used to balance the importance of the time window distance and the geographical distance. i l and a i r are the left and right boundaries of the time window of the order respectively;
[0027] Step 3.2: Cluster analysis.
[0028] Construct a similarity matrix and classify the task scenarios using the hierarchical clustering method.
[0029] The specific steps are as follows:
[0030] 1. Define the set of task scenarios as S = {s1, s2, …, s n}, and the similarity between task scenarios is calculated by the improved DTW algorithm;
[0031] 2. Construct a similarity matrix M, where M [i][j] represents the DTW distance between task scenarios s i and s j , and the calculation formula is as follows:
[0032] M [i][j]= DTW(s i , s j ) (2)
[0033] Classify the task scenarios using the hierarchical clustering method. The steps are as follows: Set the stop condition for clustering as when the number of clusters in the final generation is less than or equal to 10 clusters, stop clustering; The hierarchical clustering method starts with each task scenario as a separate cluster; Merge the two smallest clusters in the similarity matrix M and update the similarity matrix; Assume the above steps are iterated until the preset clustering stop condition is reached. When the task scenario changes, the improved DTW algorithm is applied in real time to recalculate the similarity;
[0034] Step 4: Traceability of similar task scenarios.
[0035] Step 4.1: Analysis of task scenario features.
[0036] Analyze the geographical location, time window, and number of tasks of the new task scenario.
[0037] Step 4.2: Similarity calculation for each generation.
[0038] In each generation, randomly select some samples from the task scenario class, calculate their DTW values with the new task scenario, obtain the average DTW value of the class, and find the most similar class.
[0039] Step 4.3: Trace back generation by generation.
[0040] Based on the most similar class, trace back to the previous generation of scenarios generation by generation, and finally determine the historically most similar task scenario.
[0041] Step 5: Import the historical optimization results of the initial population.
[0042] Import the historically optimal solution obtained by tracing back into the initial population of the differential evolution algorithm as the optimization starting point to improve the optimization efficiency.
[0043] Step 6: Dynamically adjust the weight of the mutation strategy.
[0044] Dynamically adjust the weight of the mutation strategy according to the strategy contribution degree and usage frequency in the historically optimal solution; further optimize the weight according to the actual performance in each generation of optimization.
[0045] As mentioned above, the advantages of the present invention are as follows:
[0046] By constructing a knowledge graph and updating it in real time, an optimization method based on similar scenario tracing and dynamic mutation strategy adjustment is proposed, which can efficiently utilize historical optimization information to accurately classify and quickly respond to dynamic task scenarios. At the same time, by dynamically adjusting the weight of the mutation strategy of the differential evolution algorithm, the global search ability and optimization efficiency are improved, so as to achieve the simultaneous optimum of the task scenario optimization goal. The above method can adapt to the complex environment with frequent task changes, significantly improve the scheduling and resource utilization efficiency, and has broad application prospects. Description of the Drawings
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0048] Figure 1 It is a schematic diagram of the knowledge graph for constructing task scenarios provided by the embodiment of the present invention. Detailed Embodiment
[0050] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0051] The following describes the dynamic task scenario traceability, initialization of the population, and logic for borrowing mutation strategy weights in the embodiments of the present invention, specifically including the following steps:
[0052] Step 1: Randomly select one-quarter of the samples from each category in the current generation task scenario set, denoted as the sample set S t sub ; Use the improved dynamic time warping (DTW) algorithm to calculate the DTW value DTWij between the new task scenario and each sample in the sample set; Take the average of the DTW values of the sample set as the average DTW value of this category and the new task scenario. The formula is as follows:
[0053]
[0054] Step 2: Compare the average DTW values of all categories, find the category corresponding to the minimum value, denoted as the most similar category S similar ; Starting from the most similar category, trace back to the previous generation task scenario set in sequence, repeatedly calculate the average DTW value until the scene S that is most similar to the current task scenario in the historical task scenarios is found optimal ;
[0055] Step 3: Use the historical optimal solution S found by tracing back optimal To initialize the population of the differential evolution algorithm and use it as part of the basic individuals of the population.
[0056] Step 4: Dynamically adjust the weight w of the current generation mutation strategy according to the usage ratio of the mutation strategies recorded in the traced-back scenario g ; Based on the adjusted mutation strategy weight, use the roulette wheel algorithm to preferentially select high-weight strategies in each mutation to improve the optimization efficiency and global search ability.
[0057] Step 5: Repeat the above steps to make real-time adjustments to the task scenario in a dynamically changing environment to ensure the efficiency and robustness of the optimization result.
[0058] A dynamic task optimization method based on a knowledge graph, which determines the optimization objective of the dynamic task vehicle routing problem, constructs a knowledge graph to store the delivery knowledge of different task scenarios, combines the dynamic time warping algorithm for similarity clustering analysis of task scenarios, initializes the differential evolution algorithm population with the historical optimal solutions of similar task scenarios, and adjusts the mutation strategy weight using the historical information of similar task scenarios to achieve a fast response to dynamic tasks and improve the efficiency and robustness of dynamic task vehicle routing optimization. The specific steps are as follows:
[0059] Step 1: Determine the optimization objective of each task vehicle routing problem:
[0060] Suppose a company has K transport vehicles with the same vehicle type parked at a station and needs to complete the tasks of N customers. The load limit of each vehicle is W, and the opening time and closing time of the task center are a0 l and a0 r respectively; each customer's task is completed by only one vehicle. Each vehicle departs from the task center and needs to return to the station after completing the pick-up task in the task order; each order contains the following attributes: order number i, the longitude and latitude coordinates (x i , y i ) of the order location, the product weight w i of the i-th order, the expected start task time a i l of the i-th order, the latest start task time a i r expected by the i-th customer, and the task duration t i of the i-th customer, where i = 0 represents the task center; 0 < K max < 50, 0 < N < 150, 0 < W < 300, 0 < a0 l < 1440, 0 < a0 r < 1440, i = 0, …, N, 0 < x i < 100, 0 < y i < 100, 0 < a i l < 1440, 0 < a i r < 1440, 0 < t i < 200;
[0061] The optimization objective of this vehicle routing problem is to minimize the number of vehicles used and the total driving time of the vehicles:
[0062] min f1 = K (1)
[0063]
[0064] Among them, f1 is the number of vehicles K used in the scheduling process, and f2 is the total driving time of the vehicles; 0 < K ≤ K max , T ij is the time for the vehicle to travel from order i to order j, i = 0, …, N, j = 0, …, N, i = 0 represents the task center, i = 1, …, N represents the order, and v ijk represents whether the k-th vehicle travels from order i to order j. v ijk = 1 means yes, and v ijk = 0 means no, k = 1, …, K;
[0065] Each vehicle needs to meet the following conditions during the task process. Each order has and only has one vehicle to complete the task:
[0066]
[0067]
[0068] Each vehicle departs from the station, completes the tasks in the corresponding customer task order, and then returns to the station:
[0069]
[0070] The sum of the weights of the customers' goods cannot be greater than the maximum load of the vehicle;
[0071]
[0072] The time when each vehicle arrives at the location agreed by each customer should be within the time window required by the customer, and the vehicle should return to that place before the station closes:
[0073]
[0074] The time for the vehicle to arrive at the next customer's agreed location is:
[0075] t j = t i + d i + t i + T ij (10)
[0076] Among them, d i is the waiting time of the vehicle at customer i, d i ≥ 0, t i is the delivery time of the vehicle at customer i, and T ij represents the time spent traveling from customer i to customer j;
[0077] Step 2 Build a knowledge graph to store order knowledge for different task scenarios:
[0078] Step 2.1 Data node construction:
[0079] Store the dataset in a CSV file after format adjustment;
[0080] Taking the task scenario as the main node, define the main node attributes including the identification information of the task scenario, the total number of tasks, the number of vehicles, the total driving distance, and the time window requirements; one task scenario contains N customers; taking each order as a secondary node, define the secondary node attributes including the geographical location information of the order, the time window constraint, the mutation strategy weight information, and the population information;
[0081] Use the graph database Neo4j to read the information in the CSV file and store the above nodes and their relationships;
[0082] Step 2.2 Relationship construction:
[0083] 2.2.1 Construction of task scenario nodes
[0084] Read the task scenario information from the dataset. For each record, check whether the task scenario is valid;
[0085] If the task scenario is valid, create a task scenario node and store the unique identifier of the task scenario as the ScenarioId attribute;
[0086] 2.2.2 Construction of longitude sequence nodes and relationships
[0087] If there is valid longitude information in the record, create a longitude sequence node and store the longitude value as the Longitude attribute;
[0088] Construct the relationship between the task scenario node and the longitude sequence node to represent the longitude sequence included in the task scenario;
[0089] 2.2.3 Construction of latitude sequence nodes and relationships
[0090] If there is valid latitude information in the record, create a latitude sequence node and store the latitude value as the Latitude attribute;
[0091] Construct the relationship between the task scenario node and the latitude sequence node to represent the latitude sequence included in the task scenario;
[0092] 2.2.4 Construction of left time window sequence nodes and relationships
[0093] If there is valid left time window information in the record, create a left time window node and store the time window value as the LeftTimeWindow attribute;
[0094] Construct the relationship between the task scenario node and the left time window node to represent the left time window information corresponding to the task scenario;
[0095] 2.2.5 Construction of Right Time Window Sequence Nodes and Relationships
[0096] If there is valid right time window information in the record, create a right time window node and store the time window value as the RightTimeWindow property;
[0097] Construct the relationship between the task scenario node and the right time window node to represent the right time window information corresponding to the task scenario;
[0098] 2.2.6 Construction of Population Mutation Strategy Nodes and Relationships
[0099] If there is valid population mutation strategy information in the record, create a population mutation strategy node, store the strategy information as the MutationInfo property, and associate it with the task scenario;
[0100] Construct the relationship between the task scenario node and the population mutation strategy node to represent the population mutation strategy information corresponding to the task scenario;
[0101] 2.2.7 Construction of Population Information Nodes and Relationships
[0102] If there is valid population information in the record, create a population information node, store the information as the PopulationInfo property, and associate it with the task scenario;
[0103] Construct the relationship between the task scenario node and the population information node to represent the population information corresponding to the task scenario;
[0104] Step 2.3 Dynamic Task Update:
[0105] When one of the cargo weight w, order location (x i , y i ), task left and right time windows (a i l , a i r ) changes, update the node and relationship information in the knowledge graph in real time; repeat Step 2.1 and Step 2.2 for the newly added order node and its relationships;
[0106] Step 3 Improvement and Application of Dynamic Time Warping Algorithm:
[0107] Step 3.1 Data Feature Analysis:
[0108] Analyze the time series data in the task scenario: order arrival time, left and right time windows (a i l , a i r ), longitude and latitude (x i , yi ) Define the similarity calculation index Dist of the dynamic delivery task time series considering geographical location and left and right time windows DTW ;
[0109] Step 3.2 Improve the dynamic time warping algorithm:
[0110] Based on the DTW algorithm, improve the time window distance, geographical distance and weight factor, and define the improved DTW distance through the formula:
[0111]
[0112] where a i l and a i r are the left and right boundaries of the time window of the order respectively;
[0113] Step 3.3 Clustering based on dynamic time warping:
[0114] Define the task scenario set as S = {s1, s2,..., s n} The similarity between task scenarios is calculated by the DTW algorithm in Step 3.2;
[0115] Construct the similarity matrix M, where M [i][j] represents the DTW distance between task scenarios s i and s j , and the calculation formula is as follows:
[0116] M [i][j] = DTW(s i , s j ) (12)
[0117] Use the hierarchical clustering method to classify the task scenarios. The steps are as follows: Set the stop condition for clustering as when the number of clusters in the final generation is less than or equal to 10 clusters, stop clustering; The hierarchical clustering method starts with each task scenario as a separate cluster; Merge the two smallest clusters in the similarity matrix M and update the similarity matrix; Assume that the above steps are iterated until the preset clustering stop condition is reached. When the task scenario changes, re-calculate the similarity in real time using the improved DTW algorithm;
[0118] Step 4 When the order changes, trace the similar task scenarios:
[0119] Step 4.1 Analysis and initialization of the current task scenario features:
[0120] In the cargo weight w, order location (x i , y i ), task left and right time windows (a il , a i r ) If one of them changes, analyze the characteristics of the current task scenario: the number of orders, the time window of the task node (a i l , a i r ), geographical location (x i , y i ) and other information;
[0121] Regard the current task scenario as a new scenario s new , s = s new .
[0122] Step 4.2 Similarity calculation and average DTW calculation for each generation:
[0123] The set of task scenarios in the current generation is S t = {s t 1, s t 2, …, s t k};
[0124] For each category Randomly select one-fourth of the samples in this category, denoted as S t sub ;
[0125] Use the improved dynamic time warping algorithm to calculate the DTW value DTW between the new task scenario and each sample in ij ;
[0126] Calculate the average DTW value of this category. The calculation formula is as follows:
[0127]
[0128] Among them, AvgDTW t represents the average DTW value of the current category S t ; DTW ij represents the DTW value between the new task and the j-th sample in the sample set; represents the number of one-fourth of the samples randomly selected from the current category.
[0129] Compare the average DTW values of all categories to find the most similar category, satisfying:
[0130]
[0131] Step 4.3 Trace back to the previous generation scenario generation by generation
[0132] According to the most similar class in the current generation, trace back to the set of task scenarios in the previous generation; repeat the random screening and average DTW calculation in step 4.2 to find the class s t best in the previous generation that is most similar to s t-1 best ; Trace back generation by generation until the most similar task scenario in the first generation is traced back;
[0133] Step 5 Initialize the population of the differential evolution algorithm using the historical optimal solutions of similar scenarios
[0134] 5.1 Import the initial population into the differential evolution algorithm:
[0135] According to the most similar task scenario determined in step 4, transfer the historical optimal solution from the knowledge graph to the differential evolution algorithm. According to the mutation strategy weight value P n of the similar scenario node in the knowledge graph, generate P n historical optimal solutions and add them to the initial population P0; the remaining P s = P0 - P n Initialize the individuals of the population, which will be randomly generated by the differential evolution algorithm. Import the generated initial population P0 into the differential evolution algorithm as the starting point of the algorithm; according to the evolutionary strategy of the algorithm, perform subsequent optimization iterations.
[0136] Step 6: Adjust the mutation strategy weight using the historical information of similar scenarios
[0137] 6.1 Use historical information:
[0138] Utilize the usage frequency and corresponding contribution degree of each mutation strategy in the historical optimization process from similar task scenarios; specifically include: mutation strategies, random mutation strategy, optimal mutation strategy, current-to-optimal mutation strategy, random-to-optimal mutation strategy usage times Count; the average improvement value Gain of the objective function corresponding to each mutation strategy g ;
[0139] 6.2 Calculate the mutation strategy weight:
[0140] Calculate the initial weight of each mutation strategy according to the historical contribution degree and usage frequency:
[0141]
[0142] where w g is the weight of the g-th mutation strategy; Gain g represents the average improvement value of the historical objective function of strategy g; Count gDenote the historical usage times of strategy i; α and β are weight adjustment parameters used to balance the influence of contribution degree and usage frequency, initially set as α = 0.5 and β = 0.5, indicating that the influence of historical contribution degree and usage frequency is equal. If the importance of historical contribution degree is more prominent, adjust it to α = 0.7 and β = 0.3.
[0143] 6.3. Initialize the weights of mutation strategies:
[0144] Initialize the calculated weight w g as the weight of the mutation strategy of the current differential evolution algorithm;
[0145] Ensure weight normalization:
[0146] 6.4. Dynamically adjust the weights of mutation strategies:
[0147] During the optimization process of each generation, dynamically update the weights according to the actual performance of each mutation strategy in the current scenario:
[0148] Record the number of candidate solutions generated by each mutation strategy and their quality in each generation;
[0149] Recalculate the weights according to the actual performance:
[0150]
[0151] where: w g (t) represents the weight of strategy g in the t-th generation; CurrentGain g represents the average improvement of the objective function of strategy g in the current generation; γ is the learning rate used to control the balance between historical weights and the performance in the current generation. The learning rate changes dynamically during the iteration process, as shown in the following formula:
[0152]
[0153] where γ0 represents the initial learning rate, set to 0.2, t represents the current iteration number, and T represents the total iteration number;
[0154] 6.5. Strategy selection:
[0155] During each mutation, randomly select a mutation strategy using the roulette wheel method according to the weight set w g ={w1, w2, …, w k};
[0156] Calculate the cumulative sum of weights: g = 1, 2, …, k, where S k is the sum of all weights; generate a random number δ: δ ∼ U(0, S k), where U(0, S k ) represents the number of uniformly distributed data from S k to; find the corresponding strategy s according to the value of δ: s = min{i|δ ≤ S k}, where s is the selected mutation strategy;
[0157] Tables 1 and 2 show the optimized data of two instances, Figure 1 giving the path optimization results for each task.
[0158] Table 1. RC101 Vehicle Route Optimization Data
[0159]
[0160]
[0161] Table 2. R102 Vehicle Route Optimization Data
[0162]
[0163]
[0164] Table 3. Optimal Vehicle Scheduling Scheme for Each Task
[0165]
[0166]
[0167]
[0168]
Claims
1. A dynamic task optimization method based on a knowledge graph, characterized in that Specifically, it includes the following steps: Step 1: Determine the optimization objectives for each vehicle routing problem of tasks: Suppose there are K transport vehicles of the same model of a certain company parked at a station, and it is necessary to complete the tasks of N customers. The load limit of each vehicle is W, and the opening time and closing time of the task center are a0 l and a0 r ; Each customer's task is completed by only one vehicle. Each vehicle departs from the task center and needs to return to the station after completing the pickup task in the task order. Each order contains the following attributes: order number i, the longitude and latitude coordinates (x i , y i ) of the order location, the product weight w of the i-th order i , the expected start task time of the i-th order The latest start task time expected by the i-th customer The task duration t of the i-th customer i , where i = 0 represents the task center; 0 < K max < 50, 0 < N < 150, 0 < W < 300, 0 < x i < 100, 0 < y i < 100, 0 < t i < 200; The vehicle routing problem aims to minimize the number of vehicles used and the total driving time of the vehicles: min f1 = K (1) Among them, f1 is the number of vehicles K used in the scheduling process, and f2 is the total vehicle travel time; 0 < K ≤ K max , T ij is the time for the vehicle to travel from order i to order j, i = 0, …, N, j = 0, …, N, i = 0 represents the task center, i = 1, …, N represents the order, v ijk indicates whether the k-th vehicle travels from order i to order j, v ijk = 1 means yes, v ijk = 0 means no, k = 1, …, K; Each vehicle needs to meet the following conditions during the task. Each order is completed by exactly one vehicle: Each vehicle departs from the station, completes the tasks in the corresponding customer task sequence, and then returns to the station: The sum of the weights of the goods of the customers cannot be greater than the maximum load of the vehicle; The time when each vehicle arrives at the location agreed upon by each customer should be within the time window required by the customer, and the vehicle should return to that location before the station closes: The time when the vehicle arrives at the next location agreed upon by the customer is: t j = t i + d i + t i + T ij (10) Among them, d i is the waiting time of the vehicle at customer i, d i ≥0, t i is the delivery time of the vehicle at customer i, T ij represents the time taken to travel from customer i to customer j; Step 2: Construct a knowledge graph to store the order knowledge of different task scenarios: Step 2.1: Construction of data nodes: After formatting the data set, store it in a CSV file; Taking the task scenario as the main node, define the main node attributes including the identification information of the task scenario, the total number of tasks, the number of vehicles, the total driving distance, and the time window requirements; one task scenario contains N customers; taking each order as the secondary node, define the secondary node attributes including the geographical location information of the order, the time window constraint, the mutation strategy weight information, and the population information; Use the graph database Neo4j to read the information in the CSV file and store the above nodes and their relationships; Step 2.2: Construction of relationships: 2.2.1 Construction of task scenario nodes Read the task scenario information from the data set. For each record, check whether the task scenario is valid; If the task scenario is valid, create a task scenario node and store the unique identifier of the task scenario as the ScenarioId attribute; 2.2.2 Construction of longitude sequence nodes and relationships If there is valid longitude information in the record, create a longitude sequence node and store the longitude value as the Longitude attribute; Construct the relationship between the task scenario node and the longitude sequence node to represent the longitude sequence included in the task scenario; 2.2.3 Construction of latitude sequence nodes and relationships If there is valid latitude information in the record, create a latitude sequence node and store the latitude value as the Latitude attribute; Construct the relationship between the task scenario node and the latitude sequence node to represent the latitude sequence included in the task scenario; 2.2.4 Construction of left time window sequence nodes and relationships If there is valid left time window information in the record, create a left time window node and store the time window value as the LeftTimeWindow attribute; Construct the relationship between the task scenario node and the left time window node to represent the left time window information corresponding to the task scenario; 2.2.5 Construction of right time window sequence nodes and relationships If there is valid right time window information in the record, create a right time window node and store the time window value as the RightTimeWindow attribute; Construct the relationship between the task scenario node and the right time window node to represent the right time window information corresponding to the task scenario; 2.2.6 Construction of population mutation strategy nodes and relationships If there is valid population mutation strategy information in the record, create a population mutation strategy node, store the strategy information as the MutationInfo attribute, and associate it with the task scenario; Construct the relationship between the task scenario node and the population mutation strategy node to represent the population mutation strategy information corresponding to the task scenario; 2.2.7 Construction of Population Information Nodes and Relationships If there is valid population information in the record, create a population information node, store the information as the PopulationInfo attribute, and associate it with the task scenario; Construct the relationship between the task scenario node and the population information node to represent the population information corresponding to the task scenario; Step 2.3 Dynamic Task Update: When any one of the weight w of the goods, the order location (x i , y i ), and the left and right time windows of the task changes, the node and relationship information in the knowledge graph is updated in real time; repeat steps 2.1 and 2.2 for the newly added order nodes and their relationships; Step 3 Improvement and Application of the Dynamic Time Warping Algorithm: Step 3.1 Data Feature Analysis: Analyze the time series data in the task scenario: the arrival time of orders, the left and right time windows (a i l , a i r ), longitude and latitude (x i , y i ); Define the similarity calculation index Dist for the dynamic delivery task time series considering geographical location and left and right time windows DTW ; Step 3.2 Improvement of the Dynamic Time Warping Algorithm: Based on the DTW algorithm, the time window distance, geographical distance, and weight factor are improved, and the improved DTW distance is defined by a formula: wherein and are the left and right boundaries of the time window of the order, respectively; Step 3.3 Clustering Based on Dynamic Time Warping: Define the set of task scenarios as S = {s1, s2, …, s n}, and the similarity between task scenarios is calculated by the DTW algorithm in step 3.2; Construct a similarity matrix M, where M [i][j] represents the DTW distance between task scenarios s i and s j The calculation formula is as follows: M [i][j] = DTW(s i , s j ) (12) Use the hierarchical clustering method to classify the task scenarios. The steps are as follows: Set the stopping condition for clustering to stop when the number of clusters in the final generation is less than or equal to 10; The hierarchical clustering method starts with each task scenario as a separate cluster; Merge the two smallest clusters in the similarity matrix M and update the similarity matrix; When the task scenario changes, recalculate the similarity; Step 4 When the order changes, trace the source of similar task scenarios: Step 4.1 Analysis and Initialization of Current Task Scenario Features: When the weight of the goods w, the order location (x i , y i ), or one of the task left and right time windows changes, analyze the characteristics of the current task scenario: the number of orders, the time windows of the task nodes geographical location (x i , y i ), etc.; Regard the current task scenario as a new scenario s new , s = s new ; Step 4.2 Similarity Calculation and Average DTW Calculation for Each Generation: The set of task scenarios for the current generation is S t ={s t 1, s t 2, …, s t k}; For each class s t i ∈ S t , randomly select a quarter of the samples in this class, denoted as S t sub ; Calculate the DTW value between the new task scenario and each sample in using the improved dynamic time warping algorithm DTW ij ; Calculate the average DTW value of this class. The calculation formula is as follows: Among them, AvgDTW t represents the average DTW value of the current class S t ; DTW ij represents the DTW value between the new task and the j-th sample in the sample set; represents the number of one-fourth of the samples randomly selected from the current class; Compare the average DTW values of all classes to find the most similar class, satisfying: Step 4.3 Trace the previous generation scenario generation by generation Backtrack to the set of task scenarios in the previous generation according to the most similar class in the current generation; repeat the random screening and average DTW calculation in step 4.2 to find the class s t best in the previous generation that is most similar to s t-1 best ; trace back generation by generation until the most similar task scenario in the first generation is traced back to. Step 5 Initialize the differential evolution algorithm population with the historical optimal solution of the similar scenario 5.1 Import the initial population into the differential evolution algorithm: According to the most similar task scenario determined in step 4, transfer the historical optimal solution from the knowledge graph into the differential evolution algorithm; according to the mutation strategy weight value P of the similar scenario nodes in the knowledge graph n , generate P n historical optimal solutions and add them to the initial population P0; the remaining P s = P0 - P n Initialize the population individuals, which will be randomly generated by the differential evolution algorithm; import the generated initial population P0 into the differential evolution algorithm as the starting point of the algorithm; according to the evolutionary strategy of the algorithm, perform subsequent optimization iterations; Step 6: Adjust the mutation strategy weight using the historical information of the similar scenario 6.1 Use the historical information: Utilize the usage frequencies of various mutation strategies and their corresponding contribution degrees in the historical optimization process from similar task scenarios; specifically including: Mutation strategies, the usage counts Count of the random mutation strategy, optimal mutation strategy, current-to-optimal mutation strategy, and random-to-optimal mutation strategy; Average improvement value Gain of the objective function corresponding to each mutation strategy g ; 6.2 Calculate the mutation strategy weight: Calculate the initial weight of each mutation strategy according to the historical contribution degree and usage frequency: where, w g is the weight of the g-th mutation strategy; Gain g Denotes the average improvement value of the historical objective function of policy g; Count g Denotes the historical usage times of policy i; α and β are weight adjustment parameters used to balance the influence of contribution degree and usage frequency, initially set as α = 0.5 and β = 0.5, indicating that the influence of historical contribution degree and usage frequency is equal; if the importance of historical contribution degree is more prominent, adjust to α = 0.7 and β = 0.3; 6.3 Initialize the mutation strategy weight: Initialize the calculated weight w g as the mutation strategy weight of the current differential evolution algorithm; Ensure weight normalization: 6.4 Dynamically adjust the mutation strategy weight: During the optimization process of each generation, dynamically update the weight according to the actual performance of each mutation strategy in the current scenario: Record the number of candidate solutions generated by each mutation strategy and their quality in each generation; Recalculate the weight according to the actual performance: Wherein: w g (t) represents the weight of policy g in the t-th generation; CurrentGain g represents the average improvement of the objective function of policy g in the current generation; γ is the learning rate, which is used to control the balance between historical weights and current performance; the learning rate changes dynamically during the iteration process, as shown in the following formula: Among them, γ0 represents the initial learning rate, set to 0.2, t represents the current iteration number, and T represents the total iteration number; 6.5 Strategy Selection: At each mutation, according to the w of the weight set of the current mutation strategy g = {w1, w2, …, w k}, the mutation strategy is randomly selected using the roulette wheel method; Calculate the cumulative sum of weights: where S k is the sum of all weights; generate a random number δ: δ ~ U(0, S k ), where U(0, S k ) represents the number of uniformly distributed data from S k ; find the corresponding strategy s according to the value of δ: s = min{i|δ ≤ S k}, where s is the selected mutation strategy.
Citation Information
Cited By
Plasticization industry intelligent logistics scheduling method based on order prediction
CN121094672A
An order prediction-based intelligent logistics scheduling method for plasticizing industry
CN121094672B