@Test public void calculateFitnessForChromosome() { population.calculateFitnessForChromosome(0, fitnessFunction); Assert.assertEquals(population.getChromosome(0).getFitness(), 0, PRECISION); }
public double calculateFitnessForChromosome(int idx, Function<Chromosome, Double> fitnessFunction) { double fitness = fitnessFunction.apply(chromosomes[idx]); chromosomes[idx].setFitness(fitness); fitnessCalculatedFlags.set(idx); return fitness; }
Population { public double calculateFitnessForChromosome(int idx, Function<Chromosome, Double> fitnessFunction) { double fitness = fitnessFunction.apply(chromosomes[idx]); chromosomes[idx].setFitness(fitness); fitnessCalculatedFlags.set(idx); return fitness; } }
Population { public double calculateFitnessForChromosome(int idx, Function<Chromosome, Double> fitnessFunction) { double fitness = fitnessFunction.apply(chromosomes[idx]); chromosomes[idx].setFitness(fitness); fitnessCalculatedFlags.set(idx); return fitness; } Population(int size); }
Population { public double calculateFitnessForChromosome(int idx, Function<Chromosome, Double> fitnessFunction) { double fitness = fitnessFunction.apply(chromosomes[idx]); chromosomes[idx].setFitness(fitness); fitnessCalculatedFlags.set(idx); return fitness; } Population(int size); Chromosome getChromosome(int idx); double calculateFitnessForChromosome(int idx, Function<Chromosome, Double> fitnessFunction); void calculateFitnessForAll(Function<Chromosome, Double> fitnessFunction); void setChromosome(int idx, Chromosome chromosome); Chromosome getChromosome(Integer idx); Chromosome[] selectBestKChromosome(int k); double getTotalFitness(); double getAverageFitness(); int size(); void setFitness(Integer idx, Double fitness); }
Population { public double calculateFitnessForChromosome(int idx, Function<Chromosome, Double> fitnessFunction) { double fitness = fitnessFunction.apply(chromosomes[idx]); chromosomes[idx].setFitness(fitness); fitnessCalculatedFlags.set(idx); return fitness; } Population(int size); Chromosome getChromosome(int idx); double calculateFitnessForChromosome(int idx, Function<Chromosome, Double> fitnessFunction); void calculateFitnessForAll(Function<Chromosome, Double> fitnessFunction); void setChromosome(int idx, Chromosome chromosome); Chromosome getChromosome(Integer idx); Chromosome[] selectBestKChromosome(int k); double getTotalFitness(); double getAverageFitness(); int size(); void setFitness(Integer idx, Double fitness);  }