护士调度与加班报酬

此示例以护士时间安排示例为基础,在满足预算要求的情况下对正常薪酬和加班薪酬进行建模。除了护理人员在时间安排方面的限制之外,还有 4 天规划期限的预算为 10,000 美元。所有护士均可享受 50 美元/小时的基本工资,且从 19 小时开始轮班的每小时差额为 10 美元/小时。40 小时后工作的任何小时均按平均基本小时费率的 1.5 倍(即(50 美元 + 60 美元)/2=55 美元)。

常规和加班薪酬

基本小时费率、调差差和加班调节系数通过 employee 中的 hourlyContract 字段表示。在每小时合同中,baseHourlyRatehourlyRateShiftDifferentials 会为常规(非加班)工作的薪酬建模。这些值还可用于估算提供 overtimePeriods 时加班薪酬的平均基本小时费率。通常,一个加班时段与一周一致,您也可以提供多个加班时段(只要这两个时段不重叠)。第一名护士 (Adam) 的每小时合同表示为:

  {
    "employees": [{
      "id": "Adam",
      "roleIds": ["Registered Nurse"],
      ...
        scheduling constraints
      ...
      "hourlyContract": {
        "baseHourlyRate": 50,
        "hourlyRateShiftDifferentials": {
          "2023-05-01 19hr": 10,
          "2023-05-02 19hr": 10,
          "2023-05-03 19hr": 10,
          "2023-05-04 19hr": 10
        },
        "overtimePeriods": [
          {
            "overtimeMultiplier": 1.5,
            "startDateTime": {
              "year": 2023,
              "month": 5,
              "day": 1
            },
            "endDateTime": {
              "year": 2023,
              "month": 5,
              "day": 5
            },
            "maximumRegularHours": 40
          }
        ]
      }
    }
  }

所有 4 名员工及其每小时合同的示例


  {
      "employees": [
        {
          "id": "Adam",
          "roleIds": [
            "Registered Nurse"
          ],
          "schedulingConstraints": [
            {
              "priority": "PRIORITY_HIGH",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "minimumRestMinutes": 720
            },
            {
              "priority": "PRIORITY_MEDIUM",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "maximumMinutes": 2160
            }
          ],
          "hourlyContract": {
            "baseHourlyRate": 50,
            "hourlyRateShiftDifferentials": {
              "2023-05-01 19h": 10,
              "2023-05-02 19h": 10,
              "2023-05-03 19h": 10,
              "2023-05-04 19h": 10
            },
            "overtimePeriods": [
              {
                "overtimeMultiplier": 1.5,
                "startDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 1
                },
                "endDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 5
                },
                "maximumRegularHours": 40
              }
            ]
          }
        },
        {
          "id": "Grace",
          "roleIds": [
            "Registered Nurse"
          ],
          "schedulingConstraints": [
            {
              "priority": "PRIORITY_HIGH",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "minimumRestMinutes": 720
            },
            {
              "priority": "PRIORITY_MEDIUM",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "maximumMinutes": 2160
            }
          ],
          "hourlyContract": {
            "baseHourlyRate": 50,
            "hourlyRateShiftDifferentials": {
              "2023-05-01 19h": 10,
              "2023-05-02 19h": 10,
              "2023-05-03 19h": 10,
              "2023-05-04 19h": 10
            },
            "overtimePeriods": [
              {
                "overtimeMultiplier": 1.5,
                "startDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 1
                },
                "endDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 5
                },
                "maximumRegularHours": 40
              }
            ]
          }
        },
        {
          "id": "James",
          "roleIds": [
            "Registered Nurse"
          ],
          "schedulingConstraints": [
            {
              "priority": "PRIORITY_HIGH",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "minimumRestMinutes": 720
            },
            {
              "priority": "PRIORITY_MEDIUM",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "maximumMinutes": 2160
            }
          ],
          "hourlyContract": {
            "baseHourlyRate": 50,
            "hourlyRateShiftDifferentials": {
              "2023-05-01 19h": 10,
              "2023-05-02 19h": 10,
              "2023-05-03 19h": 10,
              "2023-05-04 19h": 10
            },
            "overtimePeriods": [
              {
                "overtimeMultiplier": 1.5,
                "startDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 1
                },
                "endDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 5
                },
                "maximumRegularHours": 40
              }
            ]
          }
        },
        {
          "id": "Alonso",
          "roleIds": [
            "Registered Nurse"
          ],
          "schedulingConstraints": [
            {
              "priority": "PRIORITY_HIGH",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "minimumRestMinutes": 720
            },
            {
              "priority": "PRIORITY_MEDIUM",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "maximumMinutes": 2160
            }
          ],
          "hourlyContract": {
            "baseHourlyRate": 50,
            "hourlyRateShiftDifferentials": {
              "2023-05-01 19h": 10,
              "2023-05-02 19h": 10,
              "2023-05-03 19h": 10,
              "2023-05-04 19h": 10
            },
            "overtimePeriods": [
              {
                "overtimeMultiplier": 1.5,
                "startDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 1
                },
                "endDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 5
                },
                "maximumRegularHours": 40
              }
            ]
          }
        }
    ]
  }
  

预算要求

预算要求表示 $10,000 的总预算。开始时间和结束时间是可选的,如果指定了时间,则只有此时间范围内的班次和加班时间在计算此预算限制条件时才会考虑。第一名护士 (Adam) 的对应表示法可更新为:

  {
    "totalBudget": 10000,
    "priority": "PRIORITY_HIGH"
  }

完整请求示例


    {
      "employees": [
        {
          "id": "Adam",
          "roleIds": [
            "Registered Nurse"
          ],
          "schedulingConstraints": [
            {
              "priority": "PRIORITY_HIGH",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "minimumRestMinutes": 720
            },
            {
              "priority": "PRIORITY_MEDIUM",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "maximumMinutes": 2160
            }
          ],
          "hourlyContract": {
            "baseHourlyRate": 50,
            "hourlyRateShiftDifferentials": {
              "2023-05-01 19h": 10,
              "2023-05-02 19h": 10,
              "2023-05-03 19h": 10,
              "2023-05-04 19h": 10
            },
            "overtimePeriods": [
              {
                "overtimeMultiplier": 1.5,
                "startDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 1
                },
                "endDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 5
                },
                "maximumRegularHours": 40
              }
            ]
          }
        },
        {
          "id": "Grace",
          "roleIds": [
            "Registered Nurse"
          ],
          "schedulingConstraints": [
            {
              "priority": "PRIORITY_HIGH",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "minimumRestMinutes": 720
            },
            {
              "priority": "PRIORITY_MEDIUM",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "maximumMinutes": 2160
            }
          ],
          "hourlyContract": {
            "baseHourlyRate": 50,
            "hourlyRateShiftDifferentials": {
              "2023-05-01 19h": 10,
              "2023-05-02 19h": 10,
              "2023-05-03 19h": 10,
              "2023-05-04 19h": 10
            },
            "overtimePeriods": [
              {
                "overtimeMultiplier": 1.5,
                "startDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 1
                },
                "endDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 5
                },
                "maximumRegularHours": 40
              }
            ]
          }
        },
        {
          "id": "James",
          "roleIds": [
            "Registered Nurse"
          ],
          "schedulingConstraints": [
            {
              "priority": "PRIORITY_HIGH",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "minimumRestMinutes": 720
            },
            {
              "priority": "PRIORITY_MEDIUM",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "maximumMinutes": 2160
            }
          ],
          "hourlyContract": {
            "baseHourlyRate": 50,
            "hourlyRateShiftDifferentials": {
              "2023-05-01 19h": 10,
              "2023-05-02 19h": 10,
              "2023-05-03 19h": 10,
              "2023-05-04 19h": 10
            },
            "overtimePeriods": [
              {
                "overtimeMultiplier": 1.5,
                "startDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 1
                },
                "endDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 5
                },
                "maximumRegularHours": 40
              }
            ]
          }
        },
        {
          "id": "Alonso",
          "roleIds": [
            "Registered Nurse"
          ],
          "schedulingConstraints": [
            {
              "priority": "PRIORITY_HIGH",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "minimumRestMinutes": 720
            },
            {
              "priority": "PRIORITY_MEDIUM",
              "startDateTime": {
                "year": 2023,
                "month": 5,
                "day": 1,
                "hours": 7
              },
              "endDateTime": {
                "year": 2023,
                "month": 5,
                "day": 5,
                "hours": 7
              },
              "maximumMinutes": 2160
            }
          ],
          "hourlyContract": {
            "baseHourlyRate": 50,
            "hourlyRateShiftDifferentials": {
              "2023-05-01 19h": 10,
              "2023-05-02 19h": 10,
              "2023-05-03 19h": 10,
              "2023-05-04 19h": 10
            },
            "overtimePeriods": [
              {
                "overtimeMultiplier": 1.5,
                "startDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 1
                },
                "endDateTime": {
                  "year": 2023,
                  "month": 5,
                  "day": 5
                },
                "maximumRegularHours": 40
              }
            ]
          }
        }
      ],
      "shifts": [
        {
          "id": "2023-05-01 7h",
          "locationId": "department",
          "startDateTime": {
            "year": 2023,
            "month": 5,
            "day": 1,
            "hours": 7
          },
          "endDateTime": {
            "year": 2023,
            "month": 5,
            "day": 1,
            "hours": 19
          }
        },
        {
          "id": "2023-05-01 13h",
          "locationId": "department",
          "startDateTime": {
            "year": 2023,
            "month": 5,
            "day": 1,
            "hours": 13
          },
          "endDateTime": {
            "year": 2023,
            "month": 5,
            "day": 2,
            "hours": 1
          }
        },
        {
          "id": "2023-05-01 19h",
          "locationId": "department",
          "startDateTime": {
            "year": 2023,
            "month": 5,
            "day": 1,
            "hours": 19
          },
          "endDateTime": {
            "year": 2023,
            "month": 5,
            "day": 2,
            "hours": 7
          }
        },
        {
          "id": "2023-05-02 7h",
          "locationId": "department",
          "startDateTime": {
            "year": 2023,
            "month": 5,
            "day": 2,
            "hours": 7
          },
          "endDateTime": {
            "year": 2023,
            "month": 5,
            "day": 2,
            "hours": 19
          }
        },
        {
          "id": "2023-05-02 13h",
          "locationId": "department",
          "startDateTime": {
            "year": 2023,
            "month": 5,
            "day": 2,
            "hours": 13
          },
          "endDateTime": {
            "year": 2023,
            "month": 5,
            "day": 3,
            "hours": 1
          }
        },
        {
          "id": "2023-05-02 19h",
          "locationId": "department",
          "startDateTime": {
            "year": 2023,
            "month": 5,
            "day": 2,
            "hours": 19
          },
          "endDateTime": {
            "year": 2023,
            "month": 5,
            "day": 3,
            "hours": 7
          }
        },
        {
          "id": "2023-05-03 7h",
          "locationId": "department",
          "startDateTime": {
            "year": 2023,
            "month": 5,
            "day": 3,
            "hours": 7
          },
          "endDateTime": {
            "year": 2023,
            "month": 5,
            "day": 3,
            "hours": 19
          }
        },
        {
          "id": "2023-05-03 13h",
          "locationId": "department",
          "startDateTime": {
            "year": 2023,
            "month": 5,
            "day": 3,
            "hours": 13
          },
          "endDateTime": {
            "year": 2023,
            "month": 5,
            "day": 4,
            "hours": 1
          }
        },
        {
          "id": "2023-05-03 19h",
          "locationId": "department",
          "startDateTime": {
            "year": 2023,
            "month": 5,
            "day": 3,
            "hours": 19
          },
          "endDateTime": {
            "year": 2023,
            "month": 5,
            "day": 4,
            "hours": 7
          }
        },
        {
          "id": "2023-05-04 7h",
          "locationId": "department",
          "startDateTime": {
            "year": 2023,
            "month": 5,
            "day": 4,
            "hours": 7
          },
          "endDateTime": {
            "year": 2023,
            "month": 5,
            "day": 4,
            "hours": 19
          }
        },
        {
          "id": "2023-05-04 13h",
          "locationId": "department",
          "startDateTime": {
            "year": 2023,
            "month": 5,
            "day": 4,
            "hours": 13
          },
          "endDateTime": {
            "year": 2023,
            "month": 5,
            "day": 5,
            "hours": 1
          }
        },
        {
          "id": "2023-05-04 19h",
          "locationId": "department",
          "startDateTime": {
            "year": 2023,
            "month": 5,
            "day": 4,
            "hours": 19
          },
          "endDateTime": {
            "year": 2023,
            "month": 5,
            "day": 5,
            "hours": 7
          }
        }
      ],
      "coverageRequirements": [
        {
          "startDateTime": {
            "year": 2023,
            "month": 5,
            "day": 1,
            "hours": 7
          },
          "endDateTime": {
            "year": 2023,
            "month": 5,
            "day": 5,
            "hours": 7
          },
          "locationId": "department",
          "roleRequirements": [
            {
              "roleId": "Registered Nurse",
              "targetEmployeeCount": 2,
              "priority": "PRIORITY_MANDATORY"
            }
          ]
        }
      ],
      "roleIds": [
        "Registered Nurse"
      ],
      "locationIds": [
        "department"
      ],
      "budgetRequirements": [
        {
          "totalBudget": 10000,
          "priority": "PRIORITY_HIGH"
        }
      ]
    }
    

响应示例

求解器的响应包含护士对班次分配和优化程序状态。例如,分配给首位员工的班次返回如下:

  {
    "solutionStatus": "OPTIMAL",
    "shiftAssignments": [
      {
        "employeeId": "Adam",
        "shiftId": "2023-05-01 7hr",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "Adam",
        "shiftId": "2023-05-02 7hr",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "Adam",
        "shiftId": "2023-05-03 7hr",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "Adam",
        "shiftId": "2023-05-04 7hr",
        "roleId": "Registered Nurse"
      },
      ... ]
  }

完整响应示例


  {
    "solutionStatus": "OPTIMAL",
    "shiftAssignments": [
      {
        "employeeId": "Adam",
        "shiftId": "2023-05-01 7h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "Adam",
        "shiftId": "2023-05-02 7h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "Adam",
        "shiftId": "2023-05-03 7h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "Adam",
        "shiftId": "2023-05-04 7h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "Grace",
        "shiftId": "2023-05-01 19h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "Grace",
        "shiftId": "2023-05-02 19h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "Grace",
        "shiftId": "2023-05-03 19h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "Grace",
        "shiftId": "2023-05-04 19h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "James",
        "shiftId": "2023-05-01 19h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "James",
        "shiftId": "2023-05-02 19h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "James",
        "shiftId": "2023-05-03 19h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "James",
        "shiftId": "2023-05-04 19h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "We",
        "shiftId": "2023-05-01 7h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "We",
        "shiftId": "2023-05-02 7h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "We",
        "shiftId": "2023-05-03 7h",
        "roleId": "Registered Nurse"
      },
      {
        "employeeId": "We",
        "shiftId": "2023-05-04 7h",
        "roleId": "Registered Nurse"
      }
    ]
  }