# Workforce Scheduling

The Workforce Scheduling API offers two solvers using the
[SolveShiftGeneration](https://developers.google.com/optimization/service/reference/rest/v1/scheduling/solveShiftGeneration) and [SolveShiftScheduling](https://developers.google.com/optimization/service/reference/rest/v1/scheduling/solveShiftScheduling) methods. The shift
generation solver creates a set of shifts that maximizes coverage of employee
demands over a given time horizon. In contrast, the shift scheduling solver
assigns specific employees to a set of predetermined shifts. Each solver can be
used independently. In particular, the shifts to which employees are assigned in
the shift scheduling solver could be specified by the user or could be generated
with the shift generation solver.

## Shift generation solver

The shift generation solver selects a set of shifts such that the total number
of employees required to cover a given demand profile is minimized.

The input of the solver is a [request](https://developers.google.com/optimization/service/reference/rest/v1/scheduling/solveShiftGeneration#request-body) that describes shift templates and
employee demands. Shift templates determine the rules that the solver must
follow to create shifts. Employee demands describe the number of employees
overtime, with a time granularity as short as 1 minute.

The output of the solver is a [response](https://developers.google.com/optimization/service/reference/rest/v1/scheduling/solveShiftGeneration#response-body) with a list of shifts and the
corresponding number of required employees per shift. Whenever it is not
possible to cover all demands, a list of demand coverage violations is also
provided to the user for convenience.

### Features

For an in depth explanation of every feature of the solver, refer to the [API
documentation](https://developers.google.com/optimization/service/reference/rest/v1/scheduling/solveShiftGeneration). The following summarizes the most popular features of the
solver.

#### Shift templates

A shift template primarily determines the duration and potential start times for
a shift on any given day. Additionally, it is possible to specify a maximum
number of employees per shift template per day and the number of days off per
week.

Shift templates can also specify a list of event templates to represent
scheduled interruptions such as breaks or employee trainings. Event templates
determine the start time (relative to the shift start time) and the length of an
event.

#### Employee demand fluctuations

Demand for employees can fluctuate over time. In particular, employee demands
can be specified over time intervals as short as 5 minutes or as long as the
planning horizon. Time intervals for which there is not a specified demand are
equivalent to having a demand of zero employees.

## Shift scheduling solver

The shift scheduling solver optimizes the assignment of employees to shifts so
that scheduling constraints are met (or violations thereof are minimized) and
employee preferences are taken into consideration.

The input to the solver is a [request](https://developers.google.com/optimization/service/reference/rest/v1/scheduling/solveShiftScheduling#request-body) that describes employees, shifts,
coverage requirements, and budget requirements. For each employee, roles, skills
and scheduling constraints can be specified to define what a valid schedule per
employee looks like. Shifts determine when and where employees can work, while
coverage requirements determine the demand for different employee roles (and
skills) over several time spans.

The output of the solver is a [response](https://developers.google.com/optimization/service/reference/rest/v1/scheduling/solveShiftScheduling#response-body) with employee-shift-role assignments
that summarizes for every employee, the shifts and role (by shift) to which they
are assigned.

### Features

For an in depth explanation of every feature of the solver, refer to the [API
documentation](https://developers.google.com/optimization/service/reference/rest/v1/scheduling/solveShiftScheduling). The following summarizes the most popular features of the
solver.

#### Employee scheduling constraints

Specifies rules or limits that the schedule of a particular employee should
satisfy. In particular, it supports:

- Minimum / Maximum working time
- Minimum / Maximum consecutive days
- Minimum / Maximum number of shifts
- Minimum rest time between shifts
- Resource constraints
- Shift requests to work (or not) on specific shifts

#### Employee preferences

Specifies a numeric preference that an employee has for a specific shift, and
the sum of preferences across the roster is maximized.

#### Coverage requirements

Specifies a number of employees that are required to be working over several
time windows and for specific roles. Coverage requirements can align with the
given list of shifts, but they can also define more fine-grained time windows of
the required number of working employees.

#### Budget requirements

Specifies a contract for the employees with regular and overtime hourly rates,
coupled with global budget constraints. A budget can either be a maximum value
for workforce costs or an indication that such a cost needs to be minimized.

#### Constraint priorities

Every employee scheduling constraint, coverage requirement and budget
requirement is given a priority level (mandatory, high, medium, or low). All
constraints with a mandatory priority must be satisfied by the solver.
Constraints with any other priority can be violated by the solver, but these
violations are minimized according to the priority order. Employee preferences
are considered by the solver after constraint violations in every priority level
have been minimized.

## How to get started

To get access to the Workforce Scheduling API, follow the [trusted testers](https://developers.google.com/optimization/service/trusted_testers)
instructions and then follow the [setup](https://developers.google.com/optimization/service/setup) guide to obtain an API key. After
obtaining access to the API, use the [API examples](https://developers.google.com/optimization/service/scheduling/shift_scheduling_example) to get started. Should
you have questions, contact [or-workforce-scheduling+contact@google.com](mailto:or-workforce-scheduling+contact@google.com).