在OptaPlanner中,如何限制将事实分配给实体的次数



以课程安排为例,假设一名讲师只能教授n门课程。为了加强这一点,我的想法是找到一位老师教授的所有课程,并通过负差增加不良程度,如果低于负差,则增加一半。我该怎么做(获得某位教授教授教授教授的所有课程(?

如果引入List<Course> courseList双向变量(第6.2。双向变量(逆关系阴影变量(在讲师课上,你可以访问他的所有课程:

@PlanningEntity
public class Course {
@PlanningVariable(valueRangeProviderRefs = {"instructorRange"})
private Instructor instructor;
}
@PlanningEntity 
public class Instructor {
@InverseRelationShadowVariable(sourceVariableName = "instructor")
private List<Course> courseList;
}

至于评分,当老师分配的课程太多时,对硬分进行处罚,当课程不够时,对软分进行处罚。

最新更新