=>
STRING, ATTRIBUTE-HASH (optional)
The constructor for the Population class. You may customise the object by setting attributes as arguments to the constructor or edit _init() in Population.pm.
A standard cascading _init() routine, which sets attributes. It also creates PopulationDir if it doesn't exist. If you want to change the attributes, edit the hash %defaults in _init() in Population.pm.
Adds individual to Individuals.
Searches the scratch directory (PERLGP_SCRATCH) for an unused filename of the format ``Individual-%06d'' where the last bit is a serial number. For speed, instead of checking for the existence of files, a hash table in memory (%usedfilestems) is used.
=>
NUMBER (optional)
This is called on a newly created Population object in perlgp-run.pl in order to load up any pre-existing Individuals. First, it looks in PopulationDir for DBM files. If there are no files and if a gzipped tar file backup exists (see backup() for this Population, then the tar file is unpacked into PopulationDir. In other words, the Population directory in PERLGP_SCRATCH is recovered from the backup.
Then all the unique filestems in PopulationDir are used to create new Individual objects which are passed to addIndividual(). In other words, new Individuals are made, each one tied to a DBM file in PopulationDir.
This routine simply tars up the entire PopulationDir and saves it in the directory PERLGP_POPS with a name based on ExperimentId. To recover a population, see repopulate().
This method randomly selects MigrationSize Individuals and saves them in a temporary directory, which is then tarred up into a file in PERLGP_POPS (the name comes from the method export_tar_file()).
All this does is return the following string:
sprintf "%s/%s.export.tar.gz", $ENV{PERLGP_POPS}, $self->ExperimentId();
(Sometimes Perl is easier to understand than English.)
First, some explanation of a major assumption we make about migrating
populations: that is that mutually migrating populations are assumed
to have the same base ExperimentId followed by a minus sign
and an integer, i.e. pi-01 pi-02 pi-03 pi-04
. These
directories are made automatically by the wrapper script
perlgp-mrun.pl.
Potential immigrant population samples are gathered by a glob in PERLGP_POPS for ExperimentId-*.export.tar.gz. Then one of these is selected at random (but not a sample exported from this Population, of course), and is unpacked into a temporary directory. This temporary directory contains DBM files, and these are loaded up into randomly selected Individuals from this Population using Individual::load(). Each of the affected Individuals now has a new genome so its fitness is reset with a call to initFitness() (because the previous fitness may have been calculated on different training examples in the other Population).
A routine to call initFitness() on each Individual in the Population.
Returns the number of Individuals in the Population, not to be confused with PopulationSize.
Returns one randomly selected Individual from Individuals.
Returns size different, randomly selected Individuals from the Population.