[Avida-SVN] r2608 - in development/source: drivers main

jbarrick at myxo.css.msu.edu jbarrick at myxo.css.msu.edu
Fri Jun 6 08:34:47 PDT 2008


Author: jbarrick
Date: 2008-06-06 11:34:47 -0400 (Fri, 06 Jun 2008)
New Revision: 2608

Modified:
   development/source/drivers/cDefaultRunDriver.cc
   development/source/drivers/cDefaultRunDriver.h
   development/source/main/cAvidaConfig.h
   development/source/main/cPopulation.cc
Log:
Added FASTFORWARD_NUM_ORGS, fast forwarding after a specific number of organisms is reached.

Fixed bug with PREFER EMPTY and MASS ACTION replacement method.

Modified: development/source/drivers/cDefaultRunDriver.cc
===================================================================
--- development/source/drivers/cDefaultRunDriver.cc	2008-06-06 14:54:53 UTC (rev 2607)
+++ development/source/drivers/cDefaultRunDriver.cc	2008-06-06 15:34:47 UTC (rev 2608)
@@ -53,6 +53,7 @@
   
   // Save this config variable
   m_generation_update_fastforward_threshold = m_world->GetConfig().FASTFORWARD_UPDATES.Get();
+  m_population_fastforward_threshold = m_world->GetConfig().FASTFORWARD_NUM_ORGS.Get();
 }
 
 cDefaultRunDriver::~cDefaultRunDriver()
@@ -156,7 +157,7 @@
     }
     
     // Keep track of changes in generation for fast-forward purposes
-    UpdateFastForward(stats.GetGeneration());
+    UpdateFastForward(stats.GetGeneration(),stats.GetNumCreatures());
       
     // Exit conditons...
     if (population.GetNumOrganisms() == 0) m_done = true;
@@ -184,8 +185,13 @@
   cout << "Warning: " << in_string << endl;
 }
 
-void cDefaultRunDriver::UpdateFastForward (double inGeneration)
+void cDefaultRunDriver::UpdateFastForward (double inGeneration, int population)
 {
+  if (bool(m_population_fastforward_threshold))
+  {
+	if (population >= m_population_fastforward_threshold) m_fastforward = true;
+	else m_fastforward = false;
+  }
   if (!m_generation_update_fastforward_threshold) return;
 
   if (inGeneration == m_last_generation)

Modified: development/source/drivers/cDefaultRunDriver.h
===================================================================
--- development/source/drivers/cDefaultRunDriver.h	2008-06-06 14:54:53 UTC (rev 2607)
+++ development/source/drivers/cDefaultRunDriver.h	2008-06-06 15:34:47 UTC (rev 2608)
@@ -49,6 +49,7 @@
   double m_last_generation;
   int m_generation_same_update_count;
   int m_generation_update_fastforward_threshold;
+  int m_population_fastforward_threshold;
   
 public:
   cDefaultRunDriver(cWorld* world);
@@ -68,7 +69,7 @@
   void NotifyWarning(const cString& in_string);
   
   void ClearFastForward() { m_fastforward = false; m_generation_same_update_count = 0; }
-  void UpdateFastForward (double inGeneration);
+  void UpdateFastForward (double inGeneration, int population);
   bool GetFastForward() { return m_fastforward; }
 
 };

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2008-06-06 14:54:53 UTC (rev 2607)
+++ development/source/main/cAvidaConfig.h	2008-06-06 15:34:47 UTC (rev 2608)
@@ -425,6 +425,7 @@
   CONFIG_ADD_VAR(MAX_DONATES, int, 1000000, "Limit on number of donates organisms are allowed.");
   CONFIG_ADD_VAR(PRECALC_PHENOTYPE, int, 0, "0 = Disabled\n 1 = Assign precalculated merit at birth (unlimited resources only)\n 2 = Assign precalculated gestation time\n 3 = Assign precalculated merit AND gestation time.\nFitness will be evaluated for organism based on these settings.");
   CONFIG_ADD_VAR(FASTFORWARD_UPDATES, int, 0, "Fast-forward if the average generation has not changed in this many updates. (0 = off)");
+  CONFIG_ADD_VAR(FASTFORWARD_NUM_ORGS, int, 0, "Fast-forward if population is equal to this");
 
   CONFIG_ADD_GROUP(GENEOLOGY_GROUP, "Geneology");
   CONFIG_ADD_VAR(TRACK_MAIN_LINEAGE, int, 1, "Keep all ancestors of the active population?\n0=no, 1=yes, 2=yes,w/sexual population");

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2008-06-06 14:54:53 UTC (rev 2607)
+++ development/source/main/cPopulation.cc	2008-06-06 15:34:47 UTC (rev 2608)
@@ -296,6 +296,10 @@
 
 bool cPopulation::ActivateOffspring(cAvidaContext& ctx, cGenome& child_genome, cOrganism& parent_organism)
 {
+  if (m_world->GetConfig().FASTFORWARD_NUM_ORGS.Get() > 0 && GetNumOrganisms() >= m_world->GetConfig().FASTFORWARD_NUM_ORGS.Get())
+  {
+	  return true;
+  }
   assert(&parent_organism != NULL);
   
   tArray<cOrganism*> child_array;
@@ -2865,7 +2869,6 @@
    
     // Look randomly within empty cells first, if requested
     if (m_world->GetConfig().PREFER_EMPTY.Get()) {
-      
       int num_empty_cells = UpdateEmptyCellIDArray();
       if (num_empty_cells > 0) {
         int out_pos = m_world->GetRandom().GetUInt(num_empty_cells);
@@ -3171,7 +3174,6 @@
 int cPopulation::UpdateEmptyCellIDArray(int deme_id)
 {
   int num_empty_cells = 0;  
-  cDeme& deme = deme_array[deme_id];
   // Note: empty_cell_id_array was resized to be large enough to hold
   // all cells in the cPopulation when it was created. Using functions
   // that resize it (like Push) will slow this code down considerably.
@@ -3185,11 +3187,11 @@
   }
   // Look at a specific deme
   else {
+	cDeme& deme = deme_array[deme_id];
     for (int i=0; i<deme.GetSize(); i++) {
       if (GetCell(deme.GetCellID(i)).IsOccupied() == false) empty_cell_id_array[num_empty_cells++] = deme.GetCellID(i);
     }
   }
-  
   return num_empty_cells;
 }
 




More information about the Avida-cvs mailing list