[Avida-SVN] r1365 - branches/dkdev/source/main

dknoester at myxo.css.msu.edu dknoester at myxo.css.msu.edu
Sun Feb 25 11:53:04 PST 2007


Author: dknoester
Date: 2007-02-25 14:53:04 -0500 (Sun, 25 Feb 2007)
New Revision: 1365

Modified:
   branches/dkdev/source/main/cPopulation.cc
   branches/dkdev/source/main/cPopulation.h
Log:
Bugfix to handling of demes and cells.

Modified: branches/dkdev/source/main/cPopulation.cc
===================================================================
--- branches/dkdev/source/main/cPopulation.cc	2007-02-23 22:01:44 UTC (rev 1364)
+++ branches/dkdev/source/main/cPopulation.cc	2007-02-25 19:53:04 UTC (rev 1365)
@@ -62,22 +62,34 @@
 , num_organisms(0)
 , sync_events(false)
 {
-  const int geometry = world->GetConfig().WORLD_GEOMETRY.Get();
-  const int num_cells = world_x * world_y;
-  const int birth_method = m_world->GetConfig().BIRTH_METHOD.Get();
-
+  // How many demes are requested?
   int num_demes = m_world->GetConfig().NUM_DEMES.Get();    
-  
+
   // Error checking for demes vs. non-demes setup.
+  const int birth_method = m_world->GetConfig().BIRTH_METHOD.Get();
   if(num_demes > 0) {
-    assert(world_y % num_demes == 0);
     assert(birth_method != POSITION_CHILD_FULL_SOUP_ELDEST);
     assert(birth_method != POSITION_CHILD_FULL_SOUP_ELDEST);
   } else {
     assert(birth_method != POSITION_CHILD_DEME_RANDOM);
     num_demes = 1; // One population == one deme.
   }
-
+  
+  // How many cells do we need?
+  const int num_cells = world_x * world_y;
+  cell_array.Resize(num_cells);
+  resource_count.ResizeSpatialGrids(world_x, world_y);
+  market.Resize(MARKET_SIZE);
+  
+  // Setup the cells.  Do things that are not dependent upon topology here.
+  for(int i=0; i<num_cells; ++i) {
+    cell_array[i].Setup(world, i, environment.GetMutRates());
+    // Setup the reaper queue.
+    if (world->GetConfig().BIRTH_METHOD.Get() == POSITION_CHILD_FULL_SOUP_ELDEST) {
+      reaper_queue.Push(&(cell_array[i]));
+    }
+  }                         
+  
   const int deme_size_x = world_x;
   const int deme_size_y = world_y / num_demes;
   const int deme_size = deme_size_x * deme_size_y;
@@ -95,26 +107,13 @@
     deme_array[deme_id].Setup(deme_cells);
   }
   
-  
-  cell_array.Resize(num_cells);
-  resource_count.ResizeSpatialGrids(world_x, world_y);
-  market.Resize(MARKET_SIZE);
-  
-  // Setup the cells.  Do things that are not dependent upon topology here.
-  for(int i=0; i<num_cells; ++i) {
-    cell_array[i].Setup(world, i, environment.GetMutRates());
-    // Setup the reaper queue.
-    if (world->GetConfig().BIRTH_METHOD.Get() == POSITION_CHILD_FULL_SOUP_ELDEST) {
-      reaper_queue.Push(&(cell_array[i]));
-    }
-  }                         
-  
+
   // Setup the topology.
   // What we're doing here is chopping the cell_array up into num_demes pieces.
   // Note that having 0 demes (one population) is the same as having 1 deme.  Then
   // we send the cells that comprise each deme into the topology builder.
   for(int i=0; i<num_cells; i+=deme_size) {
-    switch(geometry) {
+    switch(world->GetConfig().WORLD_GEOMETRY.Get()) {
       // We're cheating here; we're using the random access nature of an iterator
       // to index beyond the end of the cell_array.
       case nGeometry::GRID: {

Modified: branches/dkdev/source/main/cPopulation.h
===================================================================
--- branches/dkdev/source/main/cPopulation.h	2007-02-23 22:01:44 UTC (rev 1364)
+++ branches/dkdev/source/main/cPopulation.h	2007-02-25 19:53:04 UTC (rev 1365)
@@ -13,33 +13,15 @@
 
 #include <fstream>
 
-#ifndef cBirthChamber_h
 #include "cBirthChamber.h"
-#endif
-#ifndef cDeme_h
 #include "cDeme.h"
-#endif
-#ifndef cOrgInterface_h
 #include "cOrgInterface.h"
-#endif
-#ifndef cPopulationInterface_h
 #include "cPopulationInterface.h"
-#endif
-#ifndef cResourceCount_h
 #include "cResourceCount.h"
-#endif
-#ifndef cString_h
 #include "cString.h"
-#endif
-#ifndef cWorld_h
 #include "cWorld.h"
-#endif
-#ifndef tArray_h
 #include "tArray.h"
-#endif
-#ifndef tList_h
 #include "tList.h"
-#endif
 
 class cAvidaContext;
 class cCodeLabel;
@@ -163,6 +145,7 @@
   int GetWorldX() { return world_x; }
   int GetWorldY() { return world_y; }
   int GetNumDemes() { return deme_array.GetSize(); }
+  cDeme& GetDeme(int demeId) { return deme_array[demeId]; }
 
   cPopulationCell& GetCell(int in_num);
   const tArray<double>& GetResources() const { return resource_count.GetResources(); }




More information about the Avida-cvs mailing list