BoltzmannSelector extends ProbabilitySelector<G, N> { @Override protected double[] probabilities( final Seq<Phenotype<G, N>> population, final int count ) { assert population != null : "Population must not be null. "; assert !population.isEmpty() : "Population is empty."; assert count > 0 : "Population to select must be greater than zero. "; final double[] fitness = new double[population.size()]; fitness[0] = population.get(0).fitness().doubleValue(); double min = fitness[0]; double max = fitness[0]; for (int i = 1; i < fitness.length; ++i) { fitness[i] = population.get(i).fitness().doubleValue(); if (fitness[i] < min) min = fitness[i]; else if (fitness[i] > max) max = fitness[i]; } final double diff = max - min; if (eq(diff, 0.0)) { Arrays.fill(fitness, 1.0/fitness.length); } else { for (int i = fitness.length; --i >= 0;) { fitness[i] = (fitness[i] - min)/diff; } for (int i = fitness.length; --i >= 0;) { fitness[i] = exp(_b*fitness[i]); } } return normalize(fitness); } BoltzmannSelector(final double b);  BoltzmannSelector(); @Override String toString();  }
@Test public void parameters() { final BoltzmannSelector<DoubleGene, Double> selector = new BoltzmannSelector<>(2); final ISeq<Phenotype<DoubleGene, Double>> population = TestUtils.newDoublePopulation(20, 0, 0); selector.probabilities(population, 10); }