[Avida-SVN] r3328 - in development/source: cpu main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Fri Jun 19 12:26:12 PDT 2009


Author: beckma24
Date: 2009-06-19 15:26:12 -0400 (Fri, 19 Jun 2009)
New Revision: 3328

Modified:
   development/source/cpu/cHardwareCPU.cc
   development/source/main/cPopulation.cc
Log:
Move some deme updating code to a more appropriate location.  Also removed implicit code to copy constructor in phermone sensing instructions... makes a BIG difference

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2009-06-19 18:36:53 UTC (rev 3327)
+++ development/source/cpu/cHardwareCPU.cc	2009-06-19 19:26:12 UTC (rev 3328)
@@ -6952,7 +6952,7 @@
   cDeme &deme = pop.GetDeme(pop.GetCell(cellid).GetDemeID());
   int relative_cell_id = deme.GetRelativeCellID(cellid);
 
-  cResourceCount deme_resource_count = deme.GetDemeResourceCount();
+  const cResourceCount& deme_resource_count = deme.GetDemeResourceCount();
   tArray<double> cell_resources = deme_resource_count.GetCellResources(relative_cell_id);
   double pher_amount = 0;
 
@@ -6979,7 +6979,7 @@
 	}
 	int reg_to_set = FindModifiedRegister(REG_BX);
   cDeme& deme = m_world->GetPopulation().GetDeme(m_organism->GetDemeID());
-	cResourceCount deme_resource_count = deme.GetDemeResourceCount();
+	const cResourceCount& deme_resource_count = deme.GetDemeResourceCount();
 
 	if(deme_resource_count.GetSize() == 0) assert(false); // change to: return false;
 	

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2009-06-19 18:36:53 UTC (rev 3327)
+++ development/source/main/cPopulation.cc	2009-06-19 19:26:12 UTC (rev 3328)
@@ -3787,13 +3787,15 @@
   m_world->GetStats().IncExecuted();
   resource_count.Update(step_size);
   
-  // Deme specific
+	// these must be done even if there is only one deme.
+	for(int i = 0; i < GetNumDemes(); i++)
+		GetDeme(i).Update(step_size);
+    
+	cDeme & deme = GetDeme(GetCell(cell_id).GetDemeID());
+	deme.IncTimeUsed(merit);
+  
   if (GetNumDemes() >= 1)
   {
-    for(int i = 0; i < GetNumDemes(); i++) GetDeme(i).Update(step_size);
-    
-    cDeme & deme = GetDeme(GetCell(cell_id).GetDemeID());
-    deme.IncTimeUsed(merit);
     CheckImplicitDemeRepro(deme);
   }
 }
@@ -3854,10 +3856,15 @@
 // Loop through all the demes getting stats and doing calculations
 // which must be done on a deme by deme basis.
 void cPopulation::UpdateDemeStats() {
-  
+
+	// these must be updated, even if there is only one deme
+	for(int i = 0; i < GetNumDemes(); i++) {
+    GetDeme(i).UpdateDemeRes();
+  }
+	
   // bail early to save time if there are no demes
   if (GetNumDemes() == 1) return ;
-  
+	
   cStats& stats = m_world->GetStats();
   
   stats.SumDemeAge().Clear();
@@ -4085,12 +4092,6 @@
   stats.SetResources(resource_count.GetResources());
   stats.SetSpatialRes(resource_count.GetSpatialRes());
   stats.SetResourcesGeometry(resource_count.GetResourcesGeometry());
-  
-  //TODO: update deme resource  (what calls DoOutput)
-  
-  for(int i = 0; i < GetNumDemes(); i++) {
-    GetDeme(i).UpdateDemeRes();
-  }
 }
 
 




More information about the Avida-cvs mailing list