public Chromosome[] doubleDaysCrossover(Chromosome secondParent, int crossoverLine, String specialty) { Chromosome first = new Chromosome(this); Chromosome second = new Chromosome(secondParent); for (int i = 0; _timetable.ElementAt(i).Value != _timetable[specialty]; i++) { second._timetable[second._timetable.ElementAt(i).Key] = _timetable.ElementAt(i).Value; first._timetable[_timetable.ElementAt(i).Key] = secondParent._timetable.ElementAt(i).Value; } WorkingWeek weekFirst = new WorkingWeek(_timetable[specialty]); WorkingWeek weekSecond = new WorkingWeek(secondParent._timetable[specialty]); for (int j = 0; j < crossoverLine; j++) { weekFirst._week[weekFirst._week.ElementAt(j).Key] = secondParent._timetable[specialty]._week.ElementAt(j).Value; weekSecond._week[weekSecond._week.ElementAt(j).Key] = _timetable[specialty]._week.ElementAt(j).Value; } first._timetable[specialty] = weekFirst; second._timetable[specialty] = weekSecond; return(new Chromosome[] { first, second }); }
public Dictionary <String, List <Lesson> > GetAllLessonsSet() //required for checking amount of specific lectures/practices { Dictionary <String, List <Lesson> > lessonsSet = new Dictionary <string, List <Lesson> >(); for (int i = 0; i < _timetable.Count; i++) { lessonsSet.Add(_timetable.ElementAt(i).Key, new List <Lesson>()); WorkingWeek specialtyWeek = _timetable.ElementAt(i).Value; for (int j = 0; j < specialtyWeek._week.Count; j++) { WorkingDay day = specialtyWeek._week.ElementAt(j).Value; for (int k = 0; k < day._day.Count; k++) { if (!day._day.ElementAt(k).Value.IsFree) { lessonsSet[_timetable.ElementAt(i).Key].Add(new Lesson(day._day.ElementAt(k).Value)); } } } } return(lessonsSet); }
public WorkingWeek(WorkingWeek week) { _week = new Dictionary <string, WorkingDay>(week._week); }