Exemplo n.º 1
0
 public void Initialize(List <GAType> pop)
 {
     for (int i = 0; i < POPULATION_SIZE; i++)
     {
         var gAType = new GAType();
         GetRandomGene(gAType.gene, OBJ_COUNT);
         gAType.fitness = 0;
         gAType.rf      = 0.0;
         gAType.cf      = 0.0;
         pop.Add(gAType);
     }
 }
Exemplo n.º 2
0
        public GAType Clone()
        {
            var gAType = new GAType();

            for (int i = 0; i < gene.Length; i++)
            {
                gAType.gene[i] = gene[i];
            }
            gAType.fitness = fitness;
            gAType.rf      = rf;
            gAType.cf      = cf;
            return(gAType);
        }
Exemplo n.º 3
0
        public int GetBestPopulation(List <GAType> pop, out GAType bestGene)
        {
            int best = 0;

            for (int i = 0; i < POPULATION_SIZE; i++)
            {
                if (pop[i].fitness > pop[best].fitness)
                {
                    best = i;
                }
            }
            bestGene = pop[best].Clone();

            return(best);
        }