Calculation method and system for parallel duration of online car-hailing driver
Through the time accumulator and timing task mechanism, combined with the K-means algorithm, the timeliness and complexity problems in the calculation of the duration of the behavior of online car-hailing drivers is solved, and high-precision and real-time calculation results are achieved, satisfying the online car-hailing The platform's demand for timeliness.
Patent Information
- Application Number
- CN202411228280.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2024-11-15
AI Technical Summary
In the field of online ride-hailing, when the duration of online ride-hailing drivers is calculated in the field of online ride-hailing, there are problems such as pre-calculating and reporting of event time, resulting in system complexity and delay, or daily calculation based on reported data, resulting in insufficient timeliness.
Using time accumulator and timing task mechanism, the driver event data is parsed and updated in real time, and the event duration is accurately recorded by the start and end event processor, and unified processing is carried out within the specified time interval, combined with the K-means algorithm for event aggregation, and improved calculations Efficiency and accuracy.
It realizes high-precision and real-time calculation of the duration of driver behavior events, meets real-time requirements, reduces computing burden, and improves system response speed and resource utilization efficiency.
Smart Images

Figure CN118967085A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of online car-hailing, and specifically to parallel computing and processing technology for online car-hailing, and in particular to a method and system for calculating the parallel duration of online car-hailing drivers. Background Art
[0002] Parallel computing is a computing and processing mode that refers to the duration of computing and processing different events simultaneously within the same time period. Specifically in the field of online ride-hailing, computing the duration of various behavioral events of online ride-hailing drivers (such as dispatching, receiving, and providing services) mainly relies on relevant event data reported in real time by upstream business systems. In traditional technologies, there are two main strategies to achieve this goal:
[0003] (1) Pre-calculation and reporting of event duration: This strategy requires the upstream data reporting end to calculate the duration of each event before sending data. However, this approach places high demands on the upstream business system because it requires adding additional calculation logic to the business system, which may increase the complexity of the system and processing delays. For example, if an online car-hailing platform needs to track the driver's vehicle dispatch and service time in real time, the upstream system must calculate it immediately when each event occurs, which will interfere with the main business process and cause performance degradation.
[0004] (2) Daily calculation based on reported data: Another strategy is to calculate the duration once a day based on the reported raw event data. Although this method reduces the burden on upstream business systems, it has a significant data output delay problem. That is, the calculated duration information cannot reflect the driver's latest behavior status in real time, and thus cannot meet application scenarios with high timeliness requirements. For example, if an online ride-hailing platform needs to monitor the driver's service time in real time to ensure compliance, using a daily calculation method may lead to regulatory lags and failure to detect violations in a timely manner.
[0005] In summary, these two strategies each have their own technical defects in the field of online car-hailing. To this end, the present invention proposes a method and system for calculating the parallel continuation time for online car-hailing drivers. Summary of the invention
[0006] In view of this, the present invention hopes to provide a method and system for calculating the parallel continuation duration of online car-hailing drivers to solve or alleviate the technical problems existing in the prior art, namely, how to calculate the corresponding continuation duration in parallel with high precision based on different events, and at least provide a beneficial option for this; the technical solution of the present invention is implemented as follows:
[0007] First, the calculation method for the parallel continuation time of online car-hailing drivers:
[0008] 1. Overview:
[0009] The present invention aims to construct an efficient and accurate event duration calculation mechanism. First, the driver event data provided by the upstream business system is received and parsed to extract the key event identifier and time information. Then, the defined time accumulator is used to calculate and accumulate the durations of different types of events such as vehicle dispatching and service events. Through the start and end processors, the start and end time of each event can be updated and accurately recorded in real time, thereby ensuring the accuracy of the calculation of the duration. At the same time, a timed task execution mechanism is also included to ensure that all events are uniformly processed and ended within a specified time or fixed time interval, further ensuring the integrity of the data and the accuracy of the calculation.
[0010] (II) Technical solution:
[0011] When receiving the driver event data sent in real time by the upstream business system and performing data analysis, extracting the data consisting of the driver ID, event type (vehicle dispatch and / or service) and event time, and parsing it into driver event information d, in order to achieve the above technical goals, perform the following steps.
[0012] 2.1 Step S1, initialize the time accumulator:
[0013] The driver event information d is parsed to form a data set D, and the start signal of the manually specified time t1 or the fixed time interval t2 is obtained from the time accumulator aggregator or the corresponding time accumulator is created.
[0014] 2.1.1 Step S100, analyzing driver event information:
[0015] The received driver event information d is parsed into a dataset D, where each element is an object containing driver ID, event type, and event time information.
[0016] 2.1.2 Step S101, setting the time accumulator:
[0017] Set the start time of the time accumulator to the current event time or the manually specified start time, and initialize the end time and duration of the time accumulator to empty or 0. The method is as follows:
[0018] S1010, traverse the data set D: for each event e in the data set D, perform the following operations:
[0019] I. Extract the driver ID and event type in event e;
[0020] II. According to the driver ID and event type, obtain or create a new time accumulator object ta from the time accumulator collection;
[0021] III. If a manually specified start time t1 is provided, t1 is used as the start time of the time accumulator ta; otherwise, the time of event e is used as the start time;
[0022] IV. Initialize the end time of the time accumulator ta to None (or 0) and the duration to 0.
[0023] S1011, returns the time accumulator collection: contains all initialized time accumulator objects; this collection will track and calculate the duration of the event.
[0024] 2.2 Step S2, event processing:
[0025] For data set D, according to the event type, the event processor of the corresponding time accumulator is triggered;
[0026] The calculated duration s is then added to the duration field S of the time accumulator.
[0027] 2.2.1 Step S200, determine:
[0028] If it is the start event I1, the start time of the update time accumulator is the current event time;
[0029] If it is the end event I2, the end time of the time accumulator is updated to the current event time, and step S201 is activated.
[0030] 2.2.2 Step S201, processing end event I2:
[0031] Update the end time of the time accumulator ta to the time of event e; calculate the duration s, which is the difference between the end time and the start time:
[0032] s=e(t)-start time ;
[0033] Among them, e(t) is the end time of the time accumulator ta, start time is the start time of the time accumulator ta.
[0034] 2.3 Step S3, data output:
[0035] The duration field S is output to the upstream business system in real time to form an end signal se at a fixed time interval.
[0036] 2.3.1 Step S300, forming an end signal of a fixed time interval:
[0037] Check whether the current time has reached a fixed time interval t2 (this interval is preset). If the fixed time interval t2 is reached, an end signal se is generated and sent to the upstream business system or other related systems.
[0038] 2.3.1 Step S301, reset the time accumulator:
[0039] Set the start time of the time accumulator to start time Set to empty (or set to None, or reset to a specific starting value); set the end time e(t) of the time accumulator to empty (or set to None).
[0040] Reset the duration field S to 0 to prepare for the next calculation.
[0041] 2.4 Step S4, scheduled task execution:
[0042] Based on the end signal se of the manually specified time or fixed time interval, all time accumulators are traversed; the duration d(t) is accumulated to the duration field S of the corresponding time accumulator to update the state of the time accumulator aggregator after the scheduled task is executed.
[0043] Finally, clean up the time accumulator corresponding to the event that has ended and release resources.
[0044] 2.4.1 Step S400, perform accumulation:
[0045] Iterate over all time accumulators and perform the following operations on each time accumulator:
[0046] S4000, check whether the event has ended: for each time accumulator, check whether the corresponding event has ended. If the event has not ended (ie, the end time is None or greater than the current time), execute S4001.
[0047] S4001, set the end time and calculate the duration:
[0048] Set the end time e(t) of the time accumulator to the current time c(t); calculate the duration d(t), which is the difference between the end time e(t) and the start time s(t).
[0049] 2.4.2 Step S401, update the duration field:
[0050] The calculated duration d(t) is accumulated into the duration field S of the corresponding time accumulator using the time window analyzer. The execution process of the time window analyzer is as follows:
[0051] S4010, obtain the current time c(t). Then traverse all time accumulators, and for each time accumulator ta, update the duration field S of the time accumulator;
[0052] S4011, reset the time window list: after calculating the total duration of the time window of all time accumulators each time, reset the list w(d) for use in the next calculation.
[0053] (III) Mechanism for solving technical problems:
[0054] 4.1 Accurate timestamp recording and real-time update and accumulation:
[0055] When an end event (such as vehicle collection) is received, the end time of the corresponding time accumulator is updated immediately, and the duration (end time - start time) is calculated. Then, the calculated duration is added to the duration field of the time accumulator. This process is carried out in real time, ensuring the timeliness and accuracy of the data.
[0056] 4.2 Timing task mechanism:
[0057] Used to uniformly process and end all events within a specified time or fixed time interval. Helps ensure data integrity and calculation accuracy, especially when processing events that span time periods or run for a long time.
[0058] 4.3 K-means algorithm for event aggregation:
[0059] The K-means algorithm can automatically cluster a large number of events without manual grouping or calculation. In addition, the algorithm will automatically consider the similarity between events during the clustering process and group similar events together, thereby simplifying the calculation process of duration. This greatly improves the calculation efficiency because only the duration of each cluster needs to be calculated, rather than the duration of each individual event.
[0060] Second, a parallel duration calculation system for online car-hailing drivers:
[0061] The system includes a processor and a memory connected to the processor, wherein the memory stores program instructions, and when the program instructions are executed by the processor, the processor executes the calculation method as described above; wherein the processor is connected to:
[0062] (1) Data receiving and parsing module responsible for receiving driver event data sent by the upstream business system in real time:
[0063] Parse the received raw data and extract key information such as driver ID, event type (such as vehicle dispatch, vehicle collection, service, etc.) and event timestamp.
[0064] (2) Based on the parsed driver event information, a time accumulator management module is used to maintain a time accumulator for each driver ID and event type: manage the life cycle of the time accumulator, including initialization, status update, and destruction. Provide an event processor interface for processing start events and end events, and update the start time, end time, and duration of the time accumulator accordingly.
[0065] (3) Using multi-threaded processing technology, a parallel computing module is implemented to realize parallel processing of different events or different driver IDs:
[0066] The parsed event data is distributed to multiple parallel computing units for processing, and each unit is responsible for calculating the duration of a portion of the data. It supports task decomposition and load balancing to ensure efficient use of computing resources. It uses thread synchronization mechanism to ensure data consistency and correctness during parallel computing.
[0067] (4) A time calculation module for calculating the duration of an event: a timestamp is used to record the start and end time of an event, and the duration is calculated based on these two time points.
[0068] (5) A timed task and data output module for triggering specific operations at a specified time or fixed time interval: When a timed task is executed, all time accumulators are traversed, and the events that have not yet ended are terminated (such as taking the current time as the end time), and the final duration is calculated. The calculated duration is output to the upstream business system or other related systems in real time.
[0069] Compared with the prior art, the present invention has the following beneficial effects:
[0070] 1. High-precision calculation: The present invention records the start and end time of events through timestamps, and updates and accumulates the duration in real time, which can achieve high-precision calculations, thereby ensuring the accuracy and reliability of the data. By utilizing the multi-core processors or multi-threading technology of modern computers, parallel processing of different events or different driver IDs can be achieved, and high efficiency can be maintained when processing large amounts of data. The K-means algorithm used in the present invention can group events based on multiple dimensions (such as time, location, type, etc.), making the clustering results more accurate. Accurate clustering results are equivalent to the events in each cluster being more similar, so the calculated duration is also more accurate.
[0071] 2. Real-time performance: The present invention can receive, parse and process driver event data sent by the upstream business system in real time. At the same time, the present invention can also update the duration in real time and output the calculation results to the upstream business system or other related systems in real time to meet the real-time requirements; at the same time, the time window analyzer can focus more on the most recent important events by only paying attention to the events within the time window, while ignoring the earlier events that are no longer timely, which helps to better understand the current system status or business situation.
[0072] 3. Adaptability: As time goes by, the number of events may continue to increase. However, the present invention uses a time window analyzer to avoid traversing and calculating all historical events, thereby significantly reducing the computational burden and improving the response speed of the system.
[0073] Flexibility: In many practical applications, the pattern and frequency of events may change over time. The present invention uses a time window analyzer to better adapt to such dynamic changes because it only considers the most recent events without recalculating the entire historical data set.
[0074] 5. Resource optimization: The present invention can effectively manage computing resources through the scheduled task execution mechanism and data cleaning strategy, release occupied resources in time, and make room for new computing tasks, which helps to maintain the stability and efficiency of the system and reduce resource consumption costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0076] Figure 1 It is a schematic diagram of the method flow of the present invention;
[0077] Figure 2 This is a schematic diagram of the implementation logic of the first embodiment of the present invention;
[0078] Figure 3 Executing a logic diagram for the time window analyzer of the present invention;
[0079] Figure 4 A logic diagram for executing the K-means algorithm of the present invention;
[0080] Figure 5 It is a schematic diagram of the system composition of the present invention. DETAILED DESCRIPTION
[0081] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below;
[0082] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0083] Embodiment 1: In the online car-hailing platform, it is necessary to track and analyze the online time of drivers to optimize driver scheduling and management. The online status of drivers can be identified by their operations of logging in and out of the online car-hailing platform. To this end, this embodiment will provide a method for calculating the parallel continuation time of online car-hailing drivers, and perform related business processing based on the calculation results, which includes the following execution steps.
[0084] In this embodiment, regarding step S1, the time accumulator is initialized: the received driver event information d includes: driver ID, event type (login, logout) and event time. Then these data are parsed to form a data set D.
[0085] And determine the start signal of the manually specified time t1 or the fixed time interval t2 to obtain or create the corresponding time accumulator from the time accumulator aggregator.
[0086] Specifically, step S100 parses driver event information: each element in the parsed data set D is an object containing driver ID, event type and event time information.
[0087] Specifically, in step S101, a time accumulator is set, and the data set D is traversed. For each event e:
[0088] 1) Extract the driver ID and event type.
[0089] 2) According to the driver ID and event type, obtain or create a new time accumulator object ta from the time accumulator collection.
[0090] 3) If a manually specified start time t1 is provided, use t1 as the start time of the time accumulator ta; otherwise, use the time of event e as the start time.
[0091] 4) Initialize the end time of the time accumulator ta to None and the duration to 0.
[0092] In this embodiment, regarding step S2, event processing: for data set D, according to the event type, trigger the event processor of the corresponding time accumulator; then add the calculated duration s to the duration field S of the time accumulator.
[0093] Specifically, step S200 determines: if the event is login (start event I1), the start time of the time accumulator is updated to the current event time. If the event is logout (end event I2), the end time of the time accumulator is updated to the current event time, and step S201 is activated.
[0094] Specifically, step S201, processing end event I2: updating the end time of time accumulator ta to the time of event e.
[0095] Calculate the duration s, which is the difference between the end time and the start time:
[0096] s=e(t)-start time ;
[0097] Among them, e(t) is the end time of the time accumulator ta, start time is the start time of the time accumulator ta. The calculated duration s is a non-negative real number, indicating the duration of the event. Finally, the calculated duration s is added to the duration field S of the time accumulator ta.
[0098] The calculated duration s is accumulated into the duration field S of the time accumulator ta.
[0099] Furthermore, the following K-means event aggregation algorithm may be used to identify the duration of an event.
[0100] In the clustering process, it is necessary to consider the time attribute of the event and calculate the duration accordingly:
[0101] S2010, Initialization:
[0102] (Randomly) select K events as the initial cluster centers. Then initialize a time accumulator ta with a start time start time Set to the earliest event time in the dataset.
[0103] S2011, assigning events to clusters:
[0104] For each event e, calculate its distance d(x,y) to each cluster center:
[0105]
[0106] Where x and y are any two different events, x i and i are their values in the i-th dimension, and n is the number of dimensions of the event.
[0107] Event e is then assigned to the cluster represented by the cluster center closest to it.
[0108] S2012, update cluster centers and time accumulators:
[0109] For each cluster, calculate the average position (or center) of all events in the cluster and update the cluster center c k :
[0110]
[0111] Among them, |C k ∣ is the cluster C k The number of events in cluster C. k events in .
[0112] At the same time, the end time of the time accumulator ta of the cluster is updated to be the time of the latest event in the cluster.
[0113] S2013, calculate the duration s of the cluster, that is, s = e(t)-start time ; where e(t) is the end time of the time accumulator ta, start time is the start time of the time accumulator ta.
[0114] S2014, Iteration:
[0115] S2011 to S2013 are continuously repeated until the cluster center no longer changes significantly or a predetermined number of iterations is reached.
[0116] S2015, output clustering results and duration:
[0117] Output the final K clusters, as well as the events in each cluster and the corresponding duration s.
[0118] Finally, the calculated duration s is accumulated into the duration field S of the time accumulator ta.
[0119] In this embodiment, regarding step S3, data output: the duration field S is output in real time to the upstream business system to form an end signal se with a fixed time interval.
[0120] Specifically, step S300, generating an end signal of a fixed time interval: checking whether the current time has reached a fixed time interval t2. If so, generating an end signal se and sending it to the upstream business system.
[0121] Specifically, step S301, reset the time accumulator: set the start time of the time accumulator to start time Set to empty (or set to None, or reset to a specific starting value); set the end time e(t) of the time accumulator to empty (or set to None).
[0122] Furthermore, the duration field S is reset to 0 to prepare for the next calculation.
[0123] In this embodiment, regarding step S4, the scheduled task is executed: based on the end signal se of the manually specified time or fixed time interval, all time accumulators are traversed; the duration d(t) is accumulated to the duration field S of the corresponding time accumulator to update the state of the time accumulator aggregator after the scheduled task is executed.
[0124] Iterate over all time accumulators and perform the following operations on each time accumulator:
[0125] S4000, check whether the event has ended: for each time accumulator, check whether the corresponding event has ended. If the event has not ended (ie, the end time is None or greater than the current time), execute S4001.
[0126] S4001, set the end time and calculate the duration: set the end time e(t) of the time accumulator to the current time c(t); calculate the duration d(t), which is the difference between the end time e(t) and the start time s(t).
[0127] Specifically, step S401, updating the duration field: using the time window analyzer, the calculated duration d(t) is accumulated into the duration field S of the corresponding time accumulator; the execution process of the time window analyzer is as follows:
[0128] S4010, obtain the current time c(t). Then traverse all time accumulators, and for each time accumulator ta, perform the following operations:
[0129] I. Calculate the start time W(t) of the time window:
[0130] W(t) = c(t) - W;
[0131] Where W is the window size.
[0132] II. Traverse all events of the time accumulator: For each event, determine whether its end time is within the time window:
[0133]
[0134] If the above conditions are met at the same time, its duration d(t) is added to the list w(d).
[0135] III. Calculate the total duration WT(d) within the time window:
[0136] WT(d)=∑w(d);
[0137] IV. Then update the duration field S of the time accumulator;
[0138] S4011, reset the time window list: after calculating the total duration of the time window of all time accumulators each time, reset the list w(d) for use in the next calculation.
[0139] It is understandable that through the above steps, the online ride-hailing platform can track and analyze the online time of drivers in real time. This information can be used to optimize driver scheduling, improve platform operation efficiency, and provide better management and support services for drivers.
[0140] For example, the platform can adjust the drivers' shift plans based on their online time, or provide rewards and incentives to drivers with longer online time.
[0141] In this embodiment, the Python execution program framework for the above solution is as follows:
[0142]
[0143]
[0144]
[0145] In the above program, a nested dictionary is created using defaultdict
[0146] time_accumulators, used to store the time accumulators for each driver and each event type. Iterate through the event list, initialize a time accumulator for each driver and event type, and set the start time.
[0147] The logic of event processing is to traverse the event list and update the start time or end time of the time accumulator according to the event type. If the event is a logout, the duration is calculated and added to the duration field of the time accumulator.
[0148] The data output is obtained by traversing the time accumulator dictionary and outputting the duration of each driver and event type.
[0149] At the same time, the program uses the threading module to create a separate thread to simulate a scheduled task. The scheduled task is executed every 60 seconds and outputs the online time of all current drivers.
[0150] Embodiment 2: Figure 5 As shown, based on the first embodiment, this embodiment further provides a parallel continuation time calculation system for online car-hailing drivers:
[0151] The system includes a processor and a memory connected to the processor, wherein the memory stores program instructions, and when the program instructions are executed by the processor, the processor executes the calculation method as described above; wherein the processor is connected to:
[0152] (1) Data receiving and parsing module responsible for receiving driver event data sent by the upstream business system in real time:
[0153] Parse the received raw data and extract key information such as driver ID, event type (such as vehicle dispatch, vehicle collection, service, etc.) and event timestamp.
[0154] (2) Based on the parsed driver event information, a time accumulator management module is used to maintain a time accumulator for each driver ID and event type: manage the life cycle of the time accumulator, including initialization, status update, and destruction. Provide an event processor interface for processing start events and end events, and update the start time, end time, and duration of the time accumulator accordingly.
[0155] (3) Using multi-threaded processing technology, a parallel computing module is implemented to realize parallel processing of different events or different driver IDs:
[0156] The parsed event data is distributed to multiple parallel computing units for processing, and each unit is responsible for calculating the duration of a portion of the data. It supports task decomposition and load balancing to ensure efficient use of computing resources. It uses thread synchronization mechanism to ensure data consistency and correctness during parallel computing.
[0157] (4) A time calculation module for calculating the duration of an event: a timestamp is used to record the start and end time of an event, and the duration is calculated based on these two time points.
[0158] (5) A timed task and data output module for triggering specific operations at a specified time or fixed time interval: When a timed task is executed, all time accumulators are traversed, and the events that have not yet ended are terminated (such as taking the current time as the end time), and the final duration is calculated. The calculated duration is output to the upstream business system or other related systems in real time.
[0159] All the above embodiments only express the implementation methods of the relevant practical applications of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be based on the attached claims.
[0160] For those skilled in the art, it can be further appreciated that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0161] At the same time, those skilled in the art can understand that all or part of the processes in all the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
Claims
1. A method for calculating the parallel duration of online car-hailing drivers, including receiving driver event data sent in real time by an upstream business system and parsing the data, extracting the driver ID, event type and event time, and parsing them into driver event information d. Features: The following operation steps are performed on the driver event information d: S1, parse the driver event information d and form a data set D, and obtain or create a corresponding time accumulator from the time accumulator aggregator for the start signal of the manually specified time t1 or the fixed time interval t2; S2, for data set D, trigger the event processor of the corresponding time accumulator according to the event type; then add the calculated duration s to the duration field S of the time accumulator; S3, output the duration field S to the upstream business system in real time to form an end signal se of a fixed time interval; S4, based on the end signal se of the manually specified time or fixed time interval, traverse all time accumulators; add the duration d(t) to the duration field S of the corresponding time accumulator to update the state of the time accumulator aggregator after the scheduled task is executed.
2. The calculation method according to claim 1, Features: The implementation method of S1 includes: S100, parsing the received driver event information d into a data set D, where each element is an object containing driver ID, event type and event time information; S101, setting the start time of the time accumulator to the current event time or the manually specified start time, and initializing the end time and duration of the time accumulator to empty or 0.
3. The calculation method according to claim 1, Features: The implementation method of S2 includes: S200, if it is a start event I1, update the start time of the time accumulator to the current event time; if it is an end event I2, update the end time of the time accumulator to the current event time, and activate step S201; S201, update the end time of the time accumulator ta to the time of event e; calculate the duration s, that is, the difference between the end time and the start time: s=e(t)-start time ; Among them, e(t) is the end time of the time accumulator ta, start time is the start time of the time accumulator ta.
4. The calculation method according to claim 3, Features: In S201, the following K-means event aggregation algorithm is used to identify the duration of the event: S2010, select K events as the initial cluster centers and initialize a time accumulator ta, whose start time is start time Set to the earliest event time in the dataset; S2011, for each event e, calculate its distance d(x,y) to each cluster center: Where x and y are any two different events, x i and i are their values in the i-th dimension, and n is the number of dimensions of the event; S2012, for each cluster, calculate the average position of all events in the cluster and update the cluster center c k : Among them, |C k ∣ is the cluster C k The number of events in cluster C. k events in S2013, calculating the duration s of the cluster.
5. The calculation method according to claim 4, Features: Also includes: S2014, continuously repeating S2011 to S2013 until a predetermined number of iterations is reached; S2015, output the final K clusters, as well as the events in each cluster and the corresponding duration s.
6. The calculation method according to claim 1 or 4, Features: The implementation method of S3 includes: S300, checking whether the current time has reached a fixed time interval t2, if so, generating an end signal se and sending it to the upstream business system; S301, set the start time of the time accumulator to start time Set to empty; set the end time e(t) of the time accumulator to empty, and reset the duration field S to 0 to prepare for the next calculation.
7. The calculation method according to claim 1 or 4, Features: The implementation method of S4 includes: S400, traverse all time accumulators, and perform the following operations on each time accumulator: S4000, check whether the event has ended: for each time accumulator, check whether the corresponding event has ended; if the event has not ended, execute S4001; S4001, set the end time e(t) of the time accumulator to the current time c(t); calculate the duration d(t), that is, the difference between the end time e(t) and the start time s(t).
8. The calculation method according to claim 7, Features: In S4, the calculated duration d(t) is accumulated into the duration field S of the corresponding time accumulator using a time window analyzer; the execution process of the time window analyzer is as follows: S4010, obtaining the current time c(t); then traversing all time accumulators, and for each time accumulator ta, performing the following operations: I. Calculate the start time W(t) of the time window: W(t) = c(t) - W; Where W is the window size; II. Traverse all events of the time accumulator: For each event, determine whether its end time is within the time window: If the above conditions are met at the same time, its duration d(t) is added to the list w(d); III. Calculate the total duration WT(d) within the time window: WT(d)=∑w(d); IV. Then update the duration field S of the time accumulator; S4011, reset the time window list.
9. A parallel duration calculation system for online car-hailing drivers. Features: The system includes a processor and a memory connected to the processor, wherein program instructions are stored in the memory, and when the program instructions are executed by the processor, the processor executes the calculation method according to any one of claims 1 to 8.
10. The computing system according to claim 9, Features: The processor is connected with, The data receiving and parsing module is responsible for receiving driver event data sent by the upstream business system in real time; A time accumulator management module that maintains a time accumulator for each driver ID and event type based on the parsed driver event information; Using multi-threaded processing technology, a parallel computing module is used to realize parallel processing of different events or different driver IDs; A time calculation module for calculating the duration of an event; A timed task and data output module used to trigger specific operations at a specified time or within a fixed time interval.
