예제 #1
0
        private BitIndividual SelectWithReplacement(List <BitIndividual> population)
        {
            BitIndividual best = new BitIndividual(population[0]);

            population.Remove(population[0]);
            return(best);
        }
예제 #2
0
        private int FitnessFunction(BitIndividual ind)
        {
            int r = 0;

            for (int i = 0; i < ind.Chromosome.Count; ++i)
            {
                r += ind.Chromosome[i].Value == this.bestIndividual.Chromosome[i].Value ? 1 : 0;
            }
            return(r);
        }
예제 #3
0
 public GeneticAlgorithm(int populationSize, int maxEpoch, Double mutationProbability, int geneCount)
 {
     this.mutationProbability = mutationProbability;
     this.maxEpoch            = maxEpoch;
     this.populationSize      = populationSize;
     this.geneCount           = geneCount;
     this.population          = new List <BitIndividual>();
     this.bestIndividual      = new BitIndividual(GenerateBestBitVector(geneCount), 0);
     subscribers = new List <ISubscriber>();
 }
예제 #4
0
 public BitIndividual(BitIndividual ind) : this(ind.Chromosome, ind.epoch)
 {
     this.epoch   = ind.epoch;
     this.fitness = ind.fitness;
 }