I'm creating a school schedule generator using OptaPlanner.
I'm going to use OptaPlanner for two separate planning problems:
- Teaching assignments: Assigning teachers to course rounds
- Lecture scheduling: Assigning timeslots and rooms to lectures
My model basically looks like this:
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;
...
}
My problem is the following:
In the teaching assignment part, I'd like the problem to be configured like this:
@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;
...
}
and in the lecture scheduling part, I'd like the annotations to be
@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;
...
}
Is there a way to achieve this?
I'm envisioning something like having the PlanningSolution
, PlanningVariable
etc mapped out in the XML config or something like that, so I can specify different setups for different solvers.
If this is not possible, are there any clever workarounds?
CodePudding user response:
If I understand it correctly, you are proposing that the annotations would be overridable by the XML config. That's currently not possible. One could argue the XML config would become very complex if it enabled everything the annotations can do (e.g. shadow variables, pinning, etc.)
What you can do in terms of reusing the domain model is share the common parts, like Room
, Timeslot
and Teacher
, and have separate classes for the different PlanningSolutions
and PlanningEntities
.