ec.select.FitProportionateSelection Maven / Gradle / Ivy
Show all versions of ecj Show documentation
/*
Copyright 2006 by Sean Luke
Licensed under the Academic Free License version 3.0
See the file "LICENSE" for more information
*/
package ec.select;
import ec.util.*;
import ec.*;
/*
* FitProportionateSelection.java
*
* Created: Thu Feb 10 16:31:24 2000
* By: Sean Luke
*/
/**
* Picks individuals in a population in direct proportion to their
* fitnesses as returned by their fitness() methods. This is expensive to
* set up and bring down, so it's not appropriate for steady-state evolution.
* If you're not familiar with the relative advantages of
* selection methods and just want a good one,
* use TournamentSelection instead. Not appropriate for
* multiobjective fitnesses.
*
*
* Note: Fitnesses must be non-negative. 0 is assumed to be the worst fitness.
*
Typical Number of Individuals Produced Per produce(...) call
Always 1.
Default Base
select.fitness-proportionate
*
* @author Sean Luke
* @version 1.0
*/
public class FitProportionateSelection extends SelectionMethod
{
/** Default base */
public static final String P_FITNESSPROPORTIONATE = "fitness-proportionate";
/** Normalized, totalized fitnesses for the population */
public double[] fitnesses;
public Parameter defaultBase()
{
return SelectDefaults.base().push(P_FITNESSPROPORTIONATE);
}
// don't need clone etc.
public void prepareToProduce(final EvolutionState s,
final int subpopulation,
final int thread)
{
// load fitnesses
fitnesses = new double[s.population.subpops[subpopulation].individuals.length];
for(int x=0;x