Intelligent scheduling method, device and electronic equipment
By constructing a candidate pool of shift templates associated with job positions, and selecting the optimal shift template round by round based on the original requirements, combined with custom shifts to generate a scheduling plan, the problem of coverage overflow caused by the greedy matching algorithm is solved, and the accuracy and practicality of the scheduling results are achieved.
Patent Information
- Application Number
- CN202611590176.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-14
- Publication Date
- 2026-11-27
AI Technical Summary
In existing scheduling methods, the greedy matching algorithm is prone to coverage overflow problems when iteratively deducting demand for scheduling. It cannot accurately assess the coverage rate of the shift template to the original demand, resulting in inaccurate scheduling results.
By constructing a candidate pool of shift templates associated with job positions, the optimal shift template is selected round by round based on the original requirements as the scoring criterion. Combined with custom shifts, a scheduling plan is generated to ensure that the difference between the shift template and the requirements is minimized, and a compliant and implementable scheduling plan is generated.
It improves the accuracy and completeness of the scheduling plan, ensures full coverage of job requirements, takes into account relevant employee constraints, and enhances the practicality and compliance of the scheduling scheme.
Smart Images

Figure CN123180653A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer technology, and in particular relates to intelligent scheduling methods, devices, electronic devices, computer-readable storage media, and computer program products. Background Technology
[0002] Employee scheduling in the store service industry is a core pain point in human resources for the retail chain industry. During the scheduling process, stores need to allocate employees according to their positions (such as cashiers, stock clerks, security guards, etc.) and time periods (such as morning shift, afternoon shift, evening shift, night shift) within the scheduling cycle (such as 7 to 14 days).
[0003] During the scheduling process, if the store manager or other staff manually schedule shifts based on experience, it is easy to overlook hard constraints, especially when there are many business rules and / or a large number of people, making it difficult to satisfy multiple complex business rules simultaneously. If a general constraint solver such as Timefold Solver is used for automatic scheduling, its accompanying greedy matching algorithm will use the remaining demand after deducting demand as the scoring benchmark during the iterative deduction of demand for scheduling, which will lead to the problem of overload—for example, in a shift that should have 2 people scheduled, only 1 person is actually scheduled, resulting in a vacancy in the schedule.
[0004] Therefore, a new method is needed to solve the above-mentioned technical problems. Summary of the Invention
[0005] This application provides intelligent scheduling methods, devices, and electronic devices that can solve the problem of overlay in existing scheduling systems.
[0006] In a first aspect, embodiments of this application provide an intelligent scheduling method, including: Obtain a scheduling request, which includes a set of job positions, a set of employee information, and a set of requirements. The set of job positions includes shift templates associated with each job position. The set of employee information includes the primary job position associated with each employee. The set of requirements includes the job position, date, and time period associated with each requirement. Based on the shift templates associated with each job in the job set and the job associated with each demand in the demand set, all shift templates corresponding to each demand are added to the candidate pool of the corresponding demand. For each demand, the following matching loop steps are executed iteratively until the iteration stopping condition is met: Initialize temporary remaining demand, the initial time period of the temporary remaining demand is the same as the original demand time period of the demand; Based on the original demand time period of the demand, calculate the difference between the shift template in the candidate pool corresponding to the demand and the demand; Select the shift template with the smallest difference from the demand as the current optimal shift template, and deduct the time period corresponding to the current optimal shift template from the current temporary remaining demand to obtain a new temporary remaining demand; A schedule allocation list is constructed based on the optimal schedule templates obtained through iteration and the corresponding required dates, and custom schedules are determined based on the temporary remaining requirements for each requirement. Based on the obtained scheduling constraint information, the schedule allocation list and the custom schedule are constrained to obtain the scheduling plan.
[0007] The beneficial effects of the embodiments in this application compared with the prior art are: In this embodiment, by obtaining scheduling requests containing job positions, employees, and demand information, a candidate pool of shift templates corresponding to each job position is constructed for each demand. During the iterative matching loop, the difference between the shift template and the demand is always calculated based on the original demand time period. The optimal shift template is selected, and time periods are deducted for any temporary remaining demand. After iteration, a shift allocation list is constructed based on the selected optimal shift template, and custom shifts are generated based on the temporary remaining demand after iteration. Finally, both types of shifts are uniformly incorporated into the constraint solution to obtain the scheduling plan. This scheme combines standard shift template matching with the generation of custom shifts for remaining gaps. Simultaneously, when evaluating template differences, it anchors the comparison to the original demand time period, avoiding the coverage overflow defect caused by the traditional greedy scheduling algorithm using the deducted remaining demand as the scoring benchmark. It can accurately evaluate the actual coverage capability of the shift template for the original business demand, ensuring the objectivity of job demand evaluation and improving the accuracy of the subsequent scheduling plan.
[0008] Meanwhile, since this application embodiment relies on shift templates associated with job positions to construct a dedicated candidate pool for demand, and only shift templates suitable for the job positions are used for matching, the scope of matching calculation can be narrowed, improving the efficiency of shift template screening. In addition, by iteratively selecting and deducting to gradually cover the job time slot requirements, custom shifts are generated to supplement the remaining demand gaps that the standard shift template cannot cover. This takes into account both the business applicability of the preset standard shifts and the ability to fill the gaps in scattered time slots, so that the final set of shifts used for constraint solving can fully cover the time slot requirements of store operations. On this basis, the shift allocation list and custom shifts are used together to participate in the scheduling constraint solving. Employees are uniformly allocated by comprehensively considering employee and job-related constraints, resulting in a compliant and implementable scheduling plan. This ensures that the scheduling results are in line with the store's job operation needs, while also taking into account employee-related scheduling constraints, improving the completeness and practicality of the scheduling plan.
[0009] Secondly, embodiments of this application provide an intelligent scheduling device, comprising: The scheduling request acquisition module is used to acquire scheduling requests, which include a set of job positions, a set of employee information, and a set of requirements. The set of job positions includes: shift templates associated with each job position; the set of employee information includes the main job position associated with each employee; and the set of requirements includes: the job position, date, and time period associated with each requirement. The candidate pool determination module is used to add all shift templates corresponding to each demand to the candidate pool of the corresponding demand based on the shift templates associated with each job in the job set and the job associated with each demand included in the demand set. The optimal shift template determination module is used to iteratively execute the following matching loop steps for each demand until the iteration stopping condition is met: initialize temporary remaining demand, the initial time period of the temporary remaining demand is the same as the original demand time period of the demand; based on the original demand time period of the demand, calculate the difference between the shift template in the candidate pool corresponding to the demand and the demand; select the shift template with the smallest difference from the demand as the current optimal shift template, and deduct the time period corresponding to the current optimal shift template from the current temporary remaining demand to obtain a new temporary remaining demand; The shift allocation set determination module is used to construct a shift allocation list based on the optimal shift templates obtained through iteration and the corresponding required dates, and to determine custom shifts based on the temporary remaining requirements of each requirement. The scheduling plan generation module is used to constrain the shift allocation list and the custom shifts based on the obtained scheduling constraint information to obtain the scheduling plan.
[0010] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in the first aspect.
[0011] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect.
[0012] Fifthly, embodiments of this application provide a computer program product that, when run on an electronic device, causes the electronic device to perform the method described in the first aspect.
[0013] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description
[0014] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.
[0015] Figure 1 This is a flowchart illustrating an intelligent scheduling method provided in an embodiment of this application; Figure 2 This is a schematic diagram of the structure of an intelligent scheduling device provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0016] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0017] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0018] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0019] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized.
[0020] In the retail chain industry, it is typically necessary to allocate employees by position and time slot within a scheduling cycle. During the scheduling process (i.e., generating scheduling plans), if a general constraint solver like Timefold Solver is used for automatic scheduling, the accompanying greedy matching algorithm, in the iterative deduction of demand during scheduling, uses the remaining demand after deduction as the scoring benchmark in the Nth round (N≥2). This leads to subsequent shift templates underestimating the true coverage of the original demand, resulting in coverage overflow. To more clearly illustrate the coverage overflow problem, an example is provided below.
[0021] Assuming the original requirement is: a certain position requires 2 people per day for 3 consecutive days; then the total original requirement is: D_origin = [2, 2, 2].
[0022] Greedy algorithm logic: Matching round by round. After each round of matching is completed, the current matching quantity is directly deducted, and the remaining demand after deduction is used as the scoring benchmark for the next round.
[0023] Assume the available shift templates are: Template A (covering days 1 and 2, providing 2 people); Template B (covering days 2 and 3, providing 2 people).
[0024] A greedy algorithm is used to select the template with the highest score in the first and second rounds respectively; the score is based on remaining, not the original requirement.
[0025] Round 1: The initial remaining demand is [2, 2, 2]. Template A covers days 1 and 2, and scores very high when calculated based on remaining time. Select Template A and assign it to 2 people.
[0026] Subtracting remaining demand: remaining = [2-2, 2-2, 2] = [0, 0, 2].
[0027] Round 2: This round of scoring only considers remaining=[0,0,2].
[0028] Template B covers days 2 and 3. From the perspective of remaining requirements, day 2 remaining=0 and day 3 remaining=2.
[0029] When calculating the score, the greedy algorithm assumes that template B only needs to meet the 2-person gap on day 3, but underestimates the contribution of template B to the coverage of the original demand on day 2.
[0030] The greedy algorithm selects template B and assigns it to 2 people.
[0031] Subtracting remaining demand: remaining = [0,0,2-2]=[0,0,0].
[0032] The final matching result is: Template A: 2 people on Day 1, 2 people on Day 2; Template B: 2 people on day 2 and 2 people on day 3.
[0033] Since the original demand was 2 people on day 1, 2 people on day 2, and 2 people on day 3, while the actual schedule was 2 people on day 1, 4 people on day 2, and 2 people on day 3, there was a supply overflow on day 2 (2 people overflow). That is, in order to fill the remaining gap, the greedy algorithm added the personnel from template B to the already filled day 2, thus causing an overflow.
[0034] To address the coverage overflow issue that arises during the scheduling process, this application provides an intelligent scheduling method. This intelligent scheduling method, regardless of the iteration stage, always uses the original requirements as the scoring benchmark to determine the difference between the shift template and the original requirements, thereby improving the coverage of the generated scheduling plan with the original requirements.
[0035] The intelligent scheduling method provided in the embodiments of this application is described below with reference to the accompanying drawings.
[0036] Figure 1 This illustration shows a flowchart of an intelligent scheduling method provided in an embodiment of this application. This intelligent scheduling method can be applied to electronic devices, including mobile devices, workstations, computers, servers, etc. The intelligent scheduling method provided in this embodiment is described in detail below: S11, Obtain the scheduling request. The scheduling request includes a set of job positions, a set of employee information, and a set of requirements. The set of job positions includes the shift templates associated with each job position. The set of employee information includes the primary job position associated with each employee. The set of requirements includes the job position, date, and time period associated with each requirement.
[0037] The aforementioned scheduling requests can be issued through user terminals or business systems, and include datasets such as job sets, employee information sets, and demand sets.
[0038] The aforementioned job set includes all job information related to this scheduling process, such as a dedicated shift template associated with each job. Different jobs correspond to independent shift template systems to accommodate the differentiated scheduling needs of different jobs. This shift template is standardized shift data pre-configured based on job business attributes, labor standards, and operational requirements, defining basic rules such as the regularly arrangable working hours, standard shift length, and suitable work scenarios for the corresponding job. Optionally, the aforementioned job set may also include one or more of the following: gender requirements, allowed job sets for cross-job assignments, single shift length range (the length range between the maximum and minimum shift length for a job), and a personnel type whitelist. A personnel type whitelist for a job refers to the set of legal personnel types allowed to be assigned to that job.
[0039] The aforementioned employee information set includes basic information and primary job descriptions for all employees awaiting scheduling within the current scheduling scope. Each employee's primary job description is a fixed, core job position that they are best suited for. This primary job description can be used for initial matching of job scheduling needs and filtering of suitable employees, serving as a fundamental identifier for achieving precise person-job matching. Optionally, the aforementioned employee information set can also be expanded to include one or more information such as gender, skill set, employee type, monthly working hours limit, consecutive working days limit, consecutive night shift days limit, and preferred shift templates, providing data support for subsequent scheduling optimization.
[0040] The aforementioned demand set contains all store operation position demand data within this scheduling cycle. Each demand is the smallest unit of scheduling demand, and each demand is bound to corresponding core dimension attributes, specifically including the job position associated with the demand, the corresponding scheduling date, and the corresponding working time period. Among them, the job position is used to define the job position to which the demand belongs, and the date and time period are used to precisely limit the working period of the job where there is a shortage of staff.
[0041] In addition to the aforementioned set of job positions, employee information, and demand, the scheduling request in this embodiment may also include a scheduling period, which includes a start date and an end date. This scheduling period can be used to solve subsequent scheduling plans to obtain a scheduling plan that better meets actual requirements.
[0042] S12, based on the shift templates associated with each job in the above job set and the job associated with each requirement in the above requirement set, add all shift templates corresponding to each requirement to the candidate pool of the corresponding requirement.
[0043] In this embodiment, a corresponding shift template can be matched for each requirement and a dedicated candidate pool can be built based on the shift templates associated with each position in the job set and the job positions associated with each requirement in the aforementioned requirement set. During the construction process, the candidate pool for the requirement can be built based on each shift template corresponding to the requirement, or the shift templates can be filtered first, and then the candidate pool for the requirement can be built based on the filtered shift templates.
[0044] When building candidate pools for each requirement based on the filtered shift templates, the following two-level hierarchical construction logic can be used: The first level involves the aggregation of all job shift templates, generating a global full template set. Specifically, based on the pre-configured shift definitions for each job in the job set, standard shift templates for the corresponding jobs are generated in batches. Each shift template is bound to a unique job identifier, establishing an association between the shift template and the job. Simultaneously, it also supports configuring employee-specific preferred shift templates: preferred shifts submitted by employees only become effective if they belong to the valid shift set for their assigned job. Once effective, preferred shifts are aggregated into the global full template set based on their job affiliation. Through this process, a unified aggregation of compliant shift templates for all jobs is completed, forming a global full template set covering all jobs and all compliant shifts.
[0045] The second level involves filtering shift templates based on the global full template set to construct a candidate pool for each requirement. In this embodiment, the requirement and shift template are uniquely linked by the job identifier. All shift templates corresponding to each job uniformly serve all scheduling requirements under that job. A single requirement does not add new or exclusively occupy any shift template; it is only used to filter the range of suitable shift templates from the global full template set. The specific filtering process is as follows: for each requirement record in the requirement set, the job identifier bound to the requirement is extracted. Using the job identifier as the matching keyword, all shift templates that completely match the current requirement job are initially filtered from the global full template set. In addition, the shift templates obtained from the initial screening can be further filtered for compliance, such as removing unqualified shift templates whose single effective working hours exceed the minimum daily working hours limit for all employees in the store. Finally, based on the remaining compliant shift templates after filtering, a candidate pool dedicated to the current requirement record is constructed.
[0046] By constructing the above two-level hierarchical logic, the global collection of compliant shift templates for all positions is completed first. Then, the effective templates are accurately screened by combining the job attributes and working hour constraints of individual requirements. This ensures the integrity of shift template resources and eliminates invalid shift templates that do not comply with employee working hour regulations. As a result, the calculation scope of subsequent shift optimization is greatly reduced, and shift matching efficiency and shift compliance are improved.
[0047] S13, for each demand, iteratively execute the following matching loop steps until the iteration stopping condition is met: initialize the temporary remaining demand, the initial time period of the temporary remaining demand is the same as the original demand time period of the demand; based on the original demand time period of the demand, calculate the difference between the shift template in the candidate pool corresponding to the demand and the demand; select the shift template with the smallest difference from the demand as the current optimal shift template, and deduct the time period corresponding to the current optimal shift template from the current temporary remaining demand to obtain the new temporary remaining demand.
[0048] The aforementioned differences include one or more of the following: the intersection of the work segments of the shift template and the original demand period, the difference of the non-work segments, and the start time difference.
[0049] The aforementioned work segment intersection refers to the duration of overlap between the work periods of the shift template and the original demand periods, representing the effective coverage that the shift template can provide for the original demand. A larger work segment intersection indicates that the shift template can meet more job requirements. This work segment intersection can also be called effective coverage, and can be obtained by weighting it using "number of people required × minutes".
[0050] The aforementioned non-working segment difference refers to the total effective working hours of the shift template minus the intersection of working segments. It represents the redundant scheduling time of the shift template exceeding the original demand period, i.e., the net wasted time. The smaller the non-working segment difference, the less invalid scheduling is generated by the shift template.
[0051] The aforementioned start time difference refers to the time difference between the start time of the shift template and the start time of the original demand period, representing the degree of deviation of the shift template from the demand start point; the smaller the start time difference, the closer the start time of the shift is to the demand start time, and the more in line with manual scheduling habits.
[0052] In this embodiment, the shift template with the smallest difference is selected as the current optimal shift template. After selecting the current optimal shift template, the working time period corresponding to the optimal shift template is deducted from the current temporary remaining demand, and a new temporary remaining demand is obtained, entering the next round of matching loop. It should be noted that the above difference calculation is always based on the original demand time period, not the temporary remaining demand obtained after deduction. The deduction operation only applies to the temporary remaining demand and is used to record the demand gap that has not yet been covered by the shift template. This method can avoid the coverage overflow defect caused by the traditional greedy matching algorithm using the remaining demand as the scoring benchmark during the iteration process, and ensure the accurate evaluation of the actual demand coverage. When the iteration stopping condition is met (such as all temporary remaining demand is covered, or there is no shift template in the candidate template pool that meets the constraint conditions), the matching loop corresponding to the current demand is terminated.
[0053] In some embodiments, when the differences include the intersection of work segments, the difference between non-work segments, and the start time difference, the above-mentioned selection of the shift template with the smallest difference from the above-mentioned requirements as the current optimal shift template includes: Based on the step-by-step comparison method of the above-mentioned work segments having the most intersection, the above-mentioned non-work segments having the smallest difference, and the above-mentioned start time difference having the smallest difference, the shift template with the smallest difference from the above-mentioned requirements is selected as the current optimal shift template.
[0054] In this embodiment, a lexicographical ordering rule of step-by-step comparison is adopted instead of calculating a comprehensive score by weighted summation of three indicators. During comparison, the intersection of work segments is compared first, and the shift template with the largest intersection is selected. If multiple shift templates have equal intersections of work segments, the difference between non-work segments is further compared, and the shift template with the smallest difference between non-work segments is selected from the shift templates with the same intersection of work segments. If both the intersection of work segments and the difference between non-work segments are the same, the start time difference is compared, and the shift template with the smallest start time difference is selected. Through this step-by-step comparison method, the current optimal shift template is determined. This step-by-step comparison method solidifies business objectives with fixed priorities: prioritizing demand coverage, reducing ineffective scheduling waste, and finally optimizing shift start times. Since no manual setting of indicator weights is required, the result deviation and coupling distortion problems caused by weighted summation schemes due to weight settings can be avoided, thus ensuring stable and reproducible scheduling results.
[0055] In some embodiments, considering that if all shift templates in the candidate pool are directly compared and selected step by step, some shift templates with excessively large non-working segment differences will enter the candidate comparison process, which not only increases computational overhead but also easily leads to shift redundancy and fragmented scheduling, before selecting the shift template with the smallest difference from the above requirements as the current optimal shift template according to the step-by-step comparison method of having the most working segment intersection, the smallest non-working segment difference, and the smallest start time difference, each shift template can be filtered first: calculate the non-working segment difference corresponding to the shift template, eliminate shift templates whose non-working segment difference exceeds the preset maximum non-working segment difference, and retain qualified shift templates that satisfy the condition that the non-working segment difference does not exceed the maximum non-working segment difference. Then, among the qualified shift templates, the filtered shift template with the smallest difference from the above requirements is selected as the current optimal shift template according to the step-by-step comparison method of having the most working segment intersection, the smallest non-working segment difference, and the smallest start time difference.
[0056] The preset maximum non-working segment difference can be set according to actual conditions, such as 60 minutes. The filtering operation described above, as a pruning step, pre-screens shift templates with excessively high redundancy durations, reducing the number of shift templates participating in subsequent hierarchical comparisons, thereby reducing the computational load of subsequent optimization. Furthermore, by limiting the maximum allowable redundant working hours of shift templates, it is possible to avoid generating too many invalid shift periods.
[0057] S14. Construct a shift allocation list based on the optimal shift templates obtained through iteration and the corresponding required dates, and determine custom shifts based on the temporary remaining requirements of each of the above requirements.
[0058] The above shift allocation list is used to store the shift allocation records obtained from this matching. Each allocation record is associated with the optimal shift template and the corresponding required date, which is used to represent the standard shift arrangement generated based on the preset job shift template.
[0059] The aforementioned temporary remaining demand represents the gaps in demand to be covered that are continuously updated during the iterative matching process. It is obtained by subtracting the working hours of the optimal shift template from the original demand time period. When there is no shift template that meets the requirements in the candidate pool, and the temporary remaining demand still retains uncovered time gaps, these uncovered time periods become the source of the custom shifts generated subsequently.
[0060] The aforementioned custom shifts, unlike the standard shift templates pre-configured for positions, are shifts specifically generated to fill gaps in demand that cannot be covered by the standard shift templates.
[0061] In this embodiment, after completing the iterative matching loop for a single requirement, the optimal shift template selected in each iteration is written into the shift allocation list along with the date information corresponding to that requirement, thus completing the aggregation of standard shift templates. Simultaneously, the temporary remaining requirements after the iteration of that requirement is completed are read, and the uncovered time periods corresponding to these temporary remaining requirements are processed to generate corresponding custom shifts. This method combines the scheduling results obtained from matching standard shift templates with the custom shifts generated for the remaining gaps. It prioritizes the reuse of pre-set standard shift templates for specific positions, aligning with the store's regular scheduling habits, while also filling in the gaps in scattered requirements that standard templates cannot cover through custom shifts, thereby ensuring that all operational needs can be covered by the scheduling plan.
[0062] In some embodiments, considering that after the aforementioned shift template iterative matching is completed, the temporary remaining demands corresponding to each demand are often scattered, fragmented, with overlapping time periods or segmented intervals, directly dividing the scattered single-segment remaining demands into shifts can easily generate a large number of invalid, fragmented shifts that are too short, do not conform to job specifications, and cannot be assigned to employees. This also leads to problems such as fragmented scheduling time periods, low scheduling regularity, and difficulty in utilizing human resources. Therefore, in the process of determining custom shifts based on the temporary remaining demands of each demand, this application embodiment first merges and deduplicates the scattered temporary remaining demands, integrating the fragmented gaps into regular, continuous time period gaps. Then, it performs standardized shift division on the integrated standard remaining gaps, ultimately generating compliant, implementable, and custom shifts that are adapted to job positions and employee working hour constraints. That is, determining custom shifts based on the aforementioned temporary remaining demands of each of the above demands includes: For the same date and the same job position, the temporary remaining requirements mentioned above are merged and deduplicated to obtain the processed remaining requirements. For each of the processed remaining requirements, the maximum shift duration, minimum shift duration, and minimum daily working hours limit for all employees in the store are obtained. The smaller value between the maximum shift duration and the minimum daily working hours limit for all employees in the store is determined as the maximum segmentation duration, and the minimum shift duration is determined as the minimum segmentation duration. Based on the maximum and minimum segmentation durations, the processed remaining requirements are segmented into shifts, and custom shifts are determined based on the shift segmentation results.
[0063] The remaining demand after the above processing is a continuous and regular demand gap period obtained by merging and deduplicating all scattered temporary remaining demand for the same date and the same position (gap in different positions and / or different dates are isolated and not included in this merging) and overlapping fusion processing, which eliminates the problems of fragmentation, overlapping time periods, and interval segmentation, and provides a basis for standardized shift division. The following is an example of the merging and deduplication process using the same date and the same sorting position. After iterative matching, three single-segment remaining demands are obtained: the first is from 09:00 to 12:00, with a demand of 2 people; the second is from 11:00 to 14:00, with a demand of 1 person; and the third is from 15:00 to 17:00, with a demand of 2 people. Among them, the first and second remaining demands have overlapping time periods. When merging, the wider time interval covered by the two is taken, from 09:00 to 14:00; for the overlapping time period from 11:00 to 12:00, the maximum number of people in the two gap demands, 2 people, is taken; the original demand numbers are retained for non-overlapping time periods. The third remaining demand does not overlap with the aforementioned merged time period, therefore it remains an independent gap. The final merge and deduplication process yields two processed remaining demand segments: the first segment is from 09:00 to 14:00, with 2 people needing the demand from 09:00 to 11:00, 2 people needing the demand from 11:00 to 12:00, and 1 person needing the demand from 12:00 to 14:00; the second segment is from 15:00 to 17:00, with 2 people needing the demand. Because the merging process does not sum the number of people in overlapping time periods, but instead uses the maximum number, it avoids duplicated demand numbers. Furthermore, since the time interval is the widest interval covering all intersecting gaps, it integrates overlapping and adjacent fragmented gaps into a continuous time period, eliminating the gap fragmentation problem.
[0064] The maximum and minimum shift durations for each position are pre-configured shift duration constraint thresholds for each position. These thresholds respectively limit the maximum and minimum valid shift duration for a single legal shift for that position, and serve as the basic constraints to ensure that shifts comply with the job's business specifications.
[0065] The aforementioned minimum daily working hours limit for all store employees is a uniform constraint on the minimum effective working hours per employee per day, designed to prevent the division of shifts into shorter durations that could lead to employees not meeting the required daily working hours and being unable to be legally assigned to their posts.
[0066] In this embodiment, all remaining single-segment demands under the same date and position after iterative matching are aggregated. Fragmented gaps with overlapping time periods or adjacent intervals are merged and combined. For overlapping time periods, the maximum number of people in demand and the widest time period are uniformly selected, and invalid duplicate gaps are eliminated. Finally, continuous, complete, and non-overlapping processed remaining demands are obtained. For each processed remaining demand, the maximum and minimum shift durations of the corresponding position are obtained, as well as the minimum daily working hours limit for all employees in the store, which is uniformly configured. The smaller value between the maximum shift duration and the minimum daily working hours limit for all employees in the store is determined as the maximum segmentation duration for this segmentation, and the minimum shift duration is determined as the minimum segmentation duration for this segmentation. This defines the effective segmentation interval for compliant shifts, ensuring that the shifts obtained from subsequent segmentation meet both the job scheduling specifications and the employee daily working hour access requirements, thus ensuring the feasibility of employee allocation for the shifts.
[0067] Optionally, considering that some of the remaining demands after merging and deduplication are very short time slots, if shift splitting is performed on these short time slots, a large number of invalid shifts with durations shorter than the minimum shift length for each position will be generated. These shifts cannot be assigned to employees. Therefore, performing shift splitting on these short time slots not only increases the workload of scheduling calculations but also produces fragmented scheduling results with no actual business value. Therefore, before splitting each remaining demand based on the maximum and minimum split lengths, the remaining demands can be filtered by duration, retaining only time slots longer than the preset time slot lengths, and then the shift splitting process can be performed on the filtered time slots. That is, the above-mentioned shift splitting process based on the maximum and minimum split lengths for each remaining demand, and the determination of custom shifts based on the shift splitting results, includes: From the remaining demand after the above processing, select the remaining demand that is greater than the preset time slot gap to obtain the filtered remaining demand; perform shift segmentation processing on each of the above-mentioned remaining demand based on the maximum and minimum segmentation durations, and determine the custom shifts based on the shift segmentation processing results.
[0068] The aforementioned preset time slot gap is a pre-defined lower limit of duration, which can be set according to actual conditions, such as 30 minutes. For tiny time slot gaps with a duration less than or equal to this preset gap, the segmentation operation is skipped, and no corresponding custom shifts are generated. This filtering step serves as a computational pruning step. By filtering out short-term gaps that cannot be implemented in scheduling, the workload of subsequent shift segmentation calculations is reduced, thereby avoiding the generation of a large number of unusable fragmented shifts, and thus improving the effectiveness of custom shift generation and the feasibility of the overall scheduling plan.
[0069] In some embodiments, to improve the uniformity of shift allocation, a strategy of prioritizing divisibility can be used for shift allocation. That is, the remaining demand after the above processing is allocated to shifts based on the maximum and minimum allocation durations, and custom shifts are determined based on the shift allocation results, including: For each remaining requirement after the above processing: Starting from the maximum segmentation time, the process iterates down to the minimum segmentation time with a preset step size, sequentially determining whether the total duration of the remaining demand after processing is divisible by the current traversal duration. If the first divisible duration is found, the remaining demand after processing is uniformly segmented according to the first divisible duration. If the minimum segmentation time is still not divisible, a greedy truncation strategy is used to non-uniformly segment the remaining demand after processing. Custom shifts are determined based on the results of uniform and / or non-uniform segmentation.
[0070] In this embodiment, considering that traditional greedy segmentation strategies typically use a "prioritize filling the longest time slot" approach to split gaps, this method is prone to uneven segmentation results where the first shift is filled while the remaining time slots are fragmented, generating a large number of short-term invalid gaps whose duration does not meet job requirements, thus reducing the feasibility of scheduling results. Therefore, to solve this technical problem, this embodiment adopts a divisibility-first segmentation logic, prioritizing the longest duration within the compliant range and traversing downwards to find a target duration that can divide the total duration of the gap. Once the first duration that meets the divisibility condition is found, the gap is evenly segmented according to this duration, resulting in multiple shift segments of equal duration, thereby increasing the regularity of shifts and facilitating subsequent employee allocation.
[0071] To more clearly describe the process of obtaining custom shifts based on the divisibility-first partitioning logic, a specific example is provided below.
[0072] Assume the minimum splitting time for the sorting position is 4 hours (240 minutes) and the maximum splitting time is 8 hours (480 minutes). The remaining demand after a certain processing period is from 09:00 to 21:00, with a total duration of 720 minutes.
[0073] Starting with the maximum segment length of 480 minutes: Since 720 is not divisible by 480, 480 continues to decrease to 420 minutes in preset increments (let's say 60 minutes). Since 720 is still not divisible by 420, 420 continues to decrease to 360 minutes in increments of 60 minutes. Since 720 is divisible by 360, this 360-minute segment is the first divisible segment. This gap (09:00-21:00) is then evenly divided into two 360-minute segments, resulting in the custom-defined segments 09:00-15:00 and 15:00-21:00.
[0074] Of course, if the total duration of the gap cannot be divided evenly after traversing all duration intervals (from the maximum segmentation duration to the minimum segmentation duration), then we will revert to the greedy interception strategy to perform non-uniform segmentation.
[0075] For example, the remaining demand period after processing is 09:30-18:00, with a total duration of 510 minutes. The minimum segment length is 4 hours (240 minutes), and the maximum segment length is 8 hours (480 minutes). Since the divisibility condition cannot be satisfied during the traversal of 480 minutes, 420 minutes, 360 minutes, 300 minutes, and 240 minutes, the greedy truncation strategy is switched back. The 09:30-17:30 shift is extracted. If the remaining 30 minutes of the time period is less than the minimum shift length for the position, it is discarded directly, and no custom shift is generated based on the remaining 30 minutes.
[0076] By prioritizing divisibility and then backing down to greedy truncation when divisibility is not possible, the above-mentioned shift segmentation method prioritizes generating custom shifts with uniform durations. Only in scenarios where uniform segmentation is not possible is the greedy truncation strategy employed. Therefore, this shift segmentation method reduces the fragmented gaps at the tail that are easily generated by traditional greedy segmentation, and improves the regularity of custom shifts and the feasibility of employee allocation.
[0077] To more clearly describe the difference between the integer division priority partitioning logic provided in the embodiments of this application and the traditional greedy partitioning logic, the following description is based on specific examples.
[0078] Taking the demand gap segmentation of the sorting position as an example, assuming that the allowed shift length for this position is between 4 and 10 hours, the maximum daily working hours for an employee is 8 hours.
[0079] Traditional greedy partitioning logic: Traditional greedy segmentation logic employs a greedy strategy of "prioritizing the segment with the longest duration". For a time period with a total gap of 480 minutes, the maximum segmentation duration is calculated as: maxMinutes = min (600, 480) = 480 minutes. One 480-minute segment is directly segmented, leaving a gap of 0 minutes.
[0080] The scheme has obvious flaws: it does not impose a limit on the daily working hours of employees; when the gap length exceeds the maximum working hours of employees per day, it will cause the problem of exceeding the working hours limit; when dividing multiple gaps, it is easy to have the front shifts filled and the back shifts have scattered small gaps, which will increase the difficulty of subsequent scheduling.
[0081] Integer-first partitioning logic: This application adopts a divisibility-first gap segmentation strategy to obtain the maximum daily working hours limit minDailyMaxMinutes for employees before segmentation.
[0082] Scenario 1: The maximum daily working hours for an employee is 480 minutes (8 hours), so maxMinutes = min(600,480) = 480 minutes. Divide the total shortfall of 480 minutes by 480; since 480 is divisible by 480, a complete shift of 480 minutes is created.
[0083] The second scenario: The maximum daily working hours for employees are adjusted to 240 minutes (4 hours), so maxMinutes = min(600,240) = 240 minutes. The total shortfall of 480 minutes is divided by 240, so it is evenly divided into two custom shifts of 240 minutes each.
[0084] The advantages of this scheme are: it uses a divisibility-first approach to divide the gaps, resulting in completely uniform durations for each custom shift; and it uses the daily working hour limit for employees as a hard constraint to ensure that the divided shifts comply with the employee working hour rules.
[0085] Greedy rollback mechanism when division fails: When the total time gap cannot be divided into any divisible lengths within the range from the maximum to the minimum segmentation length, a greedy backoff strategy is triggered. For example, suppose the total time gap for a warehouse clearing position is 500 minutes, the shift duration ranges from 4 to 10 hours, and the maximum segmentation length is 480 minutes. Iterating through the options, we find that 500 is not divisible by 480, so we continue iterating downwards. However, 500 is also not divisible by 240, and there is no divisible length that meets the condition. Therefore, the greedy backoff process is initiated.
[0086] Starting from the beginning of the gap, 480 minutes of shifts are extracted, leaving a remaining gap of 20 minutes. This remaining 20 minutes is less than the minimum shift duration of the position, minMinutes (240 minutes), and does not meet the conditions for generating a custom shift separately. Therefore, this 20-minute surplus is incorporated into the previous shift, and finally a custom shift of 500 minutes is output. This shift is still protected by the daily working hour limit constraint for employees.
[0087] Under the traditional greedy segmentation strategy, the total duration of the gap satisfies the following relationship: totalMins = N×max + R (R<minMinutes).
[0088] Where totalMins represents the total duration of the gap to be divided; max represents the maximum division duration; N represents the number of complete shifts of the maximum duration that can be divided; R represents the remaining gap duration after division; and minMinutes represents the minimum allowed shift duration for the position. When the remaining gap duration R is less than the minimum shift duration minMinutes, the remaining fragment cannot be used to generate a valid custom shift on its own, resulting in a situation where the initial shifts are filled while scattered gaps remain at the end. This uneven shift structure directly affects the subsequent constraint solving and employee matching optimization process, undermining the fairness and balance of the scheduling optimization.
[0089] The inconsistent probability of different gaps being selected for employee allocation in subsequent scheduling matching iterations can lead to uneven working hours across shifts in the final scheduling result. The solver tends to prioritize filling earlier-generated shifts, making it difficult to allocate employees to scattered gaps later on. However, the divisibility-first segmentation logic provided in this embodiment ensures that each custom shift's duration is equal to d when the total gap duration is divisible by the traversable duration d. This identical working hours across all custom shifts maintains consistency in the subsequent tiered penalty for balanced M1 shift coverage in Table 1, ensuring equal opportunities for employee allocation across shifts during solver optimization. When no divisible duration exists, the algorithm reverts to a greedy segmentation strategy, while retaining the daily working hour limit constraint for employees throughout the process. Optionally, this embodiment also adds an exception handling fallback logic, preventing overall scheduling requests from failing directly when an exception occurs during the gap segmentation stage. Ultimately, this significantly improves scheduling solution coverage and fairness.
[0090] In some embodiments, considering that labor regulations typically pre-set scheduling rules parameters for positions, such as preset continuous working time thresholds and single rest durations, to constrain the maximum continuous working time of employees, a fixed rest period must be inserted when the continuous working time of an employee reaches the continuous working time threshold. The duration of this fixed rest period is the aforementioned single rest duration. Therefore, after obtaining the initial custom shifts according to the above shift segmentation method, the initial shift segments obtained can be further normalized by combining the pre-configured continuous working time thresholds and single rest durations for the positions. Specifically, it can be first determined whether the continuous working time of each shift segment exceeds the continuous working time threshold. If the continuous working time of an employee exceeds the continuous working time threshold, then the single long shift is split into multiple continuous working periods, and the corresponding single rest duration is automatically inserted at the splitting position, ultimately generating a custom shift that conforms to labor scheduling regulations and is both normalized and feasible.
[0091] In this embodiment, a layered logic is employed—first merging fragmented gaps, then standardizing and segmenting them, and finally adapting rest rules to regularize shifts—to completely resolve the shortcomings of traditional greedy matching algorithms, such as scattered remaining demands, non-standardized shifts, and inability to implement scheduling after iteration. On one hand, merging and deduplication integrates scattered gaps, significantly reducing invalid and fragmented shifts and improving the overall regularity of scheduling. On the other hand, by combining constraints on the maximum and minimum shift durations for each position, as well as the minimum daily working hours for all employees, the shift segmentation range is defined, taking into account both job business rules and employee employment standards. This ensures that all generated custom shifts can participate in subsequent employee constraint solving and scheduling allocation, significantly improving the completeness, compliance, and implementability of the overall scheduling solution.
[0092] S15, Based on the obtained scheduling constraint information, constrain the above shift allocation list and the above custom shifts to obtain the scheduling plan.
[0093] The aforementioned scheduling constraints can originate from two sources: First, they are generated from information carried in the scheduling request. If the scheduling request includes a set of job positions with attributes such as gender requirements, allowed job sets for cross-job roles, a whitelist of personnel types, and a range of single-shift durations, and an employee information set with attributes such as employee gender, skill set, personnel type, monthly working hours limit, maximum consecutive working days, and preferred shift templates, then one or more scheduling constraints can be generated based on this information within the job and employee information sets. Second, they are pre-configured global constraints adapted to scheduling business scenarios. These global constraints may include constraints such as the store's daily staffing requirements, the minimum rest interval between adjacent employee shifts, and the maximum number of shifts an employee can be assigned per day.
[0094] The aforementioned scheduling constraints can be divided into multiple levels according to business priority, and the number of levels can be flexibly configured according to the actual business needs of stores and industries. Optionally, this application embodiment divides the scheduling constraints into three categories: hard constraints, medium constraints, and soft constraints as an example. Among them, hard constraints are the highest priority constraints and must all be satisfied; once violated, the corresponding scheduling plan is infeasible. Medium constraints have the next highest priority and should be satisfied as much as possible; violations will result in higher penalties, but the solution can still be retained. Soft constraints have the lowest priority and belong to optimization goals, used to improve the humanization of scheduling plans; violations only result in lower penalties. The constraint strength of each type of constraint is configurable, and it can be adapted to different business scenarios without modifying the code; the solution process is optimized according to the step-by-step priority of constraint strength.
[0095] The aforementioned scheduling constraint information is used to standardize the allocation relationship between employees and shifts. During the constraint solving process, the shift records obtained by matching the standard shift template in the shift allocation list, as well as the custom shifts generated by gap segmentation, are used together as the shift allocation set. The employee allocation is solved in combination with the scheduling constraint information.
[0096] In this embodiment, the solution algorithm can be flexibly selected, such as a two-stage solution strategy combining constructive heuristics and local search. The constructive heuristic stage is mainly used to quickly match suitable employees to each shift to be assigned in the shift allocation set, prioritizing the generation of initial feasible shift plans that satisfy high-priority constraints, ensuring that the initially generated shift plans have basic feasibility for implementation. The local search stage then performs neighborhood iterative optimization based on the initial feasible shift plans, continuously reducing the penalty points corresponding to low-priority constraints while strictly maintaining the high-priority constraints, thus achieving refined optimization of the shift plan.
[0097] For example, when scheduling constraints are categorized into three levels—hard constraints, medium constraints, and soft constraints—the heuristic construction phase only verifies hard constraints. The feasibility of a solution is determined solely by whether hard constraints are met; medium and soft constraints are not considered in the feasibility assessment. Therefore, the initial feasible solution (or initial feasible scheduling plan) obtained through hard constraint verification is allowed to contain violations of medium or soft constraints, as long as the overall plan has no hard constraint violations.
[0098] After constructing the initial feasible solution, the algorithm enters the local search refinement optimization stage. This stage employs a delayed acceptance strategy, combined with two types of neighborhood operations: shift employee replacement movement and double-shift employee exchange movement, continuously generating new candidate scheduling plans and iteratively selecting the best one. The candidate scheduling plan refers to the temporary scheduling plan generated through neighborhood movement operations during the local search iteration process, used for comparison and selection. It serves as the evaluation object for each round of iteration optimization. The system selects the better scheduling plan by batch evaluating the penalty scores of multiple sets of candidate scheduling plans.
[0099] During each round of neighborhood move evaluation, hard constraint penalties, medium constraint penalties, and soft constraint penalties are uniformly calculated for the current candidate scheduling plans. Since violations of hard constraints result in high-weight penalties, the solver directly discards all candidate scheduling plans with hard constraint violations, ensuring that hard constraints are consistently satisfied during the optimization process. While maintaining full compliance with hard constraints, the solver continuously filters and retains candidate scheduling plans with lower medium constraint penalties and soft constraint penalties. By continuously reducing the overall penalties for medium and soft constraints, the solver gradually achieves refined optimization of the scheduling plan, ultimately outputting an optimal scheduling plan that balances compliance, balance, and human factors.
[0100] To more clearly describe the penalties corresponding to hard constraints, medium constraints, and soft constraints, the following explanation is provided in conjunction with Table 1.
[0101] Assume that the scheduling constraints information may include the content shown in Table 1 below, where gap1 in Table 1 represents the headcount gap, and the headcount gap = demand. Allocated number, in person.
[0102] Table 1:
[0103] In this embodiment of the application, M2 and M5 are optional constraints and are not shown in Table 1.
[0104] Taking the medium constraint M1 in Table 1 as an example, the constraint name of medium constraint M1 is shift coverage balance, and it uses a tiered penalty mechanism to calculate the penalty points.
[0105] Suppose there are two sets of comparative cases with the same number of vacancies but different on-the-job status: the shift staffing requirement is 3 people, and the staffing gap1 in both sets of cases is 2.
[0106] Scenario X1: No employees were assigned to the shift. Substituting into the formula, the medium penalty score is: 1000 × 2 = 2000. Scenario X2: One employee has been assigned to the shift. Substituting into the formula, the medium penalty score is: 2×100 + 2²×50=400.
[0107] The two sets of cases have the same number of staff shortages, but scenario X1 has no staff on duty, resulting in a significantly higher penalty score than scenario X2. This demonstrates that the tiered penalty mechanism prioritizes punishing the severe situation of "entire shifts being empty," forcing the solver to ensure at least one staff member is on duty in each shift. For shifts with staff on duty but still experiencing staff shortages, a combination of linear and quadratic terms is used to calculate the penalty score: the linear term drives the algorithm to fill the staff shortages in each shift as much as possible, while the quadratic term ensures that, for the same total shortage, the total penalty score is lower when the shortage is distributed across multiple shifts, guiding the staff shortages to be evenly distributed and preventing them from being concentrated in a few shifts.
[0108] In some embodiments, during the local search refinement optimization process, whenever the solver obtains a candidate scheduling plan that is better than the current scheduling plan, the real-time solution progress information stored in the Remote Dictionary Server (Redis) is updated and can be displayed so that users can understand the relevant information in a timely manner. This real-time solution progress information may include a status identifier indicating the current solution status, the optimal score (i.e., the optimal comprehensive score that satisfies the scheduling constraints obtained up to the current time during the solution process), the number of shift allocation records in the completed shift allocation set, the total number of shift allocation records in the shift allocation set, and a score evolution record (i.e., the trajectory of the optimal score as the iteration progresses).
[0109] When the constraint solution iteration ends and the constraint termination condition is met, the final optimized scheduling plan is saved. Optionally, the state identifier is updated to the identifier corresponding to the completion state. Optionally, considering that local search neighborhood movement may unexpectedly generate candidate solutions that violate hard constraints, a final verification is performed after the solution is completed to confirm whether the high-priority constraints (such as hard constraints) of the final scheduling plan are compliant. Specifically, a score analysis is performed on the final scheduling plan. If the hard constraint penalty is 0, the scheduling plan is determined to be a feasible solution and saved; if the hard constraint penalty is not 0, it is determined to be an infeasible solution, the currently solved scheduling plan is saved and marked as infeasible, and further, a prompt message indicating that the current scheduling plan is infeasible can be issued. Optionally, the prompt message may also include information on relaxing constraints.
[0110] Furthermore, the finalized scheduling plan can be returned to the calling end through various data views. These data views may include: an employee-date matrix view, which visually displays the scheduling arrangements for each employee on each natural day; and a list view, which outputs detailed employee attendance information. A list of unmet requirements is also output, facilitating manual adjustments by business personnel to address staffing gaps.
[0111] The above describes the solution process using a two-stage solution strategy. In practice, the solution algorithm can also use integer programming to solve the constraints, which is not limited here.
[0112] In this embodiment of the application, in order to avoid infinite iterations of constraint solving during the solution process, a constraint termination condition is set. When the constraint termination condition is met, the constraint solving iteration stops.
[0113] Optionally, the constraint termination condition may include no improvement time and / or no improvement steps.
[0114] The "no improvement time" refers to the period after which, starting from the moment the optimal scheduling plan is found, the solver evaluates all candidate scheduling plans and fails to produce a schedule plan with lower penalty scores and better quality. This period without any planned optimization or improvement is called the "no improvement time." Once this preset time is exceeded, the solver terminates.
[0115] Here, "no improvement steps" refers to the following: each neighborhood move (shift employee replacement, double shift employee exchange) performed in the local search is counted as one step; "no improvement steps" means that after continuously performing a preset number of neighborhood move steps, a candidate scheduling plan with lower penalty and better quality is still not found. When the number of consecutive iterations reaches this preset threshold, the solution is terminated.
[0116] Optionally, the constraint termination condition in this application embodiment may also include a timeout limit. This timeout limit is a pre-set threshold for the total solution time, which starts timing from the local search phase. Once the cumulative solution execution time reaches this timeout limit, the iteration will terminate directly, regardless of whether further optimization space exists, and the currently obtained optimal scheduling plan will be output.
[0117] In some embodiments, assuming that the shift allocation list and the custom shifts constitute a shift allocation set, and the constraint termination condition includes the aforementioned timeout limit, then the above-mentioned constraint on the shift allocation list and the aforementioned custom shifts based on the obtained scheduling constraint information to obtain the scheduling plan includes: Based on the obtained scheduling constraint information, the following constraint solving iterations are performed on the above shift allocation set: Calculate the candidate solution timeout upper limit based on the number of natural days covered by the shift allocation records in the above shift allocation set and the total number of the above shift allocation records; determine the final timeout upper limit based on the candidate solution timeout upper limit, the preset minimum solution timeout upper limit, and the preset maximum solution timeout upper limit; determine the constraint termination condition based on the final timeout upper limit; stop the constraint solving iterations after the constraint termination condition is met, and determine the shift schedule based on the solution results.
[0118] The number of calendar days covered by the above shift assignment records is the total number of calendar days covered by this scheduling task. It is calculated from the start and end dates of the scheduling (which can be carried in the scheduling request). The calculation method is: end date minus start date plus 1, to include both start and end days. The total number of shift assignment records (assignmentCount) is the total number of shift assignment records for all employees to be assigned in this scheduling task. This includes shift records obtained by matching shift templates and custom shift records generated after gap splitting. It can be obtained by counting the total number of records in the shift assignment set before the constraint solution begins.
[0119] In this embodiment of the application, the upper limit of the candidate solution timeout can be calculated according to the following formula: Candidate solution timeout limit = assignmentCount ÷ 3 + days × 2 (unit: seconds).
[0120] In this embodiment, the upper limit of the candidate solution timeout can be limited between a preset minimum solution timeout limit and a preset maximum solution timeout limit. Assuming the preset minimum solution timeout limit is 10 seconds and the preset maximum solution timeout limit is 120 seconds, the final timeout limit is set to "max(10, min(120, candidate solution timeout limit))". Optionally, this final timeout limit can be used as one of the constraints for termination. When the constraint termination conditions include the timeout limit, no improvement time, and no improvement steps, iteration stops as long as any one of these conditions is met. This method allows for dynamic adaptation of the solution duration based on the scale of the scheduling task: the more days the scheduling covers and the larger the total number of shift allocation records, the longer the allocated solution time; while smaller-scale scheduling tasks are allocated shorter solution times, thus effectively avoiding waste of computing resources.
[0121] To more clearly describe how the final timeout limit is determined, a specific example will be used below.
[0122] Suppose a small store has a shift scheduling task that covers 7 calendar days, with a total of 50 shift allocation records. The preset minimum solution timeout is 10 seconds, and the preset maximum solution timeout is 120 seconds.
[0123] The maximum timeout for the candidate solution is 50 ÷ 3 + 7 × 2 ≈ 16.67 + 14 = 30.67 seconds.
[0124] Since this value falls within the range of 10 to 120 seconds, the final timeout limit can be set at 30.67 seconds.
[0125] In this embodiment, by obtaining scheduling requests containing job positions, employees, and demand information, a candidate pool of shift templates corresponding to each job position is constructed for each demand. During the iterative matching loop, the difference between the shift template and the demand is always calculated based on the original demand time period. The optimal shift template is selected, and time periods are deducted for any temporary remaining demand. After iteration, a shift allocation list is constructed based on the selected optimal shift template, and custom shifts are generated based on the temporary remaining demand after iteration. Finally, both types of shifts are uniformly incorporated into the constraint solution to obtain the scheduling plan. This scheme combines standard shift template matching with the generation of custom shifts for remaining gaps. Simultaneously, when evaluating template differences, it anchors the comparison to the original demand time period, avoiding the coverage overflow defect caused by the traditional greedy scheduling algorithm using the deducted remaining demand as the scoring benchmark. It can accurately evaluate the actual coverage capability of the shift template for the original business demand, ensuring the objectivity of job demand evaluation and improving the accuracy of the subsequent scheduling plan.
[0126] Meanwhile, since this application embodiment relies on shift templates associated with job positions to construct a dedicated candidate pool for demand, and only shift templates suitable for the job positions are used for matching, the scope of matching calculation can be narrowed, improving the efficiency of shift template screening. In addition, by iteratively selecting and deducting to gradually cover the job time slot requirements, custom shifts are generated to supplement the remaining demand gaps that the standard shift template cannot cover. This takes into account both the business applicability of the preset standard shifts and the ability to fill the gaps in scattered time slots, so that the final set of shifts used for constraint solving can fully cover the time slot requirements of store operations. On this basis, the shift allocation list and custom shifts are used together to participate in the scheduling constraint solving. Employees are uniformly allocated by comprehensively considering employee and job-related constraints, resulting in a compliant and implementable scheduling plan. This ensures that the scheduling results are in line with the store's job operation needs, while also taking into account employee-related scheduling constraints, improving the completeness and practicality of the scheduling plan.
[0127] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0128] Corresponding to the intelligent scheduling method described in the above embodiments, Figure 2 The diagram shows a structural block diagram of an intelligent scheduling device provided in an embodiment of this application. For ease of explanation, only the parts related to the embodiment of this application are shown.
[0129] Reference Figure 2 The intelligent scheduling device 2 is applied to electronic equipment and includes: a scheduling request acquisition module 21, a candidate pool determination module 22, an optimal shift template determination module 23, a shift allocation set determination module 24, and a scheduling plan generation module 25. Wherein: The scheduling request acquisition module 21 is used to acquire scheduling requests, which include a set of job positions, a set of employee information, and a set of requirements. The set of job positions includes shift templates associated with each job position; the set of employee information includes the main job position associated with each employee; and the set of requirements includes the job position, date, and time period associated with each requirement. The candidate pool determination module 22 is used to add all shift templates corresponding to each demand to the candidate pool of the corresponding demand based on the shift templates associated with each job in the job set and the job associated with each demand included in the demand set. The optimal shift template determination module 23 is used to iteratively execute the following matching loop steps for each demand until the iteration stop condition is met: initialize temporary remaining demand, wherein the initial time period of the temporary remaining demand is the same as the original demand time period of the demand; calculate the difference between the shift template in the candidate pool corresponding to the demand and the demand based on the original demand time period of the demand; select the shift template with the smallest difference from the demand as the current optimal shift template, and deduct the time period corresponding to the current optimal shift template from the current temporary remaining demand to obtain a new temporary remaining demand; The shift allocation set determination module 24 is used to construct a shift allocation list based on each of the optimal shift templates obtained through iteration and the corresponding required dates, and to determine custom shifts based on the temporary remaining requirements of each of the requirements. The scheduling plan generation module 25 is used to constrain the shift allocation list and the custom shifts based on the obtained scheduling constraint information to obtain the scheduling plan.
[0130] In this embodiment, by obtaining scheduling requests containing job positions, employees, and demand information, a candidate pool of shift templates corresponding to each job position is constructed for each demand. During the iterative matching loop, the difference between the shift template and the demand is always calculated based on the original demand time period. The optimal shift template is selected, and time periods are deducted for any temporary remaining demand. After iteration, a shift allocation list is constructed based on the selected optimal shift template, and custom shifts are generated based on the temporary remaining demand after iteration. Finally, both types of shifts are uniformly incorporated into the constraint solution to obtain the scheduling plan. This scheme combines standard shift template matching with the generation of custom shifts for remaining gaps. Simultaneously, when evaluating template differences, it anchors the comparison to the original demand time period, avoiding the coverage overflow defect caused by the traditional greedy scheduling algorithm using the deducted remaining demand as the scoring benchmark. It can accurately evaluate the actual coverage capability of the shift template for the original business demand, ensuring the objectivity of job demand evaluation and improving the accuracy of the subsequent scheduling plan.
[0131] Meanwhile, since this application embodiment relies on shift templates associated with job positions to construct a dedicated candidate pool for demand, and only shift templates suitable for the job positions are used for matching, the scope of matching calculation can be narrowed, improving the efficiency of shift template screening. In addition, by iteratively selecting and deducting to gradually cover the job time slot requirements, custom shifts are generated to supplement the remaining demand gaps that the standard shift template cannot cover. This takes into account both the business applicability of the preset standard shifts and the ability to fill the gaps in scattered time slots, so that the final set of shifts used for constraint solving can fully cover the time slot requirements of store operations. On this basis, the shift allocation list and custom shifts are used together to participate in the scheduling constraint solving. Employees are uniformly allocated by comprehensively considering employee and job-related constraints, resulting in a compliant and implementable scheduling plan. This ensures that the scheduling results are in line with the store's job operation needs, while also taking into account employee-related scheduling constraints, improving the completeness and practicality of the scheduling plan.
[0132] Optionally, the differences include: the intersection of working segments, the difference between non-working segments, and the start time difference. The optimal shift template determination module 23 selects the shift template with the smallest difference from the requirement as the current optimal shift template, specifically including: The shift template with the smallest difference from the requirement is selected as the current optimal shift template by a step-by-step comparison method that prioritizes the work segment intersection, the non-work segment difference, and the start time difference.
[0133] Optionally, the step of selecting the shift template with the smallest difference from the requirement as the current optimal shift template through a step-by-step comparison method based on the maximum intersection of the work segments, the minimum difference of the non-work segments, and the minimum difference of the start time includes: Each shift template is filtered according to the preset maximum difference set of non-working segments; the shift template with the smallest difference set of non-working segments and the smallest start time difference is selected as the current optimal shift template by a stepwise comparison method based on the maximum intersection of working segments, the minimum difference set of non-working segments, and the minimum difference set of start time.
[0134] Optionally, the shift allocation set determination module 24 determines custom shifts based on the temporary remaining demand for each of the aforementioned demands, specifically including: For the same date and the same job position, the temporary remaining requirements of each requirement are merged and deduplicated to obtain the processed remaining requirements. For each processed remaining requirement, the maximum shift duration, minimum shift duration, and minimum daily working hours limit for all employees in the store are obtained. The smaller value between the maximum shift duration and the minimum daily working hours limit for all employees in the store is determined as the maximum segmentation duration, and the minimum shift duration is determined as the minimum segmentation duration. Based on the maximum and minimum segmentation durations, each processed remaining requirement is segmented into shifts, and a custom shift is determined based on the shift segmentation result.
[0135] Optionally, the step of dividing the remaining demand after processing into shifts based on the maximum and minimum division durations, and determining custom shifts based on the shift division results, includes: The remaining demand after processing is selected from the remaining demand after processing that is greater than the preset time slot, and the remaining demand after processing is obtained. The remaining demand after processing is divided into shifts according to the maximum and minimum splitting time, and the custom shifts are determined according to the shift division results.
[0136] Optionally, the step of dividing the remaining demand after processing into shifts based on the maximum and minimum division durations, and determining custom shifts based on the shift division results, includes: For each of the remaining requirements after processing: Starting from the maximum segmentation time, the process iterates down to the minimum segmentation time with a preset step size, sequentially determining whether the total duration of the remaining demand after processing is divisible by the current traversal time. If the first divisible duration is found, the remaining demand after processing is uniformly segmented according to the first divisible duration. If the minimum segmentation time is still not divisible, a greedy truncation strategy is used to non-uniformly segment the remaining demand after processing. Custom shifts are determined based on the results of uniform and / or non-uniform segmentation.
[0137] Optionally, the shift allocation list and the custom shifts constitute a shift allocation set, and the shift schedule generation module 25 is specifically used for: Based on the acquired scheduling constraint information, the following constraint solving iterations are performed on the shift allocation set: a candidate solution timeout upper limit is calculated based on the number of natural days covered by the shift allocation records in the shift allocation set and the total number of shift allocation records; a final timeout upper limit is determined based on the candidate solution timeout upper limit, a preset minimum solution timeout upper limit, and a preset maximum solution timeout upper limit; a constraint termination condition is determined based on the final timeout upper limit; constraint solving iterations are stopped after the constraint termination condition is met, and the shift schedule is determined based on the solution results.
[0138] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0139] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 3 As shown, the electronic device 3 of this embodiment includes: at least one processor 30 ( Figure 3 The diagram shows only one processor, a memory 31, and a computer program 32 stored in the memory 31 and executable on the at least one processor 30, wherein the processor 30 executes the computer program 32 to implement the steps in any of the above method embodiments.
[0140] The electronic device 3 can be a desktop computer, laptop, handheld computer, or cloud server, etc. This electronic device may include, but is not limited to, a processor 30 and a memory 31. Those skilled in the art will understand that... Figure 3 This is merely an example of electronic device 3 and does not constitute a limitation on electronic device 3. It may include more or fewer components than shown in the figure, or combine certain components, or different components. For example, it may also include input / output devices, network access devices, etc.
[0141] The processor 30 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0142] In some embodiments, the memory 31 may be an internal storage unit of the electronic device 3, such as a hard disk or memory of the electronic device 3. In other embodiments, the memory 31 may be an external storage device of the electronic device 3, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the electronic device 3. Furthermore, the memory 31 may include both internal and external storage units of the electronic device 3. The memory 31 is used to store the operating system, applications, bootloader, data, and other programs, such as the program code of the computer program. The memory 31 can also be used to temporarily store data that has been output or will be output.
[0143] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0144] This application also provides a network device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor executes the computer program to implement the steps in any of the above method embodiments.
[0145] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the steps in the above-described method embodiments.
[0146] This application provides a computer program product that, when run on an electronic device, enables the electronic device to implement the steps described in the various method embodiments above.
[0147] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying computer program code to a photographic device / electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.
[0148] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0149] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0150] In the embodiments provided in this application, it should be understood that the disclosed apparatus / network devices and methods can be implemented in other ways. For example, the apparatus / network device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0151] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
Claims
1. An intelligent scheduling method, characterized in that, include: Obtain a scheduling request, which includes a set of job positions, a set of employee information, and a set of requirements. The set of job positions includes shift templates associated with each job position. The set of employee information includes the primary job position associated with each employee. The set of requirements includes the job position, date, and time period associated with each requirement. Based on the shift templates associated with each job in the job set and the job associated with each demand in the demand set, all shift templates corresponding to each demand are added to the candidate pool of the corresponding demand. For each demand, the following matching loop steps are executed iteratively until the iteration stopping condition is met: Initialize temporary remaining demand, the initial time period of the temporary remaining demand is the same as the original demand time period of the demand; Based on the original demand time period of the demand, calculate the difference between the shift template in the candidate pool corresponding to the demand and the demand; Select the shift template with the smallest difference from the demand as the current optimal shift template, and deduct the time period corresponding to the current optimal shift template from the current temporary remaining demand to obtain a new temporary remaining demand; A schedule allocation list is constructed based on the optimal schedule templates obtained through iteration and the corresponding required dates, and custom schedules are determined based on the temporary remaining requirements for each requirement. Based on the obtained scheduling constraint information, the shift allocation list and the custom shifts are constrained to obtain the scheduling plan.
2. The intelligent scheduling method as described in claim 1, characterized in that, The differences include: the intersection of working segments, the difference of non-working segments, and the start time difference. Selecting the shift template with the smallest difference from the requirement as the current optimal shift template includes: The shift template with the smallest difference from the requirement is selected as the current optimal shift template by a step-by-step comparison method that prioritizes the work segment intersection, the non-work segment difference, and the start time difference.
3. The intelligent scheduling method as described in claim 2, characterized in that, The method of selecting the shift template with the smallest difference from the requirement as the current optimal shift template through a step-by-step comparison based on the maximum intersection of the work segments, the minimum difference of the non-work segments, and the minimum start time difference includes: The shift templates are filtered according to the preset maximum non-working segment difference set; Using a step-by-step comparison method that prioritizes the work segment intersection as the maximum, the non-work segment difference as the minimum, and the start time difference as the minimum, the filtered shift template with the smallest difference from the requirement is selected as the current optimal shift template.
4. The intelligent scheduling method as described in any one of claims 1 to 3, characterized in that, The process of determining customized shifts based on the temporary remaining demand for each of the aforementioned demands includes: For the same date and the same position, the temporary remaining requirements of each requirement are merged and deduplicated to obtain the processed remaining requirements; For each remaining demand after processing, obtain the maximum shift duration, minimum shift duration, and minimum daily working hours limit for all employees in the store for the corresponding position. The smaller of the maximum shift duration for the job and the maximum daily working hours for all employees in the store is determined as the maximum segmented duration, and the minimum shift duration for the job is determined as the minimum segmented duration. Based on the maximum and minimum splitting durations, the remaining demand after each processing step is split into shifts, and the custom shifts are determined based on the shift splitting results.
5. The intelligent scheduling method as described in claim 4, characterized in that, The process of dividing the remaining demand after processing into shifts based on the maximum and minimum splitting durations, and determining custom shifts based on the shift division results, includes: The remaining demand after processing is selected from each of the remaining demand after processing that is greater than the preset time gap, and the filtered remaining demand is obtained. Based on the maximum and minimum segmentation durations, the remaining demand after each filtering is segmented into shifts, and the custom shifts are determined based on the shift segmentation results.
6. The intelligent scheduling method as described in claim 4, characterized in that, The process of dividing the remaining demand after processing into shifts based on the maximum and minimum splitting durations, and determining custom shifts based on the shift division results, includes: For each of the remaining requirements after processing: Starting from the maximum segmentation time, the process is traversed in descending order of the minimum segmentation time according to a preset step size, and it is determined in turn whether the total time of the remaining requirements after processing can be divided by the current traversal time. If the first divisible duration is found, the remaining demand after processing is evenly divided according to the first divisible duration. If the minimum segmentation time is still not divisible, a greedy truncation strategy is used to non-uniformly segment the remaining requirements after processing. Custom shifts are determined based on the results of uniform and / or non-uniform segmentation.
7. The intelligent scheduling method as described in claim 1, characterized in that, The shift allocation list and the custom shifts constitute a shift allocation set. The step of constraining the shift allocation list and the custom shifts based on the acquired scheduling constraint information to obtain a scheduling plan includes: Based on the obtained scheduling constraint information, the following constraint solving iteration is performed on the shift allocation set: Calculate the candidate solution timeout upper limit according to the number of natural days covered by the shift allocation records in the shift allocation set and the total number of shift allocation records; determine the final timeout upper limit according to the candidate solution timeout upper limit, the preset minimum solution timeout upper limit and the preset maximum solution timeout upper limit; The constraint termination condition is determined based on the final timeout limit. After the constraint termination condition is met, the constraint solution iteration is stopped, and the scheduling plan is determined based on the solution results.
8. An intelligent scheduling device, characterized in that, include: The scheduling request acquisition module is used to acquire scheduling requests, which include a set of job positions, a set of employee information, and a set of requirements. The set of job positions includes: shift templates associated with each job position; the set of employee information includes the main job position associated with each employee; and the set of requirements includes: the job position, date, and time period associated with each requirement. The candidate pool determination module is used to add all shift templates corresponding to each demand to the candidate pool of the corresponding demand based on the shift templates associated with each job in the job set and the job associated with each demand included in the demand set. The optimal shift template determination module is used to iteratively execute the following matching loop steps for each demand until the iteration stopping condition is met: initialize temporary remaining demand, the initial time period of the temporary remaining demand is the same as the original demand time period of the demand; based on the original demand time period of the demand, calculate the difference between the shift template in the candidate pool corresponding to the demand and the demand; select the shift template with the smallest difference from the demand as the current optimal shift template, and deduct the time period corresponding to the current optimal shift template from the current temporary remaining demand to obtain a new temporary remaining demand; The shift allocation set determination module is used to construct a shift allocation list based on each of the optimal shift templates obtained through iteration and the corresponding required dates, and to determine custom shifts based on the temporary remaining requirements of each of the requirements. The scheduling plan generation module is used to constrain the shift allocation list and the custom shifts based on the obtained scheduling constraint information to obtain the scheduling plan.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 7.
10. A computer program product, characterized in that, Includes a computer program, which, when executed, causes the electronic device to perform the method according to any one of claims 1 to 7.
