Programmare un ristorante

Prendi in considerazione un ristorante che pianifica gli orari settimanali della cucina. Il ristorante è disponibile dal lunedì al venerdì dalle 12 alle 23. Ci sono cinque dipendenti che possono ricoprire tre ruoli: Station chef, Head chef e Sous chef. A ogni turno, devono esserci due dipendenti che lavorano come Station chef con priorità alta e un dipendente come Sous chef con priorità media. Inoltre, un Head chef è obbligatorio i martedì e i venerdì con priorità media. L'unico altro vincolo di pianificazione è per uno dei dipendenti, Liam, che ha richiesto lavoro il "Mercoledì-03/05/2023", ma non per il turno di Friday-2023-05-05.

Copertura dei ruoli per ogni turno

La copertura per un ruolo specifico può essere specificata per un determinato insieme di turni con un requisito di copertura. Ad esempio, il primo cambiamento di questo problema può essere rappresentato come segue:

  {
    "shifts": [
      {
        "id": "Monday-2023-05-01",
        "startDateTime": {
          "year": 2023,
          "month": 5,
          "day": 1,
          "hours": 12
        },
        "endDateTime": {
          "year": 2023,
          "month": 5,
          "day": 1,
          "hours": 23
        }
      }
    ]
  }

Supponendo che tutti e cinque i turni siano: Monday-2023-05-01, Tuesday-2023-05-02, Wednesday-2023-05-03, Thursday-2023-05-04 e Friday-2023-05-05, il requisito di copertura per i ruoli Station chef e Sous chef è rappresentato come:

{
  "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"
      }]
    }
  ]
}

Per considerare il requisito di un Head chef, è possibile specificare un requisito di copertura aggiuntiva per i turni necessari. L'elenco completo dei requisiti di copertura è:

{
  "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"
      }]
    }
  ]
}

Richieste dei dipendenti

Le richieste dei dipendenti sono rappresentate con il campo shift request. In questo esempio, Liam ha chiesto di lavorare per il turno del mercoledì, ma non per il turno del venerdì. È rappresentato (insieme ai suoi ruoli) come:

{
  "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"
      }
    ]
  }]
}

Esempio con tutti e cinque i dipendenti


  {
    "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"]
      }
    ]
  }
  

Esempio di richiesta 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"
    ]
  }
  

Esempio di risposta

La risposta del risolutore include l'assegnazione dei dipendenti ai turni del ristorante e lo stato della procedura di ottimizzazione. Ad esempio, i turni assegnati a uno dei dipendenti vengono restituiti come:

{
  "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"
    }, ...
  ]
}

Esempio di risposta 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"
      }
    ]
  }