我可以在 OptaPlanner 中使用多个 @PlanningEntityCollectionProperty 吗?
Can I use multiple @PlanningEntityCollectionProperty in OptaPlanner?
我想将 Employee
分配给 Reserve
期间或 Shift
期间。
@PlanningSolution
public class RosterSolution implements Solution<HardSoftScore> {
@PlanningEntityCollectionProperty
private List<Shift> shift = new ArrayList<Shift>();
@PlanningEntityCollectionProperty
private List<Reserve> reserve = new ArrayList<Reserve>();
....
}
每个 Shift 和 Reserve 实体都有一个
的@PlanningVariable
@PlanningVariable(valueRangeProviderRefs={"employees"}, nullable= true)
private Employee emp;
是否可以在一个解决方案中使用多个@PlanningEntityCollectionProperty 注释?我还没有看到它的用法的任何例子。 @PlanningSolution 下的文档说明 'Each planning solution must have at least 1 PlanningEntityCollectionProperty or PlanningEntityProperty property',但我不确定如何实现它。
我试图避免使用类型编码的单一计划实体列表,除非我可以'replace type code with state/strategy pattern'(如果可能的话)。
是的,你可以。示例 CoachShuttleGatheringSolution
和 VehicleRoutingSolution
执行此操作。
当您有多个规划实体 类(其中一些可以是影子实体 类)时,它很有用。但除非你真的需要,否则不要去那里。
我想将 Employee
分配给 Reserve
期间或 Shift
期间。
@PlanningSolution
public class RosterSolution implements Solution<HardSoftScore> {
@PlanningEntityCollectionProperty
private List<Shift> shift = new ArrayList<Shift>();
@PlanningEntityCollectionProperty
private List<Reserve> reserve = new ArrayList<Reserve>();
....
}
每个 Shift 和 Reserve 实体都有一个
的@PlanningVariable@PlanningVariable(valueRangeProviderRefs={"employees"}, nullable= true)
private Employee emp;
是否可以在一个解决方案中使用多个@PlanningEntityCollectionProperty 注释?我还没有看到它的用法的任何例子。 @PlanningSolution 下的文档说明 'Each planning solution must have at least 1 PlanningEntityCollectionProperty or PlanningEntityProperty property',但我不确定如何实现它。
我试图避免使用类型编码的单一计划实体列表,除非我可以'replace type code with state/strategy pattern'(如果可能的话)。
是的,你可以。示例 CoachShuttleGatheringSolution
和 VehicleRoutingSolution
执行此操作。
当您有多个规划实体 类(其中一些可以是影子实体 类)时,它很有用。但除非你真的需要,否则不要去那里。