Пример #1
0
        private List<Collision> CollisionElectiveVsBaseDiffSemester(int minimumCollision, int semester, int obj = 0)
        {
            List<Collision> collisionList = new List<Collision>();
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    Slot tempSlot = Timetable[i][j];

                    if (tempSlot.Courses.Count(x => x.Elective) > minimumCollision && tempSlot.Courses.Count(x => x.Semester == semester && !x.Elective) > minimumCollision)
                    {
                        var electives = tempSlot.Courses.Where(x => x.Elective).ToList();
                        var baselectures = tempSlot.Courses.Where(x => x.Semester == semester && !x.Elective).ToList();

                        foreach (var elective in electives)
                        {
                            foreach (var baselecture in baselectures)
                            {
                                if (!elective.prerequisites.Contains(baselecture.Id))
                                {
                                    Collision tempCollision = new Collision
                                    {
                                        SlotId = tempSlot.Id,
                                        Obj = obj,
                                        Type = CollisionType.CourseCollision,
                                        Result = 1,
                                        Reason = $"Elective v Base Semester {semester}"
                                    };
                                    tempCollision.CrashingCourses.Add(elective);
                                    tempCollision.CrashingCourses.Add(baselecture);

                                    collisionList.Add(tempCollision);
                                }
                            }
                        }

                    }
                }
            }
            return collisionList;
        }
Пример #2
0
        private List<Collision> CollisionElectiveVsFacultyDiffSemester(int facultySemester, int minimumCollision, int obj = 2)
        {
            List<Collision> collisionList = new List<Collision>();
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    Slot tempSlot = Timetable[i][j];

                    if (tempSlot.Courses.Count(x => x.Elective) > minimumCollision && tempSlot.facultyCourses.Count(x => x.Semester == facultySemester) > minimumCollision)
                    {
                        var crashingFacultyCourses = tempSlot.facultyCourses.Where(x => x.Semester == facultySemester);

                        foreach (var course in crashingFacultyCourses)
                        {
                            if (ElectiveFacultySections.Any(x => x.Code == course.Code && x.Section == course.Section))
                            {
                                FacultySection temp =
                                    ElectiveFacultySections.Find(x => x.Code == course.Code && x.Section == course.Section);
                                temp.CrashCount++;
                                temp.Crashing = true;
                            }
                        }

                        Collision tempCollision = new Collision
                        {
                            SlotId = tempSlot.Id,
                            Obj = obj,
                            Type = CollisionType.CourseCollision,
                            Result = tempSlot.Courses.Count(x => x.Elective) + tempSlot.facultyCourses.Count(x => x.Semester == facultySemester) - 1,
                            Reason = $"Elective v Faculty Semester {facultySemester}"
                        };
                        tempCollision.CrashingCourses.AddRange(tempSlot.Courses.FindAll(x => x.Elective));
                        tempCollision.CrashingCourses.AddRange(tempSlot.facultyCourses.FindAll(x => x.Semester == facultySemester));

                        collisionList.Add(tempCollision);
                    }
                }
            }
            return collisionList;
        }
Пример #3
0
        static List<Collision> CollisionTeacherFreeDay(List<List<Slot>> timeTable, int teacherId)
        {
            List<Collision> collisionList = new List<Collision>();
            for (int i = 0; i < 5; i++) //gun
            {
                var counter = 0;
                for (int j = 0; j < 9; j++) //saatler
                {
                    Slot tempSlot = timeTable[i][j];

                    if (tempSlot.Courses.Any(x => x.TeacherId == teacherId) || tempSlot.meetingHour)
                    {
                        counter = 0;
                        break;
                    }

                    counter++; //boş saat
                }
                if (counter == 9) //9saat boşsa 1 günü boş.
                {
                    return collisionList;
                }

            }

            Collision tempCollision = new Collision
            {
                Obj = 2,
                Type = CollisionType.TeacherCollision,
                TeacherId = teacherId,
                Result = 1, // 1
                Reason = "Teacher doesnt have free day"
            };
            collisionList.Add(tempCollision);

            return collisionList;
        }
Пример #4
0
        private List<Collision> CollisionBaseVsFaculty(int minimumCollision, int obj = 0)
        {
            List<Collision> collisionList = new List<Collision>();
            for (int semester = 1; semester < 9; semester++)
            {
                for (int i = 0; i < 5; i++)
                {
                    for (int j = 0; j < 9; j++)
                    {
                        Slot tempSlot = Timetable[i][j];

                        if (tempSlot.Courses.Count(x => x.Semester == semester && !x.Elective) > minimumCollision &&
                            tempSlot.facultyCourses.Count(x => x.Semester == semester) > minimumCollision)
                        {
                            var semester1 = semester;
                            var crashingFacultyCourses = tempSlot.facultyCourses.Where(x => x.Semester == semester1);

                            foreach (var course in crashingFacultyCourses)
                            {
                                if (FacultySections.Any(x => x.Code == course.Code && x.Section == course.Section))
                                {
                                    FacultySection temp =
                                        FacultySections.Find(x => x.Code == course.Code && x.Section == course.Section);
                                    temp.CrashCount++;
                                    temp.Crashing = true;
                                }
                            }

                            Collision tempCollision = new Collision
                            {
                                SlotId = tempSlot.Id,
                                Obj = obj,
                                Type = CollisionType.BaseLectureWithFaculty,
                                Result = tempSlot.facultyCourses.Count(x => x.Semester == semester),
                                Reason = "Base v Faculty same semester"
                            };
                            tempCollision.CrashingCourses.AddRange(
                                tempSlot.Courses.FindAll(x => x.Semester == semester && !x.Elective));
                            tempCollision.CrashingCourses.AddRange(
                                tempSlot.facultyCourses.FindAll(x => x.Semester == semester));

                            collisionList.Add(tempCollision);
                        }
                    }
                }
            }
            return collisionList;
        }
Пример #5
0
        static List<Collision> CollisionTeacher(List<List<Slot>> timeTable, int teacherId, int minimumCollision, int obj = 0)
        {
            List<Collision> collisionList = new List<Collision>();
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    Slot tempSlot = timeTable[i][j];

                    int lectures = tempSlot.Courses.FindAll(x => x.TeacherId == teacherId).Count;
                    if (tempSlot.meetingHour)
                        lectures++;

                    if (lectures > minimumCollision)
                    {
                        Collision tempCollision = new Collision
                        {
                            SlotId = tempSlot.Id,
                            Obj = obj,
                            Type = CollisionType.TeacherCollision,
                            TeacherId = teacherId,
                            Result = lectures - minimumCollision,
                            Reason = "Teacher has multiple lectures in same hour"
                        };
                        tempCollision.CrashingCourses.AddRange(tempSlot.Courses.FindAll(x => x.TeacherId == teacherId));

                        collisionList.Add(tempCollision);
                    }

                }

            }
            return collisionList;
        }
Пример #6
0
        static List<Collision> CollisionTeacherConsicutive(List<List<Slot>> timeTable, int teacherId, int maxConsecutiveHour)
        {
            List<Collision> collisionList = new List<Collision>();

            int result = 0;
            for (int i = 0; i < 5; i++) //gün
            {
                var counter = 0;
                for (int j = 0; j < 9; j++) //saat
                {
                    Slot tempSlot = timeTable[i][j];

                    if (tempSlot.Courses.Any(x => x.TeacherId == teacherId) || tempSlot.meetingHour) //dersi veya meetingi varsa ++
                    {
                        counter++;
                    }
                    else
                    {
                        counter = 0; // ara varsa 0'la
                    }
                    if (counter > maxConsecutiveHour)
                    {
                        result++;
                    }
                }
            }
            if (result > 0)
            {
                Collision tempCollision = new Collision
                {
                    Obj = 2,
                    Type = CollisionType.TeacherCollision,
                    TeacherId = teacherId,
                    Result = 1, // how many crash
                    Reason = "Teacher has too much consicutive courses."
                };
                collisionList.Add(tempCollision);
            }
            return collisionList;
        }
Пример #7
0
        static List<Collision> CollisionLabLectureSameDay(List<List<Slot>> timeTable, int obj = 2)
        {
            List<Collision> collisionList = new List<Collision>();
            for (int i = 0; i < 5; i++)
            {
                List<Course> lectures = new List<Course>();
                List<Course> labs = new List<Course>();

                for (int j = 0; j < 9; j++)
                {
                    Slot tempSlot = timeTable[i][j];

                    lectures.AddRange(tempSlot.Courses.Where(x => x.Type == 0));
                    labs.AddRange(tempSlot.Courses.Where(x => x.Type == 1));
                }

                if (labs.Count > 0 && lectures.Count > 0) //hem lab hem lecture varsa
                {
                    foreach (Course lab in labs)
                    {
                        foreach (Course lecture in lectures)
                        {
                            if (lecture.Code == lab.Code)
                            {
                                Collision tempCollision = new Collision
                                {
                                    Obj = obj,
                                    Type = CollisionType.CourseCollision,
                                    Result = 1,
                                    Reason = "Lab and Lecture in same day"
                                };
                                tempCollision.CrashingCourses.Add(lab);
                                tempCollision.CrashingCourses.Add(lecture);

                                collisionList.Add(tempCollision);
                                break; //bir çakışma yetiyor.
                            }
                        }
                    }

                }

            }
            return collisionList;
        }
Пример #8
0
        static List<Collision> CollisionInLabs(List<List<Slot>> timeTable, int minimumCollision, int obj = 0)
        {
            List<Collision> collisionList = new List<Collision>();
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    Slot tempSlot = timeTable[i][j];

                    if (tempSlot.labCount + tempSlot.facultyLab > minimumCollision)
                    {
                        Collision tempCollision = new Collision
                        {
                            SlotId = tempSlot.Id,
                            Obj = obj,
                            Type = CollisionType.CourseCollision,
                            Result = tempSlot.labCount + tempSlot.facultyLab - minimumCollision,
                            Reason = "Lab lectures > available lab count"
                        };
                        tempCollision.CrashingCourses.AddRange(tempSlot.Courses.FindAll(x => x.Type == 1));

                        collisionList.Add(tempCollision);
                    }

                }

            }
            return collisionList;
        }
Пример #9
0
        static List<Collision> CollisionElectiveVsElective(List<List<Slot>> timeTable, int minimumCollision, int obj = 0)
        {
            List<Collision> collisionList = new List<Collision>();
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    Slot tempSlot = timeTable[i][j];

                    if (tempSlot.Courses.FindAll(x => x.Elective).Count > minimumCollision)
                    {
                        Collision tempCollision = new Collision
                        {
                            SlotId = tempSlot.Id,
                            Obj = obj,
                            Type = CollisionType.CourseCollision,
                            Result = tempSlot.Courses.FindAll(x => x.Elective).Count - minimumCollision,
                            Reason = "Elective v Elective"
                        };
                        tempCollision.CrashingCourses.AddRange(tempSlot.Courses.FindAll(x => x.Elective));

                        collisionList.Add(tempCollision);
                    }
                }
            }
            return collisionList;
        }
Пример #10
0
        static List<Collision> CollisionBaseVsBaseDiffSemester(List<List<Slot>> timeTable, int minimumCollision, List<int> semesters, int obj = 0)
        {
            List<Collision> collisionList = new List<Collision>();
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    Slot tempSlot = timeTable[i][j];

                    List<Course> selectedSemesterCourses = tempSlot.Courses.Where(x => semesters.Contains(x.Semester) && !x.Elective).ToList();

                    List<Course> nonPreCourses = selectedSemesterCourses.Where(item => !selectedSemesterCourses.Any(x => item.prerequisites.Contains(x.Id))).ToList();

                    var slotSemesters = nonPreCourses.Select(x => x.Semester);

                    bool multiSemesterInSlot = semesters.All(x => slotSemesters.Contains(x));

                    if (multiSemesterInSlot && nonPreCourses.Count(x => !x.Elective) > minimumCollision)
                    {
                        Collision tempCollision = new Collision
                        {
                            SlotId = tempSlot.Id,
                            Obj = obj,
                            Result = nonPreCourses.FindAll(x => semesters.Contains(x.Semester) && !x.Elective).Count - 1,
                            Reason = "Base v Base different semester"
                        };
                        tempCollision.CrashingCourses.AddRange(nonPreCourses.Where(x => !x.Elective));

                        collisionList.Add(tempCollision);
                    }
                }
            }
            return collisionList;
        }
Пример #11
0
        static List<Collision> CollisionBaseVsBase(List<List<Slot>> timeTable, int minimumCollision, int semester, int obj = 0)
        {
            List<Collision> collisionList = new List<Collision>();
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    Slot tempSlot = timeTable[i][j];

                    if (tempSlot.Courses.FindAll(x => x.Semester == semester && !x.Elective).Count > minimumCollision)
                    {
                        Collision tempCollision = new Collision
                        {
                            SlotId = tempSlot.Id,
                            Obj = obj,
                            Type = CollisionType.BaseLectureWithBase,
                            Result = tempSlot.Courses.FindAll(x => x.Semester == semester && !x.Elective).Count - 1,
                            Reason = "Base v Base same semester"
                        };
                        tempCollision.CrashingCourses.AddRange(tempSlot.Courses.FindAll(x => x.Semester == semester && !x.Elective));

                        collisionList.Add(tempCollision);
                    }
                }
            }
            return collisionList;
        }