Example #1
0
    //Rangking populasi dan sorting berdasarkan fitness
    private void RankPopulation()
    {
        //Hitung total fitness setiap gen
        totalFitness = 0;
        for (int i = 0; i < populationSize; i++)
        {
            Genome g = ((Genome)thisGeneration[i]);
            g.ComputeObjectiveFunction();
            totalFitness += g.Fitness;
        }
        thisGeneration.Sort(new GenomeComparer());

        //  sorting fitness setiap gen
        float fitness = 0f;

        fitnessTable.Clear();
        for (int i = 0; i < populationSize; i++)
        {
            fitness += ((Genome)thisGeneration[i]).Fitness;
            fitnessTable.Add((float)fitness);
        }
    }