Skip to content

Commit

Permalink
Merge pull request #1167 from triceo/PLANNER-1709
Browse files Browse the repository at this point in the history
PLANNER-1709 Avoid deprecated penalize/reward overloads
  • Loading branch information
gsmet authored Oct 18, 2022
2 parents d898a10 + 9b794e9 commit 42bb0a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion optaplanner-quickstart/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>999-SNAPSHOT</quarkus.platform.version>
<optaplanner-quarkus.version>8.27.0.Final</optaplanner-quarkus.version>
<optaplanner-quarkus.version>8.29.0.Final</optaplanner-quarkus.version>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<surefire-plugin.version>3.0.0-M7</surefire-plugin.version>
<docker-plugin.version>0.28.0</docker-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Constraint roomConflict(ConstraintFactory constraintFactory) {
// ... in the same room ...
Joiners.equal(Lesson::getRoom))
// ... and penalize each pair with a hard weight.
.penalize("Room conflict", HardSoftScore.ONE_HARD);
.penalize(HardSoftScore.ONE_HARD)
.asConstraint("Room conflict");
}

Constraint teacherConflict(ConstraintFactory constraintFactory) {
Expand All @@ -44,7 +45,8 @@ Constraint teacherConflict(ConstraintFactory constraintFactory) {
.forEachUniquePair(Lesson.class,
Joiners.equal(Lesson::getTimeslot),
Joiners.equal(Lesson::getTeacher))
.penalize("Teacher conflict", HardSoftScore.ONE_HARD);
.penalize(HardSoftScore.ONE_HARD)
.asConstraint("Teacher conflict");
}

Constraint studentGroupConflict(ConstraintFactory constraintFactory) {
Expand All @@ -53,7 +55,8 @@ Constraint studentGroupConflict(ConstraintFactory constraintFactory) {
.forEachUniquePair(Lesson.class,
Joiners.equal(Lesson::getTimeslot),
Joiners.equal(Lesson::getStudentGroup))
.penalize("Student group conflict", HardSoftScore.ONE_HARD);
.penalize(HardSoftScore.ONE_HARD)
.asConstraint("Student group conflict");
}

Constraint teacherRoomStability(ConstraintFactory constraintFactory) {
Expand All @@ -62,7 +65,8 @@ Constraint teacherRoomStability(ConstraintFactory constraintFactory) {
.forEachUniquePair(Lesson.class,
Joiners.equal(Lesson::getTeacher))
.filter((lesson1, lesson2) -> lesson1.getRoom() != lesson2.getRoom())
.penalize("Teacher room stability", HardSoftScore.ONE_SOFT);
.penalize(HardSoftScore.ONE_SOFT)
.asConstraint("Teacher room stability");
}

Constraint teacherTimeEfficiency(ConstraintFactory constraintFactory) {
Expand All @@ -76,7 +80,8 @@ Constraint teacherTimeEfficiency(ConstraintFactory constraintFactory) {
lesson2.getTimeslot().getStartTime());
return !between.isNegative() && between.compareTo(Duration.ofMinutes(30)) <= 0;
})
.reward("Teacher time efficiency", HardSoftScore.ONE_SOFT);
.reward(HardSoftScore.ONE_SOFT)
.asConstraint("Teacher time efficiency");
}

Constraint studentGroupSubjectVariety(ConstraintFactory constraintFactory) {
Expand All @@ -92,7 +97,8 @@ Constraint studentGroupSubjectVariety(ConstraintFactory constraintFactory) {
lesson2.getTimeslot().getStartTime());
return !between.isNegative() && between.compareTo(Duration.ofMinutes(30)) <= 0;
})
.penalize("Student group subject variety", HardSoftScore.ONE_SOFT);
.penalize(HardSoftScore.ONE_SOFT)
.asConstraint("Student group subject variety");
}

}

0 comments on commit 42bb0a6

Please sign in to comment.