A particle swarm-genetic-large neighborhood search algorithm for handling time window constrained multi-depot vehicle routing problem
By employing a particle swarm optimization-genetic algorithm combined with K-means clustering and various operators to optimize vehicle routes, the problem of high computational cost and local optima in the multi-warehouse vehicle routing problem is solved, achieving efficient route planning.
Patent Information
- Application Number
- CN202410639983.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-22
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2044-05-22
AI Technical Summary
Existing technologies for handling multi-warehouse vehicle routing problems with time window constraints suffer from high computational costs and a tendency to fall into local optima, making it difficult to achieve efficient optimization in large-scale problems.
The particle swarm optimization-genetic algorithm with large neighborhood search is adopted. It optimizes vehicle path planning by combining K-means clustering, greedy algorithm, gene crossover and mutation operations, simulated annealing algorithm and large neighborhood search, with 8 destruction operators and 7 repair operators.
It improves the local search capability of vehicle route planning, expands the neighborhood space, ensures the efficiency and optimization effect of the algorithm, and generates routes with excellent initial quality.
Smart Images

Figure CN118536580B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of vehicle path problem optimization, and particularly relates to a method for processing a multi-warehouse vehicle path planning problem with time window constraints by combining a particle swarm-genetic-large neighborhood search. BACKGROUND
[0002] In the logistics industry, balancing transportation efficiency and cost when vehicles travel between warehouse nodes and customer nodes is the key to ensuring the efficient operation of the industry. Due to the need to consider various factors when selecting a driving path, the problem is often converted into a multi-warehouse vehicle path problem with time window constraints for solution in the prior art. Common optimization methods for vehicle path problems currently include several categories such as exact algorithms based on mathematical theory, heuristic algorithms, search algorithms, and hybrid algorithms. Exact algorithms based on mathematical theory, represented by partitioning and pricing algorithms, have the characteristics of high accuracy but large computational load, and are therefore only suitable for optimization of small-scale problems. Heuristic algorithms can be divided into different types based on genetic algorithms, particle swarm algorithms, or ant colony algorithms, all of which have the advantages of high optimization efficiency and fast convergence speed, but also have the defect of being prone to falling into local optima. Search algorithms mainly include tabu search algorithms, variable neighborhood search algorithms, and large neighborhood search algorithms, and the purpose of using this type of algorithm is to obtain a better solution by increasing the breadth or depth of the search. Hybrid algorithms mainly refer to hybrid algorithms that use heuristic algorithms as the upper layer and search algorithms as the lower layer, which can achieve good optimization results. SUMMARY
[0003] In view of the above, in view of the technical problems existing in the field, the present application provides a method for processing a multi-warehouse vehicle path planning problem with time window constraints, which specifically comprises the following steps:
[0004] Step one, taking each warehouse node as a clustering center, K-means clustering is performed on the customer nodes based on the distance between the customer nodes and the warehouse nodes; in each customer node cluster, the customer nodes are sorted in order of the time window corresponding to each customer node from early to late to obtain a customer node sequence, the first customer node in the sequence is connected to the warehouse node of the clustering center and the route cost is calculated, and then a loop of route selection and route cost calculation is performed based on the greedy algorithm, while gradually inserting the customer nodes in the sequence into the candidate route to generate a set of initial routing schemes representing the customer node access sequence. These routing schemes are connected in a loop to form a gene sequence, and the other genes in the initial population are generated by shuffling the gene fragments based on this gene; the generated initial population is taken as the historical optimal gene population, and the gene sequence with the lowest total route cost is taken as the global optimal gene.
[0005] Step two, calculate the route cost of each gene in the gene population, and select a part of genes with the lowest route cost as parent genes;
[0006] Step three, construct three kinds of gene crossover options: the crossover between parent genes, the crossover between parent genes and their corresponding historical optimal genes, and the crossover between parent genes and the global optimal gene; for each parent gene, randomly select one of the options, perform order crossover to obtain offspring genes; then perform simulated annealing algorithm, based on the route cost of the obtained offspring genes and the route cost of their parent genes, determine whether to replace the parent genes with the offspring genes, and obtain the crossover offspring genes;
[0007] Step four, perform fragment node exchange gene mutation operation on the crossover offspring genes obtained in step three to obtain offspring genes; perform simulated annealing algorithm again, select one of the corresponding crossover offspring genes and offspring genes before and after the mutation operation to be reserved to obtain mutated offspring genes;
[0008] Step five, calculate the route cost of the mutated offspring genes obtained in step four, and compare it with the route cost of the historical optimal genes, select the gene with smaller route cost as the subsequent historical optimal gene; after completing the update of the historical optimal gene population, compare the minimum value of the route cost of the historical optimal gene population with the route cost of the global optimal gene, select the gene with smaller cost as the subsequent global optimal gene, complete the update of the global optimal gene;
[0009] Step six, take the global optimal gene obtained in step five as the input of the neighborhood search algorithm, perform large neighborhood search containing 8 kinds of destruction operators and 7 kinds of repair operators, and update the global optimal gene according to the neighborhood search result;
[0010] Step seven, if the number of iterations performed does not exceed the maximum number of iterations set, return to step two; otherwise, output the global optimal gene as the optimization result, and make the vehicle travel according to the route corresponding to the global optimal gene.
[0011] Further, in step one, first calculate the distance between different customer nodes based on the following formula:
[0012]
[0013] Wherein, d i,j represents the distance between the ith customer node and the jth customer node; based on the distance obtained by this calculation, perform the following K-means clustering to cluster customer nodes with similar distances into the same cluster:
[0014] Clu=K-mean(V N ,nD ,V D ,1000)
[0015] In the formula, Clu represents the clustering result, K-mean represents the K-means algorithm, V N represents clustering of customer nodes, n D represents the number of clusters, i.e. the number of warehouse nodes, V D represents the initial cluster center, i.e. the position of the warehouse node, and 1000 represents 1000 iterations of K-means clustering;
[0016] After the clustering is completed, the assignment of the warehouse is performed. First, the average distance between each cluster of customer points and different warehouse nodes is calculated according to the following formula:
[0017]
[0018] In the formula, d k,i,Dm represents the distance between the i-th customer node in the k-th cluster and the m-th warehouse node D m , D k,Dm represents the average distance between the customer nodes in the k-th cluster and the warehouse node D m , and D k,Dm represents the minimum distance. The corresponding warehouse node is assigned to the corresponding cluster of customer nodes, and the average distance between the remaining clusters and the warehouse nodes is compared to complete the assignment of the warehouse nodes to all clusters.
[0019] The specific process of the greedy algorithm includes the following steps:
[0020] a. The customer nodes in the cluster are sorted from early to late according to their time windows to form an initial customer node sequence Sv;
[0021] b. A customer node in the sequence Sv is selected, the total route cost increase value caused by inserting the node into the end of all non-empty routes and an empty route is calculated, the node is inserted into the end of the route with the minimum route cost increase value, and the customer node is deleted from the sequence Sv;
[0022] c. Step b is repeated to complete the insertion of all nodes in the sequence Sv, and the initial global optimal gene sequence is obtained by connecting the generated routes at the beginning and the end.
[0023] Further, the number of parent genes selected in step two is a fixed proportion of the number of genes in the current gene population, i.e. the selection gap, which is specifically selected as 0.9.
[0024] Further, in step four, when mutating the genes, for each gene involved in mutation, two groups of gene points are randomly selected, each group being a 3-length gene segment, and a position exchange operation is performed between the gene segments.
[0025] Further, the eight destruction operators and their corresponding operations in step six are as follows:
[0026] ① Random deletion destruction operator: randomly select a gene point to delete from the gene to obtain a destroyed gene sequence, and the deleted gene points form a destroyed gene sequence;
[0027] ② Random point deletion destruction operator: randomly select a gene point, and delete this gene point and the nearest point to the gene point from the gene to obtain a destroyed gene sequence, and the deleted gene points form a destroyed gene sequence;
[0028] ③ Greedy deletion destruction operator: select the gene point that can make the route cost represented by the gene decrease the most after deletion to obtain a destroyed gene sequence, and the deleted gene points form a destroyed gene sequence;
[0029] ④ Random sub-route deletion destruction operator: randomly select a sub-route gene segment to delete to obtain a destroyed gene sequence, and the deleted gene points form a destroyed gene sequence;
[0030] ⑤ Greedy sub-route deletion destruction operator: calculate the cost of each sub-route, and select the sub-route with the highest cost to delete to obtain a destroyed gene sequence, and the deleted gene points form a destroyed gene sequence;
[0031] ⑥ Greedy sub-route average cost deletion destruction operator: calculate the cost of each sub-route, divide the calculated sub-route cost by the number of customer nodes contained in the corresponding sub-route to obtain the average cost of each sub-route, and select the sub-route with the highest average cost to delete to obtain a destroyed gene sequence, and the deleted gene points form a destroyed gene sequence;
[0032] ⑦ Head and tail deletion destruction operator: delete the first customer gene point and the last customer gene point in each sub-route to obtain a destroyed gene sequence, and the deleted gene points form a destroyed gene sequence;
[0033] ⑧ Warehouse farthest gene point deletion destruction operator: delete the customer gene point farthest from the warehouse node in each sub-route to obtain a destroyed gene sequence, and the deleted gene points form a destroyed gene sequence:
[0034] The sub-routes in destruction operators ④-⑧ refer to the routes connecting warehouse nodes formed by customer nodes between a warehouse gene point and the next warehouse gene point in the gene sequence.
[0035] The seven repair operators include: ① a relative greedy repair operator, ② a weak relative greedy repair operator, ③ an adaptive relative greedy repair operator, ④ an absolute greedy repair operator, ⑤ a weak absolute greedy repair operator, ⑥ an adaptive absolute greedy repair operator, and ⑦ a random repair operator;
[0036] Further, the specific process of the large neighborhood search performed based on the above-mentioned destruction operator and repair operator includes:
[0037] Selection of the destruction operator and the repair operator, one of the eight destruction operators and one of the seven repair operators are selected by random selection and roulette selection to form a search operator pair in an iteration process of the large neighborhood search;
[0038] Destruction of the gene sequence, the selected destruction operator is executed to destroy the global optimal gene, to generate a destroyed gene sequence and a destroyed gene sequence;
[0039] Repair of the gene sequence, the selected repair operator is executed to repair the destroyed gene sequence, to generate a repaired gene sequence;
[0040] Gene updating, the cost of the route represented by the repaired gene sequence is calculated, and is compared with the cost of the route represented by the global optimal gene, and the gene with a lower cost is selected as a new global optimal gene;
[0041] Probability updating, if the global optimal gene is replaced, the success times of the destruction operator and the repair operator used in the current large neighborhood search are increased by 1;
[0042] Further, the selection process of the destruction operator and the repair operator, when the first 100 large neighborhood searches are performed, the random selection method is used for selection, and when the 101st large neighborhood search is performed, the roulette algorithm is used; the probability of selecting each destruction operator and repair operator in the roulette algorithm is calculated based on the following formula:
[0043] p i =N i / sum(N i )
[0044] q i =M i / sum(M i )
[0045] Wherein, N i is the success times of the corresponding destruction operator, p i is the selection probability of the corresponding destruction operator, M i is the success times of the corresponding repair operator, and q i is the selection probability of the corresponding repair operator.
[0046] Further, for the random repair operator, each gene point in the destroyed gene sequence is randomly inserted into a random point in the destroyed gene sequence to generate a repaired gene sequence;
[0047] For the relative greedy repair operator, the weak relative greedy repair operator, the adaptive relative greedy repair operator, the absolute greedy repair operator, the weak absolute greedy repair operator, and the adaptive absolute greedy repair operator, the gene repair is performed through the same steps as follows:
[0048] a. Node insertion: the first gene point in the destroyed gene sequence is selected and inserted into each gene point in the destroyed gene sequence to generate a corresponding repaired gene sequence population;
[0049] b. Cost calculation: the cost of the route corresponding to each gene in the repaired gene sequence population is calculated, and the lowest route cost and the second lowest route cost and the corresponding optimal insertion scheme and suboptimal insertion scheme are selected;
[0050] c. Repeat operation: the next gene point in the destroyed gene sequence is selected and inserted into each gene point in the destroyed gene sequence to generate a corresponding repaired gene sequence population, the cost calculation step is repeated, and the lowest repaired gene sequence route cost and the second lowest repaired gene sequence route cost and the corresponding optimal insertion repair scheme and suboptimal insertion repair scheme corresponding to each gene point in the destroyed gene sequence are recorded;
[0051] d. Gene point selection: based on the repaired gene sequence route cost corresponding to each gene point in the destroyed gene sequence generated in the cost calculation step, the corresponding gene point is selected according to the selection principle of each repair operator, and the optimal insertion scheme corresponding to the gene point is executed to perform insertion repair to obtain a stage repaired gene sequence;
[0052] e. Sequence update: the selected gene point in the gene point selection step is deleted from the destroyed gene sequence, and the stage repaired gene sequence is used to replace the destroyed gene sequence.
[0053] Further, the gene point selection rules of the relative greedy repair operator, the weak relative greedy repair operator, the adaptive relative greedy repair operator, the absolute greedy repair operator, the weak absolute greedy repair operator, and the adaptive absolute greedy repair operator in the gene repair process are as follows:
[0054] Relative greedy repair operator: the relative repair cost of each gene point in the damaged gene sequence is obtained by taking the absolute value of the difference between the optimal insertion repair gene sequence route cost and the second-lowest insertion repair gene sequence route cost of each gene point in the damaged gene sequence in the cost calculation result, the relative repair costs of each gene point in the damaged gene sequence are compared, the gene point with the largest relative repair cost is selected, and the optimal insertion repair scheme corresponding to the gene point is executed;
[0055] Weak relative greedy repair operator: the relative repair cost of each gene point in the damaged gene sequence is obtained by taking the absolute value of the difference between the optimal insertion repair gene sequence route cost and the second-lowest insertion repair gene sequence route cost of each gene point in the damaged gene sequence in the cost calculation result, and multiplying the absolute value by a random factor between [0.9, 1.1], the relative repair costs of each gene point in the damaged gene sequence are compared, the gene point with the largest relative repair cost is selected, and the optimal insertion repair scheme corresponding to the gene point is executed;
[0056] Adaptive relative greedy repair operator: the relative repair cost of each gene point in the damaged gene sequence is obtained by taking the absolute value of the difference between the optimal insertion repair gene sequence route cost and the second-lowest insertion repair gene sequence route cost of each gene point in the damaged gene sequence in the cost calculation result, and multiplying the absolute value by a random factor between [1-m, 1+m], the relative repair costs of each gene point in the damaged gene sequence are compared, the gene point with the largest relative repair cost is selected, and the optimal insertion repair scheme corresponding to the gene point is executed; wherein m is the decay factor, m = 0.1 * (1-gen / MAXGEN), wherein gen is the current main function iteration number, and MAXGEN is the maximum iteration number of the main function;
[0057] Absolute greedy repair operator: the optimal insertion repair gene sequence route cost of each gene point in the damaged gene sequence in the cost calculation result is compared, the gene point with the smallest optimal insertion repair gene sequence route cost is selected, and the optimal insertion repair scheme corresponding to the gene point is executed;
[0058] Weak absolute greedy repair operator: the absolute repair cost of each gene point in the damaged gene sequence is obtained by multiplying the optimal insertion repair gene sequence route cost of each gene point in the damaged gene sequence in the cost calculation result by a random factor between [0.9, 1.1], and the absolute repair costs are compared, the gene point with the smallest absolute repair cost is selected, and the optimal insertion repair scheme corresponding to the gene point is executed;
[0059] Adaptive absolute greedy repair operator: the optimal insertion repair gene sequence route cost of each gene point in the cost calculation result of the destroyed gene sequence is multiplied by a random factor between [1-m, 1+m] to obtain the absolute repair cost of each gene point in the destroyed gene sequence, and the absolute repair costs are compared, and the gene point with the minimum absolute repair cost is selected, and the optimal insertion repair scheme corresponding to the gene point is executed.
[0060] The method for processing the multi-warehouse vehicle path planning problem with time window constraints provided by the application has the advantages that the local search capability of the method is significantly improved by performing local search on the optimization scheme of the genetic algorithm, and the neighborhood space of the large neighborhood search algorithm is expanded by using eight destruction operators and seven repair operators. Since the large neighborhood search is directed to the optimal gene rather than all genes, the efficiency of the algorithm is guaranteed, and the cross operation between the parent gene and the optimal gene can also effectively spread the local search optimization effect of the optimal gene in the gene population. Compared with the prior art, the initialization method of the application generates routes by clustering, then distributing and finally generating routes, which has obvious advantages in quality from the initial scheme. BRIEF DESCRIPTION OF DRAWINGS
[0061] Figure 1 The flowchart of the method provided by the application;
[0062] Figure 2 The cross step schematic diagram in the method provided by the application;
[0063] Figure 3 The large neighborhood search destruction operator principle diagram in the method provided by the application;
[0064] Figure 4 The large neighborhood search repair operator principle diagram in the method provided by the application;
[0065] Figure 5 The cost curve of the optimization process in an example based on the application;
[0066] Figure 6 The optimization effect diagram in an example based on the application. DETAILED DESCRIPTION
[0067] The technical solutions of the application will be described clearly and completely below with reference to the drawings. Obviously, the described embodiments are part of the embodiments of the application, rather than all the embodiments. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor fall within the protection scope of the application.
[0068] The application provides a processing method for a multi-warehouse vehicle path planning problem with time window constraints, and specifically comprises the following steps: Figure 1 As shown in the figure, specifically comprising the following steps:
[0069] Step one, taking each warehouse point as a clustering center, performing K-means clustering on customer nodes based on the distance between the customer nodes and the warehouse nodes; in each customer node cluster, sorting the customer nodes in the cluster from early to late according to the time window corresponding to each customer node to obtain a customer node sequence, connecting the first customer node in the sequence with the warehouse node of the clustering center and calculating the route cost, and then performing a loop of route selection and route cost calculation based on a greedy algorithm, while gradually inserting the customer nodes in the sequence into the candidate route to generate a group of initial routing schemes representing the customer node access sequence, these routing schemes are connected in a loop to form a gene sequence, and other genes in the initial population are generated by scrambling the gene fragments based on the gene; the generated initial population is taken as a historical optimal gene population, and the gene sequence with the lowest total route cost is taken as a global optimal gene;
[0070] Step two, calculating the route cost corresponding to each gene in the gene population, and selecting a part of genes with the lowest route cost as parent genes;
[0071] Step three, constructing three gene crossover options: crossover between parent genes, crossover between parent genes and the corresponding historical optimal genes, and crossover between parent genes and the global optimal gene; for each parent gene, randomly selecting one of the options and performing hierarchical crossover to obtain offspring genes; then performing a simulated annealing algorithm to determine whether to replace the parent genes with the offspring genes based on the route cost corresponding to the obtained offspring genes and the route cost corresponding to the parent genes, and obtaining crossover offspring genes. Figure 2 The operation process of the above gene crossover is shown;
[0072] Step four, performing a gene mutation operation of fragment node exchange on the crossover offspring genes obtained in step three to obtain offspring genes; again performing a simulated annealing algorithm to select one of the corresponding crossover offspring genes and offspring genes before and after the mutation operation to be reserved, and obtaining mutated offspring genes;
[0073] Step five, calculating the route cost corresponding to the mutated offspring genes obtained in step four, and comparing the route cost with the route cost corresponding to the historical optimal genes, and selecting the gene with the smaller route cost as the subsequent historical optimal gene; after completing the update of the historical optimal gene population, comparing the lowest value of the route cost corresponding to the historical optimal gene population with the route cost corresponding to the global optimal gene, and selecting the gene with the smaller cost as the subsequent global optimal gene to complete the update of the global optimal gene;
[0074] Step six, taking the global optimal gene obtained in step five as the input of the neighborhood search algorithm, performing large neighborhood search containing 8 kinds of destruction operators and 7 kinds of repair operators, and updating the global optimal gene according to the neighborhood search result;
[0075] Step seven, if the number of iterations performed does not exceed the set maximum number of iterations, returning to step two; otherwise, outputting the global optimal gene as the optimization result, and making the vehicle travel according to the route corresponding to the global optimal gene.
[0076] In the preferred embodiment of the application, the distance between different customer nodes is first calculated based on the following formula in step one:
[0077]
[0078] Wherein, d i,j represents the distance between the ith customer node and the jth customer node; based on the distance calculated in this way, the following K-means clustering is performed to cluster customer nodes with similar distances into the same cluster:
[0079] Clu=K-mean(V N ,n D ,V D ,1000)
[0080] In the formula, Clu represents the clustering result, K-mean represents the K-means algorithm, V N represents clustering of customer nodes, n D represents the number of clusters, i.e., the number of warehouse nodes, V D represents the initial clustering center, i.e., the position of the warehouse node, and 1000 represents 1000 times of K-means clustering iteration;
[0081] After clustering is completed, the warehouse allocation is performed, and first, the average distance between customer nodes in each cluster and different warehouse nodes is calculated according to the following formula:
[0082]
[0083] Wherein, d k,i,Dm represents the distance between the ith customer node in the kth cluster and the mth warehouse node D m , and D k,Dm represents the average distance between the customer nodes in the kth cluster and the warehouse node D m ; the smallest one among D k,Dm is selected, and the corresponding warehouse node is allocated to the corresponding customer node cluster, and the average distance between the remaining clusters and warehouse nodes is continuously compared to complete the warehouse node allocation of all clusters;
[0084] The specific process of the greedy algorithm comprises the following steps in sequence:
[0085] a. The customer nodes in the cluster are sorted according to their time windows from early to late to form an initial customer node sequence Sv;
[0086] b. A customer node in the sequence Sv is selected, the total route cost increase value caused by inserting the node into all non-empty routes and the end of an empty route is calculated, the node is inserted into the end of the route with the minimum route cost increase value, and the customer node is deleted from the sequence Sv;
[0087] c. Step b is repeatedly executed, and after the insertion of all nodes in the sequence Sv is completed, the initial global optimal gene sequence is obtained by connecting the generated routes at their heads and tails.
[0088] In the preferred embodiment of the present application, the number of parent genes selected in step two is a fixed proportion of the number of genes in the current generation gene population, that is, the selection gap, and the selection is 0.9.
[0089] In the preferred embodiment of the present application, when performing gene mutation in step four, for each gene participating in mutation, two groups of gene points are randomly selected, each group of gene points is a gene segment with a length of 3, and a position exchange operation between the gene segments is performed.
[0090] In the preferred embodiment of the present application, as shown in Figure 3 the eight destruction operators and their corresponding operations in step six are as follows:
[0091] ① Random deletion destruction operator: a gene point is randomly selected and deleted from the gene to obtain a destroyed gene sequence, and the deleted gene points form a destroyed gene sequence;
[0092] ② Random point deletion destruction operator: a gene point is randomly selected, and the selected gene point and the nearest point to the selected gene point are deleted from the gene to obtain a destroyed gene sequence, and the deleted gene points form a destroyed gene sequence;
[0093] ③ Greedy deletion destruction operator: the gene point that can make the route cost represented by the gene decrease the most after deletion is selected for deletion to obtain a destroyed gene sequence, and the deleted gene points form a destroyed gene sequence;
[0094] ④ Random sub-route deletion destruction operator: a sub-route gene segment is randomly selected for deletion to obtain a destroyed gene sequence, and the deleted gene points form a destroyed gene sequence;
[0095] ⑤ Greedy sub-route deletion destruction operator: the cost of each sub-route is calculated, the sub-route with the highest cost is selected for deletion to obtain a destroyed gene sequence, and the deleted gene points form a destroyed gene sequence;
[0096] ⑥Greedy sub-route average cost deletion destruction operator: the cost of each sub-route is calculated, the calculated sub-route cost is divided by the number of customer nodes contained in the corresponding sub-route to obtain the average cost of each sub-route, the sub-route with the highest average cost is selected for deletion to obtain a destroyed gene sequence, and the deleted gene points are combined to form a destruction gene sequence;
[0097] ⑦Head and tail deletion destruction operator: the first customer gene point and the last customer gene point in each sub-route are deleted to obtain a destroyed gene sequence, and the deleted gene points are combined to form a destruction gene sequence;
[0098] ⑧Warehouse farthest gene point deletion destruction operator: the customer gene point farthest from the warehouse node in each sub-route is deleted to obtain a destroyed gene sequence, and the deleted gene points are combined to form a destruction gene sequence:
[0099] The sub-route in the destruction operators ④-⑧ refers to the route connecting the warehouse nodes formed by the customer nodes between a warehouse gene point and the next warehouse gene point in the gene sequence;
[0100] The seven repair operators include: ① relative greedy repair operator, ② weak relative greedy repair operator, ③ adaptive relative greedy repair operator, ④ absolute greedy repair operator, ⑤ weak absolute greedy repair operator, ⑥ adaptive absolute greedy repair operator, and ⑦ random repair operator;
[0101] In the preferred embodiment of the present application, the specific process of the large neighborhood search performed based on the above destruction operators and repair operators includes:
[0102] The selection of destruction operators and repair operators selects one of the eight destruction operators and one of the seven repair operators to form a search operator pair in each large neighborhood search iteration process by random selection and roulette selection;
[0103] Gene sequence destruction: the selected destruction operator is executed to destroy the global optimal gene, generating a destroyed gene sequence and a destroyed gene sequence;
[0104] Gene sequence repair: the selected repair operator is executed to repair the destroyed gene sequence, generating a repair gene sequence;
[0105] Gene update: the cost of the route represented by the repair gene sequence is calculated, which is compared with the cost of the route represented by the global optimal gene, and the gene with lower cost is selected as the new global optimal gene;
[0106] Probability update: if the global optimal gene is replaced, the success times of the destruction operator and the repair operator used in this large neighborhood search are increased by 1.
[0107] Further, the selection process of the destruction operator and the repair operator, when performing the first 100 times of large neighborhood search, uses a method of random selection, when performing the 101th time of large neighborhood search, uses a roulette algorithm; the probability of selecting each destruction operator and repair operator in the roulette algorithm is calculated based on the following formula:
[0108] p i = N i / sum(N i )
[0109] q i = M i / sum(M i )
[0110] Wherein, N i is the success number of the corresponding destruction operator, p i is the selection probability of the corresponding destruction operator, M i is the success number of the corresponding repair operator, and q i is the selection probability of the corresponding repair operator.
[0111] In the preferred embodiment of the present application, for the random repair operator, each gene point in the destruction gene sequence is specifically inserted into a random point of the destroyed gene sequence to generate a repair gene sequence;
[0112] As Figure 4 shown, for the relative greedy repair operator, the weak relative greedy repair operator, the adaptive relative greedy repair operator, the absolute greedy repair operator, the weak absolute greedy repair operator and the adaptive absolute greedy repair operator, gene repair is performed through the same steps as follows:
[0113] a. Node insertion; select the first gene point in the destruction gene sequence, and respectively insert it into each gene point in the destroyed gene sequence to generate a corresponding repair gene sequence population;
[0114] b. Cost calculation: calculate the cost of the route corresponding to each gene in the repair gene sequence population, select the lowest route cost and the second lowest route cost and the corresponding optimal insertion scheme and suboptimal insertion scheme;
[0115] c. Repeat operation: select the next gene point in the destruction gene sequence, respectively insert it into each gene point in the destroyed gene sequence to generate a corresponding repair gene sequence population, repeat the cost calculation step, and record the lowest repair gene sequence route cost and the second lowest repair gene sequence route cost corresponding to each gene point in the destruction gene sequence and the corresponding optimal insertion repair scheme and suboptimal insertion repair scheme;
[0116] d. Gene point selection: generate the repair gene sequence route cost corresponding to each gene point in the destroyed gene sequence based on the cost calculation step, select the corresponding gene point according to the selection principle of each repair operator, and execute the optimal insertion scheme corresponding to the gene point to perform insertion repair to obtain a stage repair gene sequence;
[0117] e. Sequence update: delete the gene point selected in the gene point selection step from the destroyed gene sequence, and replace the destroyed gene sequence with the stage repair gene sequence.
[0118] In the preferred embodiments of the present application, the gene point selection rules of the relative greedy repair operator, the weak relative greedy repair operator, the adaptive relative greedy repair operator, the absolute greedy repair operator, the weak absolute greedy repair operator, and the adaptive absolute greedy repair operator in the gene repair process are respectively:
[0119] The relative greedy repair operator: the relative repair cost of each gene point in the destroyed gene sequence is obtained by taking the absolute value of the difference between the optimal insertion repair gene sequence route cost and the second-lowest insertion repair gene sequence route cost of each gene point in the destroyed gene sequence in the cost calculation result, the relative repair costs of the gene points in the destroyed gene sequence are compared, the gene point with the largest relative repair cost is selected, and the optimal insertion repair scheme corresponding to the gene point is executed;
[0120] The weak relative greedy repair operator: the relative repair cost of each gene point in the destroyed gene sequence is obtained by taking the absolute value of the difference between the optimal insertion repair gene sequence route cost and the second-lowest insertion repair gene sequence route cost of each gene point in the destroyed gene sequence in the cost calculation result, and multiplying the absolute value by a random factor between 0.9 and 1.1, the relative repair costs of the gene points in the destroyed gene sequence are compared, the gene point with the largest relative repair cost is selected, and the optimal insertion repair scheme corresponding to the gene point is executed;
[0121] The adaptive relative greedy repair operator: the relative repair cost of each gene point in the destroyed gene sequence is obtained by taking the absolute value of the difference between the optimal insertion repair gene sequence route cost and the second-lowest insertion repair gene sequence route cost of each gene point in the destroyed gene sequence in the cost calculation result, and multiplying the absolute value by a random factor between 1-m and 1+m, the relative repair costs of the gene points in the destroyed gene sequence are compared, the gene point with the largest relative repair cost is selected, and the optimal insertion repair scheme corresponding to the gene point is executed; wherein m is a decay factor, m = 0.1 * (1-gen / MAXGEN), wherein gen is the current main function iteration number, and MAXGEN is the maximum iteration number of the main function;
[0122] Absolute greedy repair operator: comparing the optimal insertion repair gene sequence route cost of each gene point in the destroyed gene sequence in the cost calculation result, selecting the gene point with the minimum optimal insertion repair gene sequence route cost, and executing the optimal insertion repair scheme corresponding to the gene point;
[0123] Weak absolute greedy repair operator: multiplying the optimal insertion repair gene sequence route cost of each gene point in the destroyed gene sequence in the cost calculation result by a random factor between [0.9, 1.1] to obtain the absolute repair cost of each gene point in the destroyed gene sequence, and comparing the absolute repair costs, selecting the gene point with the minimum absolute repair cost, and executing the optimal insertion repair scheme corresponding to the gene point;
[0124] Adaptive absolute greedy repair operator: multiplying the optimal insertion repair gene sequence route cost of each gene point in the destroyed gene sequence in the cost calculation result by a random factor between [1-m, 1+m] to obtain the absolute repair cost of each gene point in the destroyed gene sequence, and comparing the absolute repair costs, selecting the gene point with the minimum absolute repair cost, and executing the optimal insertion repair scheme corresponding to the gene point.
[0125] In the examples based on the present application, the multi-warehouse vehicle routing problem with time windows is modeled and simulated using simulation software, Figure 5 The route total cost convergence process curve of the optimization process of the algorithm on a certain multi-warehouse vehicle routing problem with time windows is shown, Figure 6 The optimization result route map of the corresponding example.
[0126] It should be understood that the size of the serial number of each step in the embodiments of the present application does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0127] Although embodiments of the present application have been shown and described, it will be understood by those of ordinary skill in the art that various changes, modifications, replacements and variations of these embodiments can be made without departing from the principles and spirits of the present application, and the scope of the present application is defined by the appended claims and their equivalents.
Claims
1. A method for solving multi-warehouse vehicle routing problems with time window constraints, characterized in that: Specifically, the following steps are included: Step 1: Using each warehouse point as a cluster center, perform K-means clustering on customer nodes based on their distances relative to the warehouse nodes. Within each customer point cluster, sort the customer nodes from earliest to latest according to their corresponding time windows to obtain a customer node sequence. Connect the first customer node in the sequence to the warehouse node at the cluster center and calculate the route cost. Then, execute a loop of route selection and route cost calculation based on a greedy algorithm. Simultaneously, gradually insert customer nodes from the sequence into the candidate routes to generate a set of initial routing schemes representing the access order of customer nodes. These routing schemes are connected end to end to form a gene sequence. Other genes in the initial population are generated by shuffling gene fragments based on this gene. The generated initial population is taken as the historically optimal gene population, and the gene sequence with the lowest total route cost is taken as the globally optimal gene. Step 2: Calculate the route cost for each gene in the gene population, and select the genes with the lowest route cost as parent genes; Step 3: Construct three gene crossover options: crossover between parent genes, crossover between a parent gene and its corresponding historical best gene, and crossover between a parent gene and the globally best gene. For each parent gene, randomly select one of these options and perform order crossover to obtain offspring genes. Then, execute the simulated annealing algorithm to determine whether to replace the parent gene with the offspring gene based on the route cost corresponding to the obtained offspring gene and the route cost corresponding to the parent gene, and obtain the crossover offspring gene. Step 4: Perform a fragment node exchange gene mutation operation on the crossover offspring gene obtained in Step 3 to obtain the offspring gene; execute the simulated annealing algorithm again, and select one of the corresponding crossover offspring gene and offspring gene before and after the mutation operation to retain, to obtain the mutated offspring gene. Step 5: Calculate the route cost corresponding to the mutant progeny gene obtained in Step 4, and compare it with the route cost corresponding to the historical best gene. Select the gene with the smaller route cost as the subsequent historical best gene. After updating the historically optimal gene population, the lowest cost of the route corresponding to the historically optimal gene population is compared with the cost of the route corresponding to the globally optimal gene. The gene with the lower cost is selected as the subsequent globally optimal gene, and the update of the globally optimal gene is completed. Step Six: Using the globally optimal gene obtained in Step Five as input to the neighborhood search algorithm, execute a large neighborhood search with eight destruction operators, including random deletion destruction operator, random selection of nearest point deletion destruction operator, greedy deletion destruction operator, random deletion of sub-route destruction operator, greedy sub-route deletion destruction operator, greedy sub-route mean cost deletion destruction operator, head and tail deletion destruction operator, and deletion destruction operator of the farthest gene point in the warehouse, and seven repair operators, including relative greedy repair operator, weak relative greedy repair operator, adaptive relative greedy repair operator, absolute greedy repair operator, weak absolute greedy repair operator, adaptive absolute greedy repair operator, and random repair operator. Update the globally optimal gene based on the neighborhood search results. Step 7: If the number of iterations already performed does not exceed the set maximum number of iterations, return to Step 2; Otherwise, output the globally optimal gene as the optimization result, so that the vehicle travels along its corresponding route.
2. The method as described in claim 1, characterized in that: Step one first calculates the distance between different client nodes based on the following formula: Where, d i,j This represents the distance between the i-th customer node and the j-th customer node; based on this calculated distance, the following K-means clustering is performed to cluster customer nodes that are close in distance into the same cluster: Clu=K-mean(V N ,n D ,V D ,1000) In the formula, Clu represents the clustering result, K-means represents the K-means algorithm, and V N This represents clustering customer nodes, n D V represents the number of clusters, i.e., the number of warehouse nodes. D This represents the initial cluster center, i.e., the location of the warehouse node; 1000 represents 1000 K-means clustering iterations. After clustering is completed, warehouse allocation is performed. First, the average distance between customer points and different warehouse nodes in each cluster is calculated according to the following formula: Where, d k ,i, D m represents the intersection of the i-th client node and the m-th warehouse node D in the k-th cluster. m The distance between them, D k,Dm D represents the client node and warehouse node of the k-th cluster. m Average distance between them; choose D k,Dm The smallest one is assigned to the corresponding client node cluster. The average distance between the remaining clusters and the warehouse nodes is then compared to complete the allocation of warehouse nodes for all clusters. The specific process of the greedy algorithm includes the following steps: a. Sort the client nodes in the cluster from earliest to latest according to their time windows to form an initial client node sequence Sv; b. Select a customer node in sequence Sv, calculate the total route cost increase caused by inserting the point at the end of all non-empty routes and one empty route, insert the point at the end of the route with the smallest route cost increase, and delete the customer node from sequence Sv; c. Repeat step b. After inserting all points in sequence Sv, connect the generated routes end to end to obtain the initial global optimal gene sequence.
3. The method as described in claim 1, characterized in that: In step two, the number of parental genes selected is in a fixed ratio to the number of genes in the current gene population, which is called the generation gap, specifically 0.
9.
4. The method as described in claim 1, characterized in that: In step four, when performing gene mutation, for each gene involved in the mutation, two sets of gene points are randomly selected, each set of gene points being a gene fragment of length 3, and the position exchange operation between the gene fragments is performed.
5. The method as described in claim 1, characterized in that: The corresponding operations for the eight destruction operators mentioned in step six are as follows: ① Random deletion destruction operator: randomly select gene points to delete from the gene to obtain the destroyed gene sequence, and combine the deleted gene points to form the destroyed gene sequence; ② Randomly select the nearest deletion destruction operator: randomly select a gene point, delete this gene point and the nearest point from the gene to obtain the destroyed gene sequence, and combine the deleted gene points to form the destroyed gene sequence; ③ Greedy deletion destruction operator: Select the gene points that reduce the cost of the route represented by the gene the most after deletion, delete them to obtain the destroyed gene sequence, and combine the deleted gene points to form the destroyed gene sequence. ④ Random sub-route deletion destruction operator: Randomly select a sub-route gene segment for deletion to obtain the destroyed gene sequence, and combine the deleted gene points to form the destroyed gene sequence; ⑤ Greedy sub-route deletion destruction operator: Calculate the cost of each sub-route, select the sub-route with the highest cost to delete to obtain the destroyed gene sequence, and combine the deleted gene points to form the destroyed gene sequence; ⑥ Greedy Sub-Route Average Cost Deletion Damage Operator: Calculate the cost of each sub-route, divide the calculated sub-route cost by the number of customer nodes contained in the corresponding sub-route to obtain the average cost of each sub-route, select the sub-route with the highest average cost to delete to obtain the damaged gene sequence, and combine the deleted gene points to form the damaged gene sequence. ⑦ Head and tail deletion destruction operator: Delete the first and last customer gene points in each sub-route to obtain the destroyed gene sequence, and combine the deleted gene points to form the destroyed gene sequence; ⑧ Warehouse Farthest Gene Point Deletion Destruction Operator: Deletes the customer gene point farthest from its warehouse node in each sub-route to obtain the destroyed gene sequence, and combines the deleted gene points into a destroyed gene sequence: The sub-routes in the destruction operators ④ to ⑧ refer to the routes connecting warehouse nodes in the gene sequence, which are customer nodes from one warehouse gene point to the next warehouse gene point.
6. The method as described in claim 5, characterized in that: The specific process of the large neighborhood search performed based on the above-mentioned destruction and repair operators includes: The selection of destruction and repair operators is achieved by using two methods: random selection and roulette wheel selection. One of the eight destruction operators and one of the seven repair operators are selected to form a pair of search operators in a large neighborhood search iteration. Gene sequence disruption involves executing the selected disruption operator to disrupt the globally optimal gene, generating both the disrupted gene sequence and the disrupted gene sequence. Gene sequence repair involves executing the selected repair operator to repair the damaged gene sequence and generate a repaired gene sequence. Gene update involves calculating the cost of the route represented by the repaired gene sequence, comparing it with the cost of the route represented by the globally optimal gene, and selecting the gene with the lower cost as the new globally optimal gene. For probability updates, if the globally optimal gene is replaced, the success count of the destruction and repair operators used in this large neighborhood search is incremented by 1.
7. The method as described in claim 6, characterized in that: The selection process for the destruction and repair operators involves random selection during the first 100 large neighborhood searches, and a roulette wheel algorithm during the 101st large neighborhood search. The probability of selecting each destruction and repair operator using the roulette wheel algorithm is calculated based on the following formula: p i =N i / sum(N i ) q i =M i / sum(M i ) Where, N i p represents the number of successful attempts of the corresponding destruction operator. i M represents the selection probability of the corresponding destruction operator. i q represents the number of successful repairs of the corresponding repair operator. i This represents the selection probability of the corresponding repair operator.
8. The method as described in claim 7, characterized in that: For the random repair operator, each gene point in the damaged gene sequence is randomly inserted into a random point in the damaged gene sequence to generate a repair gene sequence. Gene repair is performed using the same steps for the relative greedy repair operator, weak relative greedy repair operator, adaptive relative greedy repair operator, absolute greedy repair operator, weak absolute greedy repair operator, and adaptive absolute greedy repair operator: a. Node insertion; Select the first gene point in the damaged gene sequence, insert it into each gene point in the damaged gene sequence, and generate the corresponding repair gene sequence population; b. Cost calculation: Calculate the cost of the route corresponding to each gene in the repair gene sequence population, and select the lowest route cost and the second lowest route cost, as well as their corresponding optimal and suboptimal insertion schemes. c. Repeated calculation: Select the next gene point in the damaged gene sequence, insert it into each gene point in the damaged gene sequence to generate the corresponding repair gene sequence population, repeat the cost calculation steps, and record the lowest repair gene sequence route cost and the second lowest repair gene sequence route cost corresponding to each gene point in the damaged gene sequence, as well as the corresponding optimal insertion repair scheme and suboptimal insertion repair scheme. d. Gene point selection: Based on the cost calculation step, the corresponding gene point is selected according to the selection principle of each repair operator, and the optimal insertion scheme corresponding to this gene point is executed to perform insertion repair and obtain the stage repair gene sequence. e. Sequence Update: Remove the gene points selected in the gene point selection step from the damaged gene sequence and replace the damaged gene sequence with the stage repair gene sequence.
9. The method as described in claim 8, characterized in that: The gene point selection rules for the relative greedy repair operator, weak relative greedy repair operator, adaptive relative greedy repair operator, absolute greedy repair operator, weak absolute greedy repair operator, and adaptive absolute greedy repair operator in the gene repair process are as follows: Relative Greedy Repair Operator: Take the absolute value of the difference between the optimal insertion repair gene sequence route cost and the second lowest insertion repair gene sequence route cost for each gene point in the damaged gene sequence in the cost calculation results to obtain the relative repair cost of each gene point in the damaged gene sequence. Compare the relative repair costs of each gene point in the damaged gene sequence, select the gene point with the largest relative repair cost, and execute the optimal insertion repair scheme corresponding to this gene point. Weak relative greedy repair operator: Take the absolute value of the difference between the optimal insertion repair gene sequence route cost and the second lowest insertion repair gene sequence route cost for each gene point in the damaged gene sequence in the cost calculation results, and multiply this absolute value by a random factor between [0.9, 1.1] to obtain the relative repair cost of this gene point in the damaged gene sequence. Compare the relative repair costs of each gene point in the damaged gene sequence, select the gene point with the largest relative repair cost, and execute the optimal insertion repair scheme corresponding to this gene point; The adaptive relative greedy repair operator calculates the absolute value of the difference between the optimal insertion repair gene sequence cost and the second lowest insertion repair gene sequence cost for each gene point in the damaged gene sequence. This absolute value is then multiplied by a random factor between [1-m, 1+m] to obtain the relative repair cost for that gene point in the damaged gene sequence. The relative repair costs of each gene point in the damaged gene sequence are compared, and the gene point with the highest relative repair cost is selected. The optimal insertion repair scheme corresponding to this gene point is then executed. Here, m is the decay factor, m = 0.1 * (1 - gen / MAXGEN), where gen is the current iteration number of the main function, and MAXGEN is the maximum iteration number of the main function. Absolutely greedy repair operator: Compares the cost of the optimal insertion repair gene sequence route for each gene point in the damaged gene sequence in the cost calculation results, selects the gene point with the smallest optimal insertion repair gene sequence route cost, and executes the optimal insertion repair scheme corresponding to this gene point; Weak absolute greedy repair operator: Multiply the cost of the optimal insertion repair route for each gene point in the damaged gene sequence in the cost calculation result by a random factor between [0.9, 1.1] to obtain the absolute repair cost of each gene point in the damaged gene sequence. Compare the absolute repair costs and select the gene point with the smallest absolute repair cost to execute the optimal insertion repair scheme corresponding to this gene point. Adaptive absolute greedy repair operator: Multiply the cost of the optimal insertion repair route for each gene point in the damaged gene sequence in the cost calculation results by a random factor between [1-m, 1+m] to obtain the absolute repair cost of each gene point in the damaged gene sequence. Compare the absolute repair costs and select the gene point with the smallest absolute repair cost to execute the optimal insertion repair scheme corresponding to this gene point.
Citation Information
Patent Citations
Vehicle distribution path optimization method based on genetic algorithm
CN117132010A
Optimum route searching method
JP1999118501A