[Avida-SVN] r2130 - branches/energy/source/main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Mon Oct 8 12:24:18 PDT 2007
Author: beckma24
Date: 2007-10-08 15:24:17 -0400 (Mon, 08 Oct 2007)
New Revision: 2130
Modified:
branches/energy/source/main/cAvidaConfig.h
branches/energy/source/main/cPopulation.cc
branches/energy/source/main/cPopulationCell.cc
Log:
Added germ line placement to replicateDemes that fills the deme with organisms.
Modified: branches/energy/source/main/cAvidaConfig.h
===================================================================
--- branches/energy/source/main/cAvidaConfig.h 2007-10-08 18:03:01 UTC (rev 2129)
+++ branches/energy/source/main/cAvidaConfig.h 2007-10-08 19:24:17 UTC (rev 2130)
@@ -298,7 +298,7 @@
CONFIG_ADD_VAR(DEMES_HAVE_MERIT, int, 0, "Whether demes have merit; 0=no");
CONFIG_ADD_VAR(GERMLINE_COPY_MUT, double, 0.0075, "Prob. of copy mutations occuring during\ngermline replication.");
CONFIG_ADD_VAR(GERMLINE_REPLACES_SOURCE, int, 0, "Whether the source germline is updated\non replication; 0=no.");
- CONFIG_ADD_VAR(GERMLINE_RANDOM_PLACEMENT, int, 0, "Defines how the seed for a germline is placed\n within the deme;\n0 = organisms is placed in center of deme, no orientation\n1 = organisms is placed in center of deme and oriented\n2 = organism is randomly placed in deme, no orientation");
+ CONFIG_ADD_VAR(GERMLINE_RANDOM_PLACEMENT, int, 0, "Defines how the seed for a germline is placed\n within the deme;\n0 = organisms is placed in center of deme, no orientation\n1 = organisms is placed in center of deme and oriented\n2 = organism is randomly placed in deme, no orientation\n3 = deme is filled with identical copies of organism, no orientation\n4 = deme is filled with identical oriented copies of organism");
CONFIG_ADD_VAR(MAX_DEME_AGE, int, 500, "The maximum age of a deme (in updates) to be\nused for age-based replication (default=500).");
CONFIG_ADD_GROUP(REPRODUCTION_GROUP, "Birth and Death");
Modified: branches/energy/source/main/cPopulation.cc
===================================================================
--- branches/energy/source/main/cPopulation.cc 2007-10-08 18:03:01 UTC (rev 2129)
+++ branches/energy/source/main/cPopulation.cc 2007-10-08 19:24:17 UTC (rev 2130)
@@ -1103,7 +1103,9 @@
}
case 3: {
// Replicate old demes if injected organism is not sterile
- if(source_deme.GetAge() < m_world->GetConfig().MAX_DEME_AGE.Get() || source_deme.GetBirthCount() < 1) continue;
+ if(source_deme.GetAge() < m_world->GetConfig().MAX_DEME_AGE.Get() ||
+ (source_deme.GetBirthCount() < 1 && ( m_world->GetConfig().GERMLINE_RANDOM_PLACEMENT.Get() != 3 &&
+ m_world->GetConfig().GERMLINE_RANDOM_PLACEMENT.Get() != 4 ))) continue;
break;
}
case 4: {
@@ -1172,33 +1174,62 @@
source_deme.Reset();
target_deme.Reset();
- int source_deme_inject_cell;
- int target_deme_inject_cell;
-
- if(m_world->GetConfig().GERMLINE_RANDOM_PLACEMENT.Get() == 2) {
- // organism is randomly placed in deme
- source_deme_inject_cell = source_deme.GetCellID(m_world->GetRandom().GetInt(0, source_deme.GetSize()-1));
- target_deme_inject_cell = target_deme.GetCellID(m_world->GetRandom().GetInt(0, target_deme.GetSize()-1));
- } else {
- // organisms is placed in center of deme
- source_deme_inject_cell = source_deme.GetCellID(source_deme.GetSize()/2);
- target_deme_inject_cell = target_deme.GetCellID(target_deme.GetSize()/2);
+ // 3 = deme is filled with identical copies of organism, no orientation
+ // 4 = deme is filled with identical oriented copies of organism
+ if(m_world->GetConfig().GERMLINE_RANDOM_PLACEMENT.Get() == 3 ||
+ m_world->GetConfig().GERMLINE_RANDOM_PLACEMENT.Get() == 4) {
+ // fill demes
+ for(int i = 0; i < source_deme.GetSize(); i++) { // source deme
+ InjectGenome(i, source_germline.GetLatest(), 0);
+ }
+ for(int i = 0; i < target_deme.GetSize(); i++) { // target deme
+ InjectGenome(i, target_germline.GetLatest(), 0);
+ }
+
+ if(m_world->GetConfig().GERMLINE_RANDOM_PLACEMENT.Get() == 4) {
+ // Rotate all cells to face northwest.
+ int offset = source_deme.GetCellID(0);
+ for(int i = 0; i < source_deme.GetSize(); i++) {
+ cell_array[i].Rotate(cell_array[GridNeighbor(i-offset,
+ source_deme.GetWidth(),
+ source_deme.GetHeight(), -1, -1)+offset]);
+ }
+ offset = target_deme.GetCellID(0);
+ for(int i = 0; i < target_deme.GetSize(); i++) {
+ cell_array[i].Rotate(cell_array[GridNeighbor(i-offset,
+ target_deme.GetWidth(),
+ target_deme.GetHeight(), -1, -1)+offset]);
+ }
+ }
+ } else { // 1 organism
+ int source_deme_inject_cell;
+ int target_deme_inject_cell;
+
+ if(m_world->GetConfig().GERMLINE_RANDOM_PLACEMENT.Get() == 2) {
+ // organism is randomly placed in deme
+ source_deme_inject_cell = source_deme.GetCellID(m_world->GetRandom().GetInt(0, source_deme.GetSize()-1));
+ target_deme_inject_cell = target_deme.GetCellID(m_world->GetRandom().GetInt(0, target_deme.GetSize()-1));
+ } else {
+ // organisms is placed in center of deme
+ source_deme_inject_cell = source_deme.GetCellID(source_deme.GetSize()/2);
+ target_deme_inject_cell = target_deme.GetCellID(target_deme.GetSize()/2);
+ }
+ // Lineage label is wrong here; fix.
+ InjectGenome(source_deme_inject_cell, source_germline.GetLatest(), 0); // source deme
+ InjectGenome(target_deme_inject_cell, target_germline.GetLatest(), 0); // target deme
+
+ if(m_world->GetConfig().GERMLINE_RANDOM_PLACEMENT.Get() == 1) {
+ // Rotate both injected cells to face northwest.
+ int offset = source_deme.GetCellID(0);
+ cell_array[source_deme_inject_cell].Rotate(cell_array[GridNeighbor(source_deme_inject_cell-offset,
+ source_deme.GetWidth(),
+ source_deme.GetHeight(), -1, -1)+offset]);
+ offset = target_deme.GetCellID(0);
+ cell_array[target_deme_inject_cell].Rotate(cell_array[GridNeighbor(target_deme_inject_cell-offset,
+ target_deme.GetWidth(),
+ target_deme.GetHeight(), -1, -1)+offset]);
+ }
}
- // Lineage label is wrong here; fix.
- InjectGenome(source_deme_inject_cell, source_germline.GetLatest(), 0); // source deme
- InjectGenome(target_deme_inject_cell, target_germline.GetLatest(), 0); // target deme
-
- if(m_world->GetConfig().GERMLINE_RANDOM_PLACEMENT.Get() == 1) {
- // Rotate both injected cells to face northwest.
- int offset = source_deme.GetCellID(0);
- cell_array[source_deme_inject_cell].Rotate(cell_array[GridNeighbor(source_deme_inject_cell-offset,
- source_deme.GetWidth(),
- source_deme.GetHeight(), -1, -1)+offset]);
- offset = target_deme.GetCellID(0);
- cell_array[target_deme_inject_cell].Rotate(cell_array[GridNeighbor(target_deme_inject_cell-offset,
- target_deme.GetWidth(),
- target_deme.GetHeight(), -1, -1)+offset]);
- }
} else {
// Not using germline; choose a random organism from this deme.
int cell1_id = -1;
Modified: branches/energy/source/main/cPopulationCell.cc
===================================================================
--- branches/energy/source/main/cPopulationCell.cc 2007-10-08 18:03:01 UTC (rev 2129)
+++ branches/energy/source/main/cPopulationCell.cc 2007-10-08 19:24:17 UTC (rev 2130)
@@ -156,7 +156,8 @@
if(lr==1 && du==0) return 5; //E
if(lr==1 && du==-1) return 4; //SE
- assert(false);
+ assert(false);
+ return 0; // compiler required
}
void cPopulationCell::ResetInputs(cAvidaContext& ctx)
More information about the Avida-cvs
mailing list