假设某家餐馆规划厨房每周时间表。通过
餐馆轮班时间是周一至周五的 12 小时到 23 小时。共有五种
可担任三个角色的员工:Station chef
、Head chef
和 Sous
chef
。每个班次都需要有两名员工担任高优先级的Station
chef
,以及一名担任中等优先级的Sous chef
的员工。
优先级。此外,周二和周五必须提供Head chef
中优先级。唯一一个调度限制适用于
有 Liam
名员工,他们要求在“星期三-2023-05-03”工作,但没有
负责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"
}]
}
]
}
员工请求
员工请求用 shift request 表示
字段。在这个例子中,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"
}
]
}]
}
示例:全部五名员工
{
"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"
}
]
}