|
12 | 12 | import org.acme.schooltimetabling.helperClasses.BitSetHelper; |
13 | 13 | import org.acme.schooltimetabling.helperClasses.Generators.LessonGenerator; |
14 | 14 | import org.acme.schooltimetabling.helperClasses.ScheduleConfig; |
15 | | -import org.glassfish.jaxb.runtime.v2.runtime.reflect.opt.Const; |
16 | 15 | import org.junit.jupiter.api.BeforeAll; |
17 | | -import org.junit.jupiter.api.Disabled; |
18 | 16 | import org.junit.jupiter.api.DisplayName; |
19 | 17 | import org.junit.jupiter.api.Test; |
20 | 18 | import ai.timefold.solver.test.api.score.stream.ConstraintVerifier; |
21 | 19 |
|
22 | | -import java.sql.Time; |
23 | 20 | import java.time.LocalTime; |
24 | 21 | import java.time.format.DateTimeFormatter; |
25 | 22 | import java.util.BitSet; |
@@ -342,7 +339,7 @@ void noPenLessonRoomCheck(){ |
342 | 339 | Lesson lesson2 = Lesson.test_buildLesson("1", 1, "some only lec course", "", |
343 | 340 | "", "1-0-0", 1111, ConstraintTestHelper.DUMMY_TEACHER, |
344 | 341 | ConstraintTestHelper.DUMMY_TS, LEC_ONLY_ROOM); |
345 | | - Lesson lsLabOnly = Lesson.test_buildLesson("2", 1, ConstraintTestHelper.TEST_RANDOM_LAB_ROOM, |
| 342 | + Lesson lsLabOnly = Lesson.test_buildLesson("2", 1, ConstraintTestHelper.TEST_NAME_RANDOM_LAB_ROOM, |
346 | 343 | "noName", "", "0-0-1", 1, ConstraintTestHelper.DUMMY_TEACHER, |
347 | 344 | ConstraintTestHelper.DUMMY_TS, ConstraintTestHelper.DUMMY_ROOM); |
348 | 345 |
|
@@ -710,6 +707,56 @@ void penalizeDislikedHourGap() { |
710 | 707 | likedGap1, likedGap2) |
711 | 708 | .penalizesBy(2); |
712 | 709 | } |
713 | | -} |
714 | 710 |
|
| 711 | + @Test |
| 712 | + @DisplayName("Penalty: room prescheduling blocks lab and studio lecture") |
| 713 | + void roomPrescheduleConflict() { |
| 714 | + EnumSet<Days> MWF = EnumSet.of(Days.MONDAY, Days.WEDNESDAY, Days.FRIDAY); |
| 715 | + |
| 716 | + BitSet blockedLessonBits = BitSetHelper.timeSlotBitSet(LocalTime.parse("9:00AM", formatter), 2, MWF); |
| 717 | + BitSet blockedLessonBits2 = BitSetHelper.timeSlotBitSet(LocalTime.parse("8:00AM", formatter), 2, MWF); |
| 718 | + Timeslot blockedTimeslot = Timeslot.test_lecLabBitAndDays(1, blockedLessonBits, ConstraintTestHelper.EMPTY_BS, |
| 719 | + MWF, ConstraintTestHelper.NO_DAYS); |
| 720 | + Timeslot blockedTimeslot_LecLab = Timeslot.test_lecLabBitAndDays(2, blockedLessonBits2, blockedLessonBits, |
| 721 | + MWF, MWF); |
| 722 | + |
| 723 | + Lesson blockedLessonLab = Lesson.test_buildLesson("room-blocked-lab", 2, "", "", "", |
| 724 | + "3-1-0", 1, ConstraintTestHelper.DUMMY_TEACHER,blockedTimeslot_LecLab, |
| 725 | + ConstraintTestHelper.TEST_ROOM_PRESCHEDULED); |
| 726 | + Lesson blockedStudio = Lesson.test_buildLesson("room-blocked-studio", 3, ConstraintTestHelper.DUMMY_STUDIO, |
| 727 | + "", "", "1-0-0", Constants.COURSE_ID_BIMAP.get(ConstraintTestHelper.DUMMY_STUDIO), |
| 728 | + ConstraintTestHelper.DUMMY_TEACHER, blockedTimeslot, ConstraintTestHelper.TEST_ROOM_PRESCHEDULED); |
| 729 | + |
| 730 | + constraintVerifier.verifyThat(TimetableConstraintProvider::roomPreschedule) |
| 731 | + .given(blockedLessonLab, blockedStudio) |
| 732 | + .penalizesBy(2); |
| 733 | + } |
| 734 | + |
| 735 | + @Test |
| 736 | + @DisplayName("No Penalty: room prescheduling skip branches") |
| 737 | + void noRoomPrescheduleConflict() { |
| 738 | + EnumSet<Days> MWF = EnumSet.of(Days.MONDAY, Days.WEDNESDAY, Days.FRIDAY); |
| 739 | + |
| 740 | + BitSet roomBlocked = BitSetHelper.timeSlotBitSet(LocalTime.parse("9:00AM", formatter), 2, MWF); |
| 741 | + BitSet bs_10AM = BitSetHelper.timeSlotBitSet(LocalTime.parse("10:00AM", formatter), 2, MWF); |
| 742 | + |
| 743 | + Timeslot blockedTimeslot = Timeslot.test_lecLabBitAndDays(2, roomBlocked, ConstraintTestHelper.EMPTY_BS, |
| 744 | + MWF, ConstraintTestHelper.NO_DAYS); |
| 745 | + Timeslot ts_9AM_10AM_MWF = Timeslot.test_lecLabBitAndDays(2, roomBlocked, bs_10AM, MWF, MWF); |
| 746 | + Timeslot ts_10AM_MWF = Timeslot.test_lecLabBitAndDays(2, bs_10AM, ConstraintTestHelper.EMPTY_BS, MWF, |
| 747 | + ConstraintTestHelper.NO_DAYS); |
715 | 748 |
|
| 749 | + Lesson openLessonLec = Lesson.test_buildLesson("room-open-lec", 1, "", "", "", |
| 750 | + "3-1-0", 1, ConstraintTestHelper.DUMMY_TEACHER, ts_9AM_10AM_MWF, |
| 751 | + ConstraintTestHelper.TEST_ROOM_PRESCHEDULED); |
| 752 | + Lesson lecOnlyRoomLesson = Lesson.test_buildLesson("room-lec-only", 3, "", "", "", |
| 753 | + "1-0-0", 1, ConstraintTestHelper.DUMMY_TEACHER, blockedTimeslot, |
| 754 | + ConstraintTestHelper.TEST_ROOM_PRESCHEDULED); |
| 755 | + Lesson emptyRoomLesson = Lesson.test_buildLesson("room-empty", 4, "", "", "", |
| 756 | + "1-0-0", 1, ConstraintTestHelper.DUMMY_TEACHER, blockedTimeslot, ConstraintTestHelper.DUMMY_ROOM); |
| 757 | + |
| 758 | + constraintVerifier.verifyThat(TimetableConstraintProvider::roomPreschedule) |
| 759 | + .given(openLessonLec, lecOnlyRoomLesson, emptyRoomLesson) |
| 760 | + .penalizesBy(0); |
| 761 | + } |
| 762 | +} |
0 commit comments