我想将员工
分配到保留
期间或轮类
期间。
@PlanningSolution
public class RosterSolution implements Solution<HardSoftScore> {
@PlanningEntityCollectionProperty
private List<Shift> shift = new ArrayList<Shift>();
@PlanningEntityCollectionProperty
private List<Reserve> reserve = new ArrayList<Reserve>();
....
}
每个轮类和储备实体都有一个 @PlanningVariable
@PlanningVariable(valueRangeProviderRefs={"employees"}, nullable= true)
private Employee emp;
是否可以在解决方案中使用多个 @PlanningEntityCollectionProperty 注释?我还没有看到任何其用法的例子。 @PlanningSolution 下的文档指出“每个规划解决方案必须具有至少 1 PlanningEntityCollectionProperty 或 PlanningEntityProperty 属性”,但我不确定如何实现它。
我试图避免使用类型编码的规划实体的单一列表,除非我可以“用状态/策略模式替换类型代码”(如果可能的话)。
最佳答案
是的,可以。示例 CoachShuttleGatheringSolution
和 VehicleRoutingSolution
就是这样做的。
当您有多个计划实体类(其中一些可以是影子实体类)时,它非常有用。但除非确实需要,否则不要去那里。
关于java - 我可以在 OptaPlanner 中使用多个 @PlanningEntityCollectionProperty 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37264702/