Пример #1
0
        private void ResultForm_Load(object sender, EventArgs e)
        {
            Configuration.GetInstance.ParseFile(new LINQDataContext());
            btnPause.Enabled = false;
            btnStop.Enabled  = false;

            if (Configuration.GetInstance.GetNumberOfRooms() > 0)
            {
                create_GridView = new CreateDataGridViews(Configuration.GetInstance.Rooms, this);
                Schedule prototype            = new Schedule(5, 5, 90, 10);
                Schedule.ScheduleObserver sso = new Schedule.ScheduleObserver();
                sso.SetWindow(create_GridView);

                AA = new MakeClassSchedule.Algorithm.Algorithm(1000, 180, 50, prototype, sso);

                state = ThreadState.Unstarted;
                timerWorkingSet.Start();
            }
            else
            {
                MessageBox.Show("Number of rooms is less than the limit!", "Number of Rooms Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                timerWorkingSet.Stop();
                AA = null;
                Dispose();
                return;
            }

            if (Configuration.GetInstance.GetNumberOfCourseClasses() <= 0)
            {
                btnStart.Enabled = false;
            }
        }
        private void ResultForm_Load(object sender, EventArgs e)
        {
            rooms         = roomReader.GetRooms();
            courses       = courseReader.GetCourses();
            prelectors    = prelectorReader.GetPrelectors();
            studentGroups = studentGroupReader.GetStudentGroups();

            courseClassReader.ResetData();
            if (_isExamProblem)
            {
                courseClasses = courseClassReader.GetCourseClasses();
            }
            else
            {
                courseClasses = courseClassReader.GetCourseClassesWithoutRoomSplit();
            }

            prelectors    = prelectorReader.UpdateCourseClasses(courseClasses);
            studentGroups = studentGroupReader.UpdateCourseClasses(courseClasses);

            Configuration.GetInstance.InitializeDate(prelectors, studentGroups, courses, rooms, courseClasses);

            btnPause.Enabled = false;
            btnStop.Enabled  = false;

            if (Algorithm.Configuration.GetInstance.GetNumberOfRooms() > 0)
            {
                _createGridView = new CreateDataGridViews(Configuration.GetInstance.Rooms, this);
                Schedule prototype = new Schedule(int.Parse(PARAMETER_NUMBER_OF_CROSSOVER_POINTS), int.Parse(PARAMETER_MUTAITION_SIZE),
                                                  int.Parse(PARAMETER_CROSSOVER_PROBABILITY), int.Parse(PARAMETER_MUTAITION_PROBABILITY), _isExamProblem);
                Schedule.ScheduleObserver sso = new Schedule.ScheduleObserver();
                sso.SetWindow(_createGridView);

                _algorithm = new Algorithm.Algorithm(int.Parse(PARAMETER_NUMBER_OF_CHROMOSOMES), int.Parse(PARAMETER_REPLACE_BY_GENERATION),
                                                     int.Parse(PARAMETER_TRACK_BEST), prototype, sso, _isExamProblem);

                _state = ThreadState.Unstarted;
                timerWorkingSet.Start();
            }
            else
            {
                MessageBox.Show("Not found any room!", "Number of Rooms Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                timerWorkingSet.Stop();
                _algorithm = null;
                Dispose();
                return;
            }

            if (Configuration.GetInstance.GetNumberOfCourseClasses() <= 0)
            {
                btnStart.Enabled = false;
            }
        }