Product distribution method based on ant colony algorithm
By the product distribution method based on the ant colony algorithm, the pheromone concentration choice path is used to optimize the model solution, solve the problem of lack of optimal distribution solutions in the traditional distribution method, and realize the acquisition of the optimal distribution solution and the timely delivery of the product.
Patent Information
- Application Number
- CN202411420140.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-01-28
AI Technical Summary
In the logistics or catering field, traditional product distribution methods lack clear and optimal delivery plans, resulting in uncontrollable vehicle costs and chaotic delivery, which may cause the product to not be delivered in time or missed.
Adopt the product distribution method based on the ant colony algorithm, the ants are abstracted into the vehicle, using the informatic concentration to select the path, establish a path to select models, and solve the model through optimization models.
In the case of multi -area delivery points, the optimal distribution scheme is obtained, and the problem of uncontrollable vehicle costs and confusion in distribution have been avoided, and the product delivery is timely.
Smart Images

Figure CN119379154A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a product distribution method based on ant colony algorithm. Background Art
[0002] At present, the logistics or catering fields involve delivering products to multiple areas, and each area has multiple delivery points. Generally speaking, multiple vehicles are arranged to complete the above delivery process. However, the transportation costs of different vehicles are different, and in the absence of a clear optimal delivery plan, traditional product delivery is more based on the delivery personnel's experience to arrange the delivery time and delivery plan. Therefore, not only will the cost of the vehicle be uncontrollable, but it may also cause distribution chaos, resulting in some products not being delivered in time, and some areas or some delivery points may be missed.
[0003] Therefore, a reasonable product distribution solution is urgently needed. Summary of the invention
[0004] The purpose of the present invention is to provide a product distribution method based on ant colony algorithm, which can obtain the optimal distribution plan under the condition of multiple regions and multiple distribution points.
[0005] The present invention solves the technical problem and adopts the following technical solution:
[0006] The product distribution method based on ant colony algorithm includes the following steps:
[0007] Using the ant colony algorithm, ants are abstracted as vehicles. Assuming that the total amount of pheromone in a vehicle is a fixed value M, the shorter the distance the vehicle travels, the higher the pheromone concentration. The concentration of pheromone will continue to evaporate over time during each iteration, that is, when the vehicle passes by.
[0008] Get the pheromone concentration left by all vehicles when they complete the iteration;
[0009] Considering only the case where the vehicle chooses the route completely based on the pheromone concentration, the route selection model at this time is established;
[0010] Optimizing the path selection model to obtain an optimized model;
[0011] The optimization model is solved to obtain the optimal delivery plan for the products to be delivered by the vehicle.
[0012] As a further optimization, the method of obtaining the pheromone concentrations left by all vehicles when completing the iteration includes:
[0013] set up For the probability that the k-th car chooses the j-th town among the i-th town at time t, set the set allowed kis the set of towns that the vehicle has visited, Δτ.. is the increase in pheromone concentration, and pheromone concentration volatility coefficient
[0014] ρ is a constant greater than 0 and less than 1. The pheromone concentration left by all vehicles after completing the iteration is:
[0015]
[0016] in, It represents the pheromone concentration left by the kth vehicle from location i to location j.
[0017] As a further optimization, the above-mentioned path selection model is established by considering only the vehicle to select the path completely according to the pheromone concentration, which means:
[0018]
[0019] The path selection model is the probability that the kth vehicle chooses an unvisited town at time t, that is, the pheromone concentration of the path to this town is divided by the sum of the pheromone concentrations of all unvisited paths. The unvisited town is The probability of the town set is 0, and the vehicle is based on The value of is used to select the next town, and iterates through the towns in alloweddk again and again, eventually visiting the entire set and thus traversing all the points.
[0020] As a further optimization, the path selection model is optimized to obtain an optimized model, which means:
[0021]
[0022] Among them, α and β represent the influence of pheromone concentration and distance length on the probability of vehicle selection when choosing a path. It means that the shorter the distance, the greater the probability that the ant will choose this path, allowing it to select a path based on the pheromone concentration and the length of the path. s represents the total path.
[0023] The beneficial effects of the present invention are as follows: through the above-mentioned product distribution method based on the ant colony algorithm, firstly, the ant colony algorithm is used to abstract ants into vehicles, and it is assumed that the total amount of pheromones of the vehicle is a fixed value M, then the shorter the distance traveled by the vehicle, the higher the pheromone concentration, and the concentration of pheromones will continue to evaporate over time during each round of iteration, that is, during the process of the vehicle passing; secondly, the pheromone concentration left by all vehicles when completing the current iteration is obtained; then, only considering that the vehicle selects the path completely according to the pheromone concentration, a path selection model at this time is established; then, the path selection model is optimized to obtain an optimization model; finally, the optimization model is solved to obtain the optimal distribution plan for the vehicle to distribute the product.
[0024] In the present invention, since only the vehicle is considered to select the route completely according to the pheromone concentration, the established route selection model is easy to fall into the local optimal solution when solving. Therefore, the route selection model is optimized and then solved to obtain the optimal distribution plan. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 This is a flow chart of a product distribution method based on ant colony algorithm in Embodiment 1 of the present invention;
[0026] Figure 2 This is a schematic diagram of the optimal path of area A obtained by calculation in matlab in Example 2 of the present invention. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0028] Example 1
[0029] This embodiment provides a product distribution method based on ant colony algorithm. Figure 1 , wherein the method comprises the following steps:
[0030] S1. Using the ant colony algorithm, ants are abstracted as vehicles. Assuming that the total amount of pheromone in a vehicle is a fixed value M, the shorter the distance traveled by the vehicle, the higher the pheromone concentration. The concentration of pheromone will continue to evaporate over time during each iteration, i.e., when the vehicle passes by;
[0031] S2, obtain the pheromone concentration left by all vehicles when completing the iteration;
[0032] S3, only considering that the vehicle chooses the route completely according to the pheromone concentration, then the route selection model at this time is established;
[0033] S4, optimizing the path selection model to obtain an optimized model;
[0034] S5. Solve the optimization model to obtain the optimal delivery plan for the vehicles to deliver the products.
[0035] Before performing step S1, in this embodiment, in order to find out how to arrange the shortest path in each area, a model 1 can be established to characterize this process, namely:
[0036] Let c ijDefine a 0-1 variable for the distance cost from town i to town j
[0037]
[0038] Then we have:
[0039]
[0040]
[0041] In addition, in order to find the most reasonable way to distribute the products to be delivered in each area, it is also necessary to establish a second model to characterize this process, namely:
[0042] Assumptions
[0043]
[0044] Cvz is the value coefficient of the vth vehicle going to the zth location
[0045] The objective function is
[0046]
[0047] Each vehicle is required to go to only one area, but each vehicle does not necessarily have to start, so the constraints should be:
[0048]
[0049] Specifically, in this embodiment, obtaining the pheromone concentrations left by all vehicles when completing the iteration may include:
[0050] set up For the probability that the k-th car chooses the j-th town among the i-th town at time t, set the set allowed k is the set of towns that the vehicle has visited, Δτ.. is the increase in pheromone concentration, and since pheromones evaporate, the pheromone ij is set
[0051] The concentration volatility coefficient p is a constant greater than 0 and less than 1. The pheromone concentration left by all vehicles after completing the iteration is:
[0052]
[0053] in, It represents the pheromone concentration left by the kth vehicle from location i to location j.
[0054] It should be pointed out that the above-mentioned path selection model is established when only the vehicle is considered to select the path completely according to the pheromone concentration:
[0055]
[0056] The path selection model is the probability that the kth vehicle chooses an unvisited town at time t, that is, the pheromone concentration of the path to this town is divided by the sum of the pheromone concentrations of all unvisited paths. The unvisited town is The probability of the town set is 0, and the vehicle is based on The value of k The towns in the model are visited iteratively again and again, and finally the set is visited, thus traversing all the points. However, under the initial conditions of this model, that is, the initial pheromone concentration is the same, the probability of vehicles choosing a path is the same, which will result in the vehicle only choosing part of the path during the initial iteration process, thus falling into a local optimal solution.
[0057] Therefore, the path selection model needs to be optimized. Therefore, in this embodiment, optimizing the path selection model to obtain an optimized model means:
[0058]
[0059] Where a and β represent the influence of pheromone concentration and distance length on the probability of vehicle selection when choosing a path. The shorter the distance, the greater the probability that the ant will choose this path, allowing it to choose a path based on the pheromone concentration and the length of the path. s represents the total path, so that it is not easy to fall into the local optimal solution during the initial vehicle iteration. It can be seen that when α=0, the probability of choosing a path is completely determined by the length of the path, which becomes a traditional greedy algorithm. If β=0, it will become a positive feedback heuristic algorithm, and the convergence speed may be too slow.
[0060] Example 2
[0061] Based on Example 1, this example describes in detail the distribution of nutritious meals to multiple primary schools. In this example, a food company (F) needs to deliver nutritious meals to primary schools in towns A, B, C, D, and E. The company has 6 large and 4 small trucks, each large truck can only transport 2,000 meals at most, and each small truck can transport 1,000 meals at most. The transportation cost of a large truck is 535 yuan per 100 kilometers, and the transportation cost of a small truck is 325 yuan per 100 kilometers. The relevant specific data are shown in Table 1:
[0062]
[0063] In this embodiment, taking two iterations as an example, four primary schools, D1 primary school, D2 primary school, D3 primary school and D4 primary school, are traversed, and their distance matrix is now written out:
[0064]
[0065] (1) Assume that M is 10; the initial pheromone concentration is 0.4, and the volatility is ρ = 0.5. Now assume that the optimal path selected by vehicle 1 at the initial moment is 3→1→4→2→3, and the optimal path selected by vehicle 2 at the initial moment is 1→2→4→3→1. Then the path length of vehicle 1 can be obtained as 12.9, and the path length of vehicle 2 is 17. The pheromone concentrations left on the four paths are Then the concentration left by vehicle 1 on the four paths is 0.78.
[0066] (2) The current optimal solution is the shortest path with a path length of 12.9: 3→1→4→2→3
[0067] Update pheromone concentration:
[0068] (3) Then the pheromone concentration matrix is:
[0069]
[0070] Therefore, in the second round of iteration, the vehicle will be more inclined to the paths with higher pheromone concentrations, 3→1, 4→2, 2→3, and 2→4, and select the path based on the probability formula obtained by combining the added distance matrix. The optimal path in area A is calculated in matlab as follows: Figure 2 Show:
[0071] The optimal paths from F (company) to five areas A, B, C, D, and E are obtained through iterative calculation as shown in Table 2:
[0072] Table 2
[0073]
[0074] Example of nutritious meal distribution:
[0075] Assumptions
[0076]
[0077] The objective function is
[0078]
[0079] It is required that each vehicle can only go to one area, but each vehicle does not necessarily have to depart, so the constraint should be:
[0080]
[0081] The number of vehicles required for the nutritious meals in each area is also different. For example, the number of nutritious meals required in areas A, B, C, D, and E are 3732, 2265, 1254, 1632, and 971, respectively. By observing these data, we can find that area A only needs 4 vehicles at most, and area B only needs 2 vehicles at most. And so on. The following constraints can be established:
[0082]
[0083] Now let's build a model to make its nutritional meals meet the requirements. Let the number of portions required for each area be A. z :
[0084]
[0085] The constraints are established as follows:
[0086]
[0087] Finally, through lingo solution, it is found that after observation, the optimal allocation plan is area A: 2 large trucks, area B: 1 large truck and 1 small car, area C: 1 large truck, area D: 1 large truck, area E: 1 large truck.
[0088] The optimal distribution solution obtained by the above model is shown in Table 3:
[0089] Table 3
[0090]
[0091] Therefore, the minimum cost is 1188.54 yuan.
[0092] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A product distribution method based on ant colony algorithm, characterized in that: The steps include: Using the ant colony algorithm, ants are abstracted as vehicles. Assuming that the total amount of pheromone in a vehicle is a fixed value M, the shorter the distance the vehicle travels, the higher the pheromone concentration. The concentration of pheromone will continue to evaporate over time during each iteration, that is, when the vehicle passes by. Get the pheromone concentration left by all vehicles when they complete the iteration; Considering only the case where the vehicle chooses the route completely based on the pheromone concentration, the route selection model at this time is established; Optimizing the path selection model to obtain an optimized model; The optimization model is solved to obtain the optimal delivery plan for the products to be delivered by the vehicle.
2. The product distribution method based on ant colony algorithm according to claim 1, characterized in that: The method of obtaining the pheromone concentrations left by all vehicles when completing the iteration includes: set up For the probability that the kth car chooses the jth town among the ith town at time t, set the set allowed k is the set of towns that the vehicle has visited, Δτ ij is the increase in pheromone concentration, the pheromone concentration volatility coefficient ρ is a constant greater than 0 and less than 1, and the pheromone concentration left by all vehicles after completing the iteration is: in, It represents the pheromone concentration left by the kth vehicle from location i to location j.
3. The product distribution method based on ant colony algorithm according to claim 2, characterized in that: The above-mentioned consideration is that only the vehicle selects the route completely according to the pheromone concentration, and the route selection model at this time is established, which means: The path selection model is the probability that the kth vehicle chooses an unvisited town at time t, that is, the pheromone concentration of the path to this town is divided by the sum of the pheromone concentrations of all unvisited paths. The unvisited town is The probability of the town set is 0, and the vehicle is based on The value of k The towns in the set are visited iteratively again and again, and finally the set is visited, thus traversing all the points.
4. The product distribution method based on ant colony algorithm according to claim 3 is characterized in that: Optimizing the path selection model to obtain an optimized model means: Among them, α and β represent the influence of pheromone concentration and distance length on the probability of vehicle selection when choosing a path. It means that the shorter the distance, the greater the probability that the ant will choose this path, allowing it to select a path based on the pheromone concentration and the length of the path. s represents the total path.