예제 #1
0
 private void MuatatePopulation()
 {
     currentPopulation.Sort();
     for (int i = IdealCount; i < PopulationSize; ++i)
     {
         Shedule sh = Mutate(currentPopulation.shedules[i].Item1);
         currentPopulation.shedules[i] = new Tuple <Shedule, int>(sh, sh.GetConflictsCount());
     }
 }
예제 #2
0
        public Population(Data data, int PopulationSize, Random rand)
        {
            shedules = new List <Tuple <Shedule, int> >();

            for (int i = 0; i < PopulationSize; ++i)
            {
                Shedule s = new Shedule(data, rand);
                shedules.Add(new Tuple <Shedule, int>(s, s.GetConflictsCount()));
            }
        }
예제 #3
0
        private void CrossOverPopulation()
        {
            Population newPopulation = new Population();

            currentPopulation.Sort();

            for (int i = 0; i < IdealCount; ++i)
            {
                newPopulation.shedules.Add(currentPopulation.shedules[i]);
            }

            for (int i = IdealCount; i < PopulationSize; ++i)
            {
                Shedule sh1   = currentPopulation.shedules[rand.Next(currentPopulation.shedules.Count()) % TopForCrossOvering].Item1;
                Shedule sh2   = currentPopulation.shedules[rand.Next(currentPopulation.shedules.Count()) % TopForCrossOvering].Item1;
                Shedule newSh = CrossShedules(sh1, sh2);
                newPopulation.shedules.Add(new Tuple <Shedule, int>(newSh, newSh.GetConflictsCount()));
            }

            currentPopulation = newPopulation;
        }