Index
Break
(message)BreakRule
(message)BudgetRequirement
(message)CoverageRequirement
(message)CoverageRequirement.RoleRequirement
(message)CoverageRequirement.SkillRequirement
(message)DemandCoverageViolation
(message)Employee
(message)EmployeeDemand
(message)EmployeeSchedule
(message)EmployeeSchedule.ShiftWithEvents
(message)EmployeeSchedule.ShiftWithEvents.Event
(message)EventTemplate
(message)HourlyContract
(message)HourlyContract.OvertimePeriod
(message)Priority
(enum)ResourceConstraint
(message)SchedulingConstraint
(message)Shift
(message)ShiftAssignment
(message)ShiftGenerationSolutionStatus
(enum)ShiftPreference
(message)ShiftRequest
(message)ShiftTemplate
(message)SolutionStatus
(enum)SolveParameters
(message)SolverConfig
(message)WorkStatus
(enum)
Break
A time period in which an employee interrupts their work during a shift.
Fields | |
---|---|
start_date_time |
The start time of a break. |
duration_minutes |
Duration of the break in minutes. |
BreakRule
A rule that determines when a break can start within a shift and its duration. The list of all possible breaks that are considered is determined in increments of rule_increment_minutes
. For example, if a break rule is modeling a 30-minute break that can start between 10:00 and 11:00, and the rule increment is of 20 minutes, the list of breaks that are considered are: [10:00, 10:30], [10:20, 10:50], [10:40, 11:10], [11:00, 11:30].
Fields | |
---|---|
earliest_start_time |
The earliest start time of the break (inclusive). Only |
latest_start_time |
The latest start time of the break (inclusive). Only |
duration_minutes |
Duration of the break in minutes. |
rule_increment_minutes |
[Optional] Time increment in minutes for all the breaks that can be considered in this break rule. If not set, defaults to |
BudgetRequirement
Budget requirements for a given interval.
Fields | |
---|---|
total_budget |
Total budget for the given interval. A total budget must be given if the priority is If |
start_date_time |
Start time for when this budget applies. If a start time is not specified, it is set to be the earliest start time of all given shifts. |
end_date_time |
End time for when this budget applies. If an end time is not specified, it is set to be the latest end time of all given shifts. |
priority |
Priority level for meeting the budget requirement during the specified time window. The default priority is Note that if this priority is higher than other constraint priorities and if |
CoverageRequirement
A coverage requirement specifies the number of employees required for a set of roles and/or skills during a particular time window and at a given location. DateTime intervals at a particular location cannot overlap. Alternatively, a list of shift IDs can be provided instead of a time window and a location. Only employees which can be assigned to the specific role (or that possess the specific skill) can meet this requirement.
For a given role and/or skill, the coverage requirement is fulfilled when at least target_employee_count
number of employees are working at every moment in the time window (or for every shift in shift_ids
). In contrast, the coverage requirement is violated if at any point in the time window (or for any of the shifts in shift_ids
), there are fewer than target_employee_count
number of employees working during the time window. More working employees than the target_employee_count
still fulfills the requirement, but excessive staffing is minimized by the solver.
Fields | |
---|---|
start_date_time |
The start time for the coverage requirement (inclusive). If set, |
end_date_time |
The end time for the coverage requirement (exclusive). If set, |
location_id |
Location in which the employees are needed. |
shift_ids[] |
If set, the role and skill requirements are applied individually to every shift ID in this list. If shift_ids are nonempty, then |
role_requirements[] |
Required number of employees to be assigned to the specified roles during the time window. At most one |
skill_requirements[] |
Required number of employees with the specified skills that are assigned to shifts during the time window. At most one |
RoleRequirement
Required number of employees to be assigned to the specified role during the time window.
Fields | |
---|---|
role_id |
Role ID for the requirement. |
target_employee_count |
Desired number of employees assigned to the role during the time window. |
priority |
Priority level for this requirement constraint. The default priority for all resource constraints is |
SkillRequirement
Required number of employees that are working during the time window and possess the specified skill.
Fields | |
---|---|
skill_id |
Skill ID for the requirement. |
target_employee_count |
Desired number of employees with the given skill that are working during the time window. |
priority |
Priority level for this requirement constraint. The default priority for all resource constraints is |
DemandCoverageViolation
Specifies the demand coverage violation for the given interval. The employee demand is the same throughout the entire specified interval.
Fields | |
---|---|
start_date_time |
Start date and time of the demand interval (inclusive). This value is specified down to the minute. |
end_date_time |
End date and time of the demand interval (exclusive). This value is specified down to the minute. |
coverage_violation |
Coverage violation during the specified interval. A positive value indicates that the demand is overcovered, and a negative value indicates that the demand is undercovered. |
Employee
An employee from the workforce to be scheduled.
Fields | |
---|---|
id |
Unique ID assigned to this employee. |
role_ids[] |
Role IDs that this employee can perform. There must be at least one role specified. When an employee is assigned to a shift, they are also assigned to a single role from this list. The employee may be assigned to different roles during the scheduling window. |
skill_ids[] |
Skill IDs that this employee possesses. This list can be empty. When an employee is assigned to a shift, they use any subset of the skills listed here to cover skill requirements throughout the duration of the assigned shift. |
shift_preferences[] |
Shift preferences of this employee. The shifts specified here represent shifts the employee would prefer to be assigned to during the scheduling window. The shift IDs specified in |
scheduling_constraints[] |
List of scheduling constraints for this employee. The default priority level for each of these constraints is |
resource_constraints[] |
Any additional scheduling constraints not specified in |
shift_requests[] |
List of shift requests for the employee. The request can be for an employee to be assigned or not assigned to specific shifts. Any fixed scheduling assignments for the employee can be represented with a |
hourly_contract |
Contract that specifies regular and overtime hourly rates for the employee. |
EmployeeDemand
Specifies the number of employees required to cover the demand in the given DateTime interval.
Fields | |
---|---|
start_date_time |
Start of the time interval for the given demand (inclusive). These values are read down to the minute; seconds and all smaller units are ignored. |
end_date_time |
End of the time interval for the given demand (exclusive). These values are read down to the minute; seconds and all smaller units are ignored. |
employee_count |
Number of employees needed to cover the demand for this interval. |
EmployeeSchedule
An ordered list of shifts corresponding to a single ShiftTemplate
that is to be assigned to a number of employees.
Fields | |
---|---|
shift_template_id |
ID of the template that was used to generate this set of shifts. |
shifts[] |
List of shifts to which |
employee_count |
Number of employees that should be assigned to this set of shifts to cover the demand. |
ShiftWithEvents
Specifies the start and end date along with a list of fixed events of a shift generated by the solver.
Fields | |
---|---|
start_date_time |
Start date and time of the shift. This value is specified down to the minute; seconds and smaller units are not given. |
end_date_time |
End date and time of the shift. This value is specified down to the minute; seconds and smaller units are not given. |
events[] |
List of events included in this shift, mapped exactly to, and in the same order as, the |
Event
Specifies the start and end DateTime of a specific event in a shift generated by the solver.
Fields | |
---|---|
event_template_id |
ID of the template that was used to generate this event. |
start_date_time |
Start date and time of the event. This value is specified down to the minute; seconds and smaller units are not given. |
end_date_time |
End date and time of the event. This value is specified down to the minute; seconds and smaller units are not given. |
EventTemplate
Template specifying rules for generating a single event that occurs during a shift. An event may represent a meeting, break, lunch, etc.
Fields | |
---|---|
id |
Unique ID of this template. |
minimum_minutes_after_shift_start |
Minimum number of minutes after the beginning of a shift that this event can start. |
maximum_minutes_after_shift_start |
Maximum number of minutes after the beginning of a shift that this event can start. |
duration_minutes |
Fixed duration in minutes of this event. |
start_time_increment_minutes |
The time increment (in minutes) used to generate the set of possible event start times between |
HourlyContract
Specifies a base hourly rate, rate differentials, and overtime multipliers to determine the compensation for an employee. Note regulations in different places might require a different computation of overtime compensation. The solver approximates the overtime compensation to either minimize a proxy of the total cost or meet a budget (see BudgetRequirement
). It is not intended as a tool to compute payroll.
Fields | |
---|---|
base_hourly_rate |
The compensation for working a non-overtime hour. If multiple rates apply to the employee, rate differentials are applied relative to this base hourly rate. Additionally, if there are multiple rates, the base hourly rate should be the minimum of these rates. |
hourly_rate_shift_differentials |
The hourly rate differential, paid on top of the |
overtime_periods[] |
A list of all periods for which overtime has to be computed. These periods must not overlap. |
OvertimePeriod
A fixed and regularly recurring period (typically 168 hours or seven consecutive 24-hour periods) that is used to determine the amount of overtime compensation. Each period has an overtime multiplier (e.g., 1.5) relative to the base_hourly_rate
and a limit on the number of hours that are considered regular (non-overtime) work. Any shift that overlaps with the start_date_time
(inclusive) and end_date_time
(exclusive) time window is counted towards the total number hours worked in the period. If the overlap is partial, only the overlapping hours are counted.
Fields | |
---|---|
overtime_multiplier |
Multiplier to compute the overtime hourly rate (must be greater or equal to 1.0). The overtime hourly rate will typically be computed as |
start_date_time |
Start time for the overtime period. If a shift overlaps this time, the hours of such a shift are counted from |
end_date_time |
End time for the overtime period. If a shift overlaps this time, the hours of such a shift are counted up to |
maximum_regular_hours |
Maximum number of working hours that are paid at a regular (non-overtime) rate. This quantity must be positive. |
Priority
The priority level for any constraint on an employee's schedule or the coverage requirements. These include SchedulingConstraint
, ResourceConstraint
, ShiftRequest
, and CoverageRequirement
. Because there could be conflicting constraints, it is not always possible to satisfy every constraint. As such, each type of constraint has a priority (given by the user or a default) that informs the solver about the relative importance of all the constraints given to a complete schedule.
Enums | |
---|---|
PRIORITY_UNSPECIFIED |
Unknown priority level. |
PRIORITY_LOW |
The lowest priority level. Constraints with this priority are less important that the other constraints. They are the first to be considered for violation if a feasible solution cannot be found. |
PRIORITY_MEDIUM |
Priority level medium. Constraints with this priority are more important than constraints with PRIORITY_LOW priority but less important than constraints with PRIORITY_HIGH priority. If a feasible solution cannot be found after relaxing all constraints with PRIORITY_LOW priority, then constraints of PRIORITY_MEDIUM priority are considered next for violation. |
PRIORITY_HIGH |
The highest priority level. Constraints with this priority level are the most important. They are the last to be considered for violation if a feasible solution cannot be found after relaxing constraints of the lower priority levels. |
PRIORITY_MANDATORY |
Priority level that represents something that cannot be violated by the solver. If the solver is returning SolutionStatus.INFEASIBLE , it may be due to too many PRIORITY_MANDATORY constraints. |
ResourceConstraint
A general constraint that limits the amount of a certain "resource" used by an employee. This is an abstract version of the more specific SchedulingConstraint
that is more flexible for the user. Many scheduling constraints that cannot be specified in the SchedulingConstraint.type
can be specified using this message instead.
Fields | |
---|---|
priority |
Priority level of this resource constraint. The default priority for all resource constraints is |
resource_usages |
Amount of resource used by shifts. For example, if this constraint applies to the minimum and maximum hours worked by an employee in a specific week, then this map will contain the shifts that occur in that week and the length of each shift in hours. |
minimum_resource_usage |
Minimum resource usage for a resource constraint to be satisfied. |
maximum_resource_usage |
Maximum resource usage for a resource constraint to be satisfied. |
SchedulingConstraint
Specific scheduling constraint for a particular employee. The constraint specified is only applied during the given interval [start_date_time,
end_date_time)
.
Fields | |
---|---|
priority |
Priority level for this scheduling constraint. The default priority for all scheduling constraints is |
start_date_time |
The start time for when this scheduling constraint applies (inclusive). |
end_date_time |
The end time for when this scheduling constraint applies (exclusive). |
Union field type . The type of constraint being specified. Each constraint is only applied within the time window specified above. type can be only one of the following: |
|
minimum_minutes |
Minimum number of minutes the employee can work. If the employee is assigned to a shift that overlaps (fully or partially) the time window, the number of minutes that the shift overlaps the time window is included in this count. |
maximum_minutes |
Maximum number of minutes the employee can work in the time window. If the employee is assigned to a shift that overlaps (fully or partially) the time window, the number of minutes that the shift overlaps the time window is included in this count. |
minimum_consecutive_work_days |
Minimum number of consecutive days the employee can work. An employee works on a specific day if they are assigned to a shift that starts during that day. Any shift that the employee is assigned to that begins in the time window is included in this count. |
maximum_consecutive_work_days |
Maximum number of consecutive days the employee can work. An employee works on a specific day if they are assigned to a shift that starts during that day. Any shift that the employee is assigned to that begins in the time window is included in this count. |
minimum_shift_count |
Minimum number of shifts the employee can work. Any shift that the employee is assigned to that fully overlaps with the time window is included in this count. |
maximum_shift_count |
Maximum number of shifts the employee can work. Any shift that the employee is assigned to that fully overlaps with the time window is included in this count. |
minimum_rest_minutes |
Minimum number of minutes the employee must rest after the end of one shift before being assigned to another shift. This constraint applies to every pair of shifts that are fully included in [ |
Shift
A shift specifies a fixed time window in which employees can work.
Fields | |
---|---|
id |
Unique ID assigned to this shift. |
location_id |
Location ID in which this shift is worked. This can be empty. |
start_date_time |
The start time of the shift (inclusive). |
end_date_time |
The end time of the shift (exclusive). Currently, the solver only allows for shifts that are less than 24hrs in length. |
break_rules[] |
A list of break rules that occur during the shift. Employees doing this shift are assigned a break per |
ShiftAssignment
An employee to shift-role assignment.
Fields | |
---|---|
employee_id |
The employee ID being assigned. |
shift_id |
Shift ID assigned to the employee. |
role_id |
Role ID the employee is assigned to for the shift. |
breaks[] |
List of breaks for this shift assignment. |
ShiftGenerationSolutionStatus
Solution status provided in the response of a solver.
Enums | |
---|---|
SHIFT_GENERATION_SOLUTION_STATUS_UNSPECIFIED |
Unspecified status for the response. |
SHIFT_GENERATION_SOLVED |
The solver found a solution in the time limit provided. |
SHIFT_GENERATION_NOT_SOLVED |
An issue prevented the solver from generating shifts. |
SHIFT_GENERATION_NOT_SOLVED_DEADLINE_EXCEEDED |
Shifts could not be generated to cover the demand within the time limit given. |
ShiftPreference
A numeric preference for a particular shift ID.
Fields | |
---|---|
shift_id |
Shift ID for which the preference is specified. |
preference |
Larger values of preference denote a more desirable shift. |
ShiftRequest
An employee's request to be assigned or not be assigned to specific shifts.
Fields | |
---|---|
priority |
Priority level of this scheduling request. The default priority for all scheduling requests is |
shift_ids[] |
The shift IDs of the scheduling request. |
type |
Request type, e.g., whether the request is be assigned or not be assigned to the set of shifts. |
ShiftTemplate
Template specifying rules for generating shifts. A shift is a unit of work that specifies a start time, end time, and may contain events (i.e. lunch, breaks, etc). A shift will be assigned to a specific date in the response.
Fields | |
---|---|
id |
Unique ID of this template. |
earliest_start_time |
Earliest time in the day that a shift can start. This value is specified with hours and minutes; seconds and nanos are ignored. |
latest_start_time |
Latest time in the day that a shift can start. This value is specified with hours and minutes; seconds and nanos are ignored. If this value is less than the |
duration_minutes |
Fixed duration of a shift generated by this template. |
start_time_increment_minutes |
The time increment (in minutes) used to generate the set of possible start times between |
days_off_count_per_week |
Fixed number of days off per week. An employee has a given day off if they are not assigned to a shift that starts on that day. A week is 7 days and begins on Sunday. |
event_templates[] |
Rules for generating events for each shift. Exactly one event will be included in each shift for each Event specified. |
minimum_interevent_gap_minutes |
Minimum minutes between the end of one event and the start of the next. |
maximum_employee_count |
Maximum number of employees that can be assigned to all shifts generated by this template. |
SolutionStatus
Solution (i.e., a schedule) status provided in the response of a solver.
Enums | |
---|---|
SOLUTION_STATUS_UNSPECIFIED |
Unspecified status for the response. |
FEASIBLE |
The returned schedule is feasible, but might not be optimal. |
OPTIMAL |
The returned schedule is optimal. |
INFEASIBLE |
No feasible schedule exists for the given constraints. The solver may return this value if any subset of the constraints with priority level PRIORITY_MANDATORY cannot be satisfied. |
NOT_SOLVED |
No schedule was found. |
NOT_SOLVED_DEADLINE_EXCEEDED |
No schedule was found within the time limit given. |
SolveParameters
Parameters that control a single solve of the shift scheduling problem.
Fields | |
---|---|
time_limit |
Maximum time the solver should spend on the problem. If not set, defaults to 1 minute. This value is not a hard limit and it does not account for the communication overhead. The expected latency to solve the problem may slightly exceed this value. |
SolverConfig
Specifies additional parameters for solving the Shift Generation problem.
Fields | |
---|---|
time_limit |
Maximum time the solver should spend on the problem. If not set, defaults to 1 minute. The choice of a time limit should depend on the size of the problem. To give an example, when solving a 7-day instance with 2 This value is not a hard limit and it does not account for the communication overhead. The expected latency to solve the problem may slightly exceed this value. |
multi_day_schedule |
If true, the solver generates |
shift_events_can_change |
If true, multi-day |
WorkStatus
Whether an employee is working or not.
Enums | |
---|---|
WORK_STATUS_UNSPECIFIED |
Unknown work status. |
STATUS_WORK |
Status representing a working employee. |
STATUS_NOT_WORK |
Status representing a non-working employee. |