コード例 #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;
 }