public abstract class BreedingPipeline extends BreedingSource implements SteadyStateBSourceForm
A BreedingPipeline implements SteadyStateBSourceForm, meaning that it receives the individualReplaced(...) and sourcesAreProperForm(...) messages. however by default it doesn't do anything with these except distribute them to its sources. You might override these to do something more interesting.
Parameters
base.num-sources int >= 1 |
(User-specified number of sources to the pipeline. Some pipelines have hard-coded numbers of sources; others indicate (with the java constant DYNAMIC_SOURCES) that the number of sources is determined by this user parameter instead.) |
base.source.n classname, inherits and != BreedingSource, or the value same | (Source n for this BreedingPipeline. If the value is set to same, then this source is the exact same source object as base.source.n-1, and further parameters for this object will be ignored and treated as the same as those for n-1. same is not valid for base.source.0) |
Parameter bases
base.source.n | Source n |
Modifier and Type | Field and Description |
---|---|
static int |
DYNAMIC_SOURCES
Indicates that the number of sources is variable and determined by the
user in the parameter file.
|
double |
likelihood |
Parameter |
mybase
My parameter base -- I keep it around so I can print some messages that
are useful with it (not deep cloned)
|
static java.lang.String |
P_LIKELIHOOD
Indicates the probability that the Breeding Pipeline will perform its mutative action instead of just doing reproduction.
|
static java.lang.String |
P_NUMSOURCES
Standard parameter for number of sources (only used if numSources
returns DYNAMIC_SOURCES
|
static java.lang.String |
P_SOURCE
Standard parameter for individual-selectors associated with a BreedingPipeline
|
BreedingSource[] |
sources
Array of sources feeding the pipeline
|
static java.lang.String |
V_SAME
Indicates that a source is the exact same source as the previous source.
|
NO_PROBABILITY, P_PROB, probability
Constructor and Description |
---|
BreedingPipeline() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Creates a new individual cloned from a prototype,
and suitable to begin use in its own evolutionary
context.
|
void |
finishProducing(EvolutionState state,
int subpopulation,
int thread)
Called after produce(...), usually once a generation, or maybe only
once if you're doing steady-state evolution (at the end of the run).
|
void |
individualReplaced(SteadyStateEvolutionState state,
int subpopulation,
int thread,
int individual)
Called whenever an individual has been replaced by another
in the population.
|
int |
maxChildProduction()
Returns the maximum among the typicalIndsProduced() for any children --
a function that's useful internally, not very useful for you to call externally.
|
int |
minChildProduction()
Returns the minimum among the typicalIndsProduced() for any children --
a function that's useful internally, not very useful for you to call externally.
|
abstract int |
numSources()
Returns the number of sources to this pipeline.
|
void |
preparePipeline(java.lang.Object hook)
A hook which should be passed to all your subsidiary breeding
sources.
|
void |
prepareToProduce(EvolutionState state,
int subpopulation,
int thread)
Called before produce(...), usually once a generation, or maybe only
once if you're doing steady-state evolution, to let the breeding source
"warm up" prior to producing.
|
boolean |
produces(EvolutionState state,
Population newpop,
int subpopulation,
int thread)
Returns true if this BreedingSource, when attached to the given
subpopulation, will produce individuals of the subpopulation's species.
|
int |
reproduce(int n,
int start,
int subpopulation,
Individual[] inds,
EvolutionState state,
int thread,
boolean produceChildrenFromSource)
Performs direct cloning of n individuals.
|
void |
setup(EvolutionState state,
Parameter base)
Sets up the BreedingPipeline.
|
void |
sourcesAreProperForm(SteadyStateEvolutionState state)
Issue an error (not a fatal -- we guarantee that callers
of this method will also call exitIfErrors) if any
of your sources, or their sources, etc., are not
of SteadyStateBSourceForm.
|
int |
typicalIndsProduced()
Returns the "typical" number of individuals produced -- by default
this is the minimum typical number of individuals produced by any
children sources of the pipeline.
|
getProbability, pickRandom, produce, setProbability, setupProbabilities
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
defaultBase
public static final java.lang.String V_SAME
public static final java.lang.String P_LIKELIHOOD
public static final int DYNAMIC_SOURCES
public static final java.lang.String P_NUMSOURCES
public static final java.lang.String P_SOURCE
public Parameter mybase
public double likelihood
public BreedingSource[] sources
public abstract int numSources()
public int minChildProduction()
public int maxChildProduction()
public int typicalIndsProduced()
typicalIndsProduced
in class BreedingSource
public void setup(EvolutionState state, Parameter base)
BreedingSource
The most common modification is to normalize it with some other set of probabilities, then set all of them up in increasing summation; this allows the use of the fast static BreedingSource-picking utility method, BreedingSource.pickRandom(...). In order to use this method, for example, if four breeding source probabilities are {0.3, 0.2, 0.1, 0.4}, then they should get normalized and summed by the outside owners as: {0.3, 0.5, 0.6, 1.0}.
setup
in interface Prototype
setup
in interface Setup
setup
in class BreedingSource
Prototype.setup(EvolutionState,Parameter)
public java.lang.Object clone()
Prototype
Typically this should be a full "deep" clone. However, you may share certain elements with other objects rather than clone hem, depending on the situation:
Implementations.
public Object clone()
{
try
{
return super.clone();
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
}
public Object clone()
{
try
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
return myobj;
}
public Object clone()
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
return myobj;
}
clone
in interface Prototype
clone
in class BreedingSource
public int reproduce(int n, int start, int subpopulation, Individual[] inds, EvolutionState state, int thread, boolean produceChildrenFromSource)
public boolean produces(EvolutionState state, Population newpop, int subpopulation, int thread)
BreedingSource
produces
in class BreedingSource
public void prepareToProduce(EvolutionState state, int subpopulation, int thread)
BreedingSource
prepareToProduce
in class BreedingSource
public void finishProducing(EvolutionState state, int subpopulation, int thread)
BreedingSource
finishProducing
in class BreedingSource
public void preparePipeline(java.lang.Object hook)
BreedingSource
ECJ at present does not custom-implement or call this method: it's available for you. Becuase it has custom functionality, this method might get called more than once, and by various objects as needed. If you use it, you should determine somehow how to use it to send information under the assumption that it might be sent by nested items in the pipeline; you don't want to scribble over each other's calls! Note that this method should travel *all* breeding source paths regardless of whether or not it's redundant to do so.
preparePipeline
in class BreedingSource
public void individualReplaced(SteadyStateEvolutionState state, int subpopulation, int thread, int individual)
SteadyStateBSourceForm
individualReplaced
in interface SteadyStateBSourceForm
public void sourcesAreProperForm(SteadyStateEvolutionState state)
SteadyStateBSourceForm
sourcesAreProperForm
in interface SteadyStateBSourceForm