假设有一家餐厅为厨房规划每周时间表。餐厅星期一至星期五 12 小时制至 23 小时制。公司共有 5 名员工,可担任三个角色:Station chef
、Head chef
和 Sous
chef
。在每个轮班中,需要有两名员工担任优先级较高的 Station
chef
,以及一名员工担任优先级为中等的 Sous chef
。此外,优先级为中等的星期二和星期五也需要使用 Head chef
。唯一其他的时间安排限制是针对其中一位请求在“2023-05-03”星期三工作的员工 Liam
,但不负责执行 Friday-2023-05-05
轮班。
适用于每次班次的角色涵盖范围
您可以针对一组给定的班次指定特定角色的覆盖率,并满足覆盖率要求。例如,此问题的第一位移可以表示为:
{
"shifts": [
{
"id": "Monday-2023-05-01",
"startDateTime": {
"year": 2023,
"month": 5,
"day": 1,
"hours": 12
},
"endDateTime": {
"year": 2023,
"month": 5,
"day": 1,
"hours": 23
}
}
]
}
假设所有五个班次均为:Monday-2023-05-01
、Tuesday-2023-05-02
、Wednesday-2023-05-03
、Thursday-2023-05-04
和 Friday-2023-05-05
,则 Station chef
和 Sous chef
角色的覆盖率要求表示为:
{
"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"
}]
}
]
}
如需考虑对 Head chef
的要求,可以针对必要的偏移指定额外的覆盖范围要求。完整的保修范围要求列表如下:
{
"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"
}]
}
]
}
员工请求
员工请求通过排班请求字段表示。在此示例中,Liam
请求在星期三的轮班上工作,但不在星期五的班次上工作。这一点(以及他的角色)表示为:
{
"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"
}
]
}]
}
包含全部 5 名员工的示例
{
"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"]
}
]
}
完整请求示例
{
"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"
]
}
响应示例
求解器的响应包含为餐厅班次分配的员工和优化程序的状态。例如,分配给其中一名员工的班次返回如下:
{
"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"
}, ...
]
}
完整响应示例
{
"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"
}
]
}