0

I'm new to OptaPlanner and still getting a hang of it. I'm currently going through the OptaPlanner School timetable Use Case. I need to do more tweaking there. Assume I have a list of students, and I want to use Optaplanner to assign those students to studentGroup in Lesson Class based on the capacity of a room.

I have added a capacity attribute to the Room class. since Lesson already has studentGroup variable, I need to assign students to that Lesson who are in the same studentGroup till number of students reaches the Room capacity.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120

1 Answers1

0

The School Timetabling quickstarts in Timefold/OptaPlanner assigns Lessons to Timeslot+Rooms. It doesn't assign students to lessons. Typically that's done earlier in the real world (tactical vs operation planning).

If the student for each lesson is already fixed, you can do a constraint like this:

.forEach(Lesson.class)
.filter(lesson -> lesson.getRoom().getCapacity() < lesson.getStudentSize())
.penalize(..., lesson -> lesson.getRoom().getCapacity() - lesson.getStudentSize())

And that would be it.

However, if the students can still switch lessons, it's get a lot more complicated (2 planning entities: StudentAssignment (1 planning variable Lesson) and Lesson (2 planning variables room and timeslot) and you probably need custom moves etc for it to solve efficiently.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
  • Thanks for the answer! Can you help me out with the following query as well? So our teachers have their own daysOfWeek they can come in. One teacher can come in different daysOfWeek. How to write the constraint for that? – Panaceata dev04 Jun 27 '23 at 05:19
  • A Lesson should only be assigned to a timeslot only if that teacher is available on the same day – Panaceata dev04 Jun 27 '23 at 05:42