示例#1
0
 public void CombinedPopulationCount()
 {
     int pop = 10;
     Population p1 = new Population();
     p1.NewPopulation(pop);
     Population p2 = new Population();
     p2.NewPopulation(pop);
     Population p3 = p1.Concat(p2);
     Assert.AreEqual(p3.GetCount(), p1.GetCount() + p2.GetCount());
 }
示例#2
0
        public void SelectionCountTest()
        {
            int pop = 10;
            Population genom = new Population();
            genom.NewPopulation(pop);
            Population genom2 = new Population();
            genom2.NewPopulation(pop);
            Population combined = genom.Concat(genom2);

            genom = combined.Selection();
            Assert.AreEqual(combined.GetCount() / 2, genom.GetCount());
        }
示例#3
0
        public Population StartEvaluation(int populationCount, int generationCount)
        {
            infinite = 10000;
            Population genom = new Population();
            genom.NewPopulation(populationCount);
            Console.WriteLine("Initial population");
            genom.PrintToConsole();
            Population newGenom = genom.CreateOffspring();
            Console.WriteLine("Initial population after creating offspring pop");
            genom.PrintToConsole();
            Console.WriteLine("Offspring population");
            newGenom.PrintToConsole();
            FastNonDominatedSort(genom);
            RankingsPrintToConsole();
            for (int i = 0; i < generationCount; i++)
            {
                Population combinedGenom = genom.Concat(newGenom);
                FastNonDominatedSort(combinedGenom);
                genom.RemoveAll();
                AssignCrowdingDistance();
                genom.Copy(SortPopulation(combinedGenom).Selection());
                newGenom = genom.CreateOffspring();
            }

            newGenom.PrintToConsole();
            this.RankingsPrintToConsole();
            //PrintToConsole(genom);
               // genom.PrintToConsole();

            return genom;
        }