【发布时间】:2021-07-21 18:56:18
【问题描述】:
我正在尝试使用 optaplanner 制定课程分配时间表。
我如何计算同一天同一堂课的相同课程的数量? 我正在使用约束管理
for example
-----------------------------------------------
0.P Math Math Math --> 3 ---Pen.ofHard(5)
1.P Math Math Another --> 2 -- No Pen
2.P Another Another Another --> 3 -- Pen.ofHard(5)
(我想使用 groupBy 但我不能)
我想做:
private Constraint checkMaxLesson(ConstraintFactory constraintFactory) {
return constraintFactory.fromUniquePair(Lesson.class,
Joiners.equal(Lesson::getStudentGroup),
Joiners.equal(Lesson::getSubject),
Joiners.equal(t -> t.getTimeSlot().getDayOfWeek()))
**??.filter( count() > 2)**
.penalize("Max 2 lesson some day",HardSoftScore.ofHard(5));
}
【问题讨论】:
-
如果不了解您的领域模型以及您使用的是什么类型的评分函数,就无法回答这个问题。请更新您的问题并提供更多详细信息。
-
其实我想要的是同一天最多上3节相同的课。我正在使用 optaplanner-quickstarts-schedule 域。