使用 OptaPlanner 在具有 z 分组约束的未定义数量的组中分组 x 实体

Group x entity in undefined number of groups with z grouping constraints using OptaPlanner

我正在尝试使用 OptaPlanner 对问题建模,但找不到建模。 (我从 OptaPlanner 开始)。

我的问题如下:

我希望每个 Group 的最小数量和最大数量 Process Group 和相同 Group 的所有 Process 兼容(按标准)。

下面是一些标准示例:

示例: 我有 5 Process

我想使用上面的示例标准为以下组合计算分数 (P1,P2,P3),(P1,P3,P4),(P5)。 所有其他组合应排除为不兼容

有没有办法使用 OptaPlanner 来做到这一点。我应该学习哪种方法来尝试解决我的问题。

听起来很像 CloudBalancing 问题。 以该示例为例,将 Computer 重命名为 Group(并且 Process 仍然是 Process)。

然后你可以像

那样做约束流
// Process have field code, the constraint can be Process must have same code
from(Process)
.groupBy(Process::getComputer, countDistinct(Process::getCode)
.filter((computer, codeCount) -> codeCount > 1)
.penalize(...);