Вот пример ограничений, которые я определил:
Код: Выделить всё
from optapy import constraint_provider
from optapy.constraint import Joiners, ConstraintFactory
from optapy.score import HardSoftScore
@constraint_provider
def define_constraints(constraint_factory: ConstraintFactory):
return [
room_conflict(constraint_factory),
teacher_conflict(constraint_factory),
student_group_conflict(constraint_factory),
# other constraints...
]
def room_conflict(constraint_factory: ConstraintFactory):
return constraint_factory.for_each(Lesson) \
.join(Lesson,
Joiners.equal(lambda lesson: lesson.timeslot),
Joiners.equal(lambda lesson: lesson.allotted_room),
Joiners.less_than(lambda lesson: lesson.id)) \
.penalize("Room conflict", HardSoftScore.ONE_HARD)
Код: Выделить всё
AttributeError: 'proxy.TimeTable' object has no attribute 'getScore'
Что лучше? способ получить информацию о нарушениях ограничений в OptaPy? Как я могу распечатать, какие ограничения были нарушены, и их подробности?
Буду признателен за любую помощь!
Подробнее здесь: https://stackoverflow.com/questions/790 ... -in-optapy