Research on Coordination and Optimization of Order Allocation and Delivery Route Planning in Take-Out System

-is paper studies the take-out route delivery problem (TRDP) with order allocation and unilateral soft time window constraints. -e TRDP considers the order allocation and delivery route optimization in the delivery service process. -e TRDP is a challenging version of vehicle routing problem. In order to solve this problem, this paper aims to minimize the total cost of delivery, builds an optimizationmodel of this problem by using cumulative time, and adds time dimension in order allocation and path optimization dimensions. It can not only track the real-time location of delivery personnel but also record the delivery personnel to perform a certain task. -e main algorithm is the dynamic allocation algorithm designed from the perspective of dispatch efficiency, and the subalgorithm is the improved genetic algorithm. Finally, some experiments are designed to verify the effectiveness of the established model and the designed algorithm, the order allocation and route optimization are calculated with/ without the consideration of traffic jam, and the results show that the algorithm can generate better solution in each scene.


Introduction
At present, the take-out market in China continues to develop at an extraordinary speed, and the take-out platforms are competing in all aspects, such as high-quality supply and delivery experience. e COVID-19 has begun to erupt in all parts of the world and is spreading rapidly since the end of 2019. China, as one of the countries affected earlier by the epidemic, has adopted the measures of home quarantine during the fight against epidemic diseases, which plays a vital role in overcoming the epidemic. During the period of home quarantine, a large number of purchase and distribution of life materials and medicines were completed through the take-out. e mode of sale and delivery provides certain material support for residents, effectively alleviates the risk of infection of residents going out, and makes the best effect of blockade (isolation at home). It has been proved to be effective by practice in China to use a large number of daily necessities delivered by take-out staff to urban and rural residents during the epidemic period, which is worthy of reference for other countries that are affected by the epidemic and intend to adopt blockade (home isolation). erefore, it is of great significance to research and apply the order (food, medicine, and other daily necessities) delivered by take-out staff.
Delivery timeliness and on-time rate, as important indicators of take-out delivery, are the core competitiveness of the delivery platform. Generally speaking, the most direct way to improve the delivery efficiency and punctuality rate of users is to equip more delivery personnel and expand the scale of transportation capacity. However, it also means the increase of distribution cost. erefore, on the one hand, the delivery platform should pursue a good delivery experience; on the other hand, it is constrained by the human cost of distribution. How to improve the delivery rules, optimize the delivery route, and reduce the delivery cost while improving customer satisfaction has become a hot issue. In the current delivery problem, depending on the experience of delivery personnel to choose the delivery order and delivery path is easy to cause secondary delivery, which not only reduces the delivery efficiency but also increases the delivery cost and customer dissatisfaction, and less consideration is given to the real-time distribution of delivery orders. erefore, how to improve the delivery efficiency and customer satisfaction is very important for delivery companies, businesses, and customers.
In recent years, the issue of food delivery has become a hot topic of research. Li et al. [1] studied the task assignment and scheduling of food delivery from the perspective of game theory, aiming at maximizing the income of the dispatcher; Harman [2,3] researched and developed the take-out order automatic management system, which realizes the interaction between customers and merchants through the order system and provides customers with the additional sales option service during the ordering process; Liu et al. [4,5], using the spatial crowdsourcing technology, constructed the urban food distribution network and platform, and a new way to support delivery by taxi is studied. e optimization goal is to reduce the number of delivery by taxi, so as to ensure a higher income for the drivers participating in the delivery. e simulated annealing algorithm is designed for optimization, and the experiment has achieved good results in Chengdu, China. Liao et al. [6] proposed a multiobjective scheduling model for order combination and delivery path optimization in the process of meal delivery, in order to maximize customer satisfaction and balanced utilization of dispatchers in the region, and designed a two-stage solution algorithm composed of nondominated sorting genetic algorithm II (NSGA-II) and adaptive large neighbourhood search (ALNs). Jiang et al. [7] designed a dispatch system based on big data of take out logistics.
e system can optimize the number of regional dispatchers, improve the efficiency and income of dispatchers, and increase customer satisfaction. e routing optimization problem in take-out delivery problem can be regarded as a variant of Vehicle Routing Problem (VRP). e general vehicle routing problem (VRP) refers to a certain number of customers with different quantity of cargo demand. e distribution center provides cargo to customers, and a fleet is responsible for distributing cargo and organizing proper driving route, the goal is to make the customer's needs to be met, and under certain constraints, to achieve goals such as the shortest distance, the least cost, and the shortest time-consuming [7]. However, there is no delivery center for take-out delivery. Businessmen and customers correspond to each other, and there are soft time window requirements. Take-out delivery mans do not need to send to the corresponding customers immediately after taking meals at the businesses. ey do not need to return to the starting point of delivery after the completion of delivery. ey can continue to deliver directly from the current location as the starting point.
Take-out food distribution is essentially a kind of o2o business model. Dai et al. [8] designed a task distribution and path optimization method considering the influence of detour flexibility on part-time dispatchers, aiming at the situation that dispatchers have full-time and part-time jobs in the o2o model. Shi et al. [9] proposed a B2C and o2o innovative joint distribution service and designed an improved C-W algorithm based on node insertion path merging to realize the optimization of goods receipt and delivery with time window (PDPTW). Li et al. [10] studied the task allocation and pricing strategy between o2o platform and distributors when optimizing the optimal delivery path of goods. Using mixed integer linear programming, a matching strategy was proposed. He et al. [11] also studied the impact of food quality and merchant location on o2o food ordering, established a food ordering model, and also studied the impact of different delivery policies on food quality and merchant location. e path optimization problem in the delivery problem can be regarded as a variant of vehicle routing problem (VRP) [12,13]. General vehicle routing problem (VRP) refers to a certain number of customers, each of whom have different quantity of goods demand. e distribution center provides goods to customers, and a fleet distributes goods by appropriate driving route, with the goal of satisfying customers' needs and achieving goals such as shortest distance, lowest cost, and shortest time consumption under certain constraints [14]. However, the delivery problem does not have a unique delivery center. Businesses and customers correspond to each other, and there are soft time window requirements. After the delivery, the delivery personnel do not need to send the food to the corresponding customers immediately. After the delivery, they do not need to return to the delivery starting point. ey can continue the delivery with the current position as the starting point. e research of vehicle routing problem has been relatively mature, so now it is basically focused on the problem with deformation and algorithm research. Chen et al. [15] studied different types of vehicle routing problems with virtual warehouse and time window and proposed a two-stage heuristic algorithm based on tabu search; Chen and Shen [16] proposed a hierarchical particle swarm optimization algorithm including the inner layer and outer layer for the impact of the location of the parking lot on the transportation cost, using the determined location of the depot to obtain the best establishment of the depot Location and the corresponding optimal vehicle path, in which the inner algorithm obtains the optimal vehicle path and the outer algorithm obtains the location of the parking lot. Liu et al. [17] in order to solve the problem of resource allocation and carbon emission in green vehicle path optimization, proposed a hybrid quantum immune algorithm based on cloud model (c-hqia), which can effectively improve the distribution efficiency and reduce the distribution demand Ben. Li et al. [18] comprehensively considered the vehicle routing and fleet size decision-making problems of various vehicle types when studying the multistage heterogeneous fleet scheduling problem, transformed the problem into a mixed integer programming model, and proposed a new heuristic algorithm based on greedy algorithm and simulated annealing algorithm. Ma and Sun [19] proposed a mutation ant colony algorithm for solving the freight vehicle routing problem, which has a better performance Martinovic et al. [20] proposed a new vehicle routing problem considering single item pickup and delivery and proposed an iterative improved simulated annealing algorithm based on greedy random initial solution.
Although the research on the deformation and algorithm of the vehicle routing problem has been relatively mature, for the delivery path optimization problem, we need to consider the constraints of one-sided soft time window and the special requirements of first take and send; for the regional delivery system, we must consider the distribution between the delivery order and delivery personnel. Based on this, this paper establishes a delivery path optimization model based on cumulative time and designs the shortest path order allocation algorithm and the path optimization algorithm based on the improved ant colony algorithm.
e major contributions of this study are as follows: (1) for allocation and dispatch path optimization modelling, the cumulative time modelling method is used to establish the order allocation and dispatch path optimization model; (2) a dynamic optimization algorithm is designed to solve the model in this paper.
Section 2 describes the problem of order allocation and path optimization in the take-out system. Section 3 is the construction of the optimization model. Section 4 is the algorithm design. Section 5 summarizes the research results, and Section 6 discusses the future research.

Problem Statement.
e problem of order allocation and delivery path optimization in the take-out system is that when the take-out order is generated, the order is assigned to a specific courier according to the current location and distribution status of all couriers. After receiving the new task, the courier starts from their current location and goes to the merchant to pick up the goods under the condition of time window constraint and then sends it to the corresponding customer, or continues to the next merchant node to pick up goods and then to complete the delivery task at the same time. Generally speaking, a one-sided soft time window constraints for the courier get to the merchant to pick up the meal and to the customer's home to deliver the order, as shown in Figure 1.
In the order allocation stage, we need to consider the impact of the orders already dispatched to every courier and allocate the order tasks from the aspects of delivery efficiency and service ability of all couriers. When a new order is designated to a certain courier, the originally planned delivery route of this courier may be affected rather than the most effective one. As a result, a rescheduling phase is necessary to obtain the optimal path based on current situation, which reflects the dynamic coupling characteristic between order allocation and delivery route optimization in the take-out delivery problem. In the delivery route optimization stage, it is aimed to find an optimal route with the minimum generalized cost, including the travel distance, the waiting cost, and the time penalty cost of all couriers. In Figure 2, a small example is used to illustrate the interaction process of order allocation and route optimization in the delivery problem. Figure 2 shows a simplified delivery problem. e node pairs (1,2), (3,4), and (5,6) are the orders that have been generated before and assigned to the courier v according to certain distribution rules, in which the nodes with odd number correspond to the merchant node while the nodes with even number correspond to the customer node. As can be seen from the comparison, with the emergence of new order (7,8) at a certain time, the optimal delivery route of courier v changed from (1-2-3-4-5-6) to (1-2-3-7-4-5-8-6).
When the system has more than one take-out couriers, the result of order allocation and route optimization are changed dynamically.
According to the characteristic of this problem, the set of merchant and the set of customer both have a unilateral soft time window constraint, that is, the courier can arrive at the merchant or serve the customer early but not late than the expect time window, otherwise a penalty cost associated to the delay time will be used to affect the generation of delivery route.
Without losing generality, this paper makes the following assumptions: (1) e number of couriers inside the service region is known and fixed, which can meet the demand of order dispatch (2) All orders are compatible with any courier, that is, each order can be dispatched to any courier (3) e delivery interruption caused by vehicles and couriers is not considered

Notations, Variables, and Formulation
(1) General Notations V: set of couriers M: set of businesses P: set of customers O: set of take-out couriers starting location nodes K: set of take-out orders N: set of space-time nodes A v : set of take-out delivery optimizes arcs in spacetime networks v: index of courier m: index of business p: index of customer k: index of order Ψ v p : set of service arc couriersv to customers p (i, t), (j, s): space-time nodes, (i, t), (j, s) ∈ N (i, t; j, s).: a space-time arc from head node (i, t) to tail node (j, s), (i, t; j, s) ∈ A c: penalty coefficient of courier arriving late at business node or customer node d i,t;j,s : the distance from node (i, t) to node (j, s) l j : the latest arrival time specified by node j (2) Space-Time Node Sets N KD : set of take-out orders leaving the node N KA : set of take-out orders arriving at the node N VD : set of courier leaving the node N VO : set of origin location nodes of courier

(3) Other Declaration Symbols
Area: the search area is composed of the location of the order businesses node and the radius of 3 km D k mv : the distance between the couriers and the businesses node in the search area of order k D k mp : the distance between businesses node m and customer node p in order k S v : the distance completes orders of courierv C v : capacity limitation of courierv.

(4) Decision Variables
x v i,t;j,s � 1 if the courier goes from node (i, t) to node (j, s); � 0 otherwise.   y v k � 1 if order k is assigned to courierv; � 0 otherwise.

Optimization Model Construction of Delivery Coordination
In order to optimize the delivery route of take-out, it is necessary to consider the distribution of take-out tasks and the optimization of the delivery route. Set up the take-out delivery time-space network, as shown in Figure 3, and use the cumulative time to build the model [21], so as to accurately express the take-out delivery route optimization problem with two sets of variables.
In order to represent specific nodes with temporal and spatial attributes, we define them as (i, t) and (j, s), which represent the departure node and arrival node of the order, respectively, and define a node set N � N KD ∪N KA based on delivery orders, as shown below: (1) Delivery order departure node (i, t) ∈ N KD , where i and t represents the starting position and time of a particular take-out order k, respectively, and satisfies the λ(i, t) � k, indicating the coupling relationship between the departure node (i, t) and the take-out order k (2) Take-out order arrival node (j, s) ∈ N KA denotes that, for a particular take-out order k, j and s represent the arrival location and time of take-out order k, respectively, and similarly satisfy λ(j, s) � k (1) Objective Function. e objective of this optimization model is to minimize the generated total cost of take-out delivery, including travel cost and time penalty cost, that is, the objective function can be described as (2) Delivery Start Node Constraints. From the current location, the first node that the take-out delivery courier visits must be the merchant node: (3) Delivery End Node Constraints. When the take-out delivery courier visits his last customer, it can be considered that the take-out dispatch process is completed and there is no need for him to return to the starting point or the merchant nodes: (4) Service Frequency Constraints. In a task set, for the same courier, each customer is served exactly once: where λ(i, t; j, s) � k represent the coupling relationship of departure node (i, t), arrival node (j, s), and take-out order k. (6) Order Distribution Constraints. For each order, only one take-out delivery courier can be assigned: (7) Variable Constraints. e take-out delivery couriers choice of each route is a 0-1 variable, and whether to assign order k to courier v is also a 0-1 variable:

Solution Algorithms
e delivery order allocation and dispatch route optimization studied in this paper is a dynamic process. In the solution stage, it is necessary to determine the allocation result of the subsequent new orders according to the assigned orders and their completion status of the delivery courier, as shown in Figure 4. Based  Mathematical Problems in Engineering on this, we design an order dynamic allocation algorithm embedded in a path optimization subalgorithm. First, orders generated early are assigned to couriers with the consideration of distance between the courier and the merchant and the customer, as well as the delivery ability of the couriers, and the current best delivery route is calculated according to all orders allocated to each courier. en, the new order allocation is carried out based on the former order allocation result, and finally the optimal route after adding the new order is recalculated and this process will be repeated until all orders are allocated to the corresponding courier. e allocation of new order in the take-out system is a dynamic process, which is handled with the passage of time, and the current position and remaining tasks of all the couriers should be also considered.
In this paper, from the perspective of dispatch efficiency, the evaluation function of order allocation is established based on the sum of the follow-up operation time of all the couriers in the region after receiving the new order, and the current optimal allocation scheme is determined according to the evaluation function.
Let order allocation evaluation function T(k, 1) represent the total remaining delivery time of the system after the allocation of order k, namely, e equation F(v u , k, 1) represents the remaining delivery time of the entire system after assigning order k to courier v u , which is equal to the sum of the delivery time of courier v u after assigning order kT(v u , k, 1) and the delivery time of all other couriers not allocated order T(v u , k, 0).
e delivery time of courier v u not allocated order kT(v u , k, 0) is related to status of the courier in the previous stage: where t k−1 and t k are the time of order k − 1 and order k − 1 appears, and Δ k,k−1 represents the time span from t k−1 to t k : Although the probability is small, it is possible to generate two or more orders at the same time. In this case, the way we deal with it is sorting these orders by random sequence, and then allocate the new orders to couriers one by one.
In order allocation and delivery route coordination optimization algorithm of the take-out system, the main algorithm is dynamic order allocation algorithm based on dispatch efficiency, and the subalgorithm is route optimization algorithm based on current optimal. For a new delivery order, we first try to assign it to a courier in the region, use the delivery route optimization subalgorithm to optimize the delivery route of this courier in real time, and calculate his remaining delivery time and the corresponding system remaining delivery time.
Repeat the process to get all the possible allocation schemes, and then, based on the evaluation function, the greedy strategy is adopted to select the optimal scheme to use. Continue the allocation process of the subsequent orders according to the sequence of their appearing time until all the orders have been allocated. e specific flow chart of the algorithm is shown in Figure 5.
Existing order allocation and route optimization New order allocation and route reoptimization Order generation time Collection of regional deliverer

Main Algorithm: Dynamic Order Allocation Algorithm
Step0: Initialization; Initializes the real-time location of all couriers and the information of all orders, let k � 1, and T(v u , k, 0) � 0 for each courier.
Step1: For order k in the system, search all the couriers in the Area to form the courier set V Area .
Step3: Perform Sub-Algorithm of route optimization to calculate the current optimal route of courier v u .
Step4: According to the evaluation function T(k, 1), assign order k to the corresponding courier who has the best function value.
Step5: Capacity judgment. If the capacity C v of courier v u do not exceed his maximum capacity after the order allocation in Step 4, the allocation of order k is completed; if not, return to Step 2.
Step6: Judge whether the condition K < K max is met, if so, execute k + +, update all T(v u , k, 0) according to Δ k,k−1 and return to Step 1; otherwise, the algorithm meets the termination condition and output the result Assign the order to the courier Search for the best delivery route for courier Assign order k to the corresponding courier End of algorithm, output result Mathematical Problems in Engineering of order allocation and the optimal delivery route for each courier.

Subalgorithm: Current Optimal Route Optimization
Algorithm. In order to find the optimal delivery route for the allocated but not yet completed orders for a certain courier, a genetic algorithm considering the special characteristics of the problem is designed in this paper. e flow of the algorithm is as follows: Step 0 (chromosome representation): the chromosomes are coded in natural number, i.e., the corresponding codes of orders O 1 and O 2 are 1, 2 and 3, 4, respectively, where the odd numbers 1, 3 represent the merchant nodes while the even numbers 2, 4 represent the customer node. Since the delivery stage of the order must occur after the picking up stage, the customer node (even number) corresponding to an order in the chromosome must be behind the merchant node (odd number), and the numbers used to represent the merchant and customer are sorted by the order generation time sequence. In the delivery system, the order delivery problem must be guaranteed to take first and send back, that is to say, for an order, in the chromosome, the corresponding point of the merchant must appear before the corresponding point of the customer. All of them can get reasonable offspring, which can satisfy the order's first pick-up and back delivery.
Step 1 (initial population selection): the initial population is randomly generated in existing individuals according to the constraints.
Step 2 (cross operator): green denotes the intersection of genes, with the first half of the offspring being the first half of the corresponding parent and the second half in the order of the remaining elements in the other parent. All solutions must also satisfy one constraint, that is, for five orders, the business order is 1, 3, 5, 7, 9; the customer order is 2, 4, 6, 8, 10; the access order constraints of 1 before 2, 3 before 4, 5 before 6, 7 before 8, and 9 before 10 are required. In this paper, a visit sequence-based coding is designed to solve the delivery route optimization problem. In the process of crossover, the method of generating two children from two parents is adopted. e specific operation of crossover is shown in Figure 6. First, two parent chromosomes are randomly selected from the population according their fitness function, and a crossing position is generated randomly either, as shown in the red line in the figure. Since the chromosomes are divided into the first half and the second half by the crossing position, an effective crossover operation is designed here to ensure the feasibility of the two generated children. For child 1, the first half of father 1 was copied directly, and then the missing genes were supplemented to the second half in the order in which they appeared in father 2. Similarly, this operation can be used again to generate child 2. In this mode of crossover, as long as two parents are feasible, the offspring generated by their hybridization will also be feasible. at is, the constraint of visiting the merchant nodes (1,3,5,7,9) before their corresponding customer nodes (2,4,6,8,10) can be easily satisfied.
Step 3 (mutation operator): to maintain the diversity of population, the local changes of chromosome are generated by mutation operator. First, a chromosome is selected randomly from the population. en, in order to keep the feasibility of chromosome after mutation, a variation mode based on node pair exchange is designed, that is, select two orders randomly and exchange the visit sequence of their merchant nodes correspondingly, as well as the customer nodes, so as to ensure that, for any chromosome after mutation, each customer node must appear after its corresponding merchant node. e specific mutation process is shown in Figure 7.
Step 4 (fitness function): the fitness function is the objective function in this paper, that is, the total delivery cost of all orders.

A Simple Example.
To verify the validity of the take-out order allocation and delivery route optimization model established in this paper, taking Anning District of Lanzhou City Gansu Province in China as an example, 13 orders with 26 nodes are selected, and the latitude and longitude of each node are obtained through the Golden Map API. Assuming the following take-out delivery scenario, the location of two couriers and the location of the merchants and customers are shown in Figure 8. e detailed information is shown in Table 1, where the merchants and customers correspond to each other according to the subscript. For example, the merchant node and the customer node of order O 5 are m 5 and c 5 , respectively.
In this paper, take-out order dispatch and route optimization with/without considering traffic jam are calculated and compared, in which the congestion of urban road network is reflected by the speed of couriers. If there is no traffic jam in each road section of the road network, the delivery speed of the courier is constant throughout the trip. If there is traffic jam in some road sections, the courier will pass the congested road at a lower speed. e computing environment of the numerical experiment in this paper is Intel Core i7-7500u CPU, with 16 GB memory and windows 10 operating system, and the algorithm proposed is programed by MATLAB R2019a software. Assuming that the vehicle dispatching speed is 24.5 km/h and 35 km/h when the congestion is considered or not, the penalty cost for overtime dispatching is 1 yuan/ min, and the dispatching fee is 0.1 yuan/km. e calculation termination condition is the iteration times, which is set as 100.

Large-Sized Numerical Experiments.
is section aims to conduct more numerical experiments to examine the capability of the proposed model and algorithm. In this paper, a large-scale calculation example composed of 12 couriers and 40 orders is designed. e information of couriers and orders is shown in Tables 4 and 5.
In this paper, the calculation parameters and the running environment of the large case are the same as those of the small one, and the proportion of congested road is about 50%. e results of take-out order allocation and path optimization considering traffic jam or not are shown in Tables 6 and 7, respectively.
It can be found that, in both condition with or without traffic jam, there are some differences between the result of order allocation and route optimization. e couriers 1, 6, and 11 are not assigned any delivery orders when the traffic status is good, while the couriers 1, 7, and 11 are not assigned any tasks when traffic congestion is happened. e reason for this result is that the objective function of the problem here we studied is to minimize the total system dispatch cost, but not the delivery cost or income balance of single courier.
For this numerical test, the system dispatch cost considering traffic jam or not is 41.1540 yuan and 55.0888 rough 20 calculations, it can be found that the system dispatch cost under congestion is always greater than that without considering of traffic jam. When considering the road congestion, the delivery cost of some delivery paths increases, so we have to choose congested roads or suboptimal routes for dispatching, which result in the increase of system dispatching cost.
is paper calculates 20 times for simple examples and large-scale numerical experiments, respectively, the core program of the algorithm can be obtained from https:// github.com/Guofeng-SUN/Takeaway-algorithm-coreprogram/tree/master, and the computing time of two scale and four cases is shown in Table 8.

Conclusions
In this paper, order dispatching and route coordination optimization of the take-out system is studied. A route optimization model based on the minimum cost of system dispatch is established to deal with the complexity of spacetime network of the take-out dispatch system. Considering the real-time dynamic characteristic of order distribution and route optimization, the coupling relationship between order allocation and route optimization is established based on the delivery process. e main algorithm designed in this paper includes two core parts, one of which is the order allocation algorithm based on the highest efficiency of system dispatch and the other is the route optimization algorithm based on the improved genetic algorithm. A numerical experiment is constructed to verify the effectiveness of the model and the algorithm, and the result of two different traffic status are calculated. e computing results show that the algorithm not only has a better operation efficiency but also can reduce the dispatching cost of the delivery system, therefore has great practical significance.
Our current research studies from the perspective of system optimization, which is very necessary in some emergency scenarios, such as the epidemic of COVID-19. In the further research, we will pay more attention to the equilibrium of the order allocation, and continue to study the interactive solution strategies of order allocation and route optimization to realize the real-time optimization of large-scale dispatch problem in the urban system.

Data Availability
All data included in this study are available from the corresponding author upon request.

Conflicts of Interest
e authors declare that there are no conflicts of interest regarding the publication of this article.