public class SimpleBreeder extends Breeder
Prior to breeding a subpopulation, a SimpleBreeder may first fill part of the new subpopulation up with the best n individuals from the old subpopulation. By default, n is 0 for each subpopulation (that is, this "elitism" is not done). The elitist step is performed by a single thread.
If the sequential parameter below is true, then breeding is done specially: instead of breeding all Subpopulations each generation, we only breed one each generation. The subpopulation index to breed is determined by taking the generation number, modulo the total number of subpopulations. Use of this parameter outside of a coevolutionary context (see ec.coevolve.MultiPopCoevolutionaryEvaluator) is very rare indeed.
SimpleBreeder adheres to the default-subpop parameter in Population: if either an 'elite' or 'reevaluate-elites' parameter is missing, it will use the default subpopulation's value and signal a warning.
Parameters
base.elite.i int >= 0 (default=0) |
(the number of elitist individuals for subpopulation i) |
base.reevaluate-elites.i boolean (default = false) |
(should we reevaluate the elites of subpopulation i each generation?) |
base.sequential boolean (default = false) |
(should we breed just one subpopulation each generation (as opposed to all of them)?) |
Modifier and Type | Field and Description |
---|---|
Population |
backupPopulation |
boolean |
clonePipelineAndPopulation |
int[] |
elite
An array[subpop] of the number of elites to keep for that subpopulation
|
double[] |
eliteFrac |
static int |
NOT_SET |
static java.lang.String |
P_CLONE_PIPELINE_AND_POPULATION |
static java.lang.String |
P_ELITE |
static java.lang.String |
P_ELITE_FRAC |
static java.lang.String |
P_REEVALUATE_ELITES |
static java.lang.String |
P_SEQUENTIAL_BREEDING |
ThreadPool |
pool |
boolean[] |
reevaluateElites |
boolean |
sequentialBreeding |
Constructor and Description |
---|
SimpleBreeder() |
Modifier and Type | Method and Description |
---|---|
protected void |
breedPopChunk(Population newpop,
EvolutionState state,
int[] numinds,
int[] from,
int threadnum)
A private helper function for breedPopulation which breeds a chunk
of individuals in a subpopulation for a given thread.
|
Population |
breedPopulation(EvolutionState state)
A simple breeder that doesn't attempt to do any cross-
population breeding.
|
int |
computeSubpopulationLength(EvolutionState state,
Population newpop,
int subpopulation,
int threadnum)
Elites are often stored in the top part of the subpopulation; this function returns what
part of the subpopulation contains individuals to replace with newly-bred ones
(up to but not including the elites).
|
protected void |
loadElites(EvolutionState state,
Population newpop)
A private helper function for breedPopulation which loads elites into
a subpopulation.
|
int |
numElites(EvolutionState state,
int subpopulation) |
void |
setup(EvolutionState state,
Parameter base)
Sets up the object by reading it from the parameters stored
in state, built off of the parameter base base.
|
boolean |
shouldBreedSubpop(EvolutionState state,
int subpop,
int threadnum)
Returns true if we're doing sequential breeding and it's the subpopulation's turn (round robin,
one subpopulation per generation).
|
protected void |
unmarkElitesEvaluated(EvolutionState state,
Population newpop) |
boolean |
usingElitism(int subpopulation) |
public static final java.lang.String P_ELITE
public static final java.lang.String P_ELITE_FRAC
public static final java.lang.String P_REEVALUATE_ELITES
public static final java.lang.String P_SEQUENTIAL_BREEDING
public static final java.lang.String P_CLONE_PIPELINE_AND_POPULATION
public int[] elite
public double[] eliteFrac
public boolean[] reevaluateElites
public boolean sequentialBreeding
public boolean clonePipelineAndPopulation
public Population backupPopulation
public static final int NOT_SET
public ThreadPool pool
public boolean usingElitism(int subpopulation)
public int numElites(EvolutionState state, int subpopulation)
public void setup(EvolutionState state, Parameter base)
Setup
public int computeSubpopulationLength(EvolutionState state, Population newpop, int subpopulation, int threadnum)
public Population breedPopulation(EvolutionState state)
breedPopulation
in class Breeder
public boolean shouldBreedSubpop(EvolutionState state, int subpop, int threadnum)
protected void breedPopChunk(Population newpop, EvolutionState state, int[] numinds, int[] from, int threadnum)
protected void unmarkElitesEvaluated(EvolutionState state, Population newpop)
protected void loadElites(EvolutionState state, Population newpop)