Skip to content

Commit 42bb0a6

Browse files
authored
Merge pull request #1167 from triceo/PLANNER-1709
PLANNER-1709 Avoid deprecated penalize/reward overloads
2 parents d898a10 + 9b794e9 commit 42bb0a6

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

optaplanner-quickstart/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
1111
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
1212
<quarkus.platform.version>999-SNAPSHOT</quarkus.platform.version>
13-
<optaplanner-quarkus.version>8.27.0.Final</optaplanner-quarkus.version>
13+
<optaplanner-quarkus.version>8.29.0.Final</optaplanner-quarkus.version>
1414
<compiler-plugin.version>3.8.1</compiler-plugin.version>
1515
<surefire-plugin.version>3.0.0-M7</surefire-plugin.version>
1616
<docker-plugin.version>0.28.0</docker-plugin.version>

optaplanner-quickstart/src/main/java/org/acme/optaplanner/solver/TimeTableConstraintProvider.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)