public class Subpopulation extends Object implements Group
An initial subpopulation is populated with new random individuals using the populate(...) method. This method typically populates by filling the array with individuals created using the Subpopulations' species' emptyClone() method, though you might override this to create them with other means, by loading from text files for example.
In a multithreaded area of a run, Subpopulations should be considered immutable. That is, once they are created, they should not be modified, nor anything they contain. This protocol helps ensure read-safety under multithreading race conditions.
Parameters
| base.size int >= 1 |
(total number of individuals in the subpopulation) |
| base.species classname, inherits and != ec.Species |
(the class of the subpopulations' Species) |
| base.fitness classname, inherits and != ec.Fitness |
(the class for the prototypical Fitness for individuals in this subpopulation) |
| base.file String |
(pathname of file from which the population is to be loaded. If not defined, or empty, then the population will be initialized at random in the standard manner) |
| base.duplicate-retries int >= 0 |
(during initialization, when we produce an individual which already exists in the subpopulation, the number of times we try to replace it with something unique. Ignored if we're loading from a file.) |
Default Base
ec.subpop
Parameter bases
| base.species | species (the subpopulations' species) |
| Modifier and Type | Field and Description |
|---|---|
int |
extraBehavior
What is our fill behavior beyond files?
|
Parameter |
file |
static int |
FILL |
static String |
INDIVIDUAL_INDEX_PREAMBLE |
Individual[] |
individuals
The subpopulation's individuals.
|
boolean |
loadInds |
static String |
NUM_INDIVIDUALS_PREAMBLE |
int |
numDuplicateRetries
Do we allow duplicates?
|
static String |
P_EXTRA_BEHAVIOR |
static String |
P_FILE |
static String |
P_RETRIES |
static String |
P_SPECIES |
static String |
P_SUBPOPSIZE |
static String |
P_SUBPOPULATION |
private static long |
serialVersionUID |
Species |
species
The species for individuals in this subpopulation.
|
static int |
TRUNCATE |
static String |
V_FILL |
static String |
V_TRUNCATE |
static String |
V_WRAP |
static int |
WRAP |
| Constructor and Description |
|---|
Subpopulation() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Sets all Individuals in the Subpopulation to null, preparing it to be reused.
|
Parameter |
defaultBase() |
Group |
emptyClone()
Returns an instance of Subpopulation just like it had been before it was
populated with individuals.
|
void |
populate(EvolutionState state,
int thread) |
void |
printSubpopulation(EvolutionState state,
int log)
Prints an entire subpopulation in a form readable by humans but also parseable by the computer using readSubpopulation(EvolutionState, LineNumberReader) with a verbosity of Output.V_NO_GENERAL.
|
void |
printSubpopulation(EvolutionState state,
int log,
int verbosity)
Deprecated.
Verbosity no longer has meaning
|
void |
printSubpopulation(EvolutionState state,
PrintWriter writer)
Prints an entire subpopulation in a form readable by humans but also parseable by the computer using readSubpopulation(EvolutionState, LineNumberReader).
|
void |
printSubpopulationForHumans(EvolutionState state,
int log)
Prints an entire subpopulation in a form readable by humans, with a verbosity of Output.V_NO_GENERAL.
|
void |
printSubpopulationForHumans(EvolutionState state,
int log,
int verbosity)
Deprecated.
Verbosity no longer has meaning
|
void |
readSubpopulation(EvolutionState state,
DataInput dataInput)
Reads a subpopulation in binary form, from the format generated by writeSubpopulation(...).
|
void |
readSubpopulation(EvolutionState state,
LineNumberReader reader)
Reads a subpopulation from the format generated by printSubpopulation(....).
|
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.
|
void |
writeSubpopulation(EvolutionState state,
DataOutput dataOutput)
Writes a subpopulation in binary form, in a format readable by readSubpopulation(EvolutionState, DataInput).
|
private static final long serialVersionUID
public boolean loadInds
public Parameter file
public Species species
public Individual[] individuals
public int numDuplicateRetries
public int extraBehavior
public static final String P_SUBPOPULATION
public static final String P_FILE
public static final String P_SUBPOPSIZE
public static final String P_SPECIES
public static final String P_RETRIES
public static final String P_EXTRA_BEHAVIOR
public static final String V_TRUNCATE
public static final String V_WRAP
public static final String V_FILL
public static final String NUM_INDIVIDUALS_PREAMBLE
public static final String INDIVIDUAL_INDEX_PREAMBLE
public static final int TRUNCATE
public static final int WRAP
public static final int FILL
public Parameter defaultBase()
public Group emptyClone()
emptyClone in interface GroupGroup.emptyClone()public void clear()
public void setup(EvolutionState state, Parameter base)
Setuppublic void populate(EvolutionState state, int thread)
public final void printSubpopulationForHumans(EvolutionState state, int log, int verbosity)
public final void printSubpopulation(EvolutionState state, int log, int verbosity)
public void printSubpopulationForHumans(EvolutionState state, int log)
public void printSubpopulation(EvolutionState state, int log)
public void printSubpopulation(EvolutionState state, PrintWriter writer)
public void readSubpopulation(EvolutionState state, LineNumberReader reader) throws IOException
IOExceptionpublic void writeSubpopulation(EvolutionState state, DataOutput dataOutput) throws IOException
IOExceptionpublic void readSubpopulation(EvolutionState state, DataInput dataInput) throws IOException
IOExceptionCopyright © 2014 Evolutionary Computation Laboratory at George Mason University. All rights reserved.