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 | |
---|---|
solver |
Optional. Parameters for the solver. |
shift |
Required. Set of shift templates specifying rules for generating shifts. |
employee |
Required. Total employee demand that the shifts generated by |
employees[] |
Optional. Additional employee information that should be considered when generating shifts. |
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 exceedmaximumEmployeeCount
of that template. - The set of assigned employees cover the demand at every given time interval, or the uncovered demand is minimal.
- The overlap between events and
UnwantedEventInterval
s is minimal.
If successful, the response body contains data with the following structure:
JSON representation |
---|
{ "solutionStatus": enum ( |
Fields | |
---|---|
solution |
Status of the returned solution. If |
employee |
Set of shifts generated by the solver along with the number of employees assigned to each schedule. |
demand |
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 | |
---|---|
time |
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 ' |
multi |
If true, the solver generates |
shift |
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. |
earliest |
Earliest time in the day that a shift can start. This value is specified with hours and minutes; seconds and nanos are ignored. |
latest |
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 |
Fixed duration of a shift generated by this template. |
start |
The time increment (in minutes) used to generate the set of possible start times between |
days |
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. If this field is present, |
days |
A list of distinct dates in which shifts from this template are not generated. If this field is present, |
event |
Rules for generating events for each shift. Exactly one event will be included in each shift for each Event specified. |
minimum |
Minimum minutes between the end of one event and the start of the next. |
minimum |
Minimum number of employees that can be assigned to all shifts generated by this template on working days. |
maximum |
Maximum number of employees that can be assigned to all shifts generated by this template on working days. |
assignable |
[Optional] A list of specific employee IDs that can be assigned to shifts generated by this template. If this field is present, there will be |
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 a day in 24 hour format. Must be greater than or equal to 0 and typically must be less than or equal to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time. |
minutes |
Minutes of an hour. Must be greater than or equal to 0 and less than or equal to 59. |
seconds |
Seconds of a minute. Must be greater than or equal to 0 and typically must be less than or equal to 59. An API may allow the value 60 if it allows leap-seconds. |
nanos |
Fractions of seconds, in nanoseconds. Must be greater than or equal to 0 and less than or equal to 999,999,999. |
Date
Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following:
- A full date, with non-zero year, month, and day values.
- A month and day, with a zero year (for example, an anniversary).
- A year on its own, with a zero month and a zero day.
- A year and month, with a zero day (for example, a credit card expiration date).
Related types:
JSON representation |
---|
{ "year": integer, "month": integer, "day": integer } |
Fields | |
---|---|
year |
Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year. |
month |
Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day. |
day |
Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant. |
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. |
minimum |
Minimum number of minutes after the beginning of a shift that this event can start. |
maximum |
Maximum number of minutes after the beginning of a shift that this event can start. |
duration |
Fixed duration in minutes of this event. |
start |
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. The length of the interval must be strictly positive.
JSON representation |
---|
{ "startDateTime": { object ( |
Fields | |
---|---|
start |
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 |
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 |
Number of employees needed to cover the demand for this interval. |
EmployeeInfo
Information for a particular employee regarding unwanted event intervals.
JSON representation |
---|
{
"id": string,
"unwantedEventIntervals": [
{
object ( |
Fields | |
---|---|
id |
Unique ID of this employee. |
unwanted |
A list of unwanted event intervals for this employee. The start time of the interval must be in the planning horizon. |
UnwantedEventInterval
Specifies a time interval during which the overlap with events (generated from event templates) should be minimal.
JSON representation |
---|
{
"startDateTime": {
object ( |
Fields | |
---|---|
start |
Start time of the event. |
duration |
Duration of the event. |
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
. If the shift template used to generate this schedule has assignableEmployeeIds
, then this schedule has a specific employee ID (see employeeId
). Otherwise (assignableEmployeeIds
is empty), the schedule needs to be assigned to employeeCount
employees and no specific employee ID is given.
JSON representation |
---|
{
"shiftTemplateId": string,
"shifts": [
{
object ( |
Fields | |
---|---|
shift |
ID of the template that was used to generate this set of shifts. |
shifts[] |
List of shifts to which |
employee |
Number of employees that should be assigned to this set of shifts to cover the demand. |
employee |
ID of the employee to which this schedule is assigned. This field is present if and only if the |
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 | |
---|---|
start |
Start date and time of the shift. This value is specified down to the minute; seconds and smaller units are not given. |
end |
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 | |
---|---|
event |
ID of the template that was used to generate this event. |
start |
Start date and time of the event. This value is specified down to the minute; seconds and smaller units are not given. |
end |
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 | |
---|---|
start |
Start date and time of the demand interval (inclusive). This value is specified down to the minute. |
end |
End date and time of the demand interval (exclusive). This value is specified down to the minute. |
coverage |
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. |