Esempio n. 1
0
  /** Create a population of DoubleGenes */
  public static Population<DoubleGene, Double> newDoubleGenePopulation(
      final int ngenes, final int nchromosomes, final int npopulation) {
    final MSeq<DoubleChromosome> chromosomes = MSeq.ofLength(nchromosomes);

    for (int i = 0; i < nchromosomes; ++i) {
      chromosomes.set(i, DoubleChromosome.of(0, 10, ngenes));
    }

    final Genotype<DoubleGene> genotype = new Genotype<>(chromosomes.toISeq());
    final Population<DoubleGene, Double> population = new Population<>(npopulation);

    for (int i = 0; i < npopulation; ++i) {
      population.add(Phenotype.of(genotype.newInstance(), 0, FF).evaluate());
    }

    return population;
  }