[Avida-SVN] r3199 - development/source/main

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Wed Apr 1 19:08:26 PDT 2009


Author: brysonda
Date: 2009-04-01 22:08:26 -0400 (Wed, 01 Apr 2009)
New Revision: 3199

Modified:
   development/source/main/cAvidaConfig.h
Log:
Rework the Birth Chamber.

ATTENTION:
- Sexual reproduction in DEMES is very different (and has a caveat that will be fixed in a later commit), see below
- LOCAL NEIGHBORHOOD SEX reproduction is now handled more accurately by default (legacy support available), see below
- Sexual reproduction under the ENERGY model has been *fixed*
- cMerit::EnergyToMerit has moved to cPhenotype::ConvertEnergyToMerit 
- Sexual reproduction CONSISTENCY has changed due to a small bug in cPhenotype (original mate_select_id was set incorrectly to 0)

Details:
This is the start of *major* changes to the handling of sexual reproduction on the road to implementing support for multiple hardware and instruction sets. None of the changes for those features have been implemented yet. However, I have drastically restructured how offspring selection is done for sexual recombination.

Rather than if statements that call internal functions, the birth chamber now constructs handler objects (cBirthSelectionHandler subclasses) that do the task of storing waiting genomes and selecting them as needed.   This allows for a smaller memory footprint, since only objects necessary for the selected regime are constructed.  Once additional support for multiple queues of hardware types and instruction sets is implemented, this will become important.

More immediately, however, this structure allows for nested selection types, the primary use-case being demes.  With this commit, demes now honor the population level mate selection algorithm on a deme by deme basis.  The cBirthDemeHandler creates a sub-handler object of the correct type for each deme.  During replication, offspring a shuffled to the correct sub-handler, so that only organisms originating from the same deme can be selected for recombination.  Note that there is one important caveat with the current setup, when a deme is reset the birth chamber is not currently informed, thus potentially allowing recombination with an offspring from an earlier population that occupied the deme.  It is noteworthy that this is not particularly new, as it was similarly possible under the former method of deme mate selection.  I do, however, plan to fix this caveat in a future commit.

Local neighborhood sexual reproduction has been enhanced to properly honor the current population structure (i.e. the connection list).  Previously, and now when legacy local selection is enabled, the birth chamber would select an offspring waiting in the local 3x3 toroidal grid, without any regard for the current population structure.  If local placement strategies were selected, recombination could happen across deme or other barriers without restriction.  The new method gets the current connection list, searches for valid waiting offspring, then selects a random one for recombination.

Finally, there are is both a bug fix and a structural change in this commit that have implications for the energy model.  During the course of translating offspring storage routine, I noted that although cMerit::EnergyToMerit was being called, it was not actually storing the merit in the birth chamber entry (since cMerit::EnergyToMerit was a static method).  I believe all instances of this in the birth chamber were affected, meaning that merit was potentially undefined.  This bug only affects sexual reproduction.

The structural change to the energy model code comes from the movement of cMerit::EnergyToMerit to cPhenotype::ConvertEnergyToMerit.  Although its position in the code can be debated, cMerit is in the tools directory, thus should not reference any classes from the rest of Avida (with the exception of platform support, another form of tools).  Since cPhenotype has a local pointer to the world object and is available in the context of all current usage of MeritToEnergy, I chose to move it there.  More importantly, though, cMerit::EnergyToMerit was caching a configuration option in a static variable.  This is not a safe assumption, as it will eventually be possible to construct multiple worlds in a single Avida process.


New Configuration Options:
ALLOW_MATE_SELECTION - Toggles whether the birth chamber will honor organism specified mate_select_ids.  This feature requires instruction set support and is now off by default.
LEGACY_GRID_LOCAL_SELECTION - Can be used to enable the old style, connection-list agnostic local neighborhood selection method

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2009-03-30 16:14:07 UTC (rev 3198)
+++ development/source/main/cAvidaConfig.h	2009-04-02 02:08:26 UTC (rev 3199)
@@ -359,6 +359,8 @@
   CONFIG_ADD_VAR(CORESPOND_REC_REGS, int, 1, "are (modular) recombination regions swapped randomly\n or with corresponding positions?");
   CONFIG_ADD_VAR(TWO_FOLD_COST_SEX, int, 0, "1 = only one recombined offspring is born.\n2 = both offspring are born");
   CONFIG_ADD_VAR(SAME_LENGTH_SEX, int, 0, "0 = recombine with any genome\n1 = only recombine w/ same length");
+  CONFIG_ADD_VAR(ALLOW_MATE_SELECTION, bool, 0, "Allow organisms to select mates (requires instruction set support)");
+  CONFIG_ADD_VAR(LEGACY_GRID_LOCAL_SELECTION, bool, 0, "Enable legacy grid local mate selection (ignores population structure)");
 
   CONFIG_ADD_GROUP(DIVIDE_GROUP, "Divide Restrictions");
   CONFIG_ADD_VAR(CHILD_SIZE_RANGE, double, 2.0, "Maximal differential between child and parent sizes.\n(Checked BEFORE mutations applied on divide.)");




More information about the Avida-cvs mailing list