Skip to content

Commit d6dd724

Browse files
doc updated and constraint renames
1 parent 59c22e1 commit d6dd724

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

java/hello-world/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ the lecture units and lab/act units will be bundled together into a lesson insta
109109
Other things to consider:
110110
- If a studio course instance is scheduled to have all it's lab/act time to be in **one** block, then the constraint
111111
enforcing that lab/act time must be immediately after lecture will not be enforced for this lesson.
112+
- When setting the instructor preference, the key (aka the instructor's name) should be their canonical name.
112113

113114

114115

java/hello-world/src/main/java/org/acme/schooltimetabling/solver/TimetableConstraintProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public Constraint[] defineConstraints(ConstraintFactory constraintFactory) {
3535
//universal constraints
3636
List<Constraint> solver_constraints = new ArrayList<>(Arrays.asList(
3737
// Hard constraints
38-
sameClassSameDays(constraintFactory),
38+
teacherSameCourseSamePattern(constraintFactory),
3939
teacherLessonConflict(constraintFactory),
4040
lessonConflict(constraintFactory),
41-
labActRoomConflict(constraintFactory),
41+
roomConflict(constraintFactory),
4242
wrongHoursAmount(constraintFactory),
4343
wrongRoomType(constraintFactory),
4444
timeslotPatternMatch(constraintFactory),
@@ -145,7 +145,7 @@ Constraint primeTime50Plus(ConstraintFactory constraintFactory){
145145
*
146146
* @return Penalize by {@link HardMediumSoftScore#ONE_HARD}
147147
*/
148-
Constraint sameClassSameDays(ConstraintFactory constraintFactory){
148+
Constraint teacherSameCourseSamePattern(ConstraintFactory constraintFactory){
149149
return constraintFactory
150150
.forEachUniquePair(Lesson.class,
151151
Joiners.equal(lesson -> lesson.getTeacherObj().getId()),
@@ -217,7 +217,7 @@ Constraint lessonConflict(ConstraintFactory constraintFactory){
217217
* This constraint will penalize any unique pair of lessons (w/ lab/act) that use the same room
218218
* at the same time
219219
*/
220-
Constraint labActRoomConflict(ConstraintFactory constraintFactory){
220+
Constraint roomConflict(ConstraintFactory constraintFactory){
221221
return constraintFactory
222222
//for each lesson
223223
.forEachUniquePair(Lesson.class,

java/hello-world/src/test/java/org/acme/schooltimetabling/solver/TestConstraintPropStudio.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void pen_PropDiffTchPttrn(){
4646
ConstraintTestHelper.DUMMY_TEACHER, ts_TR_TR, ConstraintTestHelper.DUMMY_ROOM);
4747

4848

49-
constraintVerifier.verifyThat(TimetableConstraintProvider::sameClassSameDays)
49+
constraintVerifier.verifyThat(TimetableConstraintProvider::teacherSameCourseSamePattern)
5050
.given(ls1_MWF_TR, ls2_TR_TR
5151
)
5252
/*Note this takes into account weight of rewards*/
@@ -67,7 +67,7 @@ void noPen_PropSameTchPttrn(){
6767
"", "3-1-0", Constants.COURSE_ID_BIMAP.get(ConstraintTestHelper.DUMMY_STUDIO),
6868
ConstraintTestHelper.DUMMY_TEACHER, ts_MWF_MWF, ConstraintTestHelper.DUMMY_ROOM);
6969

70-
constraintVerifier.verifyThat(TimetableConstraintProvider::sameClassSameDays)
70+
constraintVerifier.verifyThat(TimetableConstraintProvider::teacherSameCourseSamePattern)
7171
.given(ls1_MWF_TR, ls2_MWF_MWF
7272
)
7373
/*Note this takes into account weight of rewards*/
@@ -116,7 +116,7 @@ void pen_PropCoursesSameRoom() throws Exception{
116116
"", "3-1-0", Constants.COURSE_ID_BIMAP.get(ConstraintTestHelper.DUMMY_STUDIO),
117117
ConstraintTestHelper.DUMMY_TEACHER, ts_TR_830AM_3blcks_10AM_3blcks, ConstraintTestHelper.DUMMY_ROOM);
118118

119-
constraintVerifier.verifyThat(TimetableConstraintProvider::labActRoomConflict)
119+
constraintVerifier.verifyThat(TimetableConstraintProvider::roomConflict)
120120
.given(combo1_st1, combo1_non_st1,
121121
combo2_st2, combo2_st3)
122122
.penalizesBy(2);
@@ -147,7 +147,7 @@ void noPen_PropCoursesSameRoom() throws Exception{
147147
ConstraintTestHelper.DUMMY_ROOM);
148148

149149
//reasoning: proper studios use lab room for lec and lab/act portions, but non proper doesn't use it during lec
150-
constraintVerifier.verifyThat(TimetableConstraintProvider::labActRoomConflict)
150+
constraintVerifier.verifyThat(TimetableConstraintProvider::roomConflict)
151151
.given(combo1_st1, combo1_non_st1)
152152
.penalizesBy(NO_PENALTY);
153153

java/hello-world/src/test/java/org/acme/schooltimetabling/solver/TestConstraints.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.acme.schooltimetabling.solver;
22

3-
import ai.timefold.solver.core.api.score.stream.Constraint;
43
import org.acme.schooltimetabling.builders.lessons.LessonBuilder;
54
import org.acme.schooltimetabling.builders.teachers.TeacherBuilder;
65
import org.acme.schooltimetabling.builders.teachers.policies.DefaultTeachingPolicy;
@@ -80,7 +79,7 @@ void sameLessonNTeacher(){
8079
.build();
8180

8281

83-
constraintVerifier.verifyThat(TimetableConstraintProvider::sameClassSameDays)
82+
constraintVerifier.verifyThat(TimetableConstraintProvider::teacherSameCourseSamePattern)
8483
.given(ls1, ls2, ls3, ls4, ls5)
8584
/*Note this takes into account weight of rewards*/
8685
.penalizesBy(3);
@@ -265,7 +264,7 @@ void roomMultiLessons(){
265264
"3-0-0", 2, ConstraintTestHelper.DUMMY_TEACHER, ts_mwf_11,
266265
ConstraintTestHelper.DUMMY_ROOM);
267266

268-
constraintVerifier.verifyThat(TimetableConstraintProvider::labActRoomConflict)
267+
constraintVerifier.verifyThat(TimetableConstraintProvider::roomConflict)
269268
.given(lesson1, lesson2, lesson3, lesson4studio)
270269
.penalizesBy(2);
271270
}
@@ -287,7 +286,7 @@ void roomMultiLessons2(){
287286
, "", "3-1-0", 1, ConstraintTestHelper.DUMMY_TEACHER, timeslot2,
288287
ConstraintTestHelper.DUMMY_ROOM);
289288

290-
constraintVerifier.verifyThat(TimetableConstraintProvider::labActRoomConflict)
289+
constraintVerifier.verifyThat(TimetableConstraintProvider::roomConflict)
291290
.given(lesson1, lesson2)
292291
.penalizesBy(1);
293292
}

0 commit comments

Comments
 (0)