餐廳排程

假設某間餐廳規劃每週的廚房時間表。餐廳的交通運輸時間為週一至週五 12 小時到 23 小時。這五位員工可以執行三個角色:Station chefHead chefSous 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-01Tuesday-2023-05-02Wednesday-2023-05-03Thursday-2023-05-04Friday-2023-05-05Station chefSous 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"
      }
    ]
  }