The shift assignment app is available in two modeling languages as a Mixed Integer Problem (MIP). You can also choose to make customizations to the model by instantiating the app first.
- OR-Tools
- Default solver:
SCIP - Marketplace subscription app IDs
- Python:
nextmv-shift.assign.ortools
- Python:
- Default solver:
- Pyomo
- Default solver:
CBC - Marketplace subscription app IDs
- Python:
nextmv-shift.assign.pyomo
- Python:
- Default solver:
Once you have the code locally, you can customize the model, run it locally and deploy it to Nextmv Platform.
Input
The format for timestamps should be RFC3339, e.g.: "2023-01-01T00:00:00Z".
The input schema is a JSON payload defining the available workers and the required demand to satisfy for a shift scheduling problem. Nextmv's tools are designed to operate directly on business data (in JSON) to produce decisions that are actionable by software systems. This makes decisions more interpretable and easier to test. It also makes integration with data warehouses and business intelligence platforms significantly easier. An input contains the following components:
| Field name | Required | Data type | SI Unit | Description | Example |
|---|---|---|---|---|---|
workers | Yes | array of worker | NA | Workers to assign. | See worker |
shifts | Yes | array of shift | NA | Available shifts with some additional properties. | See shift |
rules | Yes | array of rule | NA | Defines a set of rules to obey. | See rule |
Here you can find a sample .json with the input schema:
Worker
A worker is used in the input schema.
| Field name | Required | Data type | Description | Example |
|---|---|---|---|---|
availability | Yes | array of availability | The availability times of the worker | See availability |
id | Yes | string | ID for the worker. | {"id": "1"} |
rules | Yes | string | ID of a rule to comply with (see rule). | {"rules": ["foo", "bar"]} |
qualifications | Yes | array of string | A set of qualifications/skills a worker has. | {"qualifications": ["foo", "bar"]} |
preferences | Yes | map of string to int | Defines preferred shifts, a higher number means more important. | "preferences": {"shift1": "1"} |
Availability
Availability is used in the worker schema.
| Field name | Required | Data type | SI Unit | Description | Example |
|---|---|---|---|---|---|
start_time | Yes | timestamp | NA | The start of an availability time window for a worker. | {"start_time": "2023-01-01T00:00:00Z"} |
end_time | Yes | timestamp | NA | The end of an availability time window for a worker. | {"end_time": "2023-01-01T00:00:00Z"} |
Shift
Shift is used in the input schema.
| Field name | Required | Data type | Description | Example |
|---|---|---|---|---|
start_time | Yes | timestamp | The start time of a shift. | {"start": "2023-01-01T00:00:00Z"} |
end_time | Yes | timestamp | The end time of a shift. | {"end": "2023-01-01T00:00:00Z"} |
count | Yes | int | The number of workers needed for the shift. | {"count": 1} |
shift_id | Yes | string | ID of the shift type. | {"shift_id": "1"} |
time_id | Yes | string | ID of the shift type and time combination. | {"time_id": "1"} |
qualification | Yes | string | The qualification needed to work this shift. | {"qualification": "1"} |
Rule
Rule is used in the input schema.
| Field name | Required | Data type | Description | Example |
|---|---|---|---|---|
id | Yes | string | ID of the rule. | {"id": "1"} |
min_rest_hours_between_shifts | Yes | integer | Defines the number of hours a worker must rest between shifts. | {"min_rest_hours_between_shifts": 1} |
Output
The output schema defines the solution to the shift assignment problem in JSON format. The output schema contains the following components.
| Field name | Always present | Data type | SI Unit | Description | Example |
|---|---|---|---|---|---|
solutions | Yes | array of solution | NA | Solutions to the shift assignment problem. | {"solutions": []} |
statistics | Yes | statistics | NA | Summary statistics of the solution. | {"statistics": {"total_cost": 123}} |
Solution
| Field name | Always present | Data type | SI Unit | Description | Example |
|---|---|---|---|---|---|
planned_shifts | Yes | array of planned_shift | NA | Solution to the shift scheduling problem. | {"planned_shifts": []} |
Planned shift
| Field name | Always present | Data type | SI Unit | Description | Example |
|---|---|---|---|---|---|
start_time | Yes | timestamp | NA | Start time of the shift | {"start_time": "2023-01-01T00:00:00Z"} |
end_time | Yes | timestamp | NA | End time of the shift | {"end_time": "2023-01-01T00:00:00Z"} |
id | Yes | string | NA | The ID of shift, time and qualification combination. | {"id": "1"} |
Statistics
| Field name | Always present | Data type | SI Unit | Description | Example |
|---|---|---|---|---|---|
result | No | result | NA | Final result of the solutions. | See result |
run | Yes | run | NA | Information about the run. | See run |
schema | Yes | string | NA | Schema of the statistics. | {"schema": "v1"} |
Here you can find additional definitions used in the statistics schema:
resultField name Always present Data type SI Unit Description Example durationYes floatsecondsTime duration to get to the final result. {"duration": 0.123}valueYes floatNA Value of the final result. {"value": 0.123}customYes anyNA Custom solver metrics. See customrunField name Always present Data type SI Unit Description Example durationYes floatsecondsTime duration of the run. {"duration": 0.123}customField name Always present Data type SI Unit Description Example constraintsYes intNA Number of constraints. {"constraints": 123}providerYes stringNA Solver provider. {"provider": "SCIP"}statusYes stringNA Solver status. {"status": "optimal"}variablesYes intNA Number of variables. {"variables": 123}
Run options
These are the default options that are available with shift assignment.