OptaPlanner:使用相同模型的两个不同规划问题class

OptaPlanner: Two different planning problems using the same model class

我正在使用 OptaPlanner 创建学校时间表生成器。

我将使用 OptaPlanner 解决两个单独的规划问题:

  1. 教学任务:分配教师上课
  2. 讲座安排:为讲座分配时间段和房间

我的模型基本上是这样的:

class Schedule {
    List<Teacher> teachers;
    List<CourseRound> courseRounds;
    List<Lecture> lectures;
    List<StudentGroup> studentGroups;
    ...
}

class CourseRound {
    Teacher teacher;
    String course;
    ...
}

class Lecture {
    Timeslot timeslot;
    Room room;
    ...
}

我的问题如下:

在教学作业部分,我想这样配置问题:

@PlanningSolution
class Schedule {

    @ValueRangeProvider(id = "teacherRange")
    @ProblemFactCollectionProperty
    List<Teacher> teachers;

    @PlanningEntityCollectionProperty
    List<CourseRound> courseRounds;

    List<StudentGroup> studentGroups;
    List<Lecture> lectures;
    List<Timeslot> timeslots
    List<Room> timeslots

    ...
}

@PlanningEntity
class CourseRound {

    @PlanningVariable
    @ValueRangeProvider(id = "teacherRange")
    Teacher teacher;

    String course;
    ...
}

class Lecture {
    Timeslot timeslot;
    Room room;
    ...
}

在讲座安排部分,我希望注释是

@PlanningSolution
class Schedule {

    List<Teacher> teachers;
    List<CourseRound> courseRounds;
    List<StudentGroup> studentGroups;

    @PlanningEntityCollectionProperty
    List<Lecture> lectures;

    @ValueRangeProvider(id = "timeslotRange")
    @ProblemFactCollectionProperty
    List<Timeslot> timeslots

    @ValueRangeProvider(id = "roomRange")
    @ProblemFactCollectionProperty
    List<Room> timeslots

    ...
}

class CourseRound {
    Teacher teacher;
    String course;
    ...
}

@PlanningEntity
class Lecture {

    @PlanningVariable
    Timeslot timeslot;

    @PlanningVariable
    Room room;
    ...
}

有办法实现吗?

我正在设想将 PlanningSolutionPlanningVariable 等映射到 XML 配置或类似的东西,这样我就可以为不同的求解器指定不同的设置。

如果这不可能,是否有任何巧妙的解决方法?

如果我理解正确的话,您是在提议注释可以被 XML 配置覆盖。 目前这是不可能的。有人可能会争辩说 XML 配置会变得非常复杂,如果它启用注释可以做的一切(例如影子变量、固定等)

在重用领域模型方面,您可以做的是共享公共部分,例如 RoomTimeslotTeacher,并为 类不同的 PlanningSolutionsPlanningEntities.