Just starting to test optapy, I have an error trying to use optapy, groupBy and sum:
TypeError: 'function' object is not iterable"
probably for the argument of sum. Any help?
def lecturer_teaching_load(constraint_factory: ConstraintFactory):
print("Restricting by Teaching Load")
return constraint_factory.forEach(SubjectClass) \
.groupBy(lambda subject: subject.lecturer, sum(lambda subject: subject.teaching_load)) \
.filter(lambda lecturer, load: lecturer.real_cap > load) \
.penalize("Capacity conflict", HardSoftScore.ONE_HARD)
Idea is to penalize if the subjects planned for the same lecturer are too many.