[Avida-SVN] r2690 - in branches/interrupt/source: actions main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Thu Jun 26 11:18:27 PDT 2008
Author: beckma24
Date: 2008-06-26 14:18:27 -0400 (Thu, 26 Jun 2008)
New Revision: 2690
Modified:
branches/interrupt/source/actions/PrintActions.cc
branches/interrupt/source/main/cDeme.cc
branches/interrupt/source/main/cDeme.h
branches/interrupt/source/main/cDemeCellEvent.cc
branches/interrupt/source/main/cPopulation.cc
branches/interrupt/source/main/cPopulation.h
branches/interrupt/source/main/cStats.cc
branches/interrupt/source/main/cStats.h
Log:
Added average lifetime of event to event flow tuple. Added event to print sleep log
Modified: branches/interrupt/source/actions/PrintActions.cc
===================================================================
--- branches/interrupt/source/actions/PrintActions.cc 2008-06-26 17:09:41 UTC (rev 2689)
+++ branches/interrupt/source/actions/PrintActions.cc 2008-06-26 18:18:27 UTC (rev 2690)
@@ -2390,6 +2390,36 @@
}
};
+class cActionPrintAndClearSleepLog : public cAction
+{
+private:
+ cString m_filename;
+
+public:
+ cActionPrintAndClearSleepLog(cWorld* world, const cString& args) : cAction(world, args), m_filename("")
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_filename = largs.PopWord();
+ }
+ static const cString GetDescription() { return "Arguments: [string fname='']"; }
+ void Process(cAvidaContext& ctx)
+ {
+ cString filename(m_filename);
+ if (filename == "") filename.Set("sleep.%d.dat", m_world->GetStats().GetUpdate());
+ ofstream& fp = m_world->GetDataFileOFStream(filename);
+
+ cPopulation& pop = m_world->GetPopulation();
+
+ for(int currentCell = 0; currentCell < pop.GetSize(); currentCell++) {
+ tVector<pair<int, int> > sleep_log = pop.getCellSleepLog(currentCell);
+ for(int i = 0; i < sleep_log.Size(); i++) {
+ fp << currentCell << " " << sleep_log[i].first << " " << sleep_log[i].second <<endl;
+ }
+ }
+ m_world->GetDataFileManager().Remove(filename);
+ }
+};
+
class cActionDumpTaskGrid : public cAction
{
private:
@@ -2675,6 +2705,7 @@
action_lib->Register<cActionPrintSenseData>("PrintSenseData");
action_lib->Register<cActionPrintSenseExeData>("PrintSenseExeData");
action_lib->Register<cActionPrintSleepData>("PrintSleepData");
+ action_lib->Register<cActionPrintAndClearSleepLog>("PrintAndClearSleepLog");
action_lib->Register<cActionPrintCompetitionData>("PrintCompetitionData");
// @WRE: Added printing of visit data
Modified: branches/interrupt/source/main/cDeme.cc
===================================================================
--- branches/interrupt/source/main/cDeme.cc 2008-06-26 17:09:41 UTC (rev 2689)
+++ branches/interrupt/source/main/cDeme.cc 2008-06-26 18:18:27 UTC (rev 2690)
@@ -202,12 +202,14 @@
flowRateTuples[(*iter).second].orgCount.Add(GetOrgCount());
flowRateTuples[(*iter).second].eventsKilled.Add(GetEventsKilledThisSlot());
flowRateTuples[(*iter).second].attemptsToKillEvents.Add(GetEventKillAttemptsThisSlot());
+ flowRateTuples[(*iter).second].AvgEventLifeTime.Add(averageEventLifetime.Average());
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;
+ averageEventLifetime.Clear();
break;
}
}
@@ -530,6 +532,7 @@
flowRateTuples[i].orgCount.Clear();
flowRateTuples[i].eventsKilled.Clear();
flowRateTuples[i].attemptsToKillEvents.Clear();
+ flowRateTuples[i].AvgEventLifeTime.Clear();
flowRateTuples[i].AvgEnergyUsageRatio.Clear();
flowRateTuples[i].totalBirths.Clear();
flowRateTuples[i].currentSleeping.Clear();
@@ -560,6 +563,7 @@
eventsKilled++;
eventsKilledThisSlot++;
eventKillAttempts++;
+ averageEventLifetime.Add(GetAge() - event.GetDelay());
return true;
}
}
Modified: branches/interrupt/source/main/cDeme.h
===================================================================
--- branches/interrupt/source/main/cDeme.h 2008-06-26 17:09:41 UTC (rev 2689)
+++ branches/interrupt/source/main/cDeme.h 2008-06-26 18:18:27 UTC (rev 2690)
@@ -24,8 +24,11 @@
#ifndef cDeme_h
#define cDeme_h
+#ifndef cIntSum_h
+#include "cIntSum.h"
+#endif
+
#include <vector>
-
#include "cDemeCellEvent.h"
#include "cGermline.h"
#include "cPhenotype.h"
@@ -76,6 +79,7 @@
unsigned int eventsKilledThisSlot;
unsigned int eventKillAttempts;
unsigned int eventKillAttemptsThisSlot;
+ cIntSum averageEventLifetime;
unsigned int consecutiveSuccessfulEventPeriods;
int sleeping_count; //!< Number of organisms currently sleeping
cDoubleSum energyUsage;
Modified: branches/interrupt/source/main/cDemeCellEvent.cc
===================================================================
--- branches/interrupt/source/main/cDemeCellEvent.cc 2008-06-26 17:09:41 UTC (rev 2689)
+++ branches/interrupt/source/main/cDemeCellEvent.cc 2008-06-26 18:18:27 UTC (rev 2690)
@@ -10,9 +10,10 @@
, m_deme_height(deme_height)
, m_event_width(x2-x1)
, m_event_height(y2-y1)
+ , m_use_gradient(false) // what is this?
, m_active(false)
+ , m_static_pos(static_pos)
, m_dead(false)
- , m_static_pos(static_pos)
, m_deme(deme)
, m_world(world)
{
Modified: branches/interrupt/source/main/cPopulation.cc
===================================================================
--- branches/interrupt/source/main/cPopulation.cc 2008-06-26 17:09:41 UTC (rev 2689)
+++ branches/interrupt/source/main/cPopulation.cc 2008-06-26 18:18:27 UTC (rev 2690)
@@ -1144,7 +1144,7 @@
}
// re-inject demes with count of 1
- for(int i =0; i < deme_counts.size(); i++) {
+ for(int i =0; i < (int) deme_counts.size(); i++) {
if(deme_counts[i] == 1)
ReplaceDeme(deme_array[i], deme_array[i]);
}
Modified: branches/interrupt/source/main/cPopulation.h
===================================================================
--- branches/interrupt/source/main/cPopulation.h 2008-06-26 17:09:41 UTC (rev 2689)
+++ branches/interrupt/source/main/cPopulation.h 2008-06-26 18:18:27 UTC (rev 2690)
@@ -310,6 +310,7 @@
void AddEndSleep(int cellID, int end_time);
tVector<pair<int,int> > getCellSleepLog(int i) { return sleep_log[i]; }
+ void clearSleepLog() { delete sleep_log; sleep_log = new tVector<pair<int,int> >[world_x*world_y]; }
// Trials and genetic algorithm @JEB
void NewTrial();
Modified: branches/interrupt/source/main/cStats.cc
===================================================================
--- branches/interrupt/source/main/cStats.cc 2008-06-26 17:09:41 UTC (rev 2689)
+++ branches/interrupt/source/main/cStats.cc 2008-06-26 18:18:27 UTC (rev 2690)
@@ -620,6 +620,7 @@
string flow_rate_pop_size_str(flow_rate_str+" deme pop size");
string flow_rate_events_killed_str(flow_rate_str+" events killed");
string flow_rate_events_attempted_to_kill_str(flow_rate_str+" events attempted to kill");
+ string flow_rate_average_event_lifetime_str(flow_rate_str+" average lifetime of event");
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");
@@ -628,6 +629,7 @@
df.Write((*iter).second.orgCount.Average(), flow_rate_pop_size_str.c_str());
df.Write((*iter).second.eventsKilled.Average(), flow_rate_events_killed_str.c_str());
df.Write((*iter).second.attemptsToKillEvents.Average(), flow_rate_events_attempted_to_kill_str.c_str());
+ df.Write((*iter).second.AvgEventLifeTime.Average(), flow_rate_average_event_lifetime_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());
Modified: branches/interrupt/source/main/cStats.h
===================================================================
--- branches/interrupt/source/main/cStats.h 2008-06-26 17:09:41 UTC (rev 2689)
+++ branches/interrupt/source/main/cStats.h 2008-06-26 18:18:27 UTC (rev 2690)
@@ -81,6 +81,7 @@
cIntSum orgCount;
cIntSum eventsKilled;
cIntSum attemptsToKillEvents;
+ cDoubleSum AvgEventLifeTime;
cDoubleSum AvgEnergyUsageRatio;
cIntSum totalBirths;
cIntSum currentSleeping;
More information about the Avida-cvs
mailing list