@@ -35,7 +35,8 @@ Constraint roomConflict(ConstraintFactory constraintFactory) {
3535 // ... in the same room ...
3636 Joiners .equal (Lesson ::getRoom ))
3737 // ... and penalize each pair with a hard weight.
38- .penalize ("Room conflict" , HardSoftScore .ONE_HARD );
38+ .penalize (HardSoftScore .ONE_HARD )
39+ .asConstraint ("Room conflict" );
3940 }
4041
4142 Constraint teacherConflict (ConstraintFactory constraintFactory ) {
@@ -44,7 +45,8 @@ Constraint teacherConflict(ConstraintFactory constraintFactory) {
4445 .forEachUniquePair (Lesson .class ,
4546 Joiners .equal (Lesson ::getTimeslot ),
4647 Joiners .equal (Lesson ::getTeacher ))
47- .penalize ("Teacher conflict" , HardSoftScore .ONE_HARD );
48+ .penalize (HardSoftScore .ONE_HARD )
49+ .asConstraint ("Teacher conflict" );
4850 }
4951
5052 Constraint studentGroupConflict (ConstraintFactory constraintFactory ) {
@@ -53,7 +55,8 @@ Constraint studentGroupConflict(ConstraintFactory constraintFactory) {
5355 .forEachUniquePair (Lesson .class ,
5456 Joiners .equal (Lesson ::getTimeslot ),
5557 Joiners .equal (Lesson ::getStudentGroup ))
56- .penalize ("Student group conflict" , HardSoftScore .ONE_HARD );
58+ .penalize (HardSoftScore .ONE_HARD )
59+ .asConstraint ("Student group conflict" );
5760 }
5861
5962 Constraint teacherRoomStability (ConstraintFactory constraintFactory ) {
@@ -62,7 +65,8 @@ Constraint teacherRoomStability(ConstraintFactory constraintFactory) {
6265 .forEachUniquePair (Lesson .class ,
6366 Joiners .equal (Lesson ::getTeacher ))
6467 .filter ((lesson1 , lesson2 ) -> lesson1 .getRoom () != lesson2 .getRoom ())
65- .penalize ("Teacher room stability" , HardSoftScore .ONE_SOFT );
68+ .penalize (HardSoftScore .ONE_SOFT )
69+ .asConstraint ("Teacher room stability" );
6670 }
6771
6872 Constraint teacherTimeEfficiency (ConstraintFactory constraintFactory ) {
@@ -76,7 +80,8 @@ Constraint teacherTimeEfficiency(ConstraintFactory constraintFactory) {
7680 lesson2 .getTimeslot ().getStartTime ());
7781 return !between .isNegative () && between .compareTo (Duration .ofMinutes (30 )) <= 0 ;
7882 })
79- .reward ("Teacher time efficiency" , HardSoftScore .ONE_SOFT );
83+ .reward (HardSoftScore .ONE_SOFT )
84+ .asConstraint ("Teacher time efficiency" );
8085 }
8186
8287 Constraint studentGroupSubjectVariety (ConstraintFactory constraintFactory ) {
@@ -92,7 +97,8 @@ Constraint studentGroupSubjectVariety(ConstraintFactory constraintFactory) {
9297 lesson2 .getTimeslot ().getStartTime ());
9398 return !between .isNegative () && between .compareTo (Duration .ofMinutes (30 )) <= 0 ;
9499 })
95- .penalize ("Student group subject variety" , HardSoftScore .ONE_SOFT );
100+ .penalize (HardSoftScore .ONE_SOFT )
101+ .asConstraint ("Student group subject variety" );
96102 }
97103
98104}
0 commit comments