1 Introduction

In recent years, the takeout market has expanded rapidly driven by the Internet, and takeout platforms have become an intermediate link between consumers and physical restaurants [1]. The flexible consumption time and diversified consumption scenarios of takeout have made the takeout consumer group rapidly expand. The rise and continuous growth have also expanded revenue channels for catering merchants. Statistics from Meituan, the only food delivery platform, show that the number of transactions in Meituan’s catering delivery business increased by 36.4% year-on-year in 2019, reaching 8.7 billion. pen, which shows that consumer demand for takeout delivery is constantly increasing. The diversity of demand makes takeout orders have an order structure of one order with multiple items. The one order with multiple items discussed in this article refers to a consumer order that contains two items. or more different types of food, for example [2], the food in one order includes two cups of milk tea, a burger and a fried chicken set meal, a total of 3 different types of food. This type of takeout order can better meet the diverse needs of consumers, but since one order involves multiple different restaurants, and the actual distance between each store will have a greater impact on the efficiency of food pickup and delivery, its delivery timeliness will be lower than that of a single type of food [3]. It cannot be ignored. Yes, with the diversification of consumer demand also pay more attention to factors such as service quality and service efficiency. Therefore, consumer service has become an indicator that food sellers focus on. On the premise of ensuring service quality, the operations between food sellers and collaboration requirements will be higher. Some of the published results have applied order allocation, crowdsourcing distribution model [4] and other methods to improve the delivery timeliness of orders, but there are also shortcomings such as high delayed delivery rate and high operating costs. Therefore, this article conducts optimization research from the perspective of improving the efficiency of takeout delivery, considering the characteristics of one multi-item takeout order and the time window characteristics of merchants and consumer demand, and establishes the research theme of this article [5]. It includes multiple decision-making problems: the time window of food sellers creates picking sequence problems, delivery vehicle routing picking up problems and path planning problems [6].

1.1 Literature survey

Regarding the issue of takeout delivery, the research [7] pointed out that takeout is a new model of the catering industry in the "Internet + " era. Various PC and mobile platforms and online payment functions have given rise to a variety of takeout operation models. This one [2] proposed Consumers' attitudes and behaviours toward takeout delivery services tend to be structurally related to factors such as low price, short time, and experience. Due to the diverse types of takeout and different delivery requirements, in practice, consumers' ordering preferences and order structure and customer comments [5], etc. In this regard, the article [8] proposed that time is an important factor affecting customer satisfaction. On-time delivery, improved food delivery efficiency and customer time satisfaction have become important indicators for measuring takeout delivery. In addition, takeout delivery is affected by weather conditions and population concentration [3] and other external factors have a great influence. In this regard, this [9] combined the ARIMA time series prediction model with the BP neural network to build a combination optimization model for order prediction based on the seasonal characteristics and consumption trend characteristics of takeout order delivery [10]. The above research all have considered various factors that affect delivery, and this article focuses on the impact of order structure on takeout delivery. Since the takeout order discussed in this article has the characteristics of one order and multiple items, the research on the Vehicle Routing Problem with Time Windows (VRPTW) during the delivery process mainly considers two aspects: (1) time window constraint problem [11]; (2) takeout the distribution timeliness problem caused by the strong timeliness of distribution. The time window constraint problem is one of the important constraints of the vehicle routing problem. There are currently a lot of research results in this field. This paper [12] used genetic algorithms and tabu search algorithms to optimize simultaneous pickup and delivery the vehicle routing problem of goods. Jun et al. [13] proposed a traffic request initiation grouping algorithm and a vehicle initiation grouping algorithm, and combined the memetic algorithm developed by the author to explore the simultaneous pickup and delivery problem. In this [14] improved the basic genetic algorithm, and solve the VRPTW problem based on the large-scale neighbourhood search algorithm. The research [15] improved the explosion operator in the fireworks algorithm and modelled it to find the optimal solution to the VRPTW problem. This work [16] applied the mixed integer linear programming formula and the adaptive large neighbourhood search algorithm analyses and solves the problem of simultaneous delivery of products and services with order release dates, points out that increasing the length of the service time window can significantly reduce costs, and summarizes the advantages of simultaneous delivery and separate delivery. In addition, there are also many results related to the distribution timeliness issue. In this [17] took the COVID-19 epidemic as the background and studied the multi-supply point multimodal emergency material dispatching problem based on the variable length genotype genetic algorithm. They discussed the lowest transportation cost and time penalty. Multi-objective scheduling can be completed under the premise of minimizing the risk of infection of delivery personnel and minimizing the risk of infection of delivery personnel. To solve the problems of long transportation time, high cost and short preservation time of vegetables, research [18] used a method combining genetic algorithm and simulated annealing algorithm to determine the vegetable transportation time. The optimal path for transportation and distribution is to minimize the number of vehicles and driving time in the distribution plan. This study [19] studied the multi-temperature co-location vehicle routing problem of the pharmaceutical cold chain to solve the constraints of external temperature changes, time window constraints, and loading strategies. To solve the problem, a hybrid genetic algorithm and a large neighbourhood search algorithm are used to consider the distribution optimization scheme under various temperature requirements. This paper [20] proposed a local search algorithm to solve the simultaneous pick-up and delivery VRPTW with multi-objective and large-scale properties. Problem. The papers conclude that the time window constraint problem is best addressed by employing non-basic genetic algorithms, such as heuristic algorithms and ant colony algorithms. This article, however, examines the relevant breadth of each method while considering the distribution problem's features and extent. The employment of the genetic algorithm is decided upon, with comparison tests conducted using the particle swarm algorithm; in addition, for the issue of delivery timeliness, the above articles consider delivery timeliness in combination with other factors (such as distribution fairness, product integrity, etc.), which will inevitably involve various aspects. Interference and uncertainty among factors. This article eliminates these interferences and only considers the factor of delivery timeliness.

Relevant research in this article also involves order processing problems that consider logistics distribution. This research work [21] proposed a large neighbourhood search metaheuristic solution method to minimize the cost of picking and delivering problems with time windows. This studied [22] describes the order delivery process under the cooperation model with external suppliers, whose main characteristics are multi-point pickup, one-time delivery, and time window. The work [23] considered the uncertainty of service time and travel factors and used a robust method modelling solution. An enhanced evolutionary algorithm was employed to investigate the integrated pickup and delivery truck routing issue under limitations such soft time windows in the paper [24]. Most of the above-mentioned articles consider order processing problems under the conditions of cooperation between upstream and downstream enterprises, and the scope is relatively large and this article considers the processing of consumer demand orders by individual sales merchants, and the research questions are more detailed.

The above-mentioned VRPTW problem and various research results considering the order processing problem of logistics distribution have laid a solid theoretical foundation for this study. An extension of the traditional Vehicle Routing Problem (VRP), the Vehicle Routing Problem with Time Windows (VRPTW) requires vehicles to deliver products or services to a group of clients within predetermined time windows. Every client in VRPTW has a window of time within which it can be attended to. The goal is to identify the best possible set of routes for a fleet of cars in order to reduce overall cost or distance while meeting all requirements, including window timing limitations. Some of the basic VRPTW problems are as under

Clients: A group of individuals exist, each with a distinct need for products or services.

Depot: At a central depot, vehicles begin and finish their runs.

Time Windows: There is a window of time during which each customer may be attended to. Penalties may apply if a car comes too early or too late.

Vehicle Capacity: The amount of cargo or services that a vehicle can transport is restricted.

Goal: As long as all criteria are met, reduce the overall distance driven by all vehicles or the number of cars utilized.

The VRPTW can be solved by using heuristic techniques such as insertion algorithms or closest neighbor to quickly create initial routes. Employ metaheuristic techniques to iteratively enhance solutions while striking a balance between exploration and exploitation, such as simulated annealing or genetic algorithms. Using solvers such as CPLEX or Gurobi, formulate VRPTW as an integer programming model for precise answers. For scalability, take into account hybrid solutions that blend accurate and heuristic methods. For large-scale instances, use distributed and parallel computing. Give priority to adjusting in real-time to dynamic shifts in vehicle supply or demand. Within computational bounds, preprocessing and local search methods can improve the quality of the answer even further.

However, the above research did not consider the coordination between different physical merchants, and the delivery of takeout orders in this study requires different locations. The takeout sales merchants gather together to realize the coordination of multiple entity merchants on the basis of time window constraints through the sharing and transparency of time window information. In addition, in vested theory, one must consider the distribution problem of a single takeaway order with many items. Propose feasible management suggestions based on the results.

This study has made major contributions in the areas of resource efficiency, consumer satisfaction, economic viability, regulatory ramifications, and scalability in addition to environmental sustainability. The project aims to minimize fuel consumption and emissions while optimizing delivery efficiency and lowering trip distance, hence boosting environmental sustainability. Additionally, it conserves resources including labor, fuel, and vehicle wear, improving operational effectiveness and perhaps lowering expenses. Customer satisfaction is increased via expedited delivery times and precise order fulfillment via improved routes. Productivity gains and lower operational costs increase economic viability. The results can be used by policymakers to create rules and rewards for environmentally friendly transportation. Furthermore, the benefits of scalable optimization approaches are not limited to the food delivery industry. Overall, this study supports more general sustainability objectives by having a beneficial effect on the social, economic, and environmental facets of food distribution and beyond.

Section 2, identifies and contextualizes the research issue and in Sect. 3, constructs a mathematical or conceptual framework to address the problem. In Sect. 4, develops algorithms and conducts experiments to validate their efficacy and in Sect. 5, summarizes findings, discusses implications, and suggests future research directions.

2 Problem description

The main solution to the takeout order distribution problem with time windows studied in this article is for a takeout delivery person to go to each store in turn to pick up all the food that needs to be delivered, and at the same time deliver it within the specified time according to the planned route. That is, takeaway delivery personnel need to pick up and deliver goods at the same time.

Under the premise that the order information, the distance between each seller, and the service time window of each seller are known, in order to meet the order type requirements, food integrity, order timeliness and other conditions, it is necessary to decide how to formulate a takeaway delivery plan. This includes determining the order of picking up goods from each seller, arranging the delivery route of the vehicle routing, etc.

In the distribution optimization problem of takeout orders with the characteristics of one order and multiple products, the vehicle routing scheduling and routing problems are typical NP-hard problems, which are difficult to solve.

In order to clearly define the research questions of this article, the following basic assumptions are mainly made:

  1. 1)

    The order fulfilment time mainly depends on the delivery time, and other influencing factors such as order distribution time, food loading and unloading service time, etc. are ignored;

  2. 2)

    The distribution cost mainly depends on the order, but has no impact on the final decision-making plan and is ignored here;

  3. 3)

    The delivery costs of each food seller are the same and fixed;

  4. 4)

    Path time and path cost are proportional to the length of the delivery path;

  5. 5)

    Consider vehicle routing type restrictions and vehicle loading capacity restrictions for takeout delivery, as well as vehicle load restrictions;

  6. 6)

    The location coordinates of each food seller and consumer are known, and consumer demand can be determined;

  7. 7)

    Delivery services for consumers include delivery services and pickup services;

  8. 8)

    All roads are smooth, regardless of special circumstances such as traffic congestion;

  9. 9)

    The time windows for all food sellers and consumer demand are fixed, and the time requirements for the lower limit of the time window are very strict. Those who arrive later than the lower limit of the time window will be given a certain penalty.

3 Model building

3.1 Symbol explanation

\(M=\{l\mid \text{1,2},3,\cdots ,L\}\) Is the set of foods that need to be delivered in an order.

\(C=\{j\mid j=\text{1,2},3,\cdots ,J\}\) is the set of food sellers.

BC is the maximum distribution vehicle load limit that is less than the corresponding order food demand in set C, which represents a large demand point set that needs to deliver food.

SC is the set of the remaining demand after the maximum delivery vehicle load limit is greater than the corresponding order food demand in set C and the larger demand point is fully loaded and directly distributed through the segmentation strategy. It represents the set of small demand points that need to deliver food.

\(W=\{a\mid \text{1,2},3,\cdots ,A\}\) is the consumer set.

\(V=\{k\mid k=1,\text{2,3},\cdots ,K\}\) is the set of delivery vehicles.

\(N=C\cup W\cup V\) is the set of all nodes.

\(V{Q}_{k}\) represents the maximum load capacity of the vehicle.

\({d}_{ij}\) represents the plane distance from merchant i to merchant j, with \({d}_{ij}=\sqrt{{\left({x}_{i}-{x}_{j}\right)}^{2}+{\left({y}_{i}-{y}_{j}\right)}^{2}}\). Among them, \({x}_{i}\) and \({y}_{i}(i\in N)\) are the horizontal and vertical coordinates of merchant i, \({x}_{j}\) and \({y}_{j}(j\in N)\) is the horizontal and vertical coordinates of merchant j.

\({v}_{k}\) represents the average speed per unit distance of delivery vehicle routing k.

\({q}_{j}\) represents the demand of merchant j (j ∈ C).

\(vc\) represents the dispatch cost of each vehicle.

\({S}_{i}\) represents the service time of the vehicle at merchant i, usually \({S}_{1}=0\).

\({q}_{ik}\) represents the carrying capacity of vehicle \(k\) when it leaves merchant i.

\({c}_{ij}\) represents the cost of a vehicle traveling from merchant i to merchant j.

\({c}_{ja}\) represents the cost of a vehicle traveling from merchant j to consumer a.

\(\left[{e}_{i},{l}_{i}\right]\) represents the time window corresponding to merchant i accepting services.

\(d{t}_{ja}\) represents the distance travelled by a vehicle from merchant \(j\) to consumer a; \(d{t}_{ij}\) represents the distance travelled by a vehicle from merchant \(i\) to consumer j; \(d{t}_{ia}\) represents the distance travelled by a vehicle from merchant \(i\) to consumer a.

\(V{T}_{kj}\) indicates when the \(k\) vehicle arrives at merchant j.

\({t}_{a}\) represents the end of time for consumer \(a(a\in C)\).

Decision variables:

$${x}_{ijk}:\left\{\begin{array}{l}{x}_{ijk}=1, \quad {\text{Vehicle k travels from merchant i to merchant}}j(i\ne j)\\ {x}_{ijk}=0, \quad {\text{other}}\end{array}\right.$$
$${x}_{ilk}:\left\{\begin{array}{l}{x}_{ilk}=1,\quad {\text{Vehicle k travels from merchant i to consumer}}l(i\ne l)\\ {x}_{ilk}=0,\quad {\text{other}}\end{array}\right.$$
$${x}_{\text{irk }}:\left\{\begin{array}{l}{x}_{\text{irk }}=1,\quad {\text{Vehicle k travels from merchant i to consumer}}r(i\ne r)\\ {x}_{\text{irk }}=0,\quad{\text{other}}\end{array}\right.$$
$${x}_{jik}:\left\{\begin{array}{l}{x}_{jik}=1,\quad{\text{Vehicle k travels from merchant j to merchant}}i(i\ne j)\\ {x}_{jik}=0,\quad{\text{other}}\end{array}\right.$$

These factors play a crucial role in coordinating a productive system of distribution from vendors to customers. The paths that cars travel are determined by decision variables such as \({x}_{ijk}\), \({x}_{ilk}\), and \({x}_{\text{irk}}\), which have an immediate effect on the flow of products. Route selection is influenced by distance-related factors such \({d}_{ij}\) and \(d{t}_{ij}\), which reduce transportation distances for timely and economical delivery. Demand-related factors, such as \({q}_{j}\), guarantee the fulfillment of client orders, whereas cost-related variables, such as \({c}_{ij}\) and \({c}_{ja}\), are critical in lowering total transportation costs. Delivery schedules are managed by time-related variables like \({S}_{i}\), \(\left[{e}_{i},{l}_{i}\right]\), and \({t}_{a}\), which make sure that deliveries happen within predetermined time periods. The delivery system can satisfy demand, save costs, optimize operations, and guarantee timely delivery to customers by taking into account elements like capacity and time restrictions.

3.2 Distribution model

This issue may be represented mathematically as follows:

$$min\,\,\,{Z}_{1}=\sum_{i\in N} \sum_{j\in N} \left(vc\cdot {x}_{ijk}\right)+\sum_{i\in N} \sum_{j\in N} {c}_{ij}+\sum_{j\in N} \sum_{a\in N} {c}_{ja}$$
(1)
$$\text{s.t.}\sum_{j\in S{C}_{j}} {q}_{j}\sum_{i\in N} {x}_{ijk}\le V{Q}_{k},\forall k=\text{1,2},\ldots ,{K}_{1}$$
(2)
$$\sum_{k\in V} \sum_{i\in N} {x}_{ijk}=1,\forall j\in C$$
(3)
$$\sum_{i\in N} \sum_{l\in M} {x}_{ijk}=1,\forall k\in V$$
(4)
$$\sum_{r\in W} {x}_{irk}-\sum_{j\in C} {x}_{jik}=0,\forall k\in V,i\in N$$
(5)
$$\sum_{i\in N} {x}_{ijk}-\sum_{i\in N} {x}_{jik}=0,\forall k\in V,j\in N$$
(6)
$$d{t}_{ja}=d{t}_{ji}+d{t}_{ia},\forall i,j\in N,a\in V$$
(7)
$$V{T}_{kj}\le {t}_{a},\forall j\in C,k\in V,a\in N$$
(8)
$${x}_{ijk}\in \{\text{0,1}\},\forall i,j\in N,k\in V$$
(9)
$$\sum_{i} {q}_{ik}<V{Q}_{k}$$
(10)

The objective function (1) uses \({Z}_{1}\) to represent the minimum order fulfillment cost, which mainly includes the cost of dispatching a vehicle routing, the cost of the vehicle routing during driving and the cost of the vehicle routing food delivery to consumer demand.

Constraints: Eq. (2) indicates that the demand for a certain food distribution vehicle is lower than the loading capacity of the vehicle k; Eq. (3) indicates that every merchant with food distribution needs can be served and can only be delivered by one vehicle service (the demand for food delivered by each food seller does not exceed the capacity of the delivery vehicle); Eq. (4) means that every consumer demand with food delivery needs can be served and can only be served by one delivery vehicle; Eq. (5) means that each delivery vehicle must return to the initial location of the vehicle, that is, the parking lot after completing the delivery task; Eq. (6) represents the continuous characteristics of the route constraints, that is, when the vehicle reaches the corresponding merchant, it must leave the merchant and go to the next destination. land; Formula (7) is the mathematical expression of \(d{t}_{ja}\), which means that the distance from the delivery vehicle transporting food to consumer demand a is equal to the distance to the previous merchant \(i\) plus the distance from merchant i to consumer a; Formula (8) represents the time window limit within which consumers can receive takeout; Formula (9) is the 0–1 decision variable; Formula (10) represents that the vehicle loading does not exceed the maximum capacity of the vehicle.

4 Algorithm design and numerical experiments

4.1 Ideas for solving problems

This article mainly provides the optimal solution by planning the optimal path to save costs, and uses optimization algorithms to solve mathematical models. Among the research results on vehicle path optimization, artificial bee colony algorithm, ant colony algorithm, rolling time domain delay delivery algorithm, Genetic algorithms, etc. can be selected as the solution algorithm for the mathematical model in this article. Next, this article will analyse the impact of the above various algorithms on the calculation process and results, and compare their effectiveness and practicability.

  1. (1)

    Method for simulating a colony of bees

The method for simulating a colony of bees was initially suggested as a swarm intelligence optimisation technique [25]. This algorithm solves function optimization problems by imitating the honey-gathering behaviour of bees. The algorithm requires fewer parameters and is simple to operate. It is easy to implement; however, when solving certain complex function problems, there are problems such as slow convergence and easy falling into local optimality.

For the mathematical model in this article, during the delivery process, it is necessary to confirm the time when the vehicle arrives and leaves the merchant, the capacity and load capacity of the delivery vehicle, the time range for the end consumer demand to pick up the order, etc., involving time windows, vehicle loading capacity, etc. vehicle service capabilities for merchants and consumers, etc., resulting in a large number of basic data and initial parameters for the model. Using the artificial ant colony algorithm will cause the model to fall into a local optimal state, greatly reducing the accuracy and calculation efficiency of the algorithm.

  1. (2)

    Ant colony algorithm

Ant colony algorithm is a swarm intelligence algorithm that solves combinatorial optimization problems by simulating the foraging behaviour of ants, using random search distributed computing as an optimization method [26]. This algorithm determines the final goal by finding the shortest path in the model Function value has strong parallelism and globality. However, during the calculation process, since each global optimization needs to update the global pheromone, the algorithm requires a large number of calculations, takes a long time to search, and is prone to stagnation.

In the mathematical model of this article, the random search characteristics of the ant colony algorithm make the vehicle path lack clear optimization parameters in the optimization process. Even if it can be optimized through pheromone, the optimized path will still have a certain difference from the theoretical optimal value. Moreover, after the cycle reaches a certain number of times, as the solution process progresses, the scale of the problem will also expand, and the amount of deconstruction calculations will also increase, which will easily cause the algorithm to stagnate and reduce the solution efficiency.

  1. (3)

    Rolling time domain delayed delivery algorithm

This algorithm refers to: Divide the delivery time into smaller time windows, and execute the delivery process sequentially starting from the starting time window. Every time a new time window is reached, the order allocation and route planning are re-carried out, and at the time of each order Try to postpone order allocation as much as possible under window constraints so that orders can be combined for delivery. It mainly processes dynamic time windows and hard time windows to ensure that delivery is completed within the latest delivery time [27].

This algorithm is mainly aimed at the field of distribution, so it can be applied in the mathematical model of this article, but orders will be delayed in the calculation process. Considering the strong timeliness of takeout delivery and its importance to merchant profitability and customer evaluation, delay Order allocation and delayed delivery are difficult to achieve; in addition, this algorithm has no clear constraints on the vehicle's loading capacity, which is inconsistent with the assumptions of this article's model, so it is not suitable for solving this article's model.

  1. (4)

    Genetic algorithm

An optimisation method known as a genetic algorithm was created using principles from the evolutionary process of natural selection [28].This algorithm has good robustness, stability, and versatility, so it can be used to solve various complex large-scale problems. Combinatorial optimization problems, etc.; however, it is easy to mature prematurely during the solution process, thus falling into a local optimal solution.

This article also considers the advantages and disadvantages of other algorithms, as listed in Table 1. Taking into account the characteristics of the model established in this article, through the above comparison of the characteristics of different algorithms, it is determined that the genetic algorithm is used to plan the optimal vehicle path and solve the problem space. This is because the genetic algorithm has strong global search capabilities, can achieve convergence of the solution domain with high efficiency, and obtain the optimal solution by gradually optimizing the objective function value [29].

Table 1 Comparison between other algorithms

Based on these characteristics, it can be determined that the iterative optimization of the genetic algorithm can be used to achieve the convergent evolution of the entire problem, thereby quickly solving the takeout order distribution problem in this article that considers the delivery requirements of both merchants and consumers. After the algorithm is determined, this article determines by setting different runs obtain the number of iterations of the optimal solution, then input the basic data to conduct a numerical example experiment, and analyse the running results. The genetic algorithm flow chart is shown in Fig. 1.

Fig. 1
figure 1

Genetic algorithm flow chart

An optimization algorithm that draws inspiration from natural selection and genetics is known as a genetic algorithm (GA). It mimics the process of natural selection found in biological organisms to discover answers to optimization and search issues.

A genetic algorithm's flow chart usually consists of the following important steps:

  • Initialization: The process begins by generating a population of possible fixes for the issue at hand. Every solution is expressed as a collection of characteristics, sometimes referred to as people or chromosomes.

  • Fitness Evaluation: A fitness function is used to assess each member of the population's level of fitness. This function assesses a given solution's performance in relation to the given problem.

  • Selection: Based on their level of fitness, members of the existing population are chosen to raise the next generation. In a phase that resembles natural selection, those who are more fit are given the advantage when it comes to passing on their genes to the following generation.

  • Crossover (Recombination): To create children, a certain set of people (parents) go through crossover or recombination. To come up with innovative solutions, this entails parents sharing genetic information. One can use a variety of crossover strategies, including uniform, multi-point, and single-point crossover.

  • Mutation: Random modifications are made to a portion of the population in order to add variety and delay premature convergence. Through the modification of certain parameters in the solution, new regions of the search space may be explored.

  • Replacement: The least fit members of the present population are replaced by their children and maybe modified individuals, creating a new population for the following generation.

  • Termination Criteria: Until a termination condition is satisfied, the algorithm iterates through the phases of selection, crossover, mutation, and replacement. This might be convergence, a maximum number of generations, or arriving to a workable solution.

Robust optimization methods like genetic algorithms are capable of effectively navigating intricate search spaces and locating almost ideal solutions for many issues including scheduling, machine learning, and optimization. Genetic algorithms reproduce the process of natural evolution by iteratively developing a population of solutions through selection, crossover, and mutation, yielding progressively more fit solutions over generations.

4.2 Algorithm design

This article chooses the genetic algorithm for solution and improves it on the basis of its conventional time window. Delivery efficiency is mainly achieved by constraining the lower limit of the time window, but does not set strict requirements for the upper limit of the time window, that is, the delivery vehicle can arrive earlier than the time The upper limit of the window can reach the designated location without penalty, and delivery vehicles can carry out food preparation and other services in advance, which allows greater flexibility in route planning.

Real number coding is used in the algorithm of this article; the real value of the decision variable is used for genetic operations, the corresponding gene value is a floating-point number within a certain interval, and the number of decision variables is the string length. In the chromosome, 0 is used to represent the parking lot and Merchant nodes are coded. This article uses \(\text{1,2},\ldots ,n\) to represent merchant nodes. One delivery route is responsible for the delivery of an order, and one order involves multiple merchants. If the delivery route of an order needs to go through 6 different merchants, Then the chromosome can be expressed as \(X=\{\text{0,1},\text{3,6},\text{12,4},5\}\). This paper uses random generation to generate the initial population, all merchant nodes constitute the initial population N of the algorithm. Group the genes on the chromosome according to the decoding rules, and determine the number of paths and the meal-picking nodes on each path.

This article chooses the reciprocal of the objective function as the fitness function of this algorithm, see Eq. (11). This is because the goal of the delivery route planning problem for takeaway orders is to minimize the total delivery cost, and the fitness function tends to choose a larger one. Value.

$$F\left(i\right)=\frac{1}{min{Z}_{1}}$$
(11)

After determining the above basic information, genetic operations can be performed. First of all, the individual selection method in this article adopts the roulette selection method, so that the probability of an individual being selected is proportional to the size of its fitness function value. When implementing the operation, it is first necessary to confirm that the individual is selected and the probability of inheritance to the next generation population is determined, and then a roulette operation is used to screen the individuals that are inherited to the next generation based on the obtained fitness value. The relevant formula is as follows:

$${P}_{i}=\frac{{f}_{i}\left(x\right)}{\sum_{i=1}^{N} {f}_{i}\left(x\right)}$$
(12)
$${f}_{i}\left(x\right)={Z}_{1}-\frac{{Z}_{2}}{\rho }$$
(13)

Among them, N represents the population size, fi (x) represents the fitness function.

Next, the crossover operation is performed. This paper adopts the partial matching crossover method, first exchanging the crossover area, and then exchanging the repeated genes outside the crossover area, and then performs the crossover operation based on this [10]. Then the gene inversion method is used to perform mutation operation. Two mutation points in the gene are randomly selected, and the genes at the mutation positions are inserted in reverse order to obtain a new individual [30]. Finally, the genetic operation is terminated by determining the highest possible number of cycles, and the optimal solution is obtained [31].

4.3 Example experiments and result analysis

Since there is no standard calculation example to refer to for the problem studied in this article, it is necessary to design the calculation example according to the characteristics of the problem in this article. Given multiple food sales merchants and multiple consumers, and the consumer will place several orders through the online catering sales platform Order, and then determine the type and quantity of food and its supplier based on the consumer's order.

The problem description explains that the main content of this study is the distribution and delivery of takeout orders. If all food categories in a consumer's order can be satisfied by all merchants passing through a delivery path, and the pickup time is within the time allowed by the merchant, within the window, if the delivery time is within the time window open to consumer demand, the takeout food will be delivered to these merchants. Otherwise, the order will be split into multiple sub-orders to complete, and multiple delivery routes will be planned to ensure that the calculation examples of this study are met require.

4.3.1 Basic data

To ensure that the method is functional and that the model presented in this article is reasonable, this article conducted an on-site investigation of the takeout XZ distribution centre of Company A to obtain relevant data such as merchant distribution, consumer distribution, takeout orders, etc., and constructed a calculation example based on this. The calculation example in this article is based on the delivery situation of Company A's takeout XZ distribution centre throughout a certain location and at a specific time. Taking North Railway Station as the reference point, 13 different locations around it are selected based on the geographical location on the actual map. Food sellers. The specific location relationship of each merchant is shown in the screenshot of the Baidu map shown in Fig. 2. Each merchant is marked by a red dot in the figure, and the white label next to each red dot indicates the actual address of each merchant on the map. The figure is marked with the location of number 1 is the reference point—North Railway Station, and the remaining 13 marked locations are the exact locations of 13 merchants on the map. In addition, there are also a certain number of consumers, but considering that this model is not suitable for actual ordering It is not widely used at the time, and compared with the normal order food delivery model, the demand for takeout orders with multiple items per order is relatively small, and the number of such orders will not account for the majority of the total daily orders, so this article calculates it here In the example, there are 4 consumers, and these consumers will place 4 independent orders from the online takeout platform at different points in time.

Fig. 2
figure 2

The map distribution map of all nodes

The actual geographical locations of various food sellers and consumers can be obtained from the flat map, and their location information can be converted into a flat rectangular coordinate system to facilitate subsequent route planning. For ease of expression, this article uses numerical numbers as locations the code name. Among them, the number 0 represents the parking lot, which is also the reference point for the location distribution of each point, and all the points involved in this case are within the radiation range of the reference point 0; the numbers 1–13 represent 13 different foods respectively. Sales merchant; the numbers 14, 15, 16, and 17 represent consumers 1, 2, 3, and 4 in turn. The two number axes, namely the x-axis and the y-axis, represent the conversion of the actual position relationships of all points into two-dimensional plane rectangular coordinates. After cantering the system, the actual distance between the horizontal and vertical coordinates of each point is expressed in units of km. Among them, the range of x is [24 km, 40 km], and the range of y is [33 km, 45 km]. From this assumption: The locations of multiple food sellers are randomly generated within the coordinate range of [25 km, 45 km]; the location of consumers receiving orders is randomly generated within the range of [24 km, 43 km]; [35 km, 40 km] represents at which spot in the parking lot, the reference point location, the delivery vehicle stops here when it has no tasks. The detailed data is listed in Table 2.

Table 2 location information of consumers and various food sellers

After determining all the location coordinates, it is also necessary to know the demand for different types of food in each consumer's order. For the sake of clarity and simplicity in the calculation example, this article sets up four orders, one from each of four different consumers, with five different types of food each order. It is also important to find out how long customers are willing to wait for their orders to be delivered, so we can limit the loading volume and pickup sequence of the delivery vehicle route. Although consumers are interested in different types of food, the demand for food is small, but considering the loading capacity of the delivery vehicle, the vehicle driving path still needs to be further optimized according to the objective function, so the demand for food is still an important influencing factor. This article gives the example of a single consumer order the food demand of various types of food distributed to different food merchants, that is, the food categories and total quantities that each merchant involved should distribute. Food categories are represented by lowercase English letters a-m; food demand can be expressed in units (kg), if the demand for a food type is 0, it means that there is no demand for this type of food in consumer orders. The specific data are listed in Table 3.

Table 3 Demand for different food items in individual consumer orders

After determining the food demand type and quantity of each consumer, in order to ensure that the food can be delivered within the time range allowed by the consumer, the consumer's delivery time is set to be greater than the maximum value of the lower limit of each merchant's time window, so that Provide sufficient time for the delivery vehicle to rush to the consumer's location after completing all pickup tasks. Since the takeaway consumption at the location selected in this case is mainly concentrated during lunch time, usually between 11:00 and 13:59, this article assumes the consumer order has been placed through the online platform before 12:00 noon and the merchant has received the order. The unified delivery time of the consumer order is 12:00 noon, and the upper and lower limits of the delivery time window are as listed in Table 4.

Table 4 The upper limit of the time window for each consumer

For the food that consumers demand, first determine the source merchant, and then plan a reasonable delivery route for each delivery vehicle based on factors such as its corresponding geographical location (planar coordinates), the proximity of the pickup time allowed by each merchant delivery services.

4.3.2 Analysis of the value of three-level iteration times

The genetic algorithm needs to determine parameters such as population size and crossover probability during operation. At the same time, the numerical values of the parameters also reflect the different properties of the population. Changes in any parameter will affect the results and efficiency of the genetic algorithm. In order to better obtain the optimal for the optimal solution, first analyses the parameter values for the number of iterations.

Since the data in this case is small and the data size is also small, in order to avoid too many iterative optimizations that will make the results over-optimized and deviate from the theoretical optimal solution, the population size is set to a smaller value. In addition, refer to in vehicle distribution related research, in order to ensure that the conclusion deviation is small, the number of iterations in most studies is basically 1000 [1, 14]; in order to adapt to the optimization process of this article's case, the population size is set to 200 [32]. The crossover probability range is usually in the range of 0–1, in order to obtain the best possible solution, the crossover probability is usually set slightly larger so that most individuals can participate in the optimization process, but setting it to 1 is likely to destroy some original results. If there are some excellent solutions, refer to the relevant distribution model and its solution process, and set the parameter of the crossover probability to 0. 9. The values of the final solution under this probability are not much different from the theoretical values, which can not only retain a few outstanding individuals but also ensure that most individuals participate in the optimization. The detailed parameter settings are listed in Table 5.

Table 5 Basic parameter settings

Next, the number of iterations is \(100, 200, 300, \ldots ,1000\) and each is run 10 times. 10 objective function values can be obtained. The results are listed in Table 6.

Table 6 Comparison of running cost under different iteration numbers

Figure 3 shows that both the change trend and the running time of the algorithm get longer with increasing iterations; nevertheless, the objective function value changes in an alternating fashion, going up and down. As the iterations increase from 100 to 300, the objective function's value gradually decreases. As the iterations increase from 400 to 700, the objective function's value increases. At 700 iterations, the minimum value that can be obtained within the current calculation range is 174.59 yuan. With iterations exceeding 700, the minimum value of the function always remains at 187.19 yuan, but it is still larger than the value when iterations are 700. Regardless matter whether the objective function value varies by, it will always be between [174, 246].

Fig. 3
figure 3

Comparison of running cost under different iteration numbers

It follows that the evolutionary algorithm described in this article can discover a good solution at a low solution cost, and that its effectiveness in finding solutions is increasingly apparent with increasing problem size. While doing so, the resultant solution agrees with the theoretically ideal solution. With such a little discrepancy, we can be sure that the solution procedure proposed in this article is both practical and efficient. The parameters of this calculation example are known to be 200 for the population size, 1000 for the maximum number of iterations, and 0.9 for the crossover probability, according to the findings shown above.

4.3.3 Calculation example experiments and running results

This article uses MATLAB R2020b software to run the genetic algorithm. First, the relevant basic parameter values must be determined: the population size is 200, the crossover probability is 0.9; based on the actual food delivery vehicle situation, the food delivery vehicle capacity is set to 150 (within about 10 orders), the vehicle traveling speed is 45 km/h. See Table 5 for specific parameter settings.

After adding the above basic parameters and data to the algorithm and running the program, the optimal solution of the total cost can be obtained as 174.59 yuan. The optimal solution of the running result of this example corresponds to the distribution vehicle route planning and its optimal total cost as listed in Table 7. The goal of distribution vehicle route planning is to minimize overall expenses by strategically allocating delivery trucks to efficiently distribute items to several sites. This procedure entails figuring out the most economical order of stops while taking delivery locations, vehicle capacity, time windows, traffic patterns, and fuel expenses into account. Route planning software may determine the best routes by applying optimization algorithms to reduce overall expenditures, which include fuel prices, car maintenance, driver salaries, and any other pertinent charges. In order to guarantee that items are delivered in a timely and economical way, these criteria are balanced to obtain the ideal overall cost. Among them, the digital numbers represent different consumers (underlined) and food merchants; the route from left to right represents the order in which the food delivery vehicle picks up the goods at the store and delivers the goods to the consumer; the boxes with boxes The number 0 represents the starting point and end point of the food delivery route, that is, the parking lot; each food delivery vehicle is responsible for delivering a complete order placed by the consumer on the online platform. The path diagram is shown in Fig. 4. The black dotted arrow in the figure indicates that the food delivery vehicle has completed all pickups. For the return route during food delivery tasks, the arrow points to the end point, which is the parking lot.

Table 7 Delivery vehicle route planning decisions
Fig. 4
figure 4

Path diagram

Considering the situation of simultaneous pickup and food delivery, the vehicle food delivery process is as follows: when the food delivery vehicle passes by the consumer, it takes away the food in the consumer's order; when the food delivery vehicle passes by the food merchant, it delivers the food that needs to be delivered in the order. This saves money. It reduces the manpower, material resources and time consumed in the distribution process, and can also meet the limitations of the loading capacity of distribution vehicles, so as to achieve the highest distribution efficiency with the least resources.

4.3.4 Result analysis and discussion

When the algorithm is running, the changing trend of the objective function value can be expressed in the form of an image, as shown in Fig. 5.

Fig. 5
figure 5

The objective function value of the algorithm changes

It can be seen from Fig. 4 that in the initial stage, when the number of iterations is very small, the fitness value of the individuals in the group is low, and the fitness of the operator obtained through the selection operation is poor, resulting in low efficiency of the algorithm. The objective function value of is large, making the initially formed image steep and showing a cliff-like stage change in the subsequent iterative operation process. When the algorithm runs from the first generation to about the 300th generation, as the number of iterations increases, the objective function value decreases slightly It dropped to about 232.20 yuan; when it continued to run to the 700th generation, as the number of iterations increased, the objective function value experienced slight fluctuations and dropped again to 174.59 yuan; and then continued to run to the 900th generation, the objective function value Continuously unchanged. During the entire iteration process, the image converged quickly and showed a relatively stable trend in a large number of repeated iterations. The final optimal solution was 174.59 yuan.

After on-site visits and research, it can be concluded that under the delivery model of this article, the cost of the takeout delivery process in the area around North Railway Station is approximately 230 yuan/day per person, including the cost of dispatching a car during this period of about 150 yuan/day per person. And the expenses related to the distribution process are about 80 yuan/day per person, and the model in this article is calculated to be 174. The cost is 59 yuan/day. In comparison, the cost of the one-order multi-product delivery model is 24% lower than the cost of the traditional delivery model. 09%. It can be seen that when the demand for takeout changes in diversification, the takeout food delivery of one order and multiple products can integrate distribution resources by picking up and delivering goods at the same time to achieve the purpose of reducing costs.

Combining the above examples and analysis, this paper draws the following conclusions.

(1) It can be seen from the changes in the number of iterations of the above operation that the objective function value tends to the optimal solution as the number of iterations increases. However, since the genetic algorithm is not an exact algorithm, the objective function value obtained is not the true value of the calculation example. The optimal solution in the sense is only a result that is numerically close to the exact optimal solution. At the same time, the range of the optimal solution can be roughly obtained from the above iteration number analysis.

(2) Genetic algorithms can complete the solution process for feasible food delivery time windows. However, as the size of the problem increases, the feasible food delivery time window for orders is larger, and the time window has less restrictions on the order fulfilment plan, which may. This will lead to inaccurate calculation results, or even deviate from the expected theoretical optimal solution.

(3) Based on this example, it can be seen that the upper and lower limit settings of the time window play an important role in route optimization. When the time span of the merchant's feasible pickup time window is narrow, the catering vehicle will arrive at the designated location later than the specified time. Risks are also increasing, which may directly lead to reduced food delivery efficiency and reduced satisfaction with delivery services. Currently, there are many homogeneous and similar food sales brands on the market, and market competition is fierce. The results of takeaway delivery will directly affect its future short-term sales. In order to maintain in terms of profits and market share, the time window should be relaxed appropriately so that delivery vehicles can complete the pickup task in a shorter time without being punished.

Therefore, the upper limit constraint of the time window set in this article is not very strict. Vehicles can arrive early and wait. In this case, although there is a penalty, it is small and can be ignored. This will not strictly limit the time to a short period of time. The feasible range of order processing is relaxed, allowing catering vehicles to adjust routes more flexibly to obtain the shortest total delivery time.

5 Conclusion

It can be seen from the numerical experiments that multiple food sellers collaborate to fulfil orders for multiple items on an online platform, which can complete order delivery within the time window required by consumers and ensure consumers' time and food needs. With this approach, the problem of fulfilling takeout orders on online platforms is explored in the beginning, and decisions about the takeout order delivery procedure on online platforms can have some initial theoretical basis. The delivery problem of takeaway orders with a time window and the characteristics of one order and multiple items are studied in this paper, which is relevant to online catering sales platforms and offline food sales merchants. A method that minimizes the total order fulfilment cost while accounting for the order delivery time requirements is constructed. The optimization model as the goal provides a new idea for modelling e-commerce order fulfilment problems in the online and offline integrated mode; through the analysis of the characteristics of the problem and combined with quantitative analysis, a genetic algorithm is designed to strictly control the time window for receiving consumer orders. Constraints of the lower limit. Therefore, the optimal solution for order distribution can be given with high efficiency and within an effective time, thereby solving the various food demand for orders on online catering platforms. Order delivery problems with many categories and high time window requirements. Based on the theoretical level, this paper studies the distribution optimization problem of a single multi-item takeout order. However, in actual operation, it is necessary to combine the structural relationships between multiple orders such as order overlap and the order processing efficiency of each merchant to fulfil the order. Therefore, the distribution optimization problem of multi-category takeout orders needs further research. Because this study has a positive influence on the environment, reduces expenses, and raises consumer happiness, it may be useful in the real world. As data-driven insights guide strategic choices and assist company scalability, they also cut fuel usage, reduce food waste, and support local producers, which benefits customers and the environment. In addition, considering the service level of online catering platforms, for example, quantifying consumers' time-varying utility and incorporating it into the optimization model can further improve the scientific nature of decision-making, which is also an important research direction in the future. Furthermore, the complexity of route design, dynamic elements including traffic, implementation costs, balancing client preferences, infrastructure limits, last-mile issues, human mistakes, and regulatory compliance limits this research. Resolving these problems in future calls for constant innovation and comprehensive strategies.