I'm writing a school timetable in optaplanner, and if I change my constraints slightly, the memory use increases without bound (hundreds of gigs).
The following constraint works fine (memory use on 4 threads tops out at about 1g):
private Constraint teachingLoadConflict(ConstraintFactory constraintFactory)
{
return constraintFactory
.forEach(Lecture.class)
.groupBy(Lecture::getInstructor, ConstraintCollectors.count())
.filter((instructor, count)-> count>instructor.getTeachingLoad() )
.penalize("Exceeds teaching load", HardSoftScore.ofHard(100), (instructor,count)->count-instructor.getTeachingLoad());
}
However, if I add in a filter to only check those courses in the fall the memory usage increases without bound (eventually leading to an exception):
private Constraint teachingLoadConflict(ConstraintFactory constraintFactory)
{
return constraintFactory
.forEach(Lecture.class)
.filter(Lecture::getIsFall)
.groupBy(Lecture::getInstructor, ConstraintCollectors.count())
.filter((instructor, count)-> count>instructor.getTeachingLoad() )
.penalize("Exceeds teaching load", HardSoftScore.ofHard(100), (instructor,count)->count-instructor.getTeachingLoad());
}
How should I implement this idea? I've tried various things for that filter. Right now, getIsFall is implemented as:
@ProblemFactProperty
public boolean getIsFall(){return isFall;}
We have recently fixed a bug that had very similar, if not the same, symptoms. I suggest you wait for the release of OptaPlanner 8.23.0.Final, and let us know if the issue is still there.