public SchoolTimetable(SchoolTimetable s) : this(s.getTeachers(), s.getGroups(), s.getRooms(), s.getLessons(), s.getNumberOfDays(), s.getNumberOfSlots(), s.getConfig()) { generateGroupsTimetables(groups); generateRoomsTimetables(rooms); generateTeachersTimetables(teachers); unlockAllSlots(); for (int i = 0; i < s.getLessons().Count; i++) { List <TimeSlot> ts = s.getLessons()[i].getSlots(); if (s.getLessons()[i].getRoom() != null) { Room room = this.rooms[s.getRooms().IndexOf(s.getLessons()[i].getRoom())]; this.getLessons()[i].setRoom(room); foreach (TimeSlot t in ts) { this.getLessons()[i].addLessonToTimetable(t.day, t.hour); } } } }
public int schoolTimeTableComparator(SchoolTimetable l1, SchoolTimetable l2) { return(l1.getFitnessValue().CompareTo(l2.getFitnessValue())); }
public void crossover(SchoolTimetable stt) { List <Lesson> tmp_lessons = new List <Lesson>(); int counter = 0; for (int i = 0; i < this.groupsTimetables.Count; i++) { if (this.groupsTimetables[i].getGroup().getParent() == null) { foreach (TimeSlot ts in this.groupsTimetables[i].getSlotsWithLesson()) { if (this.groupsTimetables[i].getLessons(ts.day, ts.hour).Count == 1 && stt.groupsTimetables[i].getLessons(ts.day, ts.hour).Count == 1 && this.groupsTimetables[i].getLessons(ts.day, ts.hour)[0].getSize() == 1 && this.groupsTimetables[i].getLessons(ts.day, ts.hour)[0].getSubject().Equals( stt.groupsTimetables[i].getLessons(ts.day, ts.hour)[0].getSubject() ) ) { counter++; //Console.Write(this.groupsTimetables[i].getLessons(ts.day, ts.hour)[0].ToString() + " <=> "); //Console.WriteLine(stt.groupsTimetables[i].getLessons(ts.day, ts.hour)[0].ToString()); this.groupsTimetables[i].getLessons(ts.day, ts.hour)[0].lockSlots(ts.day, ts.hour); } else { if (this.groupsTimetables[i].getLessons(ts.day, ts.hour).Count > 0) { //Console.WriteLine("x: " + this.groupsTimetables[i].getLessons(ts.day, ts.hour)[0].ToString()); if (ts.Equals(this.groupsTimetables[i].getLessons(ts.day, ts.hour)[0].getSlots()[0])) { tmp_lessons.AddRange(this.groupsTimetables[i].getLessons(ts.day, ts.hour)); } } } } } } foreach (Lesson l in tmp_lessons) { //Console.WriteLine("rem : "+ l.ToString()); for (int i = 0; i < l.getSize(); i++) { if (l.getSlots().Count > 0 && l.getSlots()[0] != null) { //Console.WriteLine(l.getSlots()[0].day + ":" + l.getSlots()[0].hour); l.removeLessonFromTimetable(l.getSlots()[0].day, l.getSlots()[0].hour); } } l.getSlots().Clear(); l.setRoom(null); } sortLessons(tmp_lessons); //Console.WriteLine("============ do wstawienia ========="); foreach (Lesson l in tmp_lessons) { //Console.WriteLine("d : " + l.ToString()); } //print(); //Console.WriteLine("===================================="); this.genereteTimetable(tmp_lessons); }