Piensa en un restaurante que planifica horarios semanales para la cocina. El
los turnos en los restaurantes son de lunes a viernes, de 12 a.m. a 23 p.m. Existen cinco
empleados que pueden realizar tres funciones: Station chef
, Head chef
y Sous
chef
. En cada turno, tiene que haber dos empleados que trabajen como Station
chef
con prioridad alta y otro que trabaje como Sous chef
con
prioridad. Además, se requiere un Head chef
los martes y viernes con
prioridad media. La única otra restricción de programación es para uno de los
empleados, Liam
, que solicitaron trabajo el “miércoles-2023-05-03”, pero no para
trabajar en el cambio Friday-2023-05-05
.
Cobertura de funciones para cada turno
Se puede especificar la cobertura de un rol específico para un conjunto determinado de turnos con una requisito de cobertura. Por ejemplo, el primer cambio de este problema puede representarse de la siguiente manera:
{
"shifts": [
{
"id": "Monday-2023-05-01",
"startDateTime": {
"year": 2023,
"month": 5,
"day": 1,
"hours": 12
},
"endDateTime": {
"year": 2023,
"month": 5,
"day": 1,
"hours": 23
}
}
]
}
Si suponemos que los cinco turnos son: Monday-2023-05-01
, Tuesday-2023-05-02
,
Wednesday-2023-05-03
, Thursday-2023-05-04
y Friday-2023-05-05
, el
se representa el requisito de cobertura para los roles de Station chef
y Sous chef
como:
{
"coverageRequirements": [{
"shiftIds": ["Monday-2023-05-01", "Tuesday-2023-05-02",
"Wednesday-2023-05-03", "Thursday-2023-05-04",
"Friday-2023-05-05"]
"roleRequirements": [{
"roleId": "Station chef",
"targetEmployeeCount": 2,
"priority": "PRIORITY_HIGH"
}, {
"roleId": "Sous chef",
"targetEmployeeCount": 1,
"priority": "PRIORITY_MEDIUM"
}]
}
]
}
Para considerar el requisito de una Head chef
, se agrega una cobertura adicional
del requerimiento de cambios
en los cambios necesarios. La lista completa de
de cobertura es:
{
"coverageRequirements": [{
"shiftIds": ["Monday-2023-05-01", "Tuesday-2023-05-02",
"Wednesday-2023-05-03", "Thursday-2023-05-04",
"Friday-2023-05-05"],
"roleRequirements": [{
"roleId": "Station chef",
"targetEmployeeCount": 2,
"priority": "PRIORITY_HIGH"
}, {
"roleId": "Sous chef",
"targetEmployeeCount": 1,
"priority": "PRIORITY_MEDIUM"
}]
},
{
"shiftIds": ["Tuesday-2023-05-02", "Friday-2023-05-05"],
"roleRequirements": [{
"roleId": "Head chef",
"targetEmployeeCount": 1,
"priority": "PRIORITY_MEDIUM"
}]
}
]
}
Solicitudes de empleados
Las solicitudes de los empleados se representan con la solicitud de turnos.
. En este ejemplo, Liam
solicitó trabajar en el turno del miércoles, pero
no trabajará en el turno del viernes. Está representado (junto con sus roles)
como:
{
"employees": [{
"id": "Liam",
"roleIds": ["Station chef", "Head chef"],
"shiftRequests": [
{
"priority": "PRIORITY_HIGH",
"shiftIds": ["Wednesday-2023-05-03"],
"type": "STATUS_WORK"
},
{
"priority": "PRIORITY_HIGH",
"shiftIds": ["Friday-2023-05-05"],
"type": "STATUS_NOT_WORK"
}
]
}]
}
Ejemplo con los cinco empleados
{
"employees": [
{
"id": "Liam",
"roleIds": [
"Station chef",
"Head chef"
],
"shiftRequests": [
{
"priority": "PRIORITY_HIGH",
"shiftIds": [
"Wednesday-2023-05-03"
],
"type": "STATUS_WORK"
},
{
"priority": "PRIORITY_HIGH",
"shiftIds": [
"Friday-2023-05-05"
],
"type": "STATUS_NOT_WORK"
}
]
}
, {
"id": "Olivia",
"roleIds": ["Station chef"]
}, {
"id": "Noah",
"roleIds": ["Station chef"]
}, {
"id": "Emma",
"roleIds": ["Head chef"]
}, {
"id": "Oliver",
"roleIds": ["Station chef", "Sous chef"]
}
]
}
Ejemplo de una solicitud completa
{
"employees": [
{
"id": "Liam",
"roleIds": [
"Station chef",
"Head chef"
],
"shiftRequests": [
{
"priority": "PRIORITY_HIGH",
"shiftIds": [
"Wednesday-2023-05-03"
],
"type": "STATUS_WORK"
},
{
"priority": "PRIORITY_HIGH",
"shiftIds": [
"Friday-2023-05-05"
],
"type": "STATUS_NOT_WORK"
}
]
},
{
"id": "Olivia",
"roleIds": [
"Station chef"
]
},
{
"id": "Noah",
"roleIds": [
"Station chef"
]
},
{
"id": "Emma",
"roleIds": [
"Head chef"
]
},
{
"id": "Oliver",
"roleIds": [
"Station chef",
"Sous chef"
]
}
],
"shifts": [
{
"id": "Monday-2023-05-01",
"startDateTime": {
"year": 2023,
"month": 5,
"day": 1,
"hours": 12
},
"endDateTime": {
"year": 2023,
"month": 5,
"day": 1,
"hours": 23
}
},
{
"id": "Tuesday-2023-05-02",
"startDateTime": {
"year": 2023,
"month": 5,
"day": 2,
"hours": 12
},
"endDateTime": {
"year": 2023,
"month": 5,
"day": 2,
"hours": 23
}
},
{
"id": "Wednesday-2023-05-03",
"startDateTime": {
"year": 2023,
"month": 5,
"day": 3,
"hours": 12
},
"endDateTime": {
"year": 2023,
"month": 5,
"day": 3,
"hours": 23
}
},
{
"id": "Thursday-2023-05-04",
"startDateTime": {
"year": 2023,
"month": 5,
"day": 4,
"hours": 12
},
"endDateTime": {
"year": 2023,
"month": 5,
"day": 4,
"hours": 23
}
},
{
"id": "Friday-2023-05-05",
"startDateTime": {
"year": 2023,
"month": 5,
"day": 5,
"hours": 12
},
"endDateTime": {
"year": 2023,
"month": 5,
"day": 5,
"hours": 23
}
}
],
"coverageRequirements": [
{
"shiftIds": [
"Monday-2023-05-01",
"Tuesday-2023-05-02",
"Wednesday-2023-05-03",
"Thursday-2023-05-04",
"Friday-2023-05-05"
],
"roleRequirements": [
{
"roleId": "Station chef",
"targetEmployeeCount": 2,
"priority": "PRIORITY_HIGH"
},
{
"roleId": "Sous chef",
"targetEmployeeCount": 1,
"priority": "PRIORITY_MEDIUM"
}
]
},
{
"shiftIds": [
"Tuesday-2023-05-02",
"Friday-2023-05-05"
],
"roleRequirements": [
{
"roleId": "Head chef",
"targetEmployeeCount": 1,
"priority": "PRIORITY_MEDIUM"
}
]
}
],
"roleIds": [
"Station chef",
"Head chef",
"Sous chef"
]
}
Ejemplo de respuesta
La respuesta de la resolución contiene la asignación de empleados al los turnos en los restaurantes y el estado del procedimiento de optimización. Por ejemplo, el los turnos asignados a uno de los empleados se devuelven de la siguiente manera:
{
"solutionStatus": "OPTIMAL",
"shiftAssignments": [
{
"employeeId": "Liam",
"shiftId": "Monday-2023-05-01",
"roleId": "Station chef"
},
{
"employeeId": "Liam",
"shiftId": "Tuesday-2023-05-02",
"roleId": "Station chef"
},
{
"employeeId": "Liam",
"shiftId": "Wednesday-2023-05-03",
"roleId": "Station chef"
},
{
"employeeId": "Liam",
"shiftId": "Thursday-2023-05-04",
"roleId": "Station chef"
}, ...
]
}
Ejemplo de una respuesta completa
{
"solutionStatus": "OPTIMAL",
"shiftAssignments": [
{
"employeeId": "Liam",
"shiftId": "Monday-2023-05-01",
"roleId": "Station chef"
},
{
"employeeId": "Liam",
"shiftId": "Tuesday-2023-05-02",
"roleId": "Station chef"
},
{
"employeeId": "Liam",
"shiftId": "Wednesday-2023-05-03",
"roleId": "Station chef"
},
{
"employeeId": "Liam",
"shiftId": "Thursday-2023-05-04",
"roleId": "Station chef"
},
{
"employeeId": "Olivia",
"shiftId": "Friday-2023-05-05",
"roleId": "Station chef"
},
{
"employeeId": "Noah",
"shiftId": "Monday-2023-05-01",
"roleId": "Station chef"
},
{
"employeeId": "Noah",
"shiftId": "Tuesday-2023-05-02",
"roleId": "Station chef"
},
{
"employeeId": "Noah",
"shiftId": "Wednesday-2023-05-03",
"roleId": "Station chef"
},
{
"employeeId": "Noah",
"shiftId": "Thursday-2023-05-04",
"roleId": "Station chef"
},
{
"employeeId": "Noah",
"shiftId": "Friday-2023-05-05",
"roleId": "Station chef"
},
{
"employeeId": "Emma",
"shiftId": "Tuesday-2023-05-02",
"roleId": "Head chef"
},
{
"employeeId": "Emma",
"shiftId": "Friday-2023-05-05",
"roleId": "Head chef"
},
{
"employeeId": "Oliver",
"shiftId": "Monday-2023-05-01",
"roleId": "Sous chef"
},
{
"employeeId": "Oliver",
"shiftId": "Tuesday-2023-05-02",
"roleId": "Sous chef"
},
{
"employeeId": "Oliver",
"shiftId": "Wednesday-2023-05-03",
"roleId": "Sous chef"
},
{
"employeeId": "Oliver",
"shiftId": "Thursday-2023-05-04",
"roleId": "Sous chef"
},
{
"employeeId": "Oliver",
"shiftId": "Friday-2023-05-05",
"roleId": "Sous chef"
}
]
}