简体   繁体   English

名册/时间表生成

[英]Roster/Timetable generation

I'm working on a tool to generate a timetable for employee up to a month taking into account commercial and labor law constraints. 考虑到商业和劳动法的限制,我正在开发一种工具来为员工制定一个长达一个月的时间表。 Few challenges and difference from similar problem : 类似问题的挑战和差异不大

  • The shift concept contains breaks split up to half an hour. 轮班概念包含最多半个小时的休息时间。
  • There is no concept of full 8 shifts as the referred similar problem. 没有完整的8个班次的概念被称为类似问题。 eg There is a need to have 2 resources at 8am, 2.5 resources at 3PM (eg give half hour break).. 例如,需要在上午8点拥有2个资源,在下午3点拥有2.5个资源(例如,休息半个小时)。
  • and regular constraints like hours per day, hours before break, break time... 以及常规限制,例如每天的小时数,休息前的时间,休息时间...

Possible solutions is to rely on using a solver aka OR-Tools and Optaplanner. 可能的解决方案是依靠使用又名OR-Tools和Optaplanner的求解器。 any hints? 有什么提示吗?

If you go with OptaPlanner and don't want to follow the Employee Rostering design of assigning 8 hours Shifts (planning entities) to Employees (planning value), because of your 2th constraint, then you could try to follow the Cheap Time Example design, something like this: 如果您使用OptaPlanner,并且由于第2项约束而不想遵循为员工分配8小时班次(计划实体)(计划值)的员工名册设计,那么您可以尝试遵循“廉价时间示例”设计,像这样的东西:

@PlanningEntity public class WorkAssignment {
     Employee employee;
     @PlanningVariable PotentialShiftStartTime startTime
     @PlanningVariable int durationInHalfHours
}

PotentialShiftStartTime is basically any time a shift can validly start, so Mon 8:00, Mon 8:30, Mon 9:00, etc. PotentialShiftStartTime基本上是轮班可以有效开始的任何时间,因此,周一8:00,周一8:30,周一9:00等。

The search space will be huge, in this free form way, but there are tricks to improve scalability (Nearby Selection, pick early for CH, Limited Selection for CH, ...). 以这种自由形式的方式,搜索空间将是巨大的,但是有一些技巧可以提高可伸缩性(邻近选择,为CH提早选择,为CH限制选择,...)。

To get out of the free form way (= to reduce the search space), you might be able to combine startTime and durationInHalfHours into PotentialShift, if for example it's not possible to start a 8 hour shift at 16:00 in the afternoon. 为了摆脱自由格式的影响(=减少搜索空间),您可以将startTime和durationInHalfHours合并到PotentialShift中,例如,如果不可能在下午16:00开始8小时轮班。 But make sure the gain is huge before introducing that complexity. 但是在引入这种复杂性之前,请确保收益巨大。

In any case, the trouble with this design is determining how many WorkAssignment instances to create. 无论如何,这种设计的麻烦在于确定要创建多少个WorkAssignment实例。 So you'll probably want to create the max number possible per employee and work with nullable=true to ignore unused assignments. 因此,您可能希望创建每个员工可能的最大数目,并使用nullable=true来忽略未使用的分配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM