private BitIndividual SelectWithReplacement(List <BitIndividual> population) { BitIndividual best = new BitIndividual(population[0]); population.Remove(population[0]); return(best); }
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); }
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>(); }
public BitIndividual(BitIndividual ind) : this(ind.Chromosome, ind.epoch) { this.epoch = ind.epoch; this.fitness = ind.fitness; }