public Solution readSolution() throws IOException { CurriculumCourseSchedule schedule = new CurriculumCourseSchedule(); schedule.setId(0L); // Name: ToyExample schedule.setName(readStringValue("Name:")); // Courses: 4 int courseListSize = readIntegerValue("Courses:"); // Rooms: 2 int roomListSize = readIntegerValue("Rooms:"); // Days: 5 int dayListSize = readIntegerValue("Days:"); // Periods_per_day: 4 int timeslotListSize = readIntegerValue("Periods_per_day:"); // Curricula: 2 int curriculumListSize = readIntegerValue("Curricula:"); // Constraints: 8 int unavailablePeriodPenaltyListSize = readIntegerValue("Constraints:"); Map<String, Course> courseMap = readCourseListAndTeacherList(schedule, courseListSize); readRoomList(schedule, roomListSize); Map<List<Integer>, Period> periodMap = createPeriodListAndDayListAndTimeslotList(schedule, dayListSize, timeslotListSize); readCurriculumList(schedule, courseMap, curriculumListSize); readUnavailablePeriodPenaltyList( schedule, courseMap, periodMap, unavailablePeriodPenaltyListSize); readEmptyLine(); readConstantLine("END."); createLectureList(schedule); int possibleForOneLectureSize = schedule.getPeriodList().size() * schedule.getRoomList().size(); BigInteger possibleSolutionSize = BigInteger.valueOf(possibleForOneLectureSize).pow(schedule.getLectureList().size()); String flooredPossibleSolutionSize = "10^" + (possibleSolutionSize.toString().length() - 1); logger.info( "CurriculumCourseSchedule {} has {} teachers, {} curricula, {} courses, {} lectures," + " {} periods, {} rooms and {} unavailable period constraints with a search space of {}.", getInputId(), schedule.getTeacherList().size(), schedule.getCurriculumList().size(), schedule.getCourseList().size(), schedule.getLectureList().size(), schedule.getPeriodList().size(), schedule.getRoomList().size(), schedule.getUnavailablePeriodPenaltyList().size(), flooredPossibleSolutionSize); return schedule; }
private void createLectureList(CurriculumCourseSchedule schedule) { List<Course> courseList = schedule.getCourseList(); List<Lecture> lectureList = new ArrayList<Lecture>(courseList.size()); long id = 0L; for (Course course : courseList) { for (int i = 0; i < course.getLectureSize(); i++) { Lecture lecture = new Lecture(); lecture.setId((long) id); id++; lecture.setCourse(course); lecture.setLectureIndexInCourse(i); // Notice that we leave the PlanningVariable properties on null lectureList.add(lecture); } } schedule.setLectureList(lectureList); }