[Avida-SVN] r2663 - in branches/BenDevelopment: source/actions source/drivers source/main tests/energy_deme_level_res

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Fri Jun 20 12:24:16 PDT 2008


Author: beckma24
Date: 2008-06-20 15:24:16 -0400 (Fri, 20 Jun 2008)
New Revision: 2663

Modified:
   branches/BenDevelopment/source/actions/PopulationActions.cc
   branches/BenDevelopment/source/drivers/cDefaultRunDriver.cc
   branches/BenDevelopment/source/main/cDemeCellEvent.cc
   branches/BenDevelopment/source/main/cWorld.cc
   branches/BenDevelopment/tests/energy_deme_level_res/test_list
Log:
Fixed InjectDeme event.  Beginning to enforce the injection of an organism, through the use of an event, at the beginning of a run

Modified: branches/BenDevelopment/source/actions/PopulationActions.cc
===================================================================
--- branches/BenDevelopment/source/actions/PopulationActions.cc	2008-06-20 18:30:16 UTC (rev 2662)
+++ branches/BenDevelopment/source/actions/PopulationActions.cc	2008-06-20 19:24:16 UTC (rev 2663)
@@ -128,7 +128,52 @@
   }
 };
 
+/********START**********/
+/*
+ Injects a different randomly generated genome into everydeme.
+ 
+ Parameters:
+   length (integer) [required]
+     Number of instructions in the randomly generated genome.
+   cell ID (integer) default: 0
+     The grid-point into which the organism should be placed.
+   merit (double) default: -1
+     The initial merit of the organism. If set to -1, this is ignored.
+   lineage label (integer) default: 0
+     An integer that marks all descendants of this organism.
+   neutral metric (double) default: 0
+     A double value that randomly drifts over time.
+*/
+class cActionInjectRandomDeme : public cAction
+{
+private:
+  int m_length;
+  int m_cell_id;
+  double m_merit;
+  int m_lineage_label;
+  double m_neutral_metric;
+public:
+  cActionInjectRandomDeme(cWorld* world, const cString& args) : cAction(world, args), m_cell_id(0), m_merit(-1), m_lineage_label(0), m_neutral_metric(0)
+  {
+    cString largs(args);
+    m_length = largs.PopWord().AsInt();
+    if (largs.GetSize()) m_cell_id = largs.PopWord().AsInt();
+    if (largs.GetSize()) m_merit = largs.PopWord().AsDouble();
+    if (largs.GetSize()) m_lineage_label = largs.PopWord().AsInt();
+    if (largs.GetSize()) m_neutral_metric = largs.PopWord().AsDouble();
+  }
+  
+  static const cString GetDescription() { return "Arguments: <int length> [int cell_id=0] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
 
+  void Process(cAvidaContext& ctx)
+  {
+    cGenome genome = cGenomeUtil::RandomGenome(ctx, m_length, m_world->GetHardwareManager().GetInstSet());
+    m_world->GetPopulation().Inject(genome, m_cell_id, m_merit, m_lineage_label, m_neutral_metric);
+  }
+};
+
+/********END*******/
+
 /*
  Injects randomly generated genomes into the entire population, plus a repro inst on the end,
  with the caveat that any instructions set to 0 probability of mutating into the genome 
@@ -560,23 +605,11 @@
   void Process(cAvidaContext& ctx)
   {
     cGenome genome = cGenomeUtil::LoadGenome(m_filename, m_world->GetHardwareManager().GetInstSet());
-    if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
-      for(int i=1; i<m_world->GetPopulation().GetNumDemes(); ++i) {  // first org has already been injected
-        m_world->GetPopulation().Inject(genome,
-                                        m_world->GetPopulation().GetDeme(i).GetCellID(0),
-                                        m_merit, m_lineage_label, m_neutral_metric);
-        m_world->GetPopulation().GetDeme(i).IncInjectedCount();
-      }
-    } else {
-      for(int i=0; i<m_world->GetPopulation().GetNumDemes(); ++i) {
-        // WARNING: initial ancestor has already be injected into the population
-        //           calling this will overwrite it.
-        m_world->GetPopulation().Inject(genome,
-                                        m_world->GetPopulation().GetDeme(i).GetCellID(0),
-                                        m_merit, m_lineage_label, m_neutral_metric);
-        m_world->GetPopulation().GetDeme(i).IncInjectedCount();
-        
-      }
+    for(int i=0; i<m_world->GetPopulation().GetNumDemes(); ++i) {
+      m_world->GetPopulation().Inject(genome,
+                                      m_world->GetPopulation().GetDeme(i).GetCellID(0),
+                                      m_merit, m_lineage_label, m_neutral_metric);
+      m_world->GetPopulation().GetDeme(i).IncInjectedCount();
     }
   }
 };

Modified: branches/BenDevelopment/source/drivers/cDefaultRunDriver.cc
===================================================================
--- branches/BenDevelopment/source/drivers/cDefaultRunDriver.cc	2008-06-20 18:30:16 UTC (rev 2662)
+++ branches/BenDevelopment/source/drivers/cDefaultRunDriver.cc	2008-06-20 19:24:16 UTC (rev 2663)
@@ -84,8 +84,24 @@
     if (cChangeList* change_list = population.GetChangeList()) {
       change_list->Reset();
     }
+  
+    m_world->GetEvents(ctx);
     
-    m_world->GetEvents(ctx);
+    if(stats.GetUpdate() == -1 && population.GetNumOrganisms() == 0) {
+      cerr << "\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"
+           << "%% No initial organism was injected!\n"
+           << "%% Add an event to immediatly inject an organism\n"
+           << "%% into the population to your event file.\n";
+      if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
+        cerr << "%% Inject event must be used with energy model.\n"
+             << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n";
+        break;
+      }
+      cerr << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\n";
+
+      population.InitiatePop();
+    }
+    
     if (m_done == true) break;
     
     // Increment the Update.

Modified: branches/BenDevelopment/source/main/cDemeCellEvent.cc
===================================================================
--- branches/BenDevelopment/source/main/cDemeCellEvent.cc	2008-06-20 18:30:16 UTC (rev 2662)
+++ branches/BenDevelopment/source/main/cDemeCellEvent.cc	2008-06-20 19:24:16 UTC (rev 2663)
@@ -11,8 +11,8 @@
   , m_event_width(x2-x1)
   , m_event_height(y2-y1)
   , m_active(false)
+  , m_static_pos(static_pos)
   , m_dead(false)
-  , m_static_pos(static_pos)
   , m_deme(deme)
   , m_world(world)
 {

Modified: branches/BenDevelopment/source/main/cWorld.cc
===================================================================
--- branches/BenDevelopment/source/main/cWorld.cc	2008-06-20 18:30:16 UTC (rev 2662)
+++ branches/BenDevelopment/source/main/cWorld.cc	2008-06-20 19:24:16 UTC (rev 2663)
@@ -107,7 +107,7 @@
 		m_class_mgr->LoadCCladeFounders(m_conf->TRACK_CCLADES_IDS.Get());
   
 	m_pop = new cPopulation(this);
-        m_pop->InitiatePop();
+//        m_pop->InitiatePop();
   
   // Setup Event List
   m_event_list = new cEventList(this);

Modified: branches/BenDevelopment/tests/energy_deme_level_res/test_list
===================================================================
--- branches/BenDevelopment/tests/energy_deme_level_res/test_list	2008-06-20 18:30:16 UTC (rev 2662)
+++ branches/BenDevelopment/tests/energy_deme_level_res/test_list	2008-06-20 19:24:16 UTC (rev 2663)
@@ -13,7 +13,7 @@
 email = beckma24 at msu.edu ; Email address for the test's creator
 
 [consistency]
-enabled = no            ; Is this test a consistency test?
+enabled = yes            ; Is this test a consistency test?
 long = no                ; Is this test a long test?
 
 [performance]




More information about the Avida-cvs mailing list