[Avida-SVN] r2523 - development/source/main
barrick at myxo.css.msu.edu
barrick at myxo.css.msu.edu
Mon Apr 7 13:55:52 PDT 2008
Author: barrick
Date: 2008-04-07 16:55:51 -0400 (Mon, 07 Apr 2008)
New Revision: 2523
Modified:
development/source/main/cAvidaConfig.h
development/source/main/cPopulation.cc
development/source/main/cStats.cc
Log:
DEMES_PREFER_EMPTY option for replication.
Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h 2008-04-07 20:36:30 UTC (rev 2522)
+++ development/source/main/cAvidaConfig.h 2008-04-07 20:55:51 UTC (rev 2523)
@@ -319,6 +319,7 @@
CONFIG_ADD_VAR(DEMES_DIVIDE_METHOD, int, 0, "Deme divide method. Only works with DEMES_SEED_METHOD 1\n0=replace and target demes\n1= replace target deme, reset source deme to founders\n2=replace target deme, leave source deme unchanged");
CONFIG_ADD_VAR(DEMES_DEFAULT_GERMLINE_PROPENSITY, double, 0.0, "Default germline propensity of organisms in deme.\nFor use with DEMES_DIVIDE_METHOD 2.");
CONFIG_ADD_VAR(DEMES_FOUNDER_GERMLINE_PROPENSITY, double, -1.0, "Default germline propensity of founder organisms in deme.\nFor use with DEMES_DIVIDE_METHOD 2.\n <0 = OFF");
+ CONFIG_ADD_VAR(DEMES_PREFER_EMPTY, int, 0, "Give empty demes preference as targets of deme replication?");
CONFIG_ADD_GROUP(REPRODUCTION_GROUP, "Birth and Death");
CONFIG_ADD_VAR(BIRTH_METHOD, int, 0, "Which organism should be replaced on birth?\n0 = Random organism in neighborhood\n1 = Oldest in neighborhood\n2 = Largest Age/Merit in neighborhood\n3 = None (use only empty cells in neighborhood)\n4 = Random from population (Mass Action)\n5 = Oldest in entire population\n6 = Random within deme\n7 = Organism faced by parent\n8 = Next grid cell (id+1)\n9 = Largest energy used in entire population\n10 = Largest energy used in neighborhood");
Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc 2008-04-07 20:36:30 UTC (rev 2522)
+++ development/source/main/cPopulation.cc 2008-04-07 20:55:51 UTC (rev 2523)
@@ -1189,13 +1189,33 @@
}
// Pick a target deme to replicate to, making sure that
- // we don't try to replicate over ourself.
- int target_id = source_deme.GetID();
- const int num_demes = GetNumDemes();
- while(target_id == source_deme.GetID()) {
- target_id = m_world->GetRandom().GetUInt(num_demes);
+ // we don't try to replicate over ourself, i.e. DEMES_REPLACE_PARENT 0
+
+ int target_id = -1;
+ if (m_world->GetConfig().DEMES_PREFER_EMPTY.Get()) {
+
+ //@JEB -- use empty_cell_id_array to hold empty demes
+ //so we don't have to allocate a list
+ int num_empty = 0;
+ for (int i=0; i<GetNumDemes(); i++) {
+ if (GetDeme(i).IsEmpty()) {
+ empty_cell_id_array[num_empty] = i;
+ num_empty++;
+ }
+ }
+ if (num_empty > 0) {
+ target_id = empty_cell_id_array[m_world->GetRandom().GetUInt(num_empty)];
+ }
}
-
+
+ // if we haven't found one yet, choose a random one
+ if (target_id == -1) {
+ target_id = source_deme.GetID();
+ const int num_demes = GetNumDemes();
+ while(target_id == source_deme.GetID()) {
+ target_id = m_world->GetRandom().GetUInt(num_demes);
+ }
+ }
ReplaceDeme(source_deme, deme_array[target_id]);
}
Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc 2008-04-07 20:36:30 UTC (rev 2522)
+++ development/source/main/cStats.cc 2008-04-07 20:55:51 UTC (rev 2523)
@@ -577,6 +577,7 @@
df.WriteTimeStamp();
df.Write(m_update, "Update");
+ df.Write(m_num_occupied_demes, "Count");
df.Write(sum_deme_age.Average(), "Age");
df.Write(sum_deme_birth_count.Average(), "Births");
df.Write(sum_deme_org_count.Average(), "Organisms");
More information about the Avida-cvs
mailing list