Space index-based delivery path scheduling optimization method and system, and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZUNYI BIG DATA GROUP CO LTD
- Filing Date
- 2026-05-15
- Publication Date
- 2026-06-30
AI Technical Summary
Existing delivery route scheduling methods struggle to evaluate route costs within scheduling time constraints when faced with massive concurrent orders, impacting capacity matching efficiency, and making it difficult to balance partition granularity with combined search scope.
By constructing a spatial index structure and a spatial filling curve to perform one-dimensional dimensionality reduction mapping, an order sequence with spatial proximity clustering characteristics is generated. The path cost of candidate order combinations is calculated using the estimated passage cost, and the optimal path combination is selected.
While reducing the consumption of computing resources, it improves the fit between scheduling results and riders' actual execution routes, thereby increasing the efficiency of capacity matching.
Smart Images

Figure CN122312017A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, and in particular to a delivery route scheduling optimization method, system, and storage medium based on spatial indexing. Background Technology
[0002] Delivery route scheduling refers to the technical process of assigning multiple orders to riders and planning the pickup and delivery sequence to fulfill the orders. Currently, the common approach to delivery route scheduling is to group spatially adjacent orders into the same scheduling batch based on the spatial distribution of orders, using grid partitioning or region clustering. Then, within each batch, pickup and delivery combinations and access sequences are generated through traversal or heuristic search. However, this approach of partitioning first and then combining is difficult to effectively balance between the granularity of batch division and the scope of combination search when facing massive concurrent orders: too fine partitioning may lead to the loss of cross-regional order merging opportunities, while too coarse partitioning causes the search space for candidate combinations to expand drastically, increasing the computational workload of path cost evaluation. This makes it difficult to complete the path cost evaluation of a large number of candidate combinations within the scheduling time constraint, affecting the matching efficiency between scheduling results and delivery capacity. Summary of the Invention
[0003] This invention provides a delivery route scheduling optimization method, system, and storage medium based on spatial indexing.
[0004] In a first aspect, embodiments of the present invention provide a delivery route scheduling optimization method based on spatial indexing, comprising: Obtain the set of pickup and delivery locations corresponding to each order in the set of orders to be assigned, and construct a spatial index structure based on the set of pickup and delivery locations. The spatial index structure divides the delivery geographic space into multiple spatial partition units, and each spatial partition unit records the order ownership relationship of the pickup and delivery locations located within it, thereby obtaining the order index mapping record bound to each spatial partition unit. By performing a one-dimensional dimensionality reduction mapping on each pickup and delivery location point in the pickup and delivery location point set through the space filling curve, a one-dimensional sorting code is generated that is bound to each order and is used to characterize the relative order position of the order on the space filling curve. All orders are then arranged in ascending order according to their respective one-dimensional sorting codes to obtain an order sequence with spatial proximity clustering characteristics. Using rider load capacity as a constraint, several consecutively arranged orders are extracted along the order sequence to form candidate order combinations. The extraction generates multiple candidate order combinations in sequence, and the number of orders contained in each candidate order combination does not exceed the rider load capacity. For any candidate order combination generated by the interception, the pickup and delivery location points bound to each order in the candidate order combination are extracted. The spatial partition unit identifiers that have spatial partition unit overlap with the extracted pickup and delivery location points in the spatial index structure are queried. Based on the spatial partition unit identifiers, the estimated passage cost corresponding to the spatial partition unit is retrieved from the order index mapping record. The estimated passage cost of the spatial partition unit is accumulated according to the access order of the pickup and delivery location points in the candidate order combination to obtain the circumvention path cost for completing all pickup and delivery tasks corresponding to the candidate order combination. The circuit path costs corresponding to all candidate order combinations generated by the extraction are compared. The candidate order combination with the smallest circuit path cost is selected as the scheduling execution result to be assigned. Based on the scheduling execution result, the rider assignment information and the rider's suggested order of pickup and delivery for each order in the candidate order combination are output.
[0005] Secondly, embodiments of the present invention provide a computer system, including: a memory for storing computer-executable instructions or computer programs; and a processor for executing the computer-executable instructions or computer programs stored in the memory to implement the above-described spatial index-based delivery route scheduling optimization method.
[0006] Thirdly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the methods described above.
[0007] The embodiments of this application have the following beneficial effects: This invention performs one-dimensional dimensionality reduction mapping on the pick-up and delivery locations of orders to be assigned using a spatial filling curve, and constructs an order sequence with spatial proximity clustering characteristics. This ensures that orders that are close in distance in two-dimensional space are arranged continuously in the sequence, thus replacing brute-force enumeration of global order combinations with continuous extraction of the sequence. This constrains the generation range of candidate order combinations to a subset of local orders with essential spatial relationships. Based on this, using a pre-built spatial index structure and its bound order index mapping records, the estimated passage cost of the spatial partition units through which the extracted candidate order combinations pass is queried, and the cycle path cost is accumulated and calculated. The order combination path evaluation is transformed into a passage cost lookup and accumulation operation at the spatial partition unit granularity. This eliminates the need for real-time path planning calculations at the road network level to obtain the path cost, thereby reducing the computational resource consumption of a single order combination evaluation. By combining the generated multiple candidate combinations with a cost comparison mechanism, the combination with the lowest route cost can be selected from multiple order groups with spatial proximity clustering characteristics as the scheduling execution result, while meeting the rider's load capacity. This makes the dispatch result take into account the actual impact of the spatial location clustering degree between orders and the order of pickup and delivery on the passage cost, and improves the fit between the scheduling result and the rider's actual execution path. Attached Figure Description
[0008] Figure 1 This is a schematic diagram of the architecture of the application scenario provided in the embodiments of this application; Figure 2 This is a schematic diagram of the structure of the computer system provided in the embodiments of this application; Figure 3 This is a logical schematic diagram of the delivery route scheduling optimization method based on spatial index provided in an embodiment of the present invention; Figure 4 This is a flowchart illustrating the delivery route scheduling optimization method based on spatial index provided in this application embodiment. Detailed Implementation
[0009] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0010] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0011] See Figure 1 , Figure 1 This is a schematic diagram of the application scenario provided in this application embodiment. The terminal device 400 is connected to the computer system 200 through a network 300. The network 300 can be a wide area network (WAN), a local area network (LAN), or a combination of both, using wireless or wired links to achieve data transmission. The computer system 200 is used to execute the method provided in this embodiment of the invention and send the generated scheduling execution result (rider dispatch information and the rider's suggested pickup and delivery order information for each order in the candidate order combination) to the terminal device 400, which is, for example, the rider's smartphone.
[0012] In some embodiments, the computer system 200 may be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0013] The computer system implementing the spatial index-based delivery route scheduling optimization method provided in the embodiments of this application will be described next. See [link to documentation]. Figure 2 , Figure 2 This is a schematic diagram of the structure of the computer system provided in the embodiments of this application. Figure 2 The computer system shown includes at least one processor 210, memory 250, at least one network interface 220, and an external interface 230. The various components in the computer system 200 are coupled together via a bus system 240. It is understood that the bus system 240 is used to implement communication between these components. In addition to a data bus, the bus system 240 also includes a power bus, a control bus, and a status signal bus. However, for clarity, ... Figure 2 The general labeled all buses as Bus System 240.
[0014] Processor 210 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0015] External interface 230 may include, for example, one or more speakers and / or one or more visual displays. External interface 230 may also include one or more input devices 232, such as a keyboard, mouse, microphone, touch screen display, camera, etc.
[0016] The memory 250 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state storage, hard disk drives, optical disk drives, etc. The memory 250 may optionally include one or more storage devices physically located away from the processor 210.
[0017] The memory 250 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 250 described in this application embodiment is intended to include any suitable type of memory.
[0018] In some embodiments, memory 250 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.
[0019] Operating system 251 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic business functions and handling hardware-based tasks; The network communication module 252 is used to reach a terminal device via one or more (wired or wireless) network interfaces 220, such as Bluetooth, WiFi, and Universal Serial Bus (USB). Presentation module 253 is configured to enable the display of information (e.g., external interface for operating peripheral devices and displaying content and information) via one or more output devices 231 (e.g., display screen, speaker, etc.) associated with external interface 230; The input processing module 254 is used to detect and translate one or more user inputs or interactions from one or more input devices 232.
[0020] Based on the above description of the application scenarios and computer systems provided in the embodiments of this application, the spatial index-based delivery route scheduling optimization method provided in the embodiments of this application is described below. In actual implementation, the spatial index-based delivery route scheduling optimization method provided in the embodiments of this application can be implemented by a computer system.
[0021] Reference Figure 3 This is an application scenario and logic diagram of the method provided in the embodiments of the present invention. In the embodiments of the present invention, See also Figure 4 , Figure 4 This is a flowchart illustrating the delivery route scheduling optimization method based on spatial indexing provided in this application embodiment. Next, we will combine... Figure 4 The steps shown are explained.
[0022] Step S100: Obtain the set of pickup and delivery locations corresponding to each order in the set of orders to be assigned, and construct a spatial index structure based on the set of pickup and delivery locations. The spatial index structure divides the delivery geographic space into multiple spatial partition units, and each spatial partition unit records the order ownership relationship of the pickup and delivery locations located within it, thereby obtaining the order index mapping record bound to each spatial partition unit.
[0023] The set of orders to be assigned is a collection of orders within the current scheduling batch that have not yet established rider assignment relationships and are in a pending state. The set of pickup and delivery location points is a complete set of coordinate points formed by deduplicating and merging the pickup and delivery location coordinates of each order in the set of orders to be assigned. The pickup location points correspond to the geographical location of the merchant where the food is prepared, and the delivery location points correspond to the geographical location of the user where the food is received.
[0024] The delivery geospatial area is a rectangular geographical region defined by the minimum and maximum values of the pickup and delivery location points in the longitude direction and the minimum and maximum values in the latitude direction. This region constitutes the boundary range for subsequent spatial division and index construction.
[0025] The spatial index structure is a data organization system that partitions the delivery geographic space into regions and establishes a mapping relationship between the partitioned products and orders. Its core lies in the mediating role of spatial partition units, enabling any geographic coordinate to be associated with a potentially affected set of orders with constant or logarithmic time complexity. A spatial partition unit is an atomic spatial management unit generated after the spatial index structure performs a partitioning operation on the delivery geographic space. Each spatial partition unit has definite lower, upper, lower, and upper latitude bounds. Different spatial partition units either form a completely overlapping, non-overlapping spatial coverage relationship or a parent-child nested relationship within a hierarchical partitioning system. Order attribution is established when the longitude and latitude coordinates of a pickup / delivery location fall within the boundary range of a spatial partition unit. The order identifier to which that pickup / delivery location belongs is recorded by that spatial partition unit, thus establishing the attribution association between the spatial partition unit and the order. The order index mapping record is a mapping entry consisting of a unique identifier of a spatial partition unit as the primary key and a list of the precise coordinates of all pickup and delivery locations within the coverage area of that spatial partition unit and their associated order identifiers as values. This record can be stored in memory using a hash table data structure for high-speed querying, or it can be persisted to a key-value database engine.
[0026] Specifically, the system first reads the data structure of all orders in the current scheduling batch in batches through the order pool interface of the scheduling server. For each order, it extracts the longitude and latitude values from the merchant coordinate field as the pickup location point, and simultaneously extracts the longitude and latitude values from the recipient coordinate field as the delivery location point. These two sets of coordinates are then combined into a pickup and delivery location point set. Subsequently, a linear scan comparison is performed on all coordinate points in the pickup and delivery location point set along both the longitude and latitude components, recording the minimum longitude, maximum longitude, minimum latitude, and maximum latitude values. These four boundary values are then combined to form a rectangular boundary description of the delivery geographic space.
[0027] Next, the delivery geographic space is gridded according to the pre-configured spatial division accuracy parameters. The division method can be a uniform grid division strategy, which divides the longitude span into several longitude segments and the latitude span into several latitude segments at equal intervals. A series of rectangular grid units formed by the interweaving of longitude and latitude segments are the spatial partition units. After the grid division is completed, a globally unique unit identifier is generated for each spatial partition unit, and an empty list with the unit identifier as the key is initialized as the carrier of the order index mapping record. Then, each coordinate point in the pickup and delivery location set is traversed, and its spatial partition unit is calculated based on its longitude and latitude values. Specifically, the calculation method is as follows: the difference between the longitude value of the coordinate point and the minimum longitude value of the delivery geographic space is divided by the width of a single grid in the longitude direction, and the quotient is rounded down to obtain the grid column index in the longitude direction; the difference between the latitude value of the coordinate point and the minimum latitude value of the delivery geographic space is divided by the width of a single grid in the latitude direction, and the quotient is rounded down to obtain the grid row index in the latitude direction; the column index and row index are combined to locate the corresponding spatial partition unit, and the order identifier and the precise value of the coordinate itself are appended to the order index mapping record list of that spatial partition unit. Once all pickup and delivery locations have been traversed, the spatial index structure is complete, and the order index mapping record of each spatial partition unit accurately maintains the coordinate information and order identifier information of all pickup and delivery locations falling within its spatial range.
[0028] As one implementation method, the spatial index structure can be constructed using either a uniform grid partitioning strategy or a quadtree spatial partitioning strategy. In this construction method, the delivery geographic space is first used as the root node of the quadtree, and a maximum recursion depth and an upper limit on the number of pickup and delivery locations a single leaf node can accommodate are set. Starting from the root node, if the number of pickup and delivery locations contained in the current node exceeds the preset upper limit and the current recursion depth has not yet reached the maximum recursion depth, the node is simultaneously bisected in both the longitude and latitude directions, generating four sub-quadrant spatial partitioning units. All pickup and delivery locations within the original node are then redistributed to their respective sub-quadrants according to their coordinates. This process continues recursively until the number of pickup and delivery locations in all leaf nodes does not exceed the upper limit, or the recursion depth reaches the maximum depth limit. Each resulting leaf node is a spatial partitioning unit, and its order index mapping record stores the precise coordinates and order identifiers of all pickup and delivery locations within the leaf node's coverage area. Compared to uniform grid partitioning, the quadtree partitioning strategy can adaptively adjust the size of spatial partitioning units according to the actual distribution density of the fetching and sending locations. It generates finer-grained partitioning in high-density areas and maintains coarser-grained partitioning in sparse areas, thereby achieving an adaptive balance between query efficiency and storage overhead.
[0029] As another implementation, the spatial index structure can also be constructed using a spatial partitioning strategy based on Delaunay triangulation and Voronoi diagrams. First, using all coordinates in the pickup / delivery location set as the vertex set, a Delaunay triangulation is constructed within the delivery geographic space boundary, ensuring that the circumcircle of each triangle does not contain other vertices, thus guaranteeing the spatial continuity of the triangulation. Based on this, a Voronoi cell is calculated for each pickup / delivery location, which is a convex polygonal region formed by all spatial points closer to that location than to other pickup / delivery locations. Each Voronoi cell serves as a spatial partitioning unit, and its order index mapping record at least records the order identifier corresponding to the vertex generated by that Voronoi cell. The advantage of this strategy is that the boundary of the spatial partitioning unit naturally lies on the perpendicular bisector of the line connecting adjacent order pickup / delivery locations, ensuring that when any rider's location coordinates fall into a Voronoi cell, its spatially nearest pickup / delivery location is the pickup / delivery location corresponding to that cell.
[0030] Step S200: Perform one-dimensional dimensionality reduction mapping on each pickup and delivery location point in the pickup and delivery location point set through the space filling curve to generate a one-dimensional sorting code that is bound to each order and is used to represent the relative order position of the order on the space filling curve. Then, arrange all orders in ascending order according to their respective one-dimensional sorting codes to obtain an order sequence with spatial proximity clustering characteristics.
[0031] In one implementation, step S200 may specifically include the following steps S210 to S260.
[0032] Step S210: Obtain the boundary coordinate range of all spatial partition units in the spatial index structure, determine the longitude span range and latitude span range of the delivery geographic space based on the boundary coordinate range, and take the direction corresponding to the longer of the longitude span range and latitude span range as the reference mapping direction.
[0033] The longitude span interval is a closed interval formed by the minimum and maximum boundary values of all spatial partition units along the longitude direction. The length of this interval is the spatial extension along the longitude direction. Similarly, the latitude span interval is a closed interval formed by the minimum and maximum boundary values of all spatial partition units along the latitudinal direction. The reference mapping direction is the principal axis direction followed by the spatial filling curve when unfolding the grid within the delivery geographic space. The curve will preferentially traverse the grid array row by row or column by column along this direction, ensuring that spatially adjacent grids in this direction remain adjacent in the unfolded one-dimensional encoding sequence.
[0034] In this step, all spatial partition units maintained by the spatial index structure are traversed. The lower and upper bounds of longitude for each spatial partition unit are extracted. By comparing each pair of units, the minimum longitude lower bound is obtained as the global minimum longitude for the delivery geospatial, and the maximum longitude upper bound is obtained as the global maximum longitude. The closed interval between the global minimum and global maximum longitude is the longitude span interval. Similarly, the lower and upper bounds of latitude for each spatial partition unit are extracted. By comparing each pair of units, the global minimum and global maximum latitude are obtained. The closed interval formed by these two is the latitude span interval. Subsequently, the interval lengths of the longitude span interval and the latitude span interval are calculated separately. The two length values are compared. If the longitude span interval length is greater than the latitude span interval length, the longitude direction is determined as the reference mapping direction; if the latitude span interval length is greater than the longitude span interval length, the latitude direction is determined as the reference mapping direction; if the two lengths are equal, the longitude direction is selected as the reference mapping direction by default. The determination of the reference mapping direction will affect the calculation of the target curve order in step S220, as well as the allocation of the number of grid rows and columns during the space-filling curve meshing process.
[0035] Step S220: Using the span length corresponding to the reference mapping direction as a reference, determine the target curve order so that the number of grids on one side of the space filling curve is not less than the number of divisions of the spatial partitioning unit in the reference mapping direction, and perform gridding processing on the delivery geographic space according to the target curve order to obtain a regular grid array.
[0036] The number of single-sided grids is the number of grid divisions of the space-filling curve along the reference mapping direction. For a space-filling curve whose order is the same as the order of the target curve, the number of cells on each side of the square grid array formed by it is equal to the second power of the order of the target curve. The number of spatial partitioning units along the reference mapping direction is the number of non-overlapping continuous intervals formed when all spatial partitioning units are arranged along the reference mapping direction. This number reflects the degree of dispersion of the spatial partitioning units along the reference mapping direction.
[0037] In one implementation, step S220 may specifically include the following steps S221 to S225.
[0038] Step S221: Extract the spatial coverage description of all spatial partition units from the spatial index structure, project the spatial coverage of all spatial partition units onto the reference mapping direction to obtain multiple projection intervals along the reference mapping direction, merge and remove duplicates from the multiple projection intervals to obtain several non-overlapping continuous interval segments, count the number of continuous interval segments and use this number as the number of divisions of the spatial partition unit on the reference mapping direction, and use the number of divisions as the initial number of grids in the reference mapping direction.
[0039] Spatial coverage description is an expression of the spatial extent occupied by each spatial partition unit under its boundary coordinate description. When the reference mapping direction is longitude, the lower and upper longitude boundaries in the spatial coverage description constitute the projection interval of the spatial partition unit in the reference mapping direction; when the reference mapping direction is latitude, the lower and upper latitude boundaries in the spatial coverage description constitute the projection interval. The initial grid number is the number of initial grid divisions used for comparison when subsequently determining the reference order, and its value is directly equal to the number of divisions of the spatial partition unit in the reference mapping direction.
[0040] In this step, all spatial partitioning units in the spatial index structure are traversed. For each spatial partitioning unit, its lower and upper bound coordinates in the reference mapping direction are read, forming a closed interval as the projection interval of that spatial partitioning unit. All collected projection intervals are placed in an interval list, which is then sorted in ascending order according to the lower bound coordinates of each interval. After sorting, an empty result interval list is initialized, and the first sorted projection interval is added to the result interval list as the current merge interval. Starting from the second projection interval, the system traverses sequentially. For each traversed projection interval, its lower bound coordinates are compared with the upper bound coordinates of the last interval in the result interval list. If the lower bound coordinates are less than or equal to the upper bound coordinates of the last interval, it indicates that the two intervals overlap or their endpoints are connected. The upper bound coordinates of the last interval need to be updated to the larger of the upper bound coordinates of the current projection interval and the upper bound coordinates of the last interval. If the lower bound coordinates are strictly greater than the upper bound coordinates of the last interval, it indicates that there is a gap between the two intervals. The current projection interval is added to the result interval list as a new merge interval. After the traversal is complete, the result interval list contains several non-overlapping continuous interval segments. The number of elements in the list is counted to obtain the number of spatial partition units in the reference mapping direction, and this number of partitions is assigned to the initial number of grids.
[0041] Step S222: Select the order value that satisfies the first time that the number of single-sided grids exceeds the initial number of grids from the preset candidate sequence of curve orders as the reference order. The number of single-sided grids is determined by a positive integer power of two.
[0042] The candidate sequence of curve orders is a pre-stored sequence of positive integers arranged in ascending order, where each element represents a possible space-filling curve order. The baseline order is the smallest order value selected from the candidate sequence of curve orders, while satisfying the constraint that the number of grid cells on one side is not less than the initial number of grid cells.
[0043] In step S222, candidate order values are extracted one by one from the candidate order sequence. For each extracted candidate order value, a power of 2 with respect to that candidate order value is calculated. This power value is the number of single-sided grids corresponding to that order. The calculated number of single-sided grids is compared with the initial number of grids obtained in step S221. If the number of single-sided grids is less than the initial number of grids, the candidate order value is skipped and the next candidate order value is processed. If the number of single-sided grids is greater than or equal to the initial number of grids for the first time, the candidate order value is marked as the baseline order, and the traversal of the candidate sequence is terminated.
[0044] Step S223: Obtain the effective span length of the delivery geospace in the non-baseline mapping direction, calculate the grid edge length generated by the single-sided grid corresponding to the base order in the non-baseline mapping direction, and if the grid edge length exceeds the preset grid edge length uniformity tolerance limit, then perform a successive incremental adjustment of the base order until the difference in grid edge length between the adjusted single-sided grid in the two directions falls back to within the tolerance limit.
[0045] The non-baseline mapping direction is another spatial dimension direction perpendicular to the baseline mapping direction determined in step S210. The effective span length is the difference between the maximum and minimum boundary values of the delivery geographic space in the non-baseline mapping direction. The grid side length uniformity tolerance limit is a preset proportional threshold used to determine whether the difference between the grid side lengths in the baseline mapping direction and the grid side lengths in the non-baseline mapping direction is within an acceptable range.
[0046] In this step, based on the reference mapping direction determined in step S210, the non-reference mapping direction perpendicular to it is identified. If the reference mapping direction is longitude, the non-reference mapping direction is latitude; if the reference mapping direction is latitude, the non-reference mapping direction is longitude. The maximum and minimum boundary values of the delivery geospace in the non-reference mapping direction are obtained, and the difference between them is calculated as the effective span length. The effective span length is divided by the number of single-sided grids corresponding to the reference order determined in step S222 to obtain the grid side length in the non-reference mapping direction. Simultaneously, the span length of the delivery geospace in the reference mapping direction is obtained and divided by the same number of single-sided grids to obtain the grid side length in the reference mapping direction. The absolute value of the difference between the grid side lengths in the two directions is calculated, and this absolute value is compared with the smaller of the two direction grid side lengths to obtain the side length difference ratio. The ratio of edge length difference is compared with the preset tolerance limit for mesh edge length uniformity. If the ratio of edge length difference exceeds the tolerance limit, it indicates that the inconsistency between the mesh edge lengths in the two directions at the current baseline order is too high. The mesh cells generated by the space-filling curve are too flat in both directions, which may impair the spatial proximity clustering characteristics. In this case, the baseline order is incremented by one, the mesh edge lengths in both directions are recalculated, and the ratio of difference is compared again. This incrementing and recalculation process is repeated until the ratio of edge length difference is less than or equal to the tolerance limit. The current order value is used as the adjusted baseline order.
[0047] Step S224: Determine the order that meets the uniformity requirement of grid side length after adjustment as the target curve order of the space filling curve. Generate the grid vertex coordinate matrix of the space filling curve in the delivery geographic space with the target curve order. Each element of the grid vertex coordinate matrix stores the lower longitude, upper longitude, lower latitude, and upper latitude of the corresponding grid.
[0048] The order of the target curve is the final order parameter determined after adjustment in step S223, used to actually generate the space-filling curve and the regular grid array. The grid vertex coordinate matrix is a two-dimensional data structure accessed by grid row index and grid column index, where the row index increases from the top to the bottom of the grid, and the column index increases from the left to the right of the grid.
[0049] Assign the final order value retained in step S223 to the target curve order variable. Calculate the number of cells on each edge of the regular grid array; this number is equal to two powers of the target curve order. Divide the span between the global minimum and global maximum longitudes in the longitude direction of the delivery geospace evenly into longitude segments equal to the number of cells, with the boundary values of each segment forming a sequence of lower and upper longitude bounds. Similarly, divide the span between the global minimum and global maximum latitudes in the latitude direction of the delivery geospace evenly into latitude segments equal to the number of cells, with the boundary values of each segment forming a sequence of lower and upper latitude bounds. Create a two-dimensional matrix with the same number of rows and columns as the number of cells to serve as the grid vertex coordinate matrix. For each position specified by the row and column indices in the matrix, take the lower bound of longitude from the value of the column index position in the longitude boundary sequence, take the upper bound of longitude from the value of the column index plus one position, take the lower bound of latitude from the value of the row index position in the latitude boundary sequence, and take the upper bound of latitude from the value of the column index plus one position. Fill these four tuples into the corresponding element positions of the matrix.
[0050] Step S225: Pass the target curve order and the grid vertex coordinate matrix to the one-dimensional sorting and encoding generation stage, so that the one-dimensional sorting and encoding generation stage can determine the total encoding bit length based on the target curve order, find the grid where each feed point is located based on the grid vertex coordinate matrix, and extract the row and column indices.
[0051] The total bit length of the encoding is the number of bits contained in the binary encoded string output by the positive mapping function of the space-filling curve under the target curve order. Its value is equal to the product of the target curve order and two.
[0052] Specifically, the target curve order determined in step S224 and the generated grid vertex coordinate matrix are passed to the one-dimensional sorting and encoding generation stage via parameter passing or shared memory reference. After receiving the target curve order, the one-dimensional sorting and encoding generation stage multiplies it by two to obtain the total encoding bit length, which will serve as the fixed output length during encoding generation. Simultaneously, the one-dimensional sorting and encoding generation stage traverses each pick-up and drop-off point in the set of pick-up and drop-off points, obtaining its longitude and latitude coordinates. By performing a binary search in the grid vertex coordinate matrix or directly calculating through linear mappings between longitude coordinates and longitude boundary sequences, and latitude coordinates and latitude boundary sequences, it quickly locates the grid cell in which the pick-up and drop-off point falls. It then extracts the row and column indices of this grid cell in the matrix, providing input for encoding generation in step S230.
[0053] Step S230: For each pick-up and delivery location point in the pick-up and delivery location point set, using the row index and column index of the location point falling into the grid in the regular grid array, and utilizing the positive mapping function of the space-filling curve under the order of the target curve, a fixed-length binary code string corresponding to the pick-up and delivery location point is generated as a one-dimensional sorting code.
[0054] A fixed-length binary encoded string is an encoded value whose length is strictly equal to the total number of bits determined in step S225, and whose each bit is a binary digit zero or a binary digit one. The space-filling curve forward mapping function is a mapping function that converts the row and column indices of a two-dimensional grid into a one-dimensional binary code according to the specific bit interleaving and bit transformation rules of the space-filling curve.
[0055] In this step, for each fetch location point in the fetch location point set, the grid row index and grid column index located in step S225 are obtained. The row index and column index are converted into binary representations respectively. The number of bits in the binary representation should be equal to the order of the target curve. If the number of bits in the converted binary representation is less than the order of the target curve, zeros are padded to the high bits to reach the order of the target curve. If the space filling curve type is set to Morton curve, the operation performed by the space filling curve forward mapping function is as follows: the current bit of the row index binary representation and the current bit of the column index binary representation are extracted sequentially from the highest bit to the lowest bit. The column index bit is placed in the even-numbered position of the code, and the row index bit is placed in the odd-numbered position of the code, or the reverse interleaved order is performed. The specific interleaved order must be consistent with the curve definition. This process is repeated from the highest bit to the lowest bit, and finally a binary sequence with a length equal to the total length of the code is obtained. This is the one-dimensional sorted code. If the space filling curve type is set to Hilbert curve, the operation performed by the forward mapping function of the space filling curve is as follows: First, the binary representation of the row and column indices is converted to Gray code. Then, according to the state machine-oriented rules unique to Hilbert curves, the binary bits of the row and column indices are transformed by swapping, inverting, and other bit-level transformations based on the orientation state of the current iteration. After the transformation, the bits are interleaved and spliced to finally generate Hilbert codes as one-dimensional sorting codes.
[0056] Step S240: After binding the one-dimensional sort code with the corresponding order identifier, perform an ascending sort operation on all bound records according to the lexicographical order of the one-dimensional sort code to obtain the initial order sequence, and check whether there are multiple different order identifiers with the same one-dimensional sort code in the initial order sequence.
[0057] Lexicographic ascending sort treats the one-dimensional sorting code as a binary string and determines the order by comparing the binary values bit by bit from the most significant bit to the least significant bit. Records with smaller encoded values are placed first, and records with larger encoded values are placed last.
[0058] In this step, after generating a one-dimensional sort code for each pickup / delivery location in the set of pickup / delivery locations, since an order may have both a pickup location and a delivery location, each pickup / delivery location will generate a one-dimensional sort code. Therefore, it is necessary to establish an accurate binding relationship between the one-dimensional sort code and the order identifier. For each order, it can be agreed that the one-dimensional sort code of the pickup location is used as the primary sort code for the order, or it can be agreed that the unique sort code of the order is generated by combining the pickup location code and the delivery location code according to a specific rule. For example, the one with the smaller lexicographical order is used as the primary code, and the other is used as an additional reference code. The primary sort code of each order is combined with the order identifier of the order to form a binding record pair, and all binding record pairs are placed in a sorting list. Merge sort or quick sort algorithm is executed on the sorted list. The comparator logic for sorting is as follows: read the one-dimensional sort code of the two bound records to be compared, and compare the binary values of corresponding bits from the highest bit to the lowest bit. If there is a difference in a bit, the relative order of the two bound records is determined by the comparison result of that bit; if all bits are equal, the two one-dimensional sort codes are completely identical. After the entire list is sorted, the sorted list of bound records is scanned sequentially. If two adjacent bound records are found to have completely identical one-dimensional sort codes, the order identifiers in these two bound records are recorded and marked as order with a code conflict. After the scan is completed, if there are no order with a code conflict, the current sorted list is the final order sequence with spatial proximity clustering characteristics; if there is a code conflict, the set of conflicting orders and the sorted list are passed to step S250 for processing.
[0059] Step S250: When there are multiple different order identifiers with the same one-dimensional sorting code, obtain the original latitude and longitude coordinates of the pick-up and delivery location points corresponding to these order identifiers, calculate their relative position offset within their respective grids, and initiate local space filling curve recursive mapping within the grids based on the relative position offset to generate extended sorting codes with increasing bit length.
[0060] The original latitude and longitude coordinates are the precise longitude and latitude values of the order's pickup or delivery location before gridding. The relative position offset is the distance the precise coordinates of the pickup / delivery location are offset from the lower bounds of the longitude and latitude of its corresponding grid cell, calculated as the normalization ratio after normalizing the grid cell's longitude and latitude side lengths. Local space-fill curve recursive mapping treats the grid cell containing the coding conflict as an independent subspace and re-executes the space-fill curve grid partitioning and coding generation process, resulting in higher-resolution distinguishable codes between conflicting orders. Extended sorting coding uses the original one-dimensional sorting code as the high-order segment and the secondary sorting code generated by the local recursive mapping as the low-order segment, concatenating the two to form a new code with increased total bit length.
[0061] In one implementation, step S250 may specifically include the following steps S251 to S256.
[0062] Step S251: Extract the original longitude and latitude coordinates of the pickup / delivery location points bound to each order identifier that caused the coding conflict, as well as the lower longitude and lower latitude coordinates, upper longitude and upper latitude coordinates of the grid in which it is located. Divide the difference between the original longitude coordinates and the lower longitude boundary by the difference between the upper and lower longitude boundaries to obtain the normalized offset of the longitude direction within the grid. Divide the difference between the original latitude coordinates and the lower latitude boundary by the difference between the upper and lower latitude boundaries to obtain the normalized offset of the latitude direction.
[0063] In this step, for each conflicting order output in step S240, the original longitude and latitude coordinates of the corresponding pickup and delivery location are retrieved from the order index mapping record of the spatial index structure based on its order identifier. If the order has both a pickup location and a delivery location, the coordinates of the pickup location are prioritized as the basis for conflict determination. Simultaneously, the grid row index and grid column index corresponding to the conflicting one-dimensional sorted code are deduced. The reverse derivation process is as follows: the one-dimensional sorted code is generated by interleaving the binary bits of the row and column indices. Therefore, during decoding, the binary bits of the row index and column index need to be separated bit by bit from the one-dimensional sorted code to reconstruct the integer values of the row and column indices. Based on the reconstructed row and column indices, the lower longitude, upper longitude, lower latitude, and upper latitude bounds of the corresponding grid are extracted from the grid vertex coordinate matrix. The difference between the upper and lower longitude bounds is calculated as the longitude span of the grid. The difference between the original longitude coordinates and the lower longitude bound is calculated as the longitude offset distance. Dividing the longitude offset distance by the longitude span yields the normalized longitude offset. Similarly, the difference between the upper and lower latitude bounds is calculated as the latitude span. The difference between the original latitude coordinates and the lower latitude bound is calculated as the latitude offset distance. Dividing the latitude offset distance by the latitude span yields the normalized latitude offset.
[0064] Step S252: Construct a two-dimensional offset point set from the normalized offsets in the longitude and latitude directions of all conflicting orders, and calculate the average Euclidean distance and the maximum Euclidean distance between each point in the two-dimensional offset point set; determine the diagonal length of the normalized grid based on the fact that the normalized grid has a unit side length in both the longitude and latitude directions, and use the quotient obtained by dividing the average Euclidean distance by the diagonal length of the normalized grid as the spatial dispersion index.
[0065] The two-dimensional offset point set is a set of two-dimensional points formed by using the normalized offset in the longitude direction of each conflicting order as the horizontal axis coordinate and the normalized offset in the latitude direction as the vertical axis coordinate. All points are located inside a unit square. The average Euclidean distance is the arithmetic mean of the Euclidean distances between all pairwise points in the two-dimensional offset point set. The maximum Euclidean distance is the maximum value of the Euclidean distance between all pairwise points in the two-dimensional offset point set. The normalized grid diagonal length is the length of the diagonal from the lower left corner to the upper right corner of a square grid with both horizontal and vertical spans normalized to unit length; its value is the square root of 2. The spatial dispersion index is a quantitative indicator that measures the degree of spatial dispersion of conflicting orders within the grid. The larger the index, the more dispersed the distribution of conflicting orders within the grid.
[0066] In this step, the normalized offsets of longitude and latitude of each conflicting order generated in step S251 are paired to form a two-dimensional offset point set. If the number of conflicting orders is a quantity value, the number of point pairs is the quantity value multiplied by the quantity value minus 1 and then divided by 2. All point pairs are traversed, and for each pair, the Euclidean distance between the two points is calculated. The Euclidean distances of all point pairs are summed and divided by the total number of point pairs to obtain the average Euclidean distance. The maximum Euclidean distance encountered during the traversal is recorded simultaneously. The length of the normalized grid diagonal is calculated, and the square root of 2 is taken as the length of the diagonal. The average Euclidean distance is divided by the normalized grid diagonal length, and the quotient is the spatial dispersion index.
[0067] Step S253: When the spatial dispersion index is greater than the preset dispersion judgment threshold, the conflict location points are determined to be distributed in a dispersed manner within the grid, and a different type of spatial filling curve, which is different from the upper-level spatial filling curve type, is selected as the secondary mapping curve type; when the spatial dispersion index is not greater than the dispersion judgment threshold, the points are determined to be distributed in a clustered manner, and the same type of spatial filling curve, which is the same as the upper-level spatial filling curve, is maintained as the secondary mapping curve type.
[0068] The dispersion threshold is a pre-defined decimal threshold used to distinguish whether the distribution of conflicting orders within a grid is biased towards dispersion or clustering. A heterogeneous space-fill curve is a different type of space-fill curve than the one used in step S230. For example, if the upper-level curve is a Morton curve, the heterogeneous curve can be a Hilbert curve or a Gray code curve. A homogeneous space-fill curve is a space-fill curve that maintains the same type as the upper-level space-fill curve. Using a homogeneous curve when conflicting orders are clustered helps maintain coding consistency across different levels, while using a heterogeneous curve when conflicting orders are dispersed helps break the tendency for secondary coding conflicts caused by potentially regular arrangements.
[0069] In this step, the spatial dispersion index calculated in step S252 is compared with a preset dispersion threshold. If the spatial dispersion index is greater than the dispersion threshold, the conflict points are determined to be dispersed within the grid. In this case, a spatial filling curve type different from the one used in step S230 is selected as the secondary mapping curve type, and its identifier is recorded. If the spatial dispersion index is less than or equal to the dispersion threshold, the conflict points are determined to be clustered. In this case, the same spatial filling curve type as in step S230 is maintained as the secondary mapping curve type, and its identifier is recorded.
[0070] Step S254: Based on the determined secondary mapping curve type and the minimum normalized distance between conflicting points, calculate the minimum secondary grid subdivision order that can distinguish each conflicting point, generate a secondary space filling curve with the order and type of secondary mapping curve within the grid, and establish a secondary mapping table from secondary grid row and column index to secondary sorting code.
[0071] The secondary meshing order is the order of the space-fill curve used when re-meshing within conflicting mesh cells. This order determines the fineness of the secondary mesh. The secondary mapping table is a lookup table structure that stores the secondary sort code corresponding to each combination of row and column indices in the secondary mesh. This table can be implemented using a two-dimensional array, where the row indices correspond to the row indices of the secondary mesh, the column indices correspond to the column indices, and the values of the array elements are the secondary sort codes.
[0072] Specifically, the smallest non-zero Euclidean distance is selected from the total number of point pairs Euclidean distances calculated in step S252 as the minimum normalized distance between conflicting points. The normalized edge length of the grid (i.e., the value 1) is divided by the number of rows and columns of the secondary grid corresponding to the minimum secondary grid subdivision order to obtain the cell edge length of the secondary grid. For any two conflicting points to fall into different secondary grid cells, the cell edge length of the secondary grid must be less than half of the minimum normalized distance. Starting from the secondary grid subdivision order, the order is incremented sequentially. Each time, the number of rows and columns of the secondary grid corresponding to the current order (i.e., the second power of the current order) is calculated, and then the value 1 is divided by the number of rows and columns of the secondary grid to obtain the cell edge length of the secondary grid. This edge length is compared with half of the minimum normalized distance. If the edge length is greater than or equal to half of the minimum normalized distance, the order continues to increase until the edge length is first less than half of the minimum normalized distance. This current order is then determined as the minimum secondary grid subdivision order. After determining the secondary mesh partitioning order, using the current conflicting mesh as a subspace, a secondary space filling curve with the minimum secondary mesh partitioning order is generated within this subspace according to the secondary mapping curve type determined in step S253. The generation method of the secondary space filling curve is consistent with the execution method of the forward mapping function in step S230, the only difference being that the curve order and curve type may be different. Based on the forward mapping function of the secondary space filling curve, all row and column index combinations of the secondary mesh are traversed, and the corresponding secondary sorting code is pre-calculated for each combination. The calculation results are filled into the corresponding positions of the secondary mapping table so that the secondary sorting code can be directly obtained through index lookup in step S255 without repeating the bit interleaving operation.
[0073] Step S255: Multiply the normalized offset in the longitude direction and the normalized offset in the latitude direction of each conflicting order by the number of rows and columns of the grid corresponding to the minimum secondary grid subdivision order, and round down to obtain the secondary row index and secondary column index. Generate the secondary sorting code by querying the secondary mapping table. Assign the secondary sorting code as the low-order segment to the end of the original one-dimensional sorting code of the order to form the extended sorting code.
[0074] The secondary row index is the row position number of the conflict location point in the secondary grid, and the secondary column index is the column position number of the conflict location point in the secondary grid.
[0075] In this step, the number of rows and columns of the secondary grid corresponding to the minimum secondary grid subdivision order is calculated. This number of rows and columns is equal to two powers of the minimum secondary grid subdivision order. For each conflicting order, the normalized offset of the order's longitude direction obtained in step S251 is multiplied by the number of columns in the secondary grid, and the product is rounded down. The rounded result is used as the secondary column index of the order within that grid. Simultaneously, the normalized offset of the order's latitude direction is multiplied by the number of rows in the secondary grid, and the product is rounded down. The rounded result is used as the secondary row index of the order within that grid. Using the secondary row index and secondary column index as lookup keys, the corresponding secondary sorting code is directly read from the secondary mapping table established in step S254. The original one-dimensional sorting code of the order is used as the high-order segment, and the secondary sorting code is used as the low-order segment. These are combined bit-by-bit to form a new binary code string. The length of this new code string is equal to the total length of the original code plus twice the minimum secondary grid partitioning order. This new code string is the extended sorting code. The extended sorting code is then re-bound to the order identifier of the order, replacing the original binding record.
[0076] Step S256: If the extended sort codes of multiple conflicting orders are still equal, mark these orders as a new set of conflicting orders and return to the two-dimensional offset point set calculation step. At the same time, lower the dispersion judgment threshold according to the preset shrinkage ratio, and iteratively execute the distribution pattern judgment, secondary curve selection and code generation until all extended sort codes are mutually distinct.
[0077] The preset shrinkage ratio is a coefficient greater than 0 and less than 1, which is used to tighten the dispersion judgment threshold as the recursion level deepens, making it easier to judge the clustered distribution pattern at higher recursion levels. It prioritizes the use of the same space filling curve type as the previous level to reduce the probability of coding conflicts continuing to deeper recursion levels.
[0078] For all extended sort codes generated in step S255, perform lexicographical sorting and equivalence detection operations similar to those in step S240 to check if there are multiple different order identifiers with identical extended sort codes. If all extended sort codes are pairwise distinct, the current extended sort code is used as the final code for these orders, completing this step. If one or more sets of extended sort codes are still equivalent, the order identifiers corresponding to each set of equivalent codes are marked as a new set of conflicting orders. For each new set of conflicting orders, return to the two-dimensional offset point set calculation stage in step S252. Before re-entering the dispersion pattern determination in step S253, multiply the dispersion determination threshold value used in the current recursive level by a preset shrinkage ratio, and use the product as the new dispersion determination threshold value used in the next recursive level. The secondary grid generated in the lower-level recursion will continue to be subdivided with finer granularity using the secondary grid corresponding to the currently generated low-order segment code as the parent space, and the new level of secondary sort codes will be spliced to the lower end of the existing extended sort codes. This recursive mapping and encoding concatenation process is repeated until the extended sorting codes for all conflicting orders are unique globally.
[0079] Step S260: Replace the original one-dimensional sort code with the extended sort code, and rearrange the affected order subsequences in ascending order until the one-dimensional sort code or extended sort code corresponding to each order identifier in the entire order sequence is unique, and output the final order sequence with spatial proximity clustering characteristics.
[0080] After generating extended sort codes for all conflicting orders in step S250 and ensuring no coding conflicts, for each order that participated in the extended code generation, its latest extended sort code replaces the original one-dimensional sort code bound to that order in step S240. For orders that did not participate in the extended code generation and whose original codes are already unique, their original one-dimensional sort codes remain unchanged. Then, a full ascending sort operation is performed on all the bound records of all orders, using the same comparator logic as in step S240. After sorting, a second scan confirms that no two orders in the entire sequence have completely identical final codes. The confirmed final order sequence is output as an order sequence with spatial proximity clustering characteristics for use in the order merging and truncation operation in step S300.
[0081] Step S300: Using rider load capacity as a constraint, extract several consecutively arranged orders along the order sequence to form candidate order combinations. Generate multiple candidate order combinations sequentially on the order sequence, and the number of orders contained in each candidate order combination does not exceed the rider load capacity.
[0082] Rider load capacity is the maximum number of orders a single rider can carry during a delivery round. This limit is determined by the rider's vehicle's loading capacity, delivery box volume, or platform business rules. A candidate order combination is a subset of orders sequentially extracted from the order sequence along the order arrangement direction. This subset will be assigned to the same rider for pickup and delivery tasks, and the number of orders within this subset will never exceed the rider load capacity.
[0083] In one implementation, step S300 may specifically include the following steps S310 to S360.
[0084] Step S310: Obtain the estimated meal preparation time and delivery time constraint data for each order in the set of orders to be assigned, and label each order in the order sequence with time attributes to generate a labeled order sequence with time constraint labels.
[0085] The estimated food preparation time is a prediction of when a merchant will complete the preparation of a meal for an order and deliver it to the rider. This data can be calculated using a food preparation time estimation model based on factors such as the merchant's historical food preparation time statistics, the current number of orders in the queue, and the complexity of the food preparation. The delivery time constraint data is the latest acceptable delivery time specified by the user when placing the order, or the promised delivery deadline calculated by the platform based on delivery distance, user level, and business commitments. The time constraint tag is a set of time-related metadata attached to each order record in the order sequence, containing at least the estimated food preparation time and the delivery time constraint data.
[0086] In this step, the estimated food preparation time and delivery time constraint data for each order in the set of orders to be assigned are requested in batches through the order details interface of the scheduling server. The estimated food preparation time data is generated by calling the food preparation time prediction model. This model adopts a gradient boosting decision tree architecture, which consists of several decision trees generated sequentially. Each decision tree contains multiple split nodes, and each split node makes a conditional judgment based on one dimension of the merchant's historical food preparation time characteristics. The model is pre-trained using historical order food preparation time samples accumulated by the platform. The features of the training samples include fields such as merchant identifier, order time, number of dishes in the order, order amount, number of backlog orders of the merchant, weekday type, and weather conditions. The training objective is to minimize the mean square logarithmic error between the estimated food preparation time and the actual food preparation time. During model training, an adaptive moment estimation optimizer is used to iteratively update the split threshold of the tree nodes on randomly sampled batch samples. The batch size is set to several samples, the initial learning rate is set to a small positive value, and the training epochs are set to several epochs. The root mean square error calculated on the independent validation set is used as the early stopping indicator. During the inference phase, the aforementioned features of each order are input into the model. The model outputs the estimated food preparation time for that order. This time is then added to the time the merchant confirms order acceptance to obtain the estimated food preparation time. For delivery time constraint data, the user-specified delivery deadline field or the platform-promised delivery time field is directly read from the order data structure. The estimated food preparation time and delivery time constraint data are used as two attribute fields for time constraint labels, respectively, and attached to the data structure of each order in the order sequence to form a labeled order sequence carrying time constraint labels.
[0087] Step S320: Locate the spatial partition unit corresponding to the rider's starting spatial position, filter out the order sub-sequence intervals from the marked order sequence where the spatial partition unit where the pickup location is located is adjacent to or overlaps with the rider's starting spatial partition unit, and limit the starting search range of the interception operation to the order sub-sequence intervals.
[0088] The rider's initial spatial location is the longitude and latitude coordinates of the rider's actual geographical location at the current dispatch time. This location is usually obtained in real time by the satellite positioning module of the rider's terminal. The order subsequence interval is a continuous subsequence extracted from the labeled order sequence. The lower and upper bound indices of this subsequence are determined by the sequence index range of orders that satisfy the spatial adjacency condition.
[0089] In one implementation, step S320 may specifically include the following steps S321 to S326.
[0090] Step S321: Obtain the rider's starting spatial position coordinates, map the starting spatial position coordinates using a space filling curve, generate a one-dimensional starting position code corresponding to the starting spatial position coordinates, and query the spatial index structure to determine the spatial partition unit to which the one-dimensional starting position code belongs.
[0091] In this step, the longitude and latitude coordinates are parsed from the location information message reported by the rider's terminal as the starting spatial position coordinates. The same spatial filling curve forward mapping function and grid vertex coordinate matrix as in step S230 are used to map these starting spatial position coordinates: based on the longitude and latitude of the starting spatial position coordinates, the grid cell into which it falls is located in the grid vertex coordinate matrix. The row and column indices of this grid cell are extracted, and the forward mapping function is called to generate the corresponding one-dimensional starting position code. Since the spatial index structure has already recorded the one-dimensional sorting code range or index mapping relationship of all grid cells within each spatial partition unit during its construction, a binary search or hash search can be performed in the spatial index structure using the one-dimensional starting position code to determine which spatial partition unit the one-dimensional starting position code falls into. The unit identifier of this spatial partition unit is then used as the identifier of the spatial partition unit to which it belongs.
[0092] Step S322: In the spatial partition unit adjacency relationship description maintained by the spatial index structure, take the home spatial partition unit as the center, obtain the directly adjacent spatial partition units that share a boundary or share a vertex with the home spatial partition unit, and form a primary adjacency partition set. The absolute value of the difference between the one-dimensional sort code and the one-dimensional starting position code of the directly adjacent spatial partition unit does not exceed the preset adjacency span.
[0093] The adjacency description of spatial partition units is a pre-stored metadata in the spatial index structure. This metadata records which spatial partition units share boundary relationships or share vertex relationships with their surrounding spatial partition units. The preset adjacency span is an integer upper limit threshold of a one-dimensional sorted encoding difference, used to constrain the linear distance between directly adjacent spatial partition units on the space-filling curve to prevent it from becoming too far.
[0094] In this step, the spatial partition unit adjacency relationship description table generated synchronously during the construction of the spatial index structure is queried. This table uses the spatial partition unit identifier as the key and lists the identifiers of side neighboring spatial partition units that share a boundary with the spatial partition unit and the identifiers of diagonally adjacent spatial partition units that share a vertex as values. Using the home spatial partition unit identifier determined in step S321 as the key, all corresponding directly adjacent spatial partition unit identifiers are read from this description table. For each directly adjacent spatial partition unit identifier read, the one-dimensional sorting code of the center point or representative grid of the directly adjacent spatial partition unit is obtained from the spatial index structure. The absolute value of the difference between the one-dimensional sorting code and the one-dimensional starting position code is calculated. If the absolute value of the difference is less than or equal to the preset adjacency span, the directly adjacent spatial partition unit identifier is included in the primary adjacency partition set; if the absolute value of the difference exceeds the preset adjacency span, it is excluded from the primary adjacency partition set. The home spatial partition unit itself is also included in the primary adjacency partition set.
[0095] Step S323: For each directly adjacent spatial partition unit in the primary adjacent partition set, obtain its corresponding secondary adjacent spatial partition unit again through the spatial partition unit adjacency relationship description. Merge the obtained secondary adjacent spatial partition units into the adjacency extension set, and perform adjacency diffusion count on the newly merged spatial partition units. Stop the expansion when the adjacency diffusion count reaches the preset diffusion layer limit.
[0096] The adjacency extension set is the total set of all spatial partition units that have been expanded outwards several layers from the primary adjacency partition set. The adjacency diffusion count is an accumulator counter that increments by 1 each time an adjacency relationship is passed through a layer of the original spatial partition unit as it expands outwards.
[0097] Initialize an adjacency diffusion count counter and set it to zero. Initialize a queue data structure for breadth-first diffusion traversal, adding all spatial partition unit identifiers from the primary adjacency partition set to this queue, and simultaneously adding these identifiers to the adjacency extension set. Increment the adjacency diffusion count counter by 1 and compare it with the preset diffusion layer limit. If the counter value is greater than or equal to the preset diffusion layer limit, terminate the diffusion process. If the limit has not been reached, record the current queue length, and sequentially remove that number of spatial partition unit identifiers from the queue. For each removed spatial partition unit identifier, query the spatial partition unit adjacency relationship description table to obtain its list of directly adjacent spatial partition unit identifiers. For each spatial partition unit identifier in the list, if the identifier does not yet exist in the adjacency extension set, add it to the adjacency extension set and append it to the end of the queue to await the next round of diffusion. After all nodes in the current layer have been processed, increment the adjacency diffusion count counter by 1 again and repeat the comparison with the preset diffusion layer limit and the layer-by-layer diffusion operation until the counter value reaches the limit.
[0098] Step S324: Merge the home spatial partition unit, the primary adjacency partition set, and the adjacency extension set, remove duplicate spatial partition unit identifiers, and form a multi-level adjacency reachable partition set. The spatial partition units in the multi-level adjacency reachable partition set are spatially continuous with the home spatial partition unit.
[0099] A multi-level adjacency reachable partition set is a complete set of spatial partition units that can be reached from the home spatial partition unit through a finite number of adjacency passes, obtained after layer-by-layer diffusion. Any spatial partition unit in this set has a spatial path with the home spatial partition unit that is formed by connecting several adjacent spatial partition units.
[0100] Specifically, an empty hash table is created as a deduplication container. The home spatial partition unit identifier is inserted into the container. Then, each spatial partition unit identifier from the primary adjacency set is inserted into the container, and each spatial partition unit identifier from the extended adjacency set is inserted into the container. Existing keys are automatically ignored during insertion. All spatial partition unit identifiers in the hash table are collected into a list, which represents the multi-level adjacency reachable partition set.
[0101] Step S325: Traverse the labeled order sequence, extract the spatial partition unit identifier of the pick-up location of each order, mark the orders whose spatial partition unit identifier belongs to the multi-level adjacency reachable partition set as candidate starting orders, and record the sequence index number of the candidate starting orders in the labeled order sequence.
[0102] Candidate starting orders are those whose pickup locations are within the rider's multi-level adjacency reach range. These orders serve as the preferred starting point when selecting candidate order combinations.
[0103] In this step, the order sequence is traversed sequentially from the first order. For each order encountered, the spatial partition unit identifier of the pickup location, stored in the order data structure, is read. This field was already populated when the spatial index structure was built in step S100. The read spatial partition unit identifier is then used to perform a membership check in a multi-level adjacency reachable partition set. The check is performed by using the identifier as the key to perform a lookup operation in a hash table. If the lookup is successful, the order is marked as a candidate starting order, and its sequence index number in the order sequence is appended to an index number list. If the lookup fails, the order is skipped, and the traversal continues until the end of the order sequence.
[0104] Step S326: Take the smallest sequence index number among all candidate starting order sequence index numbers as the lower bound of the interval, take the largest sequence index number as the upper bound of the interval, and extract the continuous subsequence from the lower bound to the upper bound of the interval in the marked order sequence as the order subsequence interval, thus completing the limitation of the starting search range for the extraction operation.
[0105] The lower bound and upper bound of the interval are the starting and ending position numbers of the order subsequence interval in the labeled order sequence, respectively.
[0106] Perform a linear scan on the candidate starting order index number list recorded in step S325, maintaining the minimum and maximum sequence index numbers encountered during the scan. Use the minimum sequence index number as the lower bound of the order subsequence interval, and the maximum sequence index number as the upper bound. Extract all orders from the labeled order sequence whose sequence index numbers fall between the lower and upper bounds of the interval, and form a new order subsequence according to their original order. This subsequence is the order subsequence interval that defines the starting search range for the truncation operation.
[0107] Step S330: Within the order subsequence interval, starting from the first order, subsequent consecutive orders are attempted to be assigned to the current candidate combined order group. For each order assigned, the inter-unit travel time information stored in the spatial index structure, the distribution of pick-up and delivery locations of the orders already assigned in the current group, and the estimated food preparation time data are immediately used to calculate the cumulative travel time and expected delivery time required to complete the pick-up and delivery of all orders in the current group.
[0108] Cumulative travel time is the total travel time taken by a rider to complete all pickup and delivery tasks within the current order group, starting from the first pickup location and following a certain visit order. This time includes travel time between spatial units along the route and waiting time at pickup locations. Expected delivery time is the estimated arrival time of the rider at each delivery location within the group.
[0109] In one implementation, step S330 may specifically include the following steps S331 to S335.
[0110] Step S331: Extract the temporary order set consisting of orders already assigned to the current group, map the pick-up location and delivery location of each order in the temporary order set to a one-dimensional reference code through a space filling curve, obtain the reference sorting value of each pick-up and delivery location, and generate the initial pick-up sequence according to the pick-up reference sorting value in ascending order.
[0111] The temporary order set is a temporary collection of all orders successfully included in the current candidate order group. The one-dimensional reference code is a sorting code generated for both the pickup and delivery locations using the same space-filling curve mapping method as in step S230. The reference sorting value is a sorting key that allows for numerical comparison after converting the one-dimensional reference code into a non-negative integer value.
[0112] In this step, all order identifiers already assigned to orders are extracted from the current candidate order group container to form a temporary order set. For each order in the temporary order set, the longitude and latitude coordinates of its pickup location and delivery location are obtained. Using the same space-filling curve forward mapping function and grid vertex coordinate matrix as in step S230, a one-dimensional pickup reference code and a one-dimensional delivery reference code are generated for each pickup location. The pickup and delivery one-dimensional reference codes are converted into corresponding integer values according to their binary bit weights; these integer values are the pickup reference sorting value and the delivery reference sorting value, respectively. All orders are arranged in ascending order of their pickup reference sorting values, resulting in the initial pickup sequence, which determines the basic order in which riders visit each pickup location.
[0113] Step S332: Starting from the first pick-up location in the initial pick-up sequence, the delivery location of the corresponding order is embedded into the access sequence according to the earliest insertable time after the pick-up is completed. During embedding, the reference sort value of the delivery location is compared with the reference sort value of the existing delivery location in the sequence to maintain the ascending order of the delivery reference sort values.
[0114] The earliest possible insertion point is after the pickup location of an order has been visited. The delivery location of that order can be inserted into the earliest position in the access sequence, provided that the delivery location is located after its corresponding pickup location.
[0115] Specifically, an empty access sequence list is initialized. Starting with the first pickup location in the initial pickup sequence, it is appended to the end of the access sequence, marking the node as a pickup type and recording the corresponding order identifier and pickup reference sorting value. Then, the delivery location is retrieved from the orders corresponding to that pickup location. The delivery reference sorting value of this delivery location is compared one by one with the delivery reference sorting values of all existing delivery locations in the access sequence. The position where the first delivery reference sorting value is greater than the current insertion delivery location's delivery reference sorting value is found, and the current delivery location is inserted before that position. If there are no delivery locations in the access sequence, or if the delivery reference sorting value of the current insertion delivery location is greater than the delivery reference sorting values of all existing delivery locations, then the delivery location is appended to the end of the access sequence. After processing the first order, the second pickup location is retrieved from the initial pickup sequence, appended to the end of the access sequence, and then its corresponding delivery location is inserted according to the same rules, ensuring that the delivery location is after its pickup location. The above operations of adding pick-up points and inserting delivery points are performed sequentially on all orders in the initial pick-up sequence until the pick-up and delivery locations of all orders are included in the access sequence.
[0116] Step S333: For each embedded access sequence, starting from the rider's current spatial location, the spatial partition unit transition relationship between adjacent access points in the sequence is sequentially input into the spatial index structure. The estimated travel time corresponding to each transition relationship is retrieved from the order index mapping record, and the waiting time for food preparation when accessing the food pickup location is added. The waiting time for food preparation is obtained by comparing the rider's expected arrival time at the food pickup location with the estimated food preparation time of the order corresponding to that food pickup location. When the expected arrival time is earlier than the estimated food preparation time, the waiting time is the difference between the estimated food preparation time and the expected arrival time; otherwise, the waiting time is zero.
[0117] Spatial partition unit transition relationships refer to the cross-unit movement behavior in a visit sequence where two adjacent visit points are located in different spatial partition units, from the first unit to the second unit. Estimated travel time is the shortest travel time estimate of the road network between the first and second spatial partition units.
[0118] For example, the rider's starting spatial location is used as the virtual starting point of the access sequence. An accumulated time counter is initialized and set to zero. Starting from the first access node in the access sequence, path segments between adjacent access points are processed one by one. For the current path segment, the starting spatial coordinates and ending spatial coordinates of the path segment are determined, and the spatial partition unit identifiers of the starting point and the ending point are queried respectively using the spatial index structure constructed in step S100. If the starting spatial partition unit identifier is the same as the ending spatial partition unit identifier, the default value of the intra-unit travel time of the spatial partition unit is extracted from the intra-unit travel attribute of the order index mapping record as the estimated travel time of the path segment. If the starting spatial partition unit identifier is different from the ending spatial partition unit identifier, the shortest travel time record from the starting spatial partition unit to the ending spatial partition unit is queried from the order index mapping record. This record is the cross-regional travel cost calculated in advance using the Dijkstra shortest path algorithm or the shrinking layering algorithm for all spatial partition units using the road network topology. The queried estimated travel time is added to the accumulated time counter. If the destination of the current route segment is a pickup location, the waiting time for food preparation at that location also needs to be added. The addition process is as follows: retrieve the estimated food preparation time data for the order corresponding to the pickup location, use the current value of the cumulative time counter as the rider's estimated arrival time at the pickup location, compare the estimated arrival time with the estimated food preparation time data. If the estimated arrival time is earlier than the estimated food preparation time data, subtract the estimated arrival time from the estimated food preparation time data and add the difference as the waiting time for food preparation to the cumulative time counter, and update the value of the cumulative time counter to the estimated food preparation time data; if the estimated arrival time is later than or equal to the estimated food preparation time data, the waiting time for food preparation is zero, and the cumulative time counter remains unchanged. Record the estimated arrival time of the destination of the current route segment as the current value of the cumulative time counter. After processing all adjacent access point pairs in the access sequence, the final value of the cumulative time counter is the cumulative travel time of the entire access sequence, and the estimated arrival time of each delivery location is the corresponding time value recorded when it was processed in the access sequence.
[0119] Step S334: Record the estimated arrival time of each delivery location in the access sequence as the expected delivery time of the order corresponding to that delivery location, and use the time difference between the estimated arrival time of the first pick-up location and the estimated arrival time of the last delivery location in the access sequence as the cumulative travel time.
[0120] During the segmented calculation process in step S333, whenever a delivery location is processed, the cumulative time counter value at that time is the estimated arrival time of that delivery location. This value is associated with the order identifier bound to that delivery location and stored as the expected delivery time of the order. After the entire access sequence is processed, the estimated arrival time value of the first pickup location in the access sequence and the estimated arrival time value of the last delivery location in the access sequence are recorded. The time difference obtained by subtracting the former from the latter is the cumulative travel time.
[0121] Step S335: Temporarily store the expected delivery time and cumulative travel time of all included orders. When it is detected that the expected delivery time of any order exceeds its delivery time limit constraint data, cancel the most recent embedding operation and adjust the access sequence. Recalculate the cumulative travel time and the expected delivery time of each order using the adjusted access sequence.
[0122] The expected delivery time of each assigned order calculated in step S334 is compared one by one with the delivery time constraint data bound to that order in step S310. If the expected delivery time of all orders is not later than their respective delivery time constraint data, the current cumulative travel time and all expected delivery times are temporarily stored to confirm the validity of the assignment and continue processing the assignment operation of the next order. If the expected delivery time of any order is later than its delivery time constraint data, it is determined that the time constraint has been violated by this assignment, and the most recent order assignment operation needs to be canceled, that is, the most recently assigned order is removed from the temporary order set. After removal, the pick-up and delivery access sequence generation and the calculation of cumulative travel time and expected delivery time in steps S331 to S334 are re-executed with the temporary order set state before the removal of the order. If the expected delivery time of all orders meets the delivery time constraint after recalculation, the adjusted state is the valid state. If the expected delivery time still exceeds the limit after recalculation, continue to try to adjust the order of the pick-up and delivery locations in the access sequence. Under the constraint of ascending order of delivery reference sorting value, locally shift the embedded position of the delivery location and recalculate until an access sequence that satisfies all delivery time constraints is found, or it is confirmed that there is no feasible access sequence under the composition of the current temporary order set.
[0123] Step S340: Compare the expected delivery time with the delivery time constraint data of each order. When the expected delivery time of any order exceeds its delivery time constraint data, stop the ordering attempt and output the set of orders corresponding to the previous state that satisfies all time constraints as a candidate order combination.
[0124] During the process of classifying and calculating the current candidate order combination in steps S330 to S335, the satisfaction of time constraints is continuously monitored. If, after classifying an order, the cancellation and adjustment in step S335 still cannot ensure that the expected delivery time of all classified orders meets their delivery time constraint data, the classification operation is terminated. The process reverts to the temporary order set state before the last failed classification, where all time constraints were met. The order set in this state is packaged into a candidate order combination, and the order identifier list, accumulated travel time temporary value, and access sequence of this combination are output together. Orders in this candidate order combination are marked as having been processed in the current round of extraction.
[0125] Step S350: Record the end position of the current candidate order combination in the order subsequence interval, slide the extracted start position to the next order after the end position, include duplicate orders in the time constraint check, and generate the next candidate order combination.
[0126] After outputting a candidate order combination in step S340, the sequence index number of the last order in the combination within the order sub-sequence interval is obtained, and this index number is used as the end position of the current extraction round. The extraction start position is then moved to the next index position after the end position index number, and the order corresponding to this new start position is used as the first order to be included in the next round of extraction. The order inclusion, cumulative travel time calculation, expected delivery time calculation, and time constraint verification processes described in steps S330 to S340 are repeated to generate the next candidate order combination.
[0127] Step S360: When the starting position after sliding exceeds the end boundary of the order subsequence interval, terminate the truncation operation and summarize all generated candidate order combinations to form a candidate order combination set.
[0128] After each round of candidate order combinations is generated, check whether the new starting position after sliding is greater than the upper bound of the order sub-sequence interval. If the sequence index number of the new starting position is greater than the upper bound of the interval, it indicates that all orders within the order sub-sequence interval have been assigned to a candidate order combination, or that the remaining orders cannot form another valid candidate order combination. At this time, the loop of the truncation operation is terminated. Collect all candidate order combinations output since the start of step S340, and summarize these candidate order combinations, their respective cumulative travel time temporary values, and access sequence temporary values into a candidate order combination set.
[0129] Step S400: For any candidate order combination generated by the interception, extract the pick-up and delivery location points bound to each order in the candidate order combination, query the spatial partition unit identifier in the spatial index structure that has a spatial partition unit overlap relationship with the extracted pick-up and delivery location points, retrieve the estimated passage cost corresponding to the spatial partition unit passed through from the order index mapping record according to the spatial partition unit identifier, and accumulate the estimated passage cost of the spatial partition unit passed through according to the access order of the pick-up and delivery location points in the candidate order combination to obtain the circumvention path cost for completing all pick-up and delivery tasks corresponding to the candidate order combination.
[0130] Spatial partition unit overlap refers to the spatial relationship between the spatial partition unit where the pickup / delivery location is located and the spatial partition units that the rider's path will traverse, where there is spatial inclusion or overlap. Passing spatial partition units are each spatial partition unit traversed by the rider during their route visiting each pickup / delivery location in the access sequence. Estimated travel cost is the estimated time or distance cost incurred by the rider when traversing a spatial partition unit or moving from one spatial partition unit to an adjacent one. The circuit cost is the sum of the total travel cost and total waiting cost incurred by the rider starting from the initial location, completing all pickup and delivery tasks within the candidate order combination in the specified access sequence, and finally arriving at the last delivery location.
[0131] In one implementation, step S400 involves accumulating the estimated passage cost of the spatial partition units through which the candidate order is passed based on the access order of the pick-up and delivery location points. Specifically, this may include the following steps S410 to S460.
[0132] Step S410: Obtain the pickup and delivery location points bound to each order in the candidate order combination, generate an initial pickup and delivery access arrangement according to the order sequence of each order, and split the initial pickup and delivery access arrangement into a pickup sub-arrangement and a delivery sub-arrangement, ensuring that the position of any order in the delivery sub-arrangement is no earlier than its position in the pickup sub-arrangement.
[0133] The initial pickup / delivery access permutation is an ordered list containing all pickup and delivery locations within the candidate order combination. Each element in the list is labeled with either pickup or delivery type and associated with a corresponding order identifier. The pickup sub-permutation is an ordered list that retains only the nodes of type pickup from the initial pickup / delivery access permutation, maintaining their original relative order. The delivery sub-permutation is an ordered list that retains only the nodes of type delivery from the initial pickup / delivery access permutation, maintaining their original relative order.
[0134] In this step, all order identifiers are read from the candidate order combinations. The initial pick-up and delivery access arrangement is then used, either based on the access order temporarily stored in step S300 or directly following the access sequences generated in steps S331 and S332. If no temporary access sequence exists, the initial pick-up and delivery access arrangement is regenerated according to the order sequence, prioritizing the pick-up location for each order over the delivery location. The initial pick-up and delivery access arrangement is traversed, and nodes marked as "pick-up" are copied to the pick-up sub-arrangement in the order of their encounters, and nodes marked as "delivery" are copied to the delivery sub-arrangement in the same order. After generating the sub-arrangements, it is verified whether each order appears after its position in the delivery sub-arrangement. If an order's delivery location precedes its pick-up location, the delivery location is moved to the nearest position after its pick-up location that satisfies the ascending order constraint of the delivery reference sorting value.
[0135] Step S420: Call the spatial index structure to calculate the initial cycle path cost of the initial fetch and send access arrangement segment by segment, and set the initial cycle path cost as the current optimal cost, and set the initial fetch and send access arrangement as the current optimal access arrangement.
[0136] The current optimal cost is a temporary variable that is continuously updated with smaller costs during the cycle path cost optimization process; its initial value is the initial cycle path cost. The current optimal access order is a temporary variable that stores a list of currently known optimal fetch and send access orders.
[0137] In one implementation, step S420 may specifically include the following steps S421 to S425.
[0138] Step S421: Determine the path segments from the rider's initial position to the first access point and between each adjacent access point in the order of the access points in the initial pick-up and delivery access arrangement.
[0139] In this step, the rider's initial position is used as the starting anchor point of the path, and the first access point in the initial pick-up and drop-off access sequence is used as the endpoint of the first path segment. The first access point is used as the starting point of the second path segment, the second access point as the endpoint, and so on, until the last access point in the sequence is used as the endpoint. Each pair of start and end points is recorded as a path segment and stored sequentially in the path segment list.
[0140] Step S422: For each path segment, query the first spatial partition unit where its starting spatial coordinates are located and the second spatial partition unit where its ending spatial coordinates are located. Extract the shortest travel time record from the first spatial partition unit to the second spatial partition unit from the order index mapping record. The shortest travel time record is a cross-regional travel cost record that is pre-generated and persisted through road network topology search.
[0141] The path segment list generated in step S421 is processed segment by segment. For the current path segment, the longitude and latitude values of the starting point's spatial coordinates are read, and the cell identifier of the spatial partition unit where the starting point is located is determined using the same grid positioning method as in step S321, denoted as the first spatial partition unit. The longitude and latitude values of the ending point's spatial coordinates are read, and the cell identifier of the spatial partition unit where the ending point is located is determined using the same method, denoted as the second spatial partition unit. A query key pair is constructed using the first and second spatial partition unit identifiers, and a key-value query is performed in the cross-regional passage cost table associated with the order index mapping record. This cross-regional passage cost table is a dataset generated by preprocessing road network data after the spatial index structure is constructed. During preprocessing, each spatial partition unit is abstracted as a node in the road network graph. The edge weights between nodes are the actual road travel times between the center points or boundary representative points of two spatial partition units, calculated using the shortest path algorithm. The calculation considers factors such as road grade, real-time or historical average traffic speed, and traffic light waiting delays. The main algorithm employs a shrinking hierarchical bidirectional Dijkstra algorithm to ensure real-time query performance even with a large number of spatial partition units. The shortest travel time record returned after a successful query is the travel cost for that path segment.
[0142] Step S423: If the first spatial partition unit is the same as the second spatial partition unit, then extract the default value of the intra-unit travel time of the spatial partition unit from the order index mapping record as the travel cost of the path segment.
[0143] The default value for travel time within a unit is a uniform estimated travel time when the start and end points of a path segment are located within the same spatial partition unit. This value can be taken as the statistical mean of travel time between any two points within the spatial partition unit.
[0144] Before executing step S422, the identifiers of the first and second spatial partition units are compared. If they are equal, the query of the cross-regional passage cost table is skipped, and instead, the preset default value of intra-unit passage time is read from the unit attribute field of the order index mapping record of the spatial partition unit, and the default value is directly returned as the passage cost of the current path segment.
[0145] Step S424: Accumulate the passage costs of all path segments according to the access order, and add the waiting time for the corresponding order when passing through the food pick-up access point to obtain the initial circulation path cost.
[0146] The passage cost returned in step S422 or S423 is accumulated sequentially according to the order of the path segment list. After processing each path segment, it is checked whether the destination access point of that path segment is a food pickup type. If so, the estimated food preparation time data of that order is read from the order attributes. The current accumulated total time value is used as the estimated arrival time, compared with the estimated food preparation time data, and the possible food preparation waiting time is added. The addition logic is completely consistent with the food preparation waiting time calculation logic in step S333. After all path segments have been processed, the accumulated total time value is the initial circulation path cost.
[0147] Step S425: Store the initial cycle path cost value into the current optimal cost storage area, and store the complete sequence structure of the initial fetch and send access arrangement into the current optimal access arrangement storage area to complete the initialization setting of the optimal state.
[0148] Write the initial cycle path cost variable value calculated in step S424 into the current optimal cost temporary storage variable, and copy all nodes of the initial fetch and send access arrangement generated in step S410 into the current optimal access arrangement temporary storage variable in the current order.
[0149] Step S430: Perform local exchange perturbation operations on the pick-up sub-permutation and the delivery sub-permutation respectively. The exchange perturbation operation selects two adjacent access points and swaps their order to form a new access permutation. The circumvention path cost of the new access permutation is evaluated through the spatial index structure.
[0150] The local exchange perturbation operation for access points involves selecting a pair of adjacent access points in the current food pickup or food delivery sub-arrangement and swapping their order to generate a new access point arrangement.
[0151] For the pick-up and delivery sub-arrangements split in step S410, pairwise traversal of adjacent access points is performed within each sub-arrangement. For each pair of adjacent pick-up access points in the pick-up sub-arrangement, the cost contribution of each pair to the local path segment in the entire access arrangement before the swap is calculated. Then, the order of the two pairs is virtually swapped, and the cost contribution of the local path segment after the swap is calculated. If the local cost after the swap is less than the local cost before the swap, the actual swap is performed, and the corresponding complete access arrangement is updated. A similar operation is performed on the delivery sub-arrangement, but when swapping delivery access points, it is additionally checked whether the swapped delivery order will cause the delivery location point of any order to appear before its pick-up location point. If such a violation occurs, the swap is abandoned. After a complete perturbation operation is completed, the cycle path cost of the new access arrangement is recalculated using the spatial index structure and compared with the current optimal cost.
[0152] In one implementation, step S430 may specifically include the following steps S431 to S436.
[0153] Step S431: In the food pick-up sub-arrangement, scan each pair of adjacent food pick-up access points in the arrangement in a step-by-step manner, construct the local food pick-up path segment before the exchange and the local food pick-up path segment after the exchange, and calculate the change in local food pick-up path cost before and after the exchange.
[0154] Before the swap, the local food pickup path segment is a short path segment extracted from the current access order, centered on the previous food pickup access point of the current adjacent food pickup access point pair, extending one access point before and after it. After the swap, the local food pickup path segment is a short path segment extracted according to the same rules after the order of the adjacent food pickup access point pair is swapped.
[0155] In this step, starting from the beginning of the food pickup sub-arrangement, the window slides within the arrangement in increments of 1. At each new position, the first and second food pickup access points covered by the current window are retrieved. Simultaneously, the predecessor and successor nodes of the first and second food pickup access points in the complete access arrangement are identified. A pre-swap local path segment is constructed, starting from the predecessor node of the first food pickup access point and ending at the successor node of the second food pickup access point. The passage cost of this local path segment is calculated using the spatial index structure and denoted as the pre-swap local food pickup path cost. Subsequently, the order of the first and second food pickup access points is swapped in the virtual replica, and the post-swap local path segment is constructed and its cost calculated using the same method. The post-swap local food pickup path cost is then subtracted from the pre-swap local food pickup path cost; the difference represents the change in the local food pickup path cost before and after the swap.
[0156] Step S432: If the cost of the local food pickup path after the swap is less than the cost of the local food pickup path before the swap, then perform the order swap of the adjacent food pickup access points and update the consistency constraints of the order access order in the food pickup sub-arrangement and the corresponding food delivery sub-arrangement.
[0157] The change calculated in step S431 is compared with zero. If the change is negative, meaning the local pick-up path cost after the swap is less than the local pick-up path cost before the swap, it indicates that the adjacent swap operation can reduce the local access cost. In this case, the order of the pair of pick-up access points is swapped in the actual pick-up sub-arrangement, and the positions of these two pick-up access points are updated synchronously in the complete access arrangement. Simultaneously, it is checked whether the order of delivery access points and pick-up access points for any order is violated due to this swap in the delivery sub-arrangement. If a violation occurs, the delivery access point for that order is moved backward in the delivery sub-arrangement by the corresponding position, so that the position of the delivery access point returns to after the position of the pick-up access point for that order. If the change is non-negative, the pair of pick-up access points are not swapped; the original order is maintained, and the scanning of the next pair of adjacent pick-up access points continues.
[0158] Step S433: In the food delivery sub-arrangement, calculate the change in local food delivery path cost before and after the swap for each pair of adjacent food delivery access points using the same step scanning method, and perform a cost-reducing swap operation if the food delivery order after the swap does not violate the order constraints of any order pickup and delivery.
[0159] After completing a full adjacent scan of the pickup sub-arrangement, a similar step scan is performed on the delivery sub-arrangement. For each pair of adjacent delivery access points in the delivery sub-arrangement, the local delivery path segments before and after the swap are constructed, and the change in local cost is calculated. Before determining whether to perform a swap, an additional pickup / delivery order constraint check is performed, i.e., checking whether swapping these two delivery access points would result in the delivery access point appearing before the pickup access point in the corresponding orders for those two delivery access points. If the pickup / delivery order constraint of either order is violated, the swap is abandoned. If the constraint check passes and the change in local cost is negative, the swap is performed, and the complete access arrangement is updated synchronously.
[0160] Step S434: Merge the food pickup and food delivery access sequences after local adjustments to the food pickup and food delivery sub-permutations into a complete new access sequence, and calculate the cycle path cost of the new access sequence.
[0161] After all the local exchange perturbation operations of the pick-up sub-arrangement and the delivery sub-arrangement are completed in one round, the updated pick-up and delivery sub-arrangements are merged again to generate a complete access arrangement. The merging method is consistent with the sequence construction logic in step S332, that is, first, pick-up access points are placed sequentially according to the order of the pick-up sub-arrangement, and after each pick-up access point is placed, its corresponding delivery access point is immediately inserted into the sequence, provided that the delivery reference sorting value is in ascending order. The new access arrangement obtained after merging is the output result of this round of perturbation. The same segmented path cost accumulation and meal delivery waiting superposition procedure as in steps S421 to S424 is called to calculate the cycle path cost corresponding to the new access arrangement.
[0162] Step S435: If the cycle path cost of the new access permutation is lower than the current optimal cost, then replace the current optimal cost and the current optimal access permutation with the cycle path cost of the new access permutation and the new access permutation, respectively, and reset the invalid attempt count of the perturbation operation to zero.
[0163] The invalid attempt count is a counter used to record the number of consecutive perturbation operations that fail to produce optimization results. In this step, the cost of the new access permutation cycle path calculated in step S434 is compared with the value stored in the current optimal cost temporary variable. If the value of the new access permutation cycle path cost is less than the current optimal cost value, an optimal state update operation is performed: the value of the current optimal cost temporary variable is overwritten with the value of the new access permutation cycle path cost, the entire access sequence stored in the current optimal access permutation temporary variable is replaced with the node sequence of the new access permutation, and the invalid attempt counter is reset to zero.
[0164] Step S436: If the cost of the new visit permutation is not lower than the current optimal cost, then cancel the visit permutation and retain the original optimal state. At the same time, increase the invalid attempt count. When the invalid attempt count reaches the preset upper limit, terminate the perturbation operation loop.
[0165] If the value of the new access permutation cycle path cost calculated in step S434 is greater than or equal to the value stored in the current optimal cost temporary variable, then the optimal state update is not performed, that is, the current optimal cost and the current optimal access permutation remain unchanged. The value of the invalid attempt counter is incremented by one. It is determined whether the incremented invalid attempt counter value is greater than or equal to the preset upper limit value of invalid attempts for perturbation operations. If the upper limit is reached, the current perturbation operation loop for the take-meal sub-permutation and deliver-meal sub-permutation is terminated, and the process proceeds to step S450; if the upper limit is not reached, the process returns to step S431 to start a new round of adjacent access point scanning and exchange perturbation.
[0166] Step S440: If the cycle path cost of the new access permutation is less than the current optimal cost, then update the current optimal cost to the cycle path cost of the new access permutation, replace the current optimal access permutation with the new access permutation, and reset the record state of the perturbation operation.
[0167] The recording status of the perturbation operation is used to record information such as the counter for continuous non-optimization of the perturbation operation and the scan start position pointer, which are information about the perturbation loop operation status.
[0168] The execution logic of this step is consistent with the update operation in step S435. Here, it is emphasized as an independent step that the state synchronization action occurs every time a valid optimization occurs. When the cycle path cost of the new access permutation is confirmed to be less than the current optimal cost, the replacement of the optimal cost and the optimal permutation is completed, the invalid attempt count is reset to zero, the scan pointer is reset to the starting position of the sub-permutation, and the search for a better access permutation continues with a completely new state.
[0169] Step S450: Repeat the access point local exchange perturbation operation until no more cost-reducing exchanges occur within a preset number of consecutive perturbation attempts. Then, determine the current optimal access arrangement as the optimized fetch and send access order.
[0170] The perturbation, evaluation, and update operations described in steps S430 to S440 are executed iteratively. In each iteration, all adjacent access point pairs of the pick-up and delivery sub-arrangements are traversed, and swaps are performed on pairs that meet the conditions. The loop uses an invalid attempt counter as the termination criterion. Once the invalid attempt counter accumulates to a preset upper limit for perturbation attempts, it indicates that the path cost cannot be further reduced through adjacent swaps within the local neighborhood of the current access arrangement, meaning that it has converged to a local optimum. At this point, the access arrangement sequence stored in the temporary variable of the current optimal access arrangement is determined as the optimized pick-up and delivery access order for the candidate combination.
[0171] Step S460: Based on the optimized retrieval and delivery access order, re-query the estimated passage cost of the spatial partition units through the spatial index structure, perform cost accumulation, and use the accumulated result as the circumvention path cost of the candidate combination.
[0172] To ensure that the circumvention path cost is completely consistent with the actual assigned path, based on the optimized pick-up and delivery access order determined in step S450, a complete round of circumvention path cost calculation is re-executed according to the segment-by-segment path cost query and accumulation procedure in steps S421 to S424. In this round of calculation, the passage cost of each path segment is directly read from the cross-area passage cost table described in step S422 or the default value of intra-unit passage time described in step S423, and the waiting time for meal preparation is added at the pick-up access point. The final accumulated circumvention path cost is the accurate circumvention path cost of the candidate order combination under the current optimal access order. This cost will be used for the horizontal comparison between candidate order combinations in step S500.
[0173] Step S500: Compare the circumvention path costs corresponding to all candidate order combinations generated by the extraction, select the candidate order combination with the smallest circumvention path cost as the scheduling execution result to be assigned, and output rider assignment information and rider's pick-up and delivery order suggestions for each order in the candidate order combination based on the scheduling execution result.
[0174] The scheduling execution result is an optimal candidate order combination selected through global comparison, which will then be formally assigned to the target rider for execution. Rider assignment information is a data packet sent to the rider's terminal containing the set of assigned orders and the rider's identifier. Pickup and delivery order suggestion information is a sequence of steps guiding the rider to visit each pickup and delivery location in a specific order.
[0175] In one implementation, step S500 compares the cycle path costs corresponding to all candidate combination combinations generated by interception, and selects the candidate combination combination with the smallest cycle path cost as the scheduling execution result to be assigned. Specifically, this may include the following steps S510 to S550.
[0176] Step S510: Group all candidate order combinations according to the spatial partition unit where the first food pickup access point is located, forming a candidate order combination group set corresponding to each spatial partition unit.
[0177] Iterate through all candidate order combinations in the candidate order combination set summarized in step S360. For each candidate order combination, read the spatial coordinates of the first access point of type "order pickup" in its optimized pickup and delivery access order, and locate the unit identifier of the spatial partition cell where the coordinates are located using the same method as in step S422. Using the spatial partition cell identifier as the grouping key, group candidate order combinations with the same grouping key into the same candidate order combination group set. Finally, multiple candidate order combination groups are formed with the spatial partition cell identifier as the index, and the first order pickup access point of the candidate order combination within each group is located within the same spatial partition cell.
[0178] Step S520: Within each candidate single-item combination group set, perform the minimum circulating path cost query operation within the group using a recursive binary comparison method: pair up the candidate single-item combinations within the group, retain the combination with the smaller circulating path cost in each pair, and the winning combination continues to enter the next round of pairing comparison until only one candidate single-item combination remains in the group, and the candidate is taken as the local optimal single-item combination of the group.
[0179] In one implementation, step S520 may specifically include the following steps S521 to S525.
[0180] Step S521: Arrange the candidate single-item combinations in the current group in any order to form a comparison queue. If the number of combinations in the queue is odd, the last candidate single-item combination is directly placed into the next round of matching pool.
[0181] List all candidate single-unit combinations in a given set of candidate single-unit combinations one by one, forming a linear comparison queue in any order. Check if the length of the queue is odd. If the length is odd, move the element of the candidate single-unit combination at the end of the queue to the next round of the pairing pool for temporary storage, and remove the element from the current comparison queue, making the length of the remaining queue even.
[0182] Step S522: Pair the remaining even-numbered candidate single combinations according to their adjacent positions. For each pair, directly read their respective cost values from the stored cycle path cost and compare them. Push the pair with the smaller cost value into the next round of pairing pool.
[0183] In the remaining even-length comparison queue after step S521, two candidate single-item combinations are taken from the head of the queue each time to form a comparison pair. For each comparison pair, the cycle path cost value of the first candidate single-item combination and the cycle path cost value of the second candidate single-item combination are read from the cycle path cost value area calculated and stored in step S460, and the two values are compared. The candidate single-item combination with the smaller cycle path cost value is pushed into the next round of matching pool.
[0184] Step S523: During the comparison of each pair of combinations, if the circumvention path costs of the two are the same, then the spatial distance between the first food pickup point of the two combinations and the rider's starting position is further obtained, and the combination with the shorter spatial distance is pushed into the next pairing pool.
[0185] During the comparison in step S522, if the cycle path cost values of the first candidate order combination and the second candidate order combination are exactly equal, the winner cannot be determined solely by the cycle path cost. At this point, the spatial coordinates of the first pickup point in the optimized pickup and delivery access sequence of the first candidate order combination are obtained, and the Euclidean distance between these coordinates and the rider's starting spatial position coordinates is calculated and recorded as the first pickup point distance. Similarly, the coordinates of the first pickup point of the second candidate order combination are obtained, and the Euclidean distance between it and the rider's starting point is calculated. The magnitudes of the two first pickup point distances are compared, and the candidate order combination with the smaller distance value is pushed into the next round of the pairing pool.
[0186] Step S524: Repeat the pairing and winning push operation, generating a new level of pairing pool each time, and recording the source path information of the winning combination in each round, until there is only one candidate single combination left in the pairing pool.
[0187] The next round of pairing pool generated in steps S522 and S523 is used as a new comparison queue, and the logic of steps S521 to S523 is repeated. During each round of execution, the source group number or identifier of the winning combination in the previous round is recorded to form a traceability path. After several rounds of recursive halving elimination, only one candidate single combination remains in the pairing pool, at which point the iteration terminates.
[0188] Step S525: Determine the remaining candidate combination as the local optimal combination of the group, and output the combination identifier and its cycle path cost of the local optimal combination.
[0189] Record the combination identifier of the only remaining candidate single combination in the pairing pool, and at the same time record the corresponding cycle path cost value of the combination, and mark the combination as the local optimal single combination of the candidate single combination group.
[0190] Step S530: Collect the locally optimal single-unit combinations of all groups to form a cross-group candidate winning set. Perform a recursive binary comparison operation on the cross-group candidate winning set again to determine the candidate single-unit combination with the minimum global circulation path cost.
[0191] Each candidate single-item combination group extracts all locally optimal single-item combinations selected through steps S520 to S525 and aggregates them into a cross-group candidate winning set. The recursive binary comparison operation described in steps S521 to S525 is then performed again on this cross-group candidate winning set, comparing the path cost of each combination and, if necessary, the spatial distance of the first-take point. After multiple rounds of cross-group elimination comparisons, the only remaining candidate single-item combination is the one with the minimum global path cost.
[0192] Step S540: If the spatial partition unit where the first pickup point of the globally optimal candidate order combination is located is different from the spatial partition unit where the rider is currently located, obtain the circuit path cost of the globally optimal candidate order combination and the circuit path cost of the second-best candidate order combination with the smallest circuit path cost other than this combination. Calculate the absolute value of the difference between the two as the cost difference. When the cost difference is less than the preset lenient acceptance threshold, further compare the empty travel costs of the rider from the current position to the spatial partition unit where the first pickup point of the globally optimal candidate order combination is located and to the spatial partition unit where the first pickup point of the second-best candidate order combination is located. Based on the comparison result of the empty travel costs, decide whether to replace the second-best candidate order combination with the final globally optimal combination.
[0193] The lenient acceptance threshold is a pre-defined tolerance value for cost differences. It is used to introduce the empty-run cost factor for secondary arbitration when the cost difference between the globally optimal combination and the second-best combination of travel paths is not significant. The empty-run cost is the cost that a rider needs to pay to travel from their current location to the spatial partition unit where the first pickup point of the candidate order combination is located without carrying any orders.
[0194] After determining the globally optimal candidate order combination in step S530, the spatial partition unit identifier of the first pickup point of the combination is read and compared with the rider's assigned spatial partition unit identifier determined in step S321. If they are the same, it indicates that the rider is currently located in the spatial partition unit where the first pickup point of the globally optimal combination is located or in its directly adjacent unit, and the globally optimal combination is directly confirmed as valid. If they are different, the second-best candidate order combination with the second-lowest circuit path cost is found from the remaining candidate order combinations. The absolute value of the circuit path cost of the globally optimal candidate order combination minus the circuit path cost of the second-best candidate order combination is taken as the cost difference. This cost difference is compared with a preset lenient acceptance threshold. If the cost difference is greater than or equal to the lenient acceptance threshold, it indicates that the advantage of the globally optimal combination is significant enough, and the globally optimal combination is retained. If the cost difference is less than the lenient acceptance threshold, it indicates that the difference in the cost of the two routes is negligible. In this case, it is necessary to calculate the empty travel cost for the rider from the starting spatial location to the spatial partition unit where the first pick-up point of the globally optimal candidate order combination is located, and the empty travel cost to the spatial partition unit where the first pick-up point of the second-best candidate order combination is located. The empty travel cost is also calculated by querying the cross-regional travel time record from the rider's spatial partition unit to the target spatial partition unit in the order index mapping record. If the empty travel cost to the second-best candidate order combination is significantly lower than the empty travel cost to the globally optimal candidate order combination, so as to make up for the small difference in the route cost, then the second-best candidate order combination is replaced with the final globally optimal combination; otherwise, the globally optimal combination remains unchanged.
[0195] Step S550: Mark the candidate combination with the lowest determined cycle path cost after adjustment as the scheduling execution result to be assigned, and record its corresponding cycle path cost and retrieval and delivery access order.
[0196] In this step, the candidate order combination identifier, which has been finally confirmed after the empty-run arbitration adjustment in step S540, is written into the variable of the scheduling execution result to be assigned. The optimized pick-up and delivery access order corresponding to the combination and the cycle path cost accurately calculated in step S460 are recorded together as the auxiliary attribute data of the scheduling execution result.
[0197] In one implementation, step S500 outputs rider dispatch information and rider's pick-up and delivery order suggestions for each order in the candidate order combination based on the scheduling execution result. Specifically, this may include the following steps S560 to S5110.
[0198] Step S560: Parse the set of order identifiers corresponding to the optimal candidate combination of orders and the optimized pick-up and delivery access sequence from the scheduling execution results to be assigned. Each node in the pick-up and delivery access sequence carries a pick-up and delivery type flag and an order identifier.
[0199] Read the order identifier set field and the pickup / delivery access sequence field from the data structure of the scheduling execution result to be assigned. Expand the order identifier set into an order identifier list, and extract the pickup / delivery access sequence one by one according to the node order. Each node contains a pickup / delivery type flag and an order identifier. The pickup / delivery type flag is either a pickup identifier or a delivery identifier.
[0200] Step S570: Associate the pickup / delivery type tag of each node in the pickup / delivery access sequence with the pickup location coordinates or delivery location coordinates of the corresponding order to generate a sequential node linked list with spatial location tags.
[0201] A sequential node linked list is a chain-like data structure that connects the first and last nodes in the order of pickup and delivery. Each node in the linked list adds longitude and latitude coordinate fields to the original pickup / delivery type marker and order identifier.
[0202] Iterate through each node in the pickup / delivery access sequence and read its pickup / delivery type flag. If the pickup / delivery type flag is a pickup identifier, extract the longitude and latitude coordinates of the pickup location from the order data structure based on the order identifier associated with the node, and fill them into the spatial location flag field of the node. If the pickup / delivery type flag is a delivery identifier, extract the longitude and latitude coordinates of the delivery location based on the order identifier, and fill them into the spatial location flag field. Concatenate all nodes in their original order into a sequential node linked list.
[0203] Step S580: Scan the sequential node list, attach the spatial partition unit identifier corresponding to the spatial location mark to each node, and check whether adjacent nodes have the same spatial partition unit identifier and the same pick-up / drop-off type mark. Merge adjacent nodes that meet the conditions to generate a task cluster node sequence.
[0204] The task cluster node sequence is a new sequence formed by merging consecutive access nodes located in the same spatial partition unit and with the same pickup and delivery type into a cluster node. Each cluster node can contain multiple order identifiers and multiple specific coordinate locations.
[0205] The process begins by traversing the linked list from the head node. For each node, the spatial index structure is queried based on its longitude and latitude coordinates in its spatial location marker to obtain the spatial partition unit identifier where the coordinates are located. This identifier is then written into the node's spatial partition unit field. A merge scan is then performed on the linked list: the spatial partition unit identifiers and delivery type markers of the current and next nodes are checked sequentially. If both conditions are met, the current and next nodes are merged into a cluster node. The cluster node's order identifier list and spatial location coordinate list are the concatenation of the corresponding lists from the original two nodes, while the delivery type marker remains unchanged. The merged cluster node is then compared with the next node until the merging conditions are no longer met. The resulting new node sequence is the task cluster node sequence.
[0206] Step S590: Analyze the spatial partition unit transition relationship between each node in the task cluster node sequence, extract the preset navigation turning description text between each pair of transition partitions from the order index mapping record, insert the navigation turning description text as a guidance fragment between the intent nodes, and form a set of pick-up and delivery order guidance instructions with travel guidance.
[0207] The navigation turn description text is a description field pre-stored in the cross-zone passage cost table of the order index mapping record. This field records key turning actions, road names, and directional indications during the movement from one spatial zone unit to an adjacent spatial zone unit in natural language text form.
[0208] For every two adjacent task cluster nodes in the task cluster node sequence, obtain the spatial partition unit identifier of the preceding cluster node and the spatial partition unit identifier of the following cluster node. Use these two spatial partition unit identifiers to form a query key pair, and retrieve a corresponding navigation turning description text from the transition navigation text table in the order index mapping record. This transition navigation text table is a post-processing product generated synchronously during the preprocessing of cross-regional passage costs in step S422. During the preprocessing stage, the names and turning types of each road segment in the road network path planning results are used to convert the sequential relationship of the road segments into coherent natural language travel guidance through rule templates. The retrieved navigation turning description text is inserted as a guidance fragment between the preceding and following task cluster nodes. After processing all adjacent nodes, a complete set of pick-up and delivery sequence guidance instructions with travel guidance is formed according to the original order of the task cluster nodes and the inserted guidance fragment.
[0209] Step S5100: Encapsulate the rider's terminal identifier, order identifier set, and pickup / delivery sequence instruction set into data and transmit them to the corresponding rider terminal, while simultaneously enabling instruction reception confirmation listening.
[0210] The system reads the terminal identifier of the rider currently being dispatched, and serializes and encapsulates the order identifier set parsed in step S560 and the pickup / delivery sequence guidance instruction set generated in step S590 according to the communication protocol agreed upon between the dispatch platform and the rider's terminal. The encapsulation format can adopt a lightweight data exchange structure, and each field is written into the data packet in sequence. The encapsulated data packet is sent to the rider's terminal through the wireless network push channel, and an instruction reception confirmation listening timer with a preset timeout period is started on the dispatch server to wait for the rider's terminal to return a confirmation response signal.
[0211] Step S5110: After receiving the confirmation signal from the rider terminal within the predetermined time window, update the scheduling status of all orders in the order identifier set to "assigned", synchronize the scheduling status to the order index mapping record in the spatial index structure, and freeze these orders to participate in subsequent scheduling.
[0212] The scheduled time window is the timeout duration set when the instruction reception confirmation listening is enabled in step S5100. The assigned scheduling status is the status indicator in the lifecycle of an order in the scheduling system that has changed from unassigned to assigned and the rider has confirmed acceptance.
[0213] The dispatch server's listening component continuously listens to the response channel corresponding to the designated rider's terminal before the end of the predetermined time window. If a confirmation signal is received from the rider's terminal, the timeout timer is canceled, the rider's terminal identifier in the confirmation signal is parsed, and it is matched and verified against the rider's terminal identifiers to be confirmed in this batch. If the match is successful, each order identifier in the order identifier set is traversed, and the dispatch status field of these orders is updated to the assigned status value in the order dispatch status database one by one. At the same time, the corresponding order index mapping record in the spatial index structure is located, the dispatch status field in the record is updated to assigned synchronously, and a freeze flag is set, so that these orders are removed from the set of orders to be assigned and will no longer participate in the dispatch and order merging calculation of any subsequent batch. If no confirmation signal is received within the predetermined time window, the timeout retransmission mechanism is triggered or the rider is marked as temporarily unassignable and the order identifier set is released to the unassigned state.
[0214] This application provides a computer-readable storage medium storing computer-executable instructions or a computer program. When the computer-executable instructions or the computer program are executed by a processor, the processor will execute the spatial index-based delivery route scheduling optimization method provided in this application. For example, ... Figure 4 The method for optimizing delivery route scheduling based on spatial indexing is shown.
[0215] In some embodiments, the computer-readable storage medium may be a read-only memory (ROM), random access memory (RAM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), flash memory, magnetic surface memory, optical disk, or CD-ROM, etc.; or it may be a device that includes one or any combination of the above-mentioned memories.
[0216] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.
Claims
1. A delivery route scheduling optimization method based on spatial indexing, characterized in that, The method includes: Obtain the set of pickup and delivery locations corresponding to each order in the set of orders to be assigned, and construct a spatial index structure based on the set of pickup and delivery locations. The spatial index structure divides the delivery geographic space into multiple spatial partition units, and each spatial partition unit records the order ownership relationship of the pickup and delivery locations located within it, thereby obtaining the order index mapping record bound to each spatial partition unit. By performing a one-dimensional dimensionality reduction mapping on each pickup and delivery location point in the pickup and delivery location point set through the space filling curve, a one-dimensional sorting code is generated that is bound to each order and is used to characterize the relative order position of the order on the space filling curve. All orders are then arranged in ascending order according to their respective one-dimensional sorting codes to obtain an order sequence with spatial proximity clustering characteristics. Using rider load capacity as a constraint, several consecutively arranged orders are extracted along the order sequence to form candidate order combinations. The extraction generates multiple candidate order combinations in sequence, and the number of orders contained in each candidate order combination does not exceed the rider load capacity. For any candidate order combination generated by the interception, the pickup and delivery location points bound to each order in the candidate order combination are extracted. The spatial partition unit identifiers that have spatial partition unit overlap with the extracted pickup and delivery location points in the spatial index structure are queried. Based on the spatial partition unit identifiers, the estimated passage cost corresponding to the spatial partition unit is retrieved from the order index mapping record. The estimated passage cost of the spatial partition unit is accumulated according to the access order of the pickup and delivery location points in the candidate order combination to obtain the circumvention path cost for completing all pickup and delivery tasks corresponding to the candidate order combination. The circuit path costs corresponding to all candidate order combinations generated by the extraction are compared. The candidate order combination with the smallest circuit path cost is selected as the scheduling execution result to be assigned. Based on the scheduling execution result, the rider assignment information and the rider's suggested order of pickup and delivery for each order in the candidate order combination are output.
2. The delivery route scheduling optimization method based on spatial indexing according to claim 1, characterized in that, The process involves performing a one-dimensional dimensionality reduction mapping on each pickup / delivery location in the set of pickup / delivery location points using a space-filling curve to generate a one-dimensional sorting code bound to each order, representing the relative order position of the order on the space-filling curve. All orders are then arranged in ascending order according to their respective one-dimensional sorting codes to obtain an order sequence with spatial proximity clustering characteristics, including: Obtain the boundary coordinate range of all spatial partition units in the spatial index structure, determine the longitude span range and latitude span range of the delivery geographic space based on the boundary coordinate range, and take the direction corresponding to the longer of the longitude span range and latitude span range as the reference mapping direction. Using the span length corresponding to the reference mapping direction as a reference, a target curve order is determined so that the number of grids on one side of the space filling curve is not less than the number of divisions of the space partitioning unit in the reference mapping direction. The delivery geographic space is then gridded according to the target curve order to obtain a regular grid array. For each pickup location point in the pickup location point set, a fixed-length binary code string corresponding to the pickup location point is generated as a one-dimensional sorting code by using the row index and column index of the grid falling into the regular grid array and the positive mapping function of the space filling curve under the order of the target curve. After binding the one-dimensional sorting code with the corresponding order identifier, all bound records are sorted in ascending order according to the lexicographical order of the one-dimensional sorting code to obtain an initial order sequence, and it is detected whether there are multiple different order identifiers with the same one-dimensional sorting code in the initial order sequence. When there are multiple different order identifiers with the same one-dimensional sorting code, obtain the original latitude and longitude coordinates of the pick-up and delivery location points corresponding to these order identifiers, calculate their relative position offset within their respective grids, and initiate local space filling curve recursive mapping within the grids based on the relative position offset to generate an extended sorting code with increasing bit length. The extended sorting code replaces the original one-dimensional sorting code, and the affected order subsequences are rearranged in ascending order until the one-dimensional sorting code or extended sorting code corresponding to each order identifier in the entire order sequence is unique, and the final order sequence with spatial proximity clustering characteristics is output.
3. The delivery route scheduling optimization method based on spatial indexing according to claim 2, characterized in that, When multiple different order identifiers have the same one-dimensional sorting code, the original latitude and longitude coordinates of the pickup and delivery locations corresponding to these order identifiers are obtained, their relative position offsets within their respective grids are calculated, and a recursive mapping of local space-filling curves is initiated within the grid based on the relative position offsets to generate an extended sorting code with increasing bit length, including: Extract the original longitude and latitude coordinates of the pickup and delivery location points bound to each order identifier that caused the coding conflict, as well as the lower longitude and lower latitude coordinates, upper longitude and upper latitude coordinates of the grid in which it is located. Divide the difference between the original longitude coordinates and the lower longitude boundary by the difference between the upper and lower longitude boundaries to obtain the normalized offset of the longitude direction within the grid. Divide the difference between the original latitude coordinates and the lower latitude boundary by the difference between the upper and lower latitude boundaries to obtain the normalized offset of the latitude direction. The normalized offsets in the longitude and latitude directions of all conflicting orders are used to form a two-dimensional offset point set. The average Euclidean distance and the maximum Euclidean distance between each point in the two-dimensional offset point set are calculated. The diagonal length of the normalized grid is determined based on the fact that the normalized grid has a unit side length in both the longitude and latitude directions. The quotient obtained by dividing the average Euclidean distance by the diagonal length of the normalized grid is used as the spatial dispersion index. When the spatial dispersion index is greater than the preset dispersion judgment threshold, the conflict location points are determined to be distributed in a dispersed manner within the grid, and a different spatial filling curve than the upper-level spatial filling curve type is selected as the secondary mapping curve type; when the spatial dispersion index is not greater than the dispersion judgment threshold, the points are determined to be distributed in a clustered manner, and the same spatial filling curve type as the upper-level spatial filling curve is maintained as the secondary mapping curve type. Based on the determined secondary mapping curve type and the minimum normalized distance between conflicting points, calculate the minimum secondary grid partitioning order that can distinguish each conflicting point, and generate a secondary space filling curve with the order and the type of the secondary mapping curve within the grid, and establish a secondary mapping table from secondary grid row and column index to secondary sorting code. The normalized offsets of longitude and latitude of each conflicting order are multiplied by the number of grid rows and columns corresponding to the minimum secondary grid subdivision order, and then rounded down to obtain the secondary row index and secondary column index. The secondary sorting code is generated by querying the secondary mapping table. The secondary sorting code is then used as a low-order segment and appended to the end of the original one-dimensional sorting code of the order to form an extended sorting code. If the extended sort codes of multiple conflicting orders are still equal, these orders are marked as a new set of conflicting orders and the two-dimensional offset point set calculation step is returned. At the same time, the dispersion judgment threshold is lowered according to the preset shrinkage ratio, and the distribution pattern judgment, secondary curve selection and code generation are iteratively executed until all extended sort codes are mutually distinct.
4. The delivery route scheduling optimization method based on spatial indexing according to claim 2, characterized in that, The step of determining the target curve order, which uses the span length corresponding to the reference mapping direction as a reference, to ensure that the number of single-sided grids of the space-filling curve is not less than the number of divisions of the space partitioning unit in the reference mapping direction, includes: Extract the spatial coverage description of all spatial partition units from the spatial index structure, project the spatial coverage of all spatial partition units onto the reference mapping direction to obtain multiple projection intervals along the reference mapping direction, merge and remove duplicates from the multiple projection intervals to obtain several non-overlapping continuous interval segments, count the number of the continuous interval segments and use the number as the number of divisions of the spatial partition unit on the reference mapping direction, and use the number of divisions as the initial number of grids in the reference mapping direction. From the preset candidate sequence of curve orders, select the order value that satisfies the first time that the number of single-sided grids exceeds the initial number of grids as the reference order, wherein the number of single-sided grids is determined by a positive integer power of 2; Obtain the effective span length of the delivery geospace in the non-reference mapping direction, calculate the grid side length of the single-sided grid corresponding to the reference order in the non-reference mapping direction, and if the grid side length exceeds the preset grid side length uniformity tolerance limit, then perform a successive incremental adjustment of the reference order until the difference in grid side length between the adjusted single-sided grid in the two directions falls back to the tolerance limit. The order that meets the uniformity requirement of grid side length after adjustment is determined as the target curve order of the space filling curve. The grid vertex coordinate matrix of the space filling curve in the delivery geographic space is generated with the target curve order. Each element of the grid vertex coordinate matrix stores the lower longitude, upper longitude, lower latitude, and upper latitude of the corresponding grid. The target curve order and the grid vertex coordinate matrix are passed to the one-dimensional sorting and encoding generation stage, so that the one-dimensional sorting and encoding generation stage determines the total encoding bit length based on the target curve order, and finds the grid where each feed point is located and extracts the row and column indices based on the grid vertex coordinate matrix.
5. The delivery route scheduling optimization method based on spatial indexing according to claim 1, characterized in that, The step of using rider load capacity as a constraint to extract several consecutively arranged orders along the order sequence to form candidate order combinations includes: Obtain the estimated food preparation time and delivery time constraint data for each order in the set of orders to be assigned, and label each order in the order sequence with time attributes to generate a labeled order sequence with time constraint tags; The spatial partition unit corresponding to the rider's starting spatial position is located. From the marked order sequence, the order sub-sequence intervals that are adjacent to or overlap with the spatial partition unit where the pickup location is located and the rider's starting spatial partition unit are selected. The starting search range of the interception operation is limited to the order sub-sequence intervals. Within the order subsequence interval, starting from the first order, subsequent consecutive orders are sequentially attempted to be assigned to the current candidate combined order group. For each order assigned, the inter-unit travel time information stored in the spatial index structure, the distribution of pick-up and delivery locations of the orders already assigned in the current group, and the estimated food preparation time data are immediately used to calculate the cumulative travel time and expected delivery time required to complete the pick-up and delivery of all orders in the current group. The expected delivery time is compared with the delivery time constraint data of each order. When the expected delivery time of any order exceeds its delivery time constraint data, the ordering attempt is stopped, and the set of orders corresponding to the previous state that satisfies all time constraints is output as a candidate order combination. Record the end position of the current candidate order combination in the order subsequence interval, slide the extracted start position to the next order after the end position, repeat the order inclusion and time constraint verification, and generate the next candidate order combination; When the starting position after sliding exceeds the end boundary of the order sub-sequence interval, the truncation operation is terminated, and all generated candidate order combinations are summarized to form a candidate order combination set.
6. The delivery route scheduling optimization method based on spatial indexing according to claim 5, characterized in that, For each order assigned, the system immediately uses the inter-unit travel time information stored in the spatial index structure, the distribution of pickup and delivery locations of orders already assigned within the current group, and the estimated food preparation time data to calculate the cumulative travel time and expected delivery time required to complete the pickup and delivery of all orders within the current group, including: Extract the temporary order set that has been assigned to the current group, map the pick-up location and delivery location of each order in the temporary order set to a one-dimensional reference code through the space filling curve, obtain the reference sorting value of each pick-up and delivery location, and generate the initial pick-up sequence according to the pick-up reference sorting value in ascending order. Starting from the first pickup location in the initial pickup sequence, the delivery location of the corresponding order is sequentially embedded into the access sequence according to the earliest insertable time after pickup is completed. During embedding, the reference sorting value of the delivery location is compared with the reference sorting value of the existing delivery location in the sequence to maintain the ascending order of the delivery reference sorting values. For each embedded access sequence, starting from the rider's current spatial location, the spatial partition unit transition relationship between adjacent access points in the sequence is sequentially input into the spatial index structure. The estimated travel time corresponding to each transition relationship is retrieved from the order index mapping record, and the waiting time for food preparation when accessing the food pickup location is added. The waiting time for food preparation is obtained by comparing the rider's expected arrival time at the food pickup location with the estimated food preparation time of the order corresponding to that food pickup location. When the expected arrival time is earlier than the estimated food preparation time, the waiting time is the difference between the estimated food preparation time and the expected arrival time; otherwise, the waiting time is zero. The estimated arrival time of each delivery location in the access sequence is recorded as the estimated delivery time of the order corresponding to that delivery location, and the time difference between the estimated arrival time of the first pick-up location and the estimated arrival time of the last delivery location in the access sequence is used as the cumulative travel time. The expected delivery time and cumulative travel time of all included orders are temporarily stored. When it is detected that the expected delivery time of any order exceeds its delivery time limit constraint data, the most recent embedding operation is undone and the access sequence is adjusted. The cumulative travel time and the expected delivery time of each order are recalculated in the adjusted access sequence.
7. The delivery route scheduling optimization method based on spatial indexing according to claim 5, characterized in that, The spatial partition unit corresponding to the rider's starting spatial location is used to filter out order sub-sequence intervals from the labeled order sequence where the spatial partition unit of the pickup location is adjacent to or overlaps with the rider's starting spatial partition unit. The starting search range of the truncation operation is limited to the order sub-sequence interval, including: The rider's starting spatial position coordinates are obtained, and the starting spatial position coordinates are mapped by the spatial filling curve to generate a one-dimensional starting position code corresponding to the starting spatial position coordinates. The spatial index structure is then queried to determine the spatial partition unit to which the one-dimensional starting position code belongs. In the spatial partition unit adjacency relationship description maintained by the spatial index structure, taking the home spatial partition unit as the center, the directly adjacent spatial partition units that share a boundary or share a vertex with the home spatial partition unit are obtained to form a primary adjacency partition set. The absolute value of the difference between the one-dimensional sorting code and the one-dimensional starting position code of the directly adjacent spatial partition unit does not exceed the preset adjacency span. For each directly adjacent spatial partition unit in the primary adjacent partition set, its corresponding secondary adjacent spatial partition unit is obtained again through the adjacency relationship description of the spatial partition unit. The obtained secondary adjacent spatial partition units are merged into the adjacency extension set, and the adjacency diffusion count is performed on the newly merged spatial partition units. When the adjacency diffusion count reaches the upper limit of the preset diffusion layer, the expansion stops. The home space partition unit, the primary adjacency partition set, and the adjacency extension set are merged, and duplicate space partition unit identifiers are removed to form a multi-level adjacency reachable partition set. The space partition units in the multi-level adjacency reachable partition set are spatially continuous with the home space partition unit. Traverse the labeled order sequence, extract the spatial partition unit identifier of the pick-up location of each order, mark the orders whose spatial partition unit identifier belongs to the multi-level adjacency reachable partition set as candidate starting orders, and record the sequence index number of the candidate starting orders in the labeled order sequence. The minimum sequence index number among all candidate starting order sequence index numbers is used as the lower bound of the interval, and the maximum sequence index number is used as the upper bound of the interval. A continuous subsequence from the lower bound to the upper bound of the interval is extracted from the marked order sequence as the order subsequence interval, thus completing the limitation of the starting search range for the extraction operation.
8. The delivery route scheduling optimization method based on spatial indexing according to claim 1, characterized in that, The step of accumulating the estimated passage cost of the traversed spatial partition units based on the access order of the pick-up and drop-off locations within the candidate bundle includes: Obtain the pickup and delivery location points bound to each order in the candidate order combination, generate an initial pickup and delivery access arrangement according to the order order of each order in the order sequence, and split the initial pickup and delivery access arrangement into a pickup sub-arrangement and a delivery sub-arrangement to ensure that the position of any order in the delivery sub-arrangement is no earlier than its position in the pickup sub-arrangement. The initial cycle path cost of the initial fetch and send access arrangement is calculated segment by segment using the spatial index structure, and the initial cycle path cost is set as the current optimal cost, while the initial fetch and send access arrangement is set as the current optimal access arrangement. The local exchange perturbation operation of the access point is performed on the food pick-up sub-arrangement and the food delivery sub-arrangement respectively. The exchange perturbation operation selects two adjacent access points and swaps their order to form a new access arrangement. The circumvention path cost of the new access arrangement is evaluated through the spatial index structure. If the cycle path cost of the new access permutation is less than the current optimal cost, then update the current optimal cost to the cycle path cost of the new access permutation, replace the current optimal access permutation with the new access permutation, and reset the record state of the perturbation operation. Repeat the access point local exchange perturbation operation until no more cost-reducing exchanges occur within a preset number of consecutive perturbation attempts. Then, determine the current optimal access arrangement as the optimized fetch and send access order. Based on the optimized retrieval and delivery access order, the estimated passage cost of the spatial partition unit through the spatial index structure is re-queried segment by segment, the cost is accumulated, and the accumulated result is used as the circumvention path cost of the candidate combination.
9. The delivery route scheduling optimization method based on spatial indexing according to claim 8, characterized in that, The step of calling the spatial index structure to calculate the initial cycle path cost of the initial fetch and send access arrangement segment by segment, setting the initial cycle path cost as the current optimal cost, and setting the initial fetch and send access arrangement as the current optimal access arrangement includes: According to the order of the access points in the initial pick-up and delivery access arrangement, the path segments from the rider's initial position to the first access point and between each adjacent access point are determined sequentially. For each path segment, query the first spatial partition unit where its starting spatial coordinates are located and the second spatial partition unit where its ending spatial coordinates are located. Extract the shortest travel time record from the first spatial partition unit to the second spatial partition unit from the order index mapping record. The shortest travel time record is a cross-regional travel cost record that is generated in advance through road network topology search and persisted. If the first spatial partition unit is the same as the second spatial partition unit, then the default value of the intra-unit travel time of the spatial partition unit is extracted from the order index mapping record as the travel cost of the path segment. The passage cost of all path segments is accumulated according to the access order, and the waiting time for the corresponding order is added when passing through the food pick-up access point to obtain the initial circulation path cost; The initial cycle path cost is stored in the current optimal cost storage area, and the complete sequential structure of the initial fetch and send access arrangement is stored in the current optimal access arrangement storage area, thus completing the initialization setting of the optimal state.
10. A computer system, characterized in that, include: Memory is used to store executable instructions or computer programs. A processor, when executing computer-executable instructions or computer programs stored in the memory, implements the spatial index-based delivery route scheduling optimization method according to any one of claims 1 to 9.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 9.