Esempio n. 1
0
        public static void Run()
        {
            lock (uiLock)
            {
                stop = false;
            }
            _minScore = Int32.MaxValue;
            _solutions.Clear();
            _noEvaluated = 0;
            noParSess    = Convert.ToInt32(_parent.NoParSess);
            noSessBlocks = Convert.ToInt32(_parent.NoSessBlocks);
            if (_initMeetings.Count > noSessBlocks * noParSess)
            {
                MessageBox.Show("More sessions than slots. Abort.");
                return;
            }
            _d = new MainUI.ProgressDelegate(_parent.UpdateProgress);
            Schedule emptySched = new Schedule(noParSess, noSessBlocks);
            bool     earlyStop  = false;

            // int total = BuildAndEvalSchedule(_initMeetings.Count, emptySched, ref _minScore, true, ref earlyStop);

            _d.BeginInvoke("Calculating number of candidate schedules...", 0M, null, null);


            _numC = ScheduleEngine.CalculateNoCombis(_initMeetings.Count, noParSess, noSessBlocks);

            _minScore  = Int32.MaxValue;
            emptySched = new Schedule(noParSess, noSessBlocks);
            BuildAndEvalSchedule(_initMeetings.Count, emptySched, ref _minScore, false, ref earlyStop);
            _d.BeginInvoke(String.Format("{0} schedules evaluated. Lowest penalty: {1}", _noEvaluated, _minScore), 100M * (decimal)_noEvaluated / _numC, null, null);
            _parent.Callback(null);
        }
Esempio n. 2
0
        public static void Run_oud()
        {
            facAll    = Faculteit(_parent.LVMeetings.Items.Count);
            _minScore = Int32.MaxValue;
            _solutions.Clear();
            noParSess    = Convert.ToInt32(_parent.NoParSess);
            noSessBlocks = Convert.ToInt32(_parent.NoSessBlocks);
            if (_parent.LVMeetings.Items.Count > noSessBlocks * noParSess)
            {
                MessageBox.Show("More sessions than slots. Abort.");
                return;
            }

            _d = new MainUI.ProgressDelegate(_parent.UpdateProgress);
            _d.BeginInvoke("begin", 0.0M, null, null);
            List <Schedule> allPerms = BuildPermutations(_initMeetings);

            _d.BeginInvoke("midden", 50.0M, null, null);
            FinishPermutations(ref allPerms);

            System.Diagnostics.Trace.WriteLine("we have " + allPerms.Count + " sessions");

            int pi = 0, pN = allPerms.Count;

            foreach (Schedule pSchedule in allPerms)
            {
                int score = pSchedule.Evaluate(_penalties);
                if (score < _minScore)
                {
                    _minScore = score;
                    _solutions.Clear();
                }
                if (score == _minScore)
                {
                    _solutions.Add(pSchedule);
                }
                if (pi % 5000 == 0)
                {
                    _d.BeginInvoke("eval", 50M + (decimal)pi * 50M / pN, null, null);
                }
                pi++;
            }
            _parent.Callback(null);
            _d.BeginInvoke("eind", 100.0M, null, null);
        }