【发布时间】:2022-08-20 16:25:58
【问题描述】:
我在 python 中使用 Optapy 库,我想添加需要满足课程的约束,因为我现在得到了许多未分配的课程,即使大部分时间段和房间都是空的,而且教师资源大多未使用。 我尝试添加以下约束:
def curriculum_needs_to_be_met(constraint_factory):
return constraint_factory \\
.forEach(LessonClass) \\
.filter(lambda lesson: lesson.timeslot is None) \\
.penalize(\"Curriculum needs to be met\", HardSoftScore.ONE_HARD)
但我仍然得到许多未分配的课程。知道如何定义课程限制吗?