Solves a shift generation problem from the given SolveShiftGenerationRequest
by generating shifts from given shift templates in order to cover the employee demand.
HTTP request
POST https://optimization.googleapis.com/v1/scheduling:solveShiftGeneration
The URL uses gRPC Transcoding syntax.
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "solverConfig": { object ( |
Fields | |
---|---|
solverConfig |
Optional. Parameters for the solver. |
shiftTemplates[] |
Required. Set of shift templates specifying rules for generating shifts. |
employeeDemands[] |
Required. Total employee demand that the shifts generated by |
Response body
Response for the Shift Generation problem. If the solutionStatus
returned is SOLVED
, then a set of valid shifts generated by the solver are returned in employeeSchedules
. For a valid shift schedule, the following properties hold:
- Each shift generated in
employeeSchedules
adheres to the rules specified in the correspondingShiftTemplate
. - Each event selected in each shift adheres to the rules specified in the corresponding
ShiftTemplate.Event
. - The total number of employees assigned to the set of shifts generated from the same ShiftTemplate does not exceed
maximumEmployeeCount
of that template. - The set of assigned employees cover the demand at every given interval.
If successful, the response body contains data with the following structure:
JSON representation |
---|
{ "solutionStatus": enum ( |
Fields | |
---|---|
solutionStatus |
Status of the returned solution. If |
employeeSchedules[] |
Set of shifts generated by the solver along with the number of employees assigned to each schedule. |
demandCoverageViolations[] |
Demand coverage violations based on the assigned |
SolverConfig
Specifies additional parameters for solving the Shift Generation problem.
JSON representation |
---|
{ "timeLimit": string, "multiDaySchedule": boolean, "shiftEventsCanChange": boolean } |
Fields | |
---|---|
timeLimit |
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. A duration in seconds with up to nine fractional digits, ending with ' |
multiDaySchedule |
If true, the solver generates |
shiftEventsCanChange |
If true, multi-day |
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.
JSON representation |
---|
{ "id": string, "earliestStartTime": { object ( |
Fields | |
---|---|
id |
Unique ID of this template. |
earliestStartTime |
Earliest time in the day that a shift can start. This value is specified with hours and minutes; seconds and nanos are ignored. |
latestStartTime |
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 |
durationMinutes |
Fixed duration of a shift generated by this template. |
startTimeIncrementMinutes |
The time increment (in minutes) used to generate the set of possible start times between |
daysOffCountPerWeek |
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. |
eventTemplates[] |
Rules for generating events for each shift. Exactly one event will be included in each shift for each Event specified. |
minimumIntereventGapMinutes |
Minimum minutes between the end of one event and the start of the next. |
maximumEmployeeCount |
Maximum number of employees that can be assigned to all shifts generated by this template. |
TimeOfDay
Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may choose to allow leap seconds. Related types are google.type.Date
and google.protobuf.Timestamp
.
JSON representation |
---|
{ "hours": integer, "minutes": integer, "seconds": integer, "nanos": integer } |
Fields | |
---|---|
hours |
Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time. |
minutes |
Minutes of hour of day. Must be from 0 to 59. |
seconds |
Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds. |
nanos |
Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999. |
EventTemplate
Template specifying rules for generating a single event that occurs during a shift. An event may represent a meeting, break, lunch, etc.
JSON representation |
---|
{ "id": string, "minimumMinutesAfterShiftStart": integer, "maximumMinutesAfterShiftStart": integer, "durationMinutes": integer, "startTimeIncrementMinutes": integer } |
Fields | |
---|---|
id |
Unique ID of this template. |
minimumMinutesAfterShiftStart |
Minimum number of minutes after the beginning of a shift that this event can start. |
maximumMinutesAfterShiftStart |
Maximum number of minutes after the beginning of a shift that this event can start. |
durationMinutes |
Fixed duration in minutes of this event. |
startTimeIncrementMinutes |
The time increment (in minutes) used to generate the set of possible event start times between |
EmployeeDemand
Specifies the number of employees required to cover the demand in the given DateTime interval.
JSON representation |
---|
{ "startDateTime": { object ( |
Fields | |
---|---|
startDateTime |
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. |
endDateTime |
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. |
employeeCount |
Number of employees needed to cover the demand for this interval. |
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. |
EmployeeSchedule
An ordered list of shifts corresponding to a single ShiftTemplate
that is to be assigned to a number of employees.
JSON representation |
---|
{
"shiftTemplateId": string,
"shifts": [
{
object ( |
Fields | |
---|---|
shiftTemplateId |
ID of the template that was used to generate this set of shifts. |
shifts[] |
List of shifts to which |
employeeCount |
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.
JSON representation |
---|
{ "startDateTime": { object ( |
Fields | |
---|---|
startDateTime |
Start date and time of the shift. This value is specified down to the minute; seconds and smaller units are not given. |
endDateTime |
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.
JSON representation |
---|
{ "eventTemplateId": string, "startDateTime": { object ( |
Fields | |
---|---|
eventTemplateId |
ID of the template that was used to generate this event. |
startDateTime |
Start date and time of the event. This value is specified down to the minute; seconds and smaller units are not given. |
endDateTime |
End date and time of the event. This value is specified down to the minute; seconds and smaller units are not given. |
DemandCoverageViolation
Specifies the demand coverage violation for the given interval. The employee demand is the same throughout the entire specified interval.
JSON representation |
---|
{ "startDateTime": { object ( |
Fields | |
---|---|
startDateTime |
Start date and time of the demand interval (inclusive). This value is specified down to the minute. |
endDateTime |
End date and time of the demand interval (exclusive). This value is specified down to the minute. |
coverageViolation |
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. |