ec
Class Subpopulation

java.lang.Object
  |
  +--ec.Subpopulation
All Implemented Interfaces:
java.lang.Cloneable, Group, java.io.Serializable, Setup
Direct Known Subclasses:
SPEA2Subpopulation

public class Subpopulation
extends java.lang.Object
implements Group

Subpopulation is a group which is basically an array of Individuals. There is always one or more Subpopulations in the Population. Each Subpopulation has a Species, which governs the formation of the Individuals in that Subpopulation. Subpopulations also contain a Fitness prototype which is cloned to form Fitness objects for individuals in the subpopulation.

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.)

Parameter bases
base.species species (the subpopulations' species)
base.fitness f_prototype (the prototypical fitness)

See Also:
Serialized Form

Field Summary
 Fitness f_prototype
          The prototypical fitness for individuals in this subpopulation.
 Individual[] individuals
          The subpopulation's individuals.
 java.io.File loadInds
          A new subpopulation should be loaded from this file if it is non-null; otherwise they should be created at random.
 int numDuplicateRetries
          Do we allow duplicates?
static java.lang.String P_FILE
           
static java.lang.String P_FITNESS
           
static java.lang.String P_RETRIES
           
static java.lang.String P_SPECIES
           
static java.lang.String P_SUBPOPSIZE
           
 Species species
          The species for individuals in this subpopulation.
 
Constructor Summary
Subpopulation()
           
 
Method Summary
 Group emptyClone()
          Returns an instance of Subpopulation just like it had been before it was populated with individuals.
 void populate(EvolutionState state)
          Note: don't call populate() in a multithreaded environment unless at least one instance of Fitness has been called already.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loadInds

public java.io.File loadInds
A new subpopulation should be loaded from this file if it is non-null; otherwise they should be created at random.

f_prototype

public Fitness f_prototype
The prototypical fitness for individuals in this subpopulation.

species

public Species species
The species for individuals in this subpopulation.

individuals

public Individual[] individuals
The subpopulation's individuals.

numDuplicateRetries

public int numDuplicateRetries
Do we allow duplicates?

P_FILE

public static final java.lang.String P_FILE

P_SUBPOPSIZE

public static final java.lang.String P_SUBPOPSIZE

P_SPECIES

public static final java.lang.String P_SPECIES

P_FITNESS

public static final java.lang.String P_FITNESS

P_RETRIES

public static final java.lang.String P_RETRIES
Constructor Detail

Subpopulation

public Subpopulation()
Method Detail

emptyClone

public Group emptyClone()
Returns an instance of Subpopulation just like it had been before it was populated with individuals. You may need to override this if you override Subpopulation. IMPORTANT NOTE: if the size of the array in Subpopulation has been changed, then the clone will take on the new array size. This helps some evolution strategies.
Specified by:
emptyClone in interface Group
See Also:
Group.emptyClone()

setup

public void setup(EvolutionState state,
                  Parameter base)
Description copied from interface: Setup
Sets up the object by reading it from the parameters stored in state, built off of the parameter base base. If an ancestor implements this method, be sure to call super.setup(state,base); before you do anything else.
Specified by:
setup in interface Setup

populate

public void populate(EvolutionState state)
Note: don't call populate() in a multithreaded environment unless at least one instance of Fitness has been called already. Otherwise MultiObjectiveFitness *may* have an initial race condition. As presently coded, Subpopulation's constructor runs in a single thread only, during population initialization, which is single-threaded on purpose.