예제 #1
0
        public void TestGenerating()
        {
            List <Lesson>  lessons  = new List <Lesson>();
            List <Teacher> teachers = new List <Teacher>();
            List <Group>   groups   = new List <Group>();
            List <Subject> subjects = new List <Subject>();
            List <Room>    rooms    = new List <Room>();

            // Console.WriteLine("create 6 teachers");
            for (int j = 0; j < 7; j++)
            {
                teachers.Add(new Teacher(j, "t" + j));
            }

            //Console.WriteLine("create 6 groups");
            for (int j = 0; j < 6; j++)
            {
                groups.Add(new Group(j, "g" + j, 25 + j));
            }
            int nr = 0;

            rooms.Add(new Room(nr, "nr" + nr++, 25, "A"));
            rooms.Add(new Room(nr, "nr" + nr++, 40, "A"));
            rooms.Add(new Room(nr, "nr" + nr++, 40, "A"));
            rooms.Add(new Room(nr, "nr" + nr++, 40, "A"));
            rooms.Add(new Room(nr, "nr" + nr++, 40, "B"));
            rooms.Add(new Room(nr, "nr" + nr++, 40, "B"));
            rooms.Add(new Room(nr, "nr" + nr++, 40, "C"));

            //Console.WriteLine("create 10 subject");
            int i = 0;

            subjects.Add(new Subject(i++, "pol", SubjectType.HUM, "A"));
            subjects.Add(new Subject(i++, "ang", SubjectType.JEZ, "A"));
            subjects.Add(new Subject(i++, "mat", SubjectType.SCI, "A"));
            subjects.Add(new Subject(i++, "his", SubjectType.HUM, "A"));
            subjects.Add(new Subject(i++, "wos", SubjectType.HUM, "A"));
            subjects.Add(new Subject(i++, "fiz", SubjectType.SCI, "A"));
            subjects.Add(new Subject(i++, "bio", SubjectType.SCI, "A"));
            subjects.Add(new Subject(i++, "geo", SubjectType.SCI, "A"));
            subjects.Add(new Subject(i++, "w-f", SubjectType.SPO, "C"));
            subjects.Add(new Subject(i++, "rel", SubjectType.INN, "A"));
            subjects.Add(new Subject(i++, "inf", SubjectType.SPE, "B"));
            subjects.Add(new Subject(i++, "PRO", SubjectType.SPE, "B"));

            Console.WriteLine("create list of lesson");
            foreach (Group g in groups)
            {
                int tI     = 0;
                int sI     = 0;
                int amount = 0;
                //max = 45
                //----------pol----------
                tI = 0; sI = 0; amount = 5;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount, 2));
                //----------ang----------
                tI = 1; sI = 1; amount = 4;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------mat----------
                tI = 2; sI = 2; amount = 5;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------his----------
                tI = 3; sI = 3; amount = 1;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------wos----------
                tI = 3; sI = 4; amount = 2;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------fiz----------
                tI = 5; sI = 5; amount = 2;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------bio----------
                tI = 3; sI = 6; amount = 1;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------geo----------
                tI = 3; sI = 7; amount = 2;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------w-f----------
                tI = 4; sI = 8; amount = 3;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------rel----------
                tI = 5; sI = 9; amount = 2;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------inf----------
                tI = 4; sI = 10; amount = 2;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------pro----------
                tI = 6; sI = 11; amount = 5;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount, 2));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount, 3));
            }

            SchoolTimeTable stt = new SchoolTimeTable(lessons, teachers, groups, rooms);

            stt.teacherTimeTables[5].getDays()[0].getSlots()[0].lockSlot();
            stt.teacherTimeTables[5].getDays()[1].getSlots()[1].lockSlot();
            stt.teacherTimeTables[5].getDays()[2].getSlots()[2].lockSlot();
            stt.teacherTimeTables[5].getDays()[3].getSlots()[3].lockSlot();
            stt.teacherTimeTables[5].getDays()[4].getSlots()[4].lockSlot();

            stt.generateSchoolTimeTable();
            stt.printTimeTable();
            stt.timeTableCheckSume();
        }
예제 #2
0
        public void TestCrossing()
        {
            List <Lesson>  lessons  = new List <Lesson>();
            List <Teacher> teachers = new List <Teacher>();
            List <Group>   groups   = new List <Group>();
            List <Subject> subjects = new List <Subject>();

            // Console.WriteLine("create 7 teachers");
            for (int j = 0; j < 2; j++)
            {
                teachers.Add(new Teacher(j, "t" + j));
            }
            //Console.WriteLine("create 6 groups");
            for (int j = 0; j < 6; j++)
            {
                groups.Add(new Group(j, "g" + j));
            }
            //Console.WriteLine("create 10 subject");
            int i = 0;

            subjects.Add(new Subject(i++, "pol", SubjectType.HUM));
            subjects.Add(new Subject(i++, "mat", SubjectType.SCI));


            Console.WriteLine("create list of lesson");
            foreach (Group g in groups)
            {
                int tI     = 0;
                int sI     = 0;
                int amount = 0;
                //max = 45
                //----------pol----------
                tI = 0; sI = 0; amount = 5;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount, 2));

                tI = 1; sI = 1; amount = 6;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
            }

            SchoolTimeTable stt1 = new SchoolTimeTable(lessons, teachers, groups);

            stt1.generateSchoolTimeTable();
            stt1.printTimeTable();

            SchoolTimeTable stt2 = new SchoolTimeTable(lessons, teachers, groups);

            stt2.generateSchoolTimeTable();
            stt2.printTimeTable();

            SchoolTimeTable stt3 = new SchoolTimeTable(lessons, teachers, groups);

            stt3.crossSchoolTimeTables(stt1, stt2);
            stt3.printSimpleTimeTable();
        }
예제 #3
0
        public void TestMutating()
        {
            List <Lesson>  lessons  = new List <Lesson>();
            List <Teacher> teachers = new List <Teacher>();
            List <Group>   groups   = new List <Group>();
            List <Subject> subjects = new List <Subject>();

            // Console.WriteLine("create 6 teachers");
            for (int j = 0; j < 7; j++)
            {
                teachers.Add(new Teacher(j, "t" + j));
            }
            //Console.WriteLine("create 6 groups");
            for (int j = 0; j < 6; j++)
            {
                groups.Add(new Group(j, "g" + j));
            }
            //Console.WriteLine("create 10 subject");
            int i = 0;

            subjects.Add(new Subject(i++, "pol", SubjectType.HUM));
            subjects.Add(new Subject(i++, "ang", SubjectType.JEZ));
            subjects.Add(new Subject(i++, "mat", SubjectType.SCI));
            subjects.Add(new Subject(i++, "his", SubjectType.HUM));
            subjects.Add(new Subject(i++, "wos", SubjectType.HUM));
            subjects.Add(new Subject(i++, "fiz", SubjectType.SCI));
            subjects.Add(new Subject(i++, "bio", SubjectType.SCI));
            subjects.Add(new Subject(i++, "geo", SubjectType.SCI));
            subjects.Add(new Subject(i++, "w-f", SubjectType.SPO));
            subjects.Add(new Subject(i++, "rel", SubjectType.INN));
            subjects.Add(new Subject(i++, "inf", SubjectType.SPE));
            subjects.Add(new Subject(i++, "PRO", SubjectType.SPE));

            Console.WriteLine("create list of lesson");
            foreach (Group g in groups)
            {
                int tI     = 0;
                int sI     = 0;
                int amount = 0;
                //max = 45
                //----------pol----------
                tI = 0; sI = 0; amount = 5;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount, 2));
                //----------ang----------
                tI = 1; sI = 1; amount = 4;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------mat----------
                tI = 2; sI = 2; amount = 5;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------his----------
                tI = 3; sI = 3; amount = 1;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------wos----------
                tI = 3; sI = 4; amount = 2;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------fiz----------
                tI = 5; sI = 5; amount = 2;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------bio----------
                tI = 3; sI = 6; amount = 1;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------geo----------
                tI = 3; sI = 7; amount = 2;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------w-f----------
                tI = 4; sI = 8; amount = 3;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------rel----------
                tI = 5; sI = 9; amount = 3;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------inf----------
                tI = 4; sI = 10; amount = 2;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount));
                //----------pro----------
                tI = 6; sI = 11; amount = 5;
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount, 2));
                lessons.Add(new Lesson(teachers[tI], g, subjects[sI], amount, 3));
            }

            SchoolTimeTable stt = new SchoolTimeTable(lessons, teachers, groups);

            stt.generateSchoolTimeTable();
            stt.printTimeTable();
            stt.timeTableCheckSume();
            Console.WriteLine("\n\n\n");
            stt.mutate();
            stt.printTimeTable();
        }