Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLANNER-2861 Upgrate to OptaPlanner 9 #32879

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions docs/src/main/asciidoc/optaplanner.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ public class Lesson {
private String teacher;
private String studentGroup;

@PlanningVariable(valueRangeProviderRefs = "timeslotRange")
@PlanningVariable
private Timeslot timeslot;
@PlanningVariable(valueRangeProviderRefs = "roomRange")
@PlanningVariable
private Room room;

public Lesson() {
Expand Down Expand Up @@ -339,11 +339,8 @@ The `Lesson` class has an `@PlanningEntity` annotation,
so OptaPlanner knows that this class changes during solving
because it contains one or more planning variables.

The `timeslot` field has an `@PlanningVariable` annotation,
so OptaPlanner knows that it can change its value.
In order to find potential `Timeslot` instances to assign to this field,
OptaPlanner uses the `valueRangeProviderRefs` property to connect to a value range provider
(explained later) that provides a `List<Timeslot>` to pick from.
The `timeslot` field has an `@PlanningVariable` annotation, so OptaPlanner knows that it can change its value.
In order to find potential Timeslot instances to assign to this field, OptaPlanner uses the variable type to connect to a value range provider that provides a List<Timeslot> to pick from.

The `room` field also has an `@PlanningVariable` annotation, for the same reasons.

Expand Down Expand Up @@ -468,7 +465,7 @@ public class TimeTableConstraintProvider implements ConstraintProvider {
Joiners.equal(Lesson::getTeacher),
Joiners.lessThan(Lesson::getId))
.penalize(HardSoftScore.ONE_HARD)
.asConstraint(""Teacher conflict");
.asConstraint("Teacher conflict");
}

Constraint studentGroupConflict(ConstraintFactory constraintFactory) {
Expand All @@ -479,7 +476,7 @@ public class TimeTableConstraintProvider implements ConstraintProvider {
Joiners.equal(Lesson::getStudentGroup),
Joiners.lessThan(Lesson::getId))
.penalize(HardSoftScore.ONE_HARD)
.asConstraint(""Student group conflict");
.asConstraint("Student group conflict");
}

}
Expand Down Expand Up @@ -518,10 +515,10 @@ import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore;
@PlanningSolution
public class TimeTable {

@ValueRangeProvider(id = "timeslotRange")
@ValueRangeProvider
@ProblemFactCollectionProperty
private List<Timeslot> timeslotList;
@ValueRangeProvider(id = "roomRange")
@ValueRangeProvider
@ProblemFactCollectionProperty
private List<Room> roomList;
@PlanningEntityCollectionProperty
Expand Down Expand Up @@ -585,7 +582,7 @@ However, this class is also the output of the solution:
The `timeslotList` field is a value range provider.
It holds the `Timeslot` instances which OptaPlanner can pick from to assign to the `timeslot` field of `Lesson` instances.
The `timeslotList` field has an `@ValueRangeProvider` annotation to connect the `@PlanningVariable` with the `@ValueRangeProvider`,
by matching the value of the `id` property with the value of the `valueRangeProviderRefs` property of the `@PlanningVariable` annotation in the `Lesson` class.
by matching the type of the planning variable with the type returned by the value range provider.

Following the same logic, the `roomList` field also has an `@ValueRangeProvider` annotation.

Expand Down