Disclosure of Invention
The invention aims to provide a time-limited multi-vehicle-type multi-vehicle-number path planning method based on a simulated annealing algorithm, which can effectively solve the path planning problem that vehicles of various vehicle types go out for multiple times and have working time limitation.
The method comprises the following steps:
(1) importing data and initializing parameters;
(2) generating an initial population, and calculating the objective function value of an individual;
(3) selecting an optimal individual s according to the objective function value in the step (2);
(4) cooling, the current temperature T is equal to alpha T0And alpha is a cooling coefficient;
(5) generating a new solution S';
(6) comparing the new solution with the current solution, and judging whether to accept the new solution as the current solution: if the new solution is better than the current solution, accepting the new solution as the current solution; if the new solution is worse than the current solution, selectively accepting the new solution as the current solution according to the probability p;
(7) when the number of internal circulation times meets the initialization parameters in the step (1), returning to the step (4);
(8) and (3) outputting the current solution as the optimal solution and outputting the planned route when the termination condition in the initialization parameters in the step (1) is met.
Wherein the data imported in the step (1) comprises weight information of each point, vehicle information and a distance matrix MDTime matrix MT。
The initialization parameters in the step (1) comprise setting an initial temperature T0 (ensuring enough) and a termination temperature TendInner layer ofNumber of cycles L and initial population size Np。
The initial population in the step (2) consists of a plurality of individuals, each individual consists of a plurality of arrays, and each array comprises a path which consists of a starting point, a passing point and an end point; the initial population generation method comprises the following steps:
s21: generating a random ordering of all collection points;
s22: randomly selecting a vehicle, and recording the load and the working time limit of the vehicle;
s23: considering the limitation of vehicle load and vehicle working time length, dividing paths for vehicles according to the collection point sequence, wherein the starting point of the path is the parking position of the vehicle, and performing greedy operation on the current path after the path division is completed: selecting a point closest to the current from a starting point as a next point, selecting a closest end point for the current route according to a greedy result and a last collection point, and performing intra-route neighborhood search on the route so as to enable the planned route to be more in line with the actual situation;
s24: if the working time of the current vehicle is remained, continuing to plan the route of the current vehicle, wherein the starting point of the route is the end point of the route on the current vehicle, and the rest is S23;
s25: returning to S22 when the current working time of the vehicle is used up;
s26: all collection points are divided into routes and the process ends.
The model used for calculating the objective function value in step (2) is as follows:
an objective function:
minimizing the total number of vehicles used:
minimizing the cost of using the vehicle:
minimizing the total path and the weighted sum of the balance values: min F;
wherein: f ═ β ═ L + γ ═ B;
by passing
To know
Restricting a point to be visited by one vehicle only once;
by passing
Ensuring the load limit of the vehicle;
by passing
Ensuring the limitation of the working time;
f is the value of the sum of the total distance and the balance index weight, and beta and gamma are the weight coefficients of the total distance and the balance target respectively and are determined according to the actual situation; l is the total route value, B is the balance index value; the number of vehicles is K, QkThe load of the kth vehicle, ckIs the cost of the kth vehicle; the total number of collection points is N, and the collection amount per point is qi(i=1,2...N),dijDistance of course between two points i, j, tijIs the time distance between two points i, j,xkij1 means that k passes through point i to point j, ykWith 1, the k-th vehicle is used and h is the operating time limit for all vehicles.
The generation mechanism of the new solution in the step (5) is as follows: and operating in the neighborhood of the current solution to generate a new solution, wherein the neighborhood has eight structures which are divided into an exchange neighborhood and a plug-in neighborhood, and under the conditions of full-load vehicle load and working time limit, exchanging a certain number of points (the number is more than or equal to 1 and less than or equal to 3) between two routes or inserting a certain number of points (the number is more than or equal to 1 and less than or equal to 5) of one route into the other route to generate the new solution.
The calculation formula of the probability p in the step (6) is as follows: p ═ exp (- (F' -F) T/T0) And F' is the third target value of the new solution.
The technical scheme of the invention has the following beneficial effects:
in the scheme, the load limit and the working time limit of the vehicle can be considered, the path planning algorithm for reaching multiple destinations can be calculated, and the algorithm can plan multiple paths of multiple vehicles instead of only one path of one vehicle. And various neighborhood structures are designed in the algorithm, so that the search space of the algorithm is enlarged. The algorithm is widely applied, and can be applied to the following scenes besides the application of truck delivery of logistics enterprises: (1) sharing the route planning of the single vehicle recovery; (2) planning the path of a maintenance worker; (3) planning the route of the school bus for picking up and delivering students; (4) path planning of multiple sightseeing points of a travel enterprise vehicle, and the like.
Detailed Description
In order to make the technical problems, technical solutions and advantages of the present invention more apparent, the following detailed description is given with reference to the accompanying drawings and specific embodiments.
The invention provides a time-limited multi-vehicle-type multi-train-number path planning method based on a simulated annealing algorithm.
As shown in fig. 1, the method comprises the steps of:
(1) importing data and initializing parameters;
(2) generating an initial population, and calculating the objective function value of an individual;
(3) selecting an optimal individual s according to the objective function value in the step (2);
(4) cooling, the current temperature T is equal to alpha T0And alpha is a cooling coefficient;
(5) generating a new solution S';
(6) comparing the new solution with the current solution, and judging whether to accept the new solution as the current solution: if the new solution is better than the current solution, accepting the new solution as the current solution; if the new solution is worse than the current solution, selectively accepting the new solution as the current solution according to the probability p;
(7) if the internal circulation times are met, returning to the step (4);
(8) and when the termination condition is met, outputting the current solution as the optimal solution and outputting the planned route.
The following description is given with reference to specific examples.
When the method is specifically applied, the method comprises the following steps:
step 1, considering the characteristics of the VRP problem of multiple vehicle types constrained by the working time length, generating an initial population, wherein the initial population is composed of a plurality of individuals, each individual is composed of a plurality of arrays, and each array comprises a path which is composed of a starting point, a passing point and a finishing point. The specific individual generation steps are as follows:
and 1.1, generating random sequencing of all the collection points.
And 1.2, randomly selecting a vehicle, and recording the load and the working time limit of the vehicle.
And step 1.3, considering the vehicle load and the vehicle working time limit, and dividing paths for the vehicles according to the collection point sequence, wherein the starting point of the route is the vehicle parking position. And after the path division is finished, performing greedy operation on the current route: and selecting the point closest to the current point from the starting point as the next point. And selecting the nearest end point for the current route according to the position of the last collection point of the greedy result. And performing neighborhood search in the route on the route to ensure reasonable internal planning of the route.
And 1.4, if the working time of the current vehicle is remained, continuing to plan the route of the current vehicle, wherein the starting point of the route is the end point of the last route of the vehicle, and the rest is the same as the step 1.2.
And step 1.5, returning to the step 1.1 when the current working time of the vehicle is used up.
And step 1.6, dividing all the collection points into routes, and ending the program.
And 2, calculating the adaptive value of the initial population. The adaptive value has three indexes which are respectively: the total distance value and the balance value are weighted to calculate the obtained value by using the number of vehicles and the vehicle cost. The specific calculation model is as follows:
an objective function:
min F        (3)
and (3) constraint:
F=(β*L+γ*B)      (4)
equations (1) - (3) are the objective functions of the model, which are the sum of the minimum total number of vehicles used, the minimum cost of vehicles used, the minimum total route and the weight of the balance value; formula (4) is a formula for calculating the F value, formula (5) is a formula for calculating the total route, formula (6) is a formula for calculating the balance index, and the formula is obtained by subtracting the minimum working time from the maximum working time; equations (7) and (8) constrain that a point can only be visited once by one vehicle; equation (9) ensures vehicle load limiting; the formula (10) guarantees the working time limit; the symbols referred to in the above formula define the following meanings: f is the value of the sum of the total distance and the balance index weight, beta and gamma are the weight coefficients of the total distance and the balance target respectively, and the value is determined by a decision maker according to the preference; l is the total route value, B is the balance index value; the number of vehicles is K, QkThe load of the kth vehicle, ckIs the cost of the kth vehicle; the total number of collection points is N, and the collection amount per point is qi(i=1,2...N),dijDistance of course between two points i, j, tijIs the time distance between two points i, j, xkij1 means that k passes through point i to point j, ykWith 1, the k-th vehicle is used and h is the operating time limit for all vehicles.
And selecting the optimal individual in the initial population according to the objective function value. When judging, selecting the individual with less vehicle number, selecting the individual with less vehicle cost, and finally selecting the minimum individual as the optimal individual of the current population from the total route value and the balance value according to the weight calculation. And performing simulated annealing operation by using the optimal individuals.
Step 3, beginningThe initialization algorithm parameters are: initial temperature T0(ensure sufficiently large), termination temperature TendAnd inner loop times L.
And 4, cooling. The cooling formula is adopted as follows: t ═ α T0And alpha is a temperature reduction coefficient.
And 5, generating a new solution: a new solution is generated in the neighborhood of the current solution according to the rules. Eight kinds of neighborhood structures are set, and new solutions are generated in the eight kinds of neighborhood structures in sequence. The neighborhood structures are respectively exchange collection points among the lines, and as shown in fig. 2, 1 to 3 points are respectively exchanged between the two lines; the points of insertion between the routes, as shown in FIG. 3, are inserted from 1 to 5 points, respectively. Under the condition of meeting the limits of vehicle load and working time, new solutions are sequentially generated in eight neighborhoods.
Step 6, according to the metropolis criterion, if the new solution is superior to the current solution, accepting the new solution as the current solution; if the new solution is worse than the current solution, an acceptance probability is calculated, p ═ exp (- (F' -F) T/T0) And F' is the third target value of the new solution. And generating a random number between 0 and 1, and if the number is less than p, accepting a new solution, otherwise, not accepting the new solution.
And 7, if the inner layer circulation times are met, returning to the step 4.
Step 8, the termination temperature is satisfied, namely T is less than TendAnd then ending the program, outputting the current solution as the optimal solution, and outputting the vehicle division route.
While the foregoing is directed to the preferred embodiment of the present invention, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention as defined in the appended claims.