[Avida-SVN] r2613 - in branches/jobScheduling/source: cpu main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Fri Jun 6 18:27:11 PDT 2008


Author: beckma24
Date: 2008-06-06 21:27:11 -0400 (Fri, 06 Jun 2008)
New Revision: 2613

Modified:
   branches/jobScheduling/source/cpu/cHardwareBase.cc
   branches/jobScheduling/source/cpu/cHardwareCPU.cc
   branches/jobScheduling/source/main/cDeme.cc
   branches/jobScheduling/source/main/cDeme.h
   branches/jobScheduling/source/main/cPopulation.cc
   branches/jobScheduling/source/main/cStats.cc
   branches/jobScheduling/source/main/cStats.h
Log:
Added sleep data to attack flow tuple

Modified: branches/jobScheduling/source/cpu/cHardwareBase.cc
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareBase.cc	2008-06-06 17:55:51 UTC (rev 2612)
+++ branches/jobScheduling/source/cpu/cHardwareBase.cc	2008-06-07 01:27:11 UTC (rev 2613)
@@ -858,7 +858,7 @@
             pop.AddBeginSleep(cellID,m_world->GetStats().GetUpdate());
           }
           pop.GetCell(cellID).GetOrganism()->SetSleeping(true);
-          m_world->GetStats().incNumAsleep(pop.GetCell(cellID).GetDemeID());
+          pop.GetCell(cellID).GetOrganism()->GetOrgInterface().GetDeme()->IncSleepingCount();
         }
       } else {
         organism->GetPhenotype().SetToDie();

Modified: branches/jobScheduling/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareCPU.cc	2008-06-06 17:55:51 UTC (rev 2612)
+++ branches/jobScheduling/source/cpu/cHardwareCPU.cc	2008-06-07 01:27:11 UTC (rev 2613)
@@ -4541,7 +4541,8 @@
     pop.AddEndSleep(cellID, m_world->GetStats().GetUpdate());
   }
   organism->SetSleeping(false);  //this instruction get executed at the end of a sleep cycle
-  m_world->GetStats().decNumAsleep(pop.GetCell(cellID).GetDemeID());
+  GetOrganism()->GetOrgInterface().GetDeme()->DecSleepingCount();
+//  m_world->GetStats().decNumAsleep(pop.GetCell(cellID).GetDemeID());
   if(m_world->GetConfig().APPLY_ENERGY_METHOD.Get() == 2) {
     organism->GetPhenotype().RefreshEnergy();
     organism->GetPhenotype().ApplyToEnergyStore();
@@ -5028,7 +5029,8 @@
       m_advance_ip = false; // Don't automatically move the IP
       if(organism->IsSleeping()) {
         organism->SetSleeping(false);
-        m_world->GetStats().decNumAsleep(organism->GetOrgInterface().GetDemeID());
+        GetOrganism()->GetOrgInterface().GetDeme()->DecSleepingCount();
+//        m_world->GetStats().decNumAsleep(organism->GetOrgInterface().GetDemeID());
       }
       return true;
     }

Modified: branches/jobScheduling/source/main/cDeme.cc
===================================================================
--- branches/jobScheduling/source/main/cDeme.cc	2008-06-06 17:55:51 UTC (rev 2612)
+++ branches/jobScheduling/source/main/cDeme.cc	2008-06-07 01:27:11 UTC (rev 2613)
@@ -156,11 +156,15 @@
       else
         consecutiveSuccessfulEventPeriods = 0;
       
-      (m_world->GetStats().FlowRateTuples())[(*iter).second].orgCount.Add(GetOrgCount());
-      (m_world->GetStats().FlowRateTuples())[(*iter).second].eventsKilled.Add(GetEventsKilledThisSlot());
-      (m_world->GetStats().FlowRateTuples())[(*iter).second].attemptsToKillEvents.Add(GetEventKillAttemptsThisSlot());
-      (m_world->GetStats().FlowRateTuples())[(*iter).second].AvgEnergyUsageRatio.Add(energyUsage.Average());
-      (m_world->GetStats().FlowRateTuples())[(*iter).second].totalBirths.Add(birth_count_perslot);
+      // update stats.flow_rate_tuples
+      std::map<int, flow_rate_tuple>& flowRateTuples = m_world->GetStats().FlowRateTuples();
+
+      flowRateTuples[(*iter).second].orgCount.Add(GetOrgCount());
+      flowRateTuples[(*iter).second].eventsKilled.Add(GetEventsKilledThisSlot());
+      flowRateTuples[(*iter).second].attemptsToKillEvents.Add(GetEventKillAttemptsThisSlot());
+      flowRateTuples[(*iter).second].AvgEnergyUsageRatio.Add(energyUsage.Average());
+      flowRateTuples[(*iter).second].totalBirths.Add(birth_count_perslot);
+      flowRateTuples[(*iter).second].currentSleeping.Add(sleeping_count);
       birth_count_perslot = 0;
       eventsKilledThisSlot = 0;
       eventKillAttemptsThisSlot = 0;
@@ -212,6 +216,7 @@
   eventsKilledThisSlot = 0;
   eventKillAttempts = 0;
   eventKillAttemptsThisSlot = 0;
+  sleeping_count = 0;
   
   consecutiveSuccessfulEventPeriods = 0;
   
@@ -369,14 +374,15 @@
   }
     
   // setup stats.flow_rate_tuples
-  cStats& stats = m_world->GetStats();
+  std::map<int, flow_rate_tuple>& flowRateTuples = m_world->GetStats().FlowRateTuples();
+
   for(int i = m_total_events_per_slot_min; i <= m_total_events_per_slot_max; i+=flow_level_increment) {
-    (stats.FlowRateTuples())[i].orgCount.Clear();
-    (stats.FlowRateTuples())[i].eventsKilled.Clear();
-    (stats.FlowRateTuples())[i].attemptsToKillEvents.Clear();
-    (stats.FlowRateTuples())[i].AvgEnergyUsageRatio.Clear();
-    (stats.FlowRateTuples())[i].totalBirths.Clear();
-
+    flowRateTuples[i].orgCount.Clear();
+    flowRateTuples[i].eventsKilled.Clear();
+    flowRateTuples[i].attemptsToKillEvents.Clear();
+    flowRateTuples[i].AvgEnergyUsageRatio.Clear();
+    flowRateTuples[i].totalBirths.Clear();
+    flowRateTuples[i].currentSleeping.Clear();
   }
 }
 

Modified: branches/jobScheduling/source/main/cDeme.h
===================================================================
--- branches/jobScheduling/source/main/cDeme.h	2008-06-06 17:55:51 UTC (rev 2612)
+++ branches/jobScheduling/source/main/cDeme.h	2008-06-07 01:27:11 UTC (rev 2613)
@@ -52,9 +52,9 @@
   int width; //!< Width of this deme.
 
 // The following should be moved to cDemePhenotype
-  int birth_count; //!< Number of organisms that have been born into this deme since reset.
+  int birth_count; //!< Number of organisms born into deme since reset.
   int birth_count_perslot;
-  int org_count; //!< Number of organisms are currently in this deme.
+  int org_count; //!< Number of organisms currently in this deme.
   int _age; //!< Age of this deme, in updates.
   int generation; //!< Generation of this deme
   double total_org_energy; //! total amount of energy in organisms in this deme
@@ -68,6 +68,7 @@
   unsigned int eventKillAttempts;
   unsigned int eventKillAttemptsThisSlot;
   unsigned int consecutiveSuccessfulEventPeriods;
+  int sleeping_count; //!< Number of organisms currently sleeping
   cDoubleSum energyUsage;
   
   // End of phenotypic traits
@@ -93,7 +94,7 @@
   cDeme() : _id(0), width(0), birth_count(0), birth_count_perslot(0), org_count(0), _age(0), generation(0), total_org_energy(0.0), total_energy_testament(0.0),
             time_used(0), gestation_time(0), cur_normalized_time_used(0.0), last_normalized_time_used(0.0), 
             eventsKilled(0), eventsKilledThisSlot(0), eventKillAttempts(0), eventKillAttemptsThisSlot(0),
-            consecutiveSuccessfulEventPeriods(0), deme_resource_count(0), m_germline_genotype_id(0) { ; }
+            consecutiveSuccessfulEventPeriods(0), sleeping_count(0), deme_resource_count(0), m_germline_genotype_id(0) { ; }
   ~cDeme() { ; }
 
   void Setup(int id, const tArray<int>& in_cells, int in_width = -1, cWorld* world = NULL);
@@ -120,6 +121,10 @@
   int GetOrgCount() const { return org_count; }
   void IncOrgCount() { org_count++; }
   void DecOrgCount() { org_count--; }
+
+  int GetSleepingCount() const { return sleeping_count; }
+  void IncSleepingCount() { sleeping_count++; }
+  void DecSleepingCount() { sleeping_count--; }
   
   int GetGeneration() const { return generation; }
 

Modified: branches/jobScheduling/source/main/cPopulation.cc
===================================================================
--- branches/jobScheduling/source/main/cPopulation.cc	2008-06-06 17:55:51 UTC (rev 2612)
+++ branches/jobScheduling/source/main/cPopulation.cc	2008-06-07 01:27:11 UTC (rev 2613)
@@ -655,9 +655,10 @@
   
   int cellID = in_cell.GetID();
 
-  if(GetCell(cellID).GetOrganism()->IsSleeping()) {
-    GetCell(cellID).GetOrganism()->SetSleeping(false);
-    m_world->GetStats().decNumAsleep(GetCell(cellID).GetDemeID());
+  if(organism->IsSleeping()) {
+    organism->SetSleeping(false);
+    organism->GetOrgInterface().GetDeme()->DecSleepingCount();
+//    m_world->GetStats().decNumAsleep(GetCell(cellID).GetDemeID());
   }
   if(m_world->GetConfig().LOG_SLEEP_TIMES.Get() == 1) {
     if(sleep_log[cellID].Size() > 0) {

Modified: branches/jobScheduling/source/main/cStats.cc
===================================================================
--- branches/jobScheduling/source/main/cStats.cc	2008-06-06 17:55:51 UTC (rev 2612)
+++ branches/jobScheduling/source/main/cStats.cc	2008-06-07 01:27:11 UTC (rev 2613)
@@ -226,9 +226,6 @@
 
   genotype_map.Resize( m_world->GetConfig().WORLD_X.Get() * m_world->GetConfig().WORLD_Y.Get() );
 
-  numAsleep.Resize(m_world->GetConfig().NUM_DEMES.Get());
-  numAsleep.SetAll(0);
-
   SetupPrintDatabase();
 }
 
@@ -608,6 +605,7 @@
     string flow_rate_events_attempted_to_kill_str(flow_rate_str+" events attempted to kill");
     string flow_rate_exe_ratio_str(flow_rate_str+" exe ratio");
     string flow_rate_total_births_str(flow_rate_str+" total births");
+    string flow_rate_total_sleeping_str(flow_rate_str+" total sleeping");
     
     df.Write((*iter).first, flow_rate_str.c_str());
     df.Write((*iter).second.orgCount.Average(), flow_rate_pop_size_str.c_str());
@@ -615,6 +613,7 @@
     df.Write((*iter).second.attemptsToKillEvents.Average(), flow_rate_events_attempted_to_kill_str.c_str());
     df.Write((*iter).second.AvgEnergyUsageRatio.Average(), flow_rate_exe_ratio_str.c_str());
     df.Write((*iter).second.totalBirths.Average(), flow_rate_total_births_str.c_str());
+    df.Write((*iter).second.currentSleeping.Average(), flow_rate_total_sleeping_str.c_str());
     
   }
   df.Endl();
@@ -626,6 +625,7 @@
     (*iter).second.attemptsToKillEvents.Clear();
     (*iter).second.AvgEnergyUsageRatio.Clear();
     (*iter).second.totalBirths.Clear();
+    (*iter).second.currentSleeping.Clear();
   }
 }
 
@@ -1176,9 +1176,12 @@
   df.WriteComment("total number of organisms sleeping" );
   
   df.Write( GetUpdate(), "update" );
-    
-  for( int i=0; i < numAsleep.GetSize(); i++ ){
-    df.Write(numAsleep[i], cStringUtil::Stringf("DemeID %d", i));
+  
+  cPopulation& pop = m_world->GetPopulation();
+  int numDemes = pop.GetNumDemes();
+  
+  for( int i=0; i < numDemes; i++ ){
+    df.Write(pop.GetDeme(i).GetSleepingCount(), cStringUtil::Stringf("DemeID %d", i));
   }
   df.Endl();
 }
@@ -1268,9 +1271,6 @@
   m_deme_births.Add(source_deme.GetBirthCount());
   m_deme_merit.Add(source_deme.GetHeritableDemeMerit().GetDouble());
   m_deme_generation.Add(source_deme.GetGeneration());
-  
-  numAsleep[source_deme.GetID()]=0;
-  numAsleep[target_deme.GetID()]=0;
 }
 
 

Modified: branches/jobScheduling/source/main/cStats.h
===================================================================
--- branches/jobScheduling/source/main/cStats.h	2008-06-06 17:55:51 UTC (rev 2612)
+++ branches/jobScheduling/source/main/cStats.h	2008-06-07 01:27:11 UTC (rev 2613)
@@ -78,6 +78,7 @@
   cIntSum attemptsToKillEvents;
   cDoubleSum AvgEnergyUsageRatio;
   cIntSum totalBirths;
+  cIntSum currentSleeping;
 };
 
 class cStats
@@ -272,7 +273,7 @@
   double max_competition_copied_fitness;  
   int num_orgs_replicated;
 
-  tArray<int> numAsleep;
+//  tArray<int> numAsleep;
   
   // simple deme stats
   cIntSum sum_deme_age;
@@ -673,10 +674,10 @@
 
   int GetNumSenseSlots();
 
-  int getNumAsleep(int demeID) { return numAsleep[demeID]; }
+/*  int getNumAsleep(int demeID) { return numAsleep[demeID]; }
   void incNumAsleep(int demeID) { numAsleep[demeID]++; }
   void decNumAsleep(int demeID) { numAsleep[demeID]--; }
-
+*/
   double GetAveSpeculative() const { return (m_spec_num) ? ((double)m_spec_total / (double)m_spec_num) : 0.0; }
   int GetSpeculativeWaste() const { return m_spec_waste; }
 




More information about the Avida-cvs mailing list