Pharmaceutical distribution path optimization based on K-nearest neighbor algorithm

: With the changing situation of the prevention and control of the new crown epidemic, the demand for various types of pharmaceutical supplies is rising, which puts forward very high requirements on the timeliness of distribution. In view of this, this paper establishes a pharmaceutical logistics distribution path optimization model by comprehensively considering constraints such as vehicle loading and latest delivery time in pharmaceutical distribution. In order to solve this type of problem, a nearest neighbor algorithm is proposed, which introduces correlation coefficients to realize the improvement of the performance of the original algorithm. At the end of the paper, the effectiveness of the model and the algorithm is verified by applying a comparative analysis with the existing correlation algorithm with real data from a pharmaceutical company. The experimental results show that the method effectively reduces the delivery mileage and improves the pharmaceutical delivery timeliness.


Introduction
The pharmaceutical industry has become the focus of competition among the world's economic powers, and many countries around the world regard the establishment of a pharmaceutical industry as a symbol of national strength. The current pharmaceutical demand market is dominated by hospitals, community health care sites, and retail pharmacies, with other channels accounting for a relatively small share. Since the outbreak of the new coronavirus in 2019, people are paying more and more attention to healthy living, and the demand for pharmaceuticals has also increased significantly while putting forward higher requirements on the timeliness of pharmaceutical distribution. In order to improve the efficiency of drug delivery and customer satisfaction, pharmaceutical distribution companies have cooperated with offline physical pharmacies to set up pharmaceutical front warehouses to meet the dynamic needs of customers and accelerate the development of online and offline integration. Among them, the route selection of delivery vehicles is an important aspect of the pharmaceutical distribution system and an important factor affecting the efficiency of pharmaceutical companies' drug transportation.
The nearest neighbor algorithm [1]is a combinatorial optimization algorithm that is often mentioned in the study of distribution vehicle path optimization problems. For example, Zhu et al [2] proposed fuzzy monotonic K-nearest neighbors to construct monotonic classifiers by exploiting fuzzy dominance relations between pairs of instances and using fuzzy dominance relations between non-comparable instances, and finally experimentally verified that FMKNN has advantages over other state-of-the-art monotonic classifiers. liao et al [3] proposed a new method called KCNN to improve the performance of kNN performance by using prototype reduction to learn a reduced prototype set that can represent the original prototype set and verified that the proposed method has better robustness and convergence than CNN. wang et al [4] proposed a new local adaptive neighbor classification based on average distance in order to address the performance of KNN and finally experimentally verified the classification performance of the new method using 24 real datasets. Yuan et al [5] proposed a new ensemble learning based model named hybrid k-nearest neighbor and random forest, and a block cipher algorithm identification scheme was constructed, and the proposed scheme was used to perform binary and quintuple classification experiments on the block cipher algorithm, and finally its accuracy was verified experimentally.
In view of this, this paper improves the Nearest Neighbor Algorithm by constructing a vehicle path optimization model for pharmaceutical distribution scenarios, introducing correlation coefficients, and testing the algorithm using actual operational data of a pharmaceutical company.

Pharmaceutical distribution route
planning problem modeling 2.1. Problem assumptions and symbol definitions 2.1.1. Problem description of pharmaceutical distribution vehicle paths The pharmaceutical distribution path optimization problem can be modeled as a vehicle path problem with the following assumptions: There exists a fixed drug warehouse in a city, where the delivery vehicles are concentrated, and there will be no stockout situation. All drugs are delivered from this drug warehouse, and the delivery vehicles start from the drug warehouse and return to the starting warehouse after visiting a customer. The distance between customers and each customer is known, and the shortest delivery route is found. Customer order information is centralized in the customer center to ensure that each customer is served by one vehicle only once. Orders are processed and vehicle delivery routes are arranged within a fixed period of time each day. Customers are various offline pharmacies, medical points and hospitals, etc. Customers place orders through online and mark the weight of drugs when placing orders.

Description and definition of symbols
The symbol descriptions and definitions are shown Table1.

Objective Model
Pharmaceutical distribution path planning can be modeled as a vehicle path problem, where the single-vehicle path planning problem can be described as follows: under the premise that N customers are known and the distance between each customer, a delivery vehicle leaves the warehouse and returns to the departure warehouse after visiting N customers. and then returns to the departure warehouse after visiting N customers, how to find find a shortest access path to ensure that each customer is visited and visited only once, the mathematical model is as follows: t ij +h t +g t ≤T (5) ∑ ∑ x ij l ≤|S| jϵS i∈S -1 ∀S⊂{1,2,⋯,n} 2≤|S|≤n-1 j=1,2,⋯,n (7) where equation (1) indicates that the sum of all demands of all customer nodes served by one vehicle should not be greater than the total carrying capacity of the vehicle; equation (2) indicates the calculated relationship between the moment when the vehicle arrives at the customer point and the moment when it leaves the customer point; equation (3) indicates the time from point i to point j; equation (4) indicates to be earlier than the latest delivery time; equation (5) indicates the elimination of subloops; and equation (6) indicates that each customer point is served and is served only once.

The nearest neighbor algorithm
The basic idea of the algorithm [6][7][8] is to start from the starting point and select the closest and unvisited point to the current point as the next visited point each time until all points have been visited and then return to the starting point. The main advantages of this algorithm [9] are that it is simple to understand, easy to implement, and can find acceptable solutions for small and medium scale problems.

Model measurement and analysis of results
The operating system of the algorithm experiment environment is Windows 10, the processor is Intel(R) Core (TM) i7-9700 CPU @ 3.00GHz, the memory is 16G, and the algorithm code is written using Matlab R2017b.
The one-day order data of a pharmaceutical company is selected and solved for the improved nearest neighbor backtracking algorithm. Since the line has more customer points and a larger distance matrix, the following table shows the distance information between some customers on a certain day of the intercepted line. The table above shows that the improved nearest-neighbor back algorithm performs best in test 1 with an optimization ratio of 30%, followed by test 5 with 29%, and the worst performance is test 4 with an optimization ratio of -8% among the seven tests. In general, the improved algorithm performs better on the actual data, with an overall optimization ratio of 27%.
(a) Initial Roadmap (b) Optimized path

Summary
In this research , we consider constraints such as vehicle loading rate, latest return time and dynamic change of traffic information, construct a pharmaceutical distribution vehicle model with the help of map API, and use the actual data of a pharmaceutical company to solve the improved algorithm, and finally find that the distribution path before and after optimization has changed, and the optimization ratio has reached 13%, and the optimization algorithm has improved the distribution efficiency and distribution mileage.