[Avida-SVN] r2888 - in development/source: actions main tools
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Mon Oct 27 11:23:57 PDT 2008
Author: beckma24
Date: 2008-10-27 14:23:57 -0400 (Mon, 27 Oct 2008)
New Revision: 2888
Modified:
development/source/actions/PrintActions.cc
development/source/main/cDeme.cc
development/source/main/cDeme.h
development/source/main/cOrganism.cc
development/source/main/cPopulationInterface.cc
development/source/main/cStats.cc
development/source/main/cStats.h
development/source/tools/cDataFile.cc
development/source/tools/cDataFile.h
Log:
Added PrintMessageData
Modified: development/source/actions/PrintActions.cc
===================================================================
--- development/source/actions/PrintActions.cc 2008-10-27 17:07:01 UTC (rev 2887)
+++ development/source/actions/PrintActions.cc 2008-10-27 18:23:57 UTC (rev 2888)
@@ -75,6 +75,7 @@
STATS_OUT_FILE(PrintDominantData, dominant.dat );
STATS_OUT_FILE(PrintStatsData, stats.dat );
STATS_OUT_FILE(PrintCountData, count.dat );
+STATS_OUT_FILE(PrintMessageData, message.dat );
STATS_OUT_FILE(PrintTotalsData, totals.dat );
STATS_OUT_FILE(PrintTasksData, tasks.dat );
STATS_OUT_FILE(PrintTasksExeData, tasks_exe.dat );
@@ -2664,6 +2665,7 @@
action_lib->Register<cActionPrintDominantData>("PrintDominantData");
action_lib->Register<cActionPrintStatsData>("PrintStatsData");
action_lib->Register<cActionPrintCountData>("PrintCountData");
+ action_lib->Register<cActionPrintMessageData>("PrintMessageData");
action_lib->Register<cActionPrintTotalsData>("PrintTotalsData");
action_lib->Register<cActionPrintTasksData>("PrintTasksData");
action_lib->Register<cActionPrintTasksExeData>("PrintTasksExeData");
Modified: development/source/main/cDeme.cc
===================================================================
--- development/source/main/cDeme.cc 2008-10-27 17:07:01 UTC (rev 2887)
+++ development/source/main/cDeme.cc 2008-10-27 18:23:57 UTC (rev 2888)
@@ -266,7 +266,11 @@
eventKillAttempts = 0;
eventKillAttemptsThisSlot = 0;
sleeping_count = 0;
-
+ MSG_sendFailed = 0;
+ MSG_dropped = 0;
+ MSG_SuccessfullySent = 0;
+ MSG_sent = 0;
+
consecutiveSuccessfulEventPeriods = 0;
cur_task_exe_count.SetAll(0);
Modified: development/source/main/cDeme.h
===================================================================
--- development/source/main/cDeme.h 2008-10-27 17:07:01 UTC (rev 2887)
+++ development/source/main/cDeme.h 2008-10-27 18:23:57 UTC (rev 2888)
@@ -70,6 +70,10 @@
int gestation_time; // Time used during last generation
double cur_normalized_time_used; // normalized by merit and number of orgs
double last_normalized_time_used;
+ unsigned int MSG_sendFailed;
+ unsigned int MSG_dropped;
+ unsigned int MSG_SuccessfullySent;
+ unsigned int MSG_sent;
double total_energy_testament; //! total amount of energy from suicide organisms for offspring deme
int eventsTotal;
unsigned int eventsKilled;
@@ -121,7 +125,8 @@
public:
cDeme() : _id(0), width(0), cur_birth_count(0), last_birth_count(0), cur_org_count(0), last_org_count(0), injected_count(0), birth_count_perslot(0),
_age(0), generation(0), total_org_energy(0.0),
- time_used(0), gestation_time(0), cur_normalized_time_used(0.0), last_normalized_time_used(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),
+ MSG_sendFailed(0), MSG_dropped(0), MSG_SuccessfullySent(0), MSG_sent(0), total_energy_testament(0.0),
eventsTotal(0), eventsKilled(0), eventsKilledThisSlot(0), eventKillAttempts(0), eventKillAttemptsThisSlot(0),
consecutiveSuccessfulEventPeriods(0), sleeping_count(0),
avg_founder_generation(0.0), generations_per_lifetime(0.0),
@@ -284,6 +289,17 @@
void AddEventMoveBetweenTargetsPred(int times);
void AddEventMigrateToTargetsPred(int times);
void AddEventEventNUniqueIndividualsMovedIntoTargetPred(int times);
+
+ // --- Messaging stats --- //
+ void IncMessageSent() { ++MSG_sent; }
+ void MessageSuccessfullySent() { ++MSG_SuccessfullySent; }
+ void messageDropped() { ++MSG_dropped; }
+ void messageSendFailed() { ++MSG_sendFailed; }
+ unsigned int GetMessagesSent() { return MSG_sent; }
+ unsigned int GetMessageSuccessfullySent() { return MSG_SuccessfullySent; }
+ unsigned int GetMessageDropped() { return MSG_dropped; }
+ unsigned int GetMessageSendFailed() { return MSG_sendFailed; }
+
// --- Pheromones --- //
void AddPheromone(int absolute_cell_id, double value);
Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc 2008-10-27 17:07:01 UTC (rev 2887)
+++ development/source/main/cOrganism.cc 2008-10-27 18:23:57 UTC (rev 2888)
@@ -671,12 +671,14 @@
assert(m_interface);
InitMessaging();
+ m_interface->GetDeme()->IncMessageSent();
// If we're able to succesfully send the message...
if(m_interface->SendMessage(msg)) {
// save it...
m_msg->sent.push_back(msg);
// stat-tracking...
m_world->GetStats().SentMessage(msg);
+ m_interface->GetDeme()->MessageSuccessfullySent();
// check to see if we've performed any tasks...
DoOutput(ctx);
// and set the receiver-pointer of this message to NULL. We don't want to
@@ -684,7 +686,7 @@
m_msg->sent.back().SetReceiver(0);
return true;
}
-
+ m_interface->GetDeme()->messageSendFailed();
return false;
}
Modified: development/source/main/cPopulationInterface.cc
===================================================================
--- development/source/main/cPopulationInterface.cc 2008-10-27 17:07:01 UTC (rev 2887)
+++ development/source/main/cPopulationInterface.cc 2008-10-27 18:23:57 UTC (rev 2888)
@@ -261,6 +261,12 @@
/*! Send a message to the faced organism, failing if this cell does not have
neighbors or if the cell currently faced is not occupied. */
bool cPopulationInterface::SendMessage(cOrgMessage& msg) {
+ static const double drop_prob = m_world->GetConfig().NET_DROP_PROB.Get();
+ if (drop_prob > 0.0 && m_world->GetRandom().P(drop_prob)) {
+ GetDeme()->messageDropped();
+ return false; // message dropped
+ }
+
cPopulationCell& cell = m_world->GetPopulation().GetCell(m_cell_id);
assert(cell.IsOccupied()); // This organism; sanity.
cPopulationCell* rcell = cell.ConnectionList().GetFirst();
Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc 2008-10-27 17:07:01 UTC (rev 2887)
+++ development/source/main/cStats.cc 2008-10-27 18:23:57 UTC (rev 2888)
@@ -799,6 +799,35 @@
df.Endl();
}
+void cStats::PrintMessageData(const cString& filename) {
+ cDataFile& df = m_world->GetDataFile(filename);
+
+ df.WriteComment( "Number of organsism to organisms messages\n" );
+
+ df.Write( GetUpdate(), "update" );
+
+ cPopulation& pop = m_world->GetPopulation();
+ int numDemes = pop.GetNumDemes();
+
+ unsigned int totalMessagesSent(0);
+ unsigned int totalMessagesSuccessfullySent(0);
+ unsigned int totalMessagesDropped(0);
+ unsigned int totalMessagesFailed(0);
+
+ for( int i=0; i < numDemes; i++ ){
+ totalMessagesSent += pop.GetDeme(i).GetMessagesSent();
+ totalMessagesSuccessfullySent += pop.GetDeme(i).GetMessageSuccessfullySent();
+ totalMessagesDropped += pop.GetDeme(i).GetMessageDropped();
+ totalMessagesFailed += pop.GetDeme(i).GetMessageSendFailed();
+ }
+
+ df.Write(totalMessagesSent, "Totlal messages sent");
+ df.Write(totalMessagesSuccessfullySent, "Sent successfully");
+ df.Write(totalMessagesDropped, "Dropped");
+ df.Write(totalMessagesFailed, "Failed");
+
+ df.Endl();
+}
void cStats::PrintTotalsData(const cString& filename)
{
Modified: development/source/main/cStats.h
===================================================================
--- development/source/main/cStats.h 2008-10-27 17:07:01 UTC (rev 2887)
+++ development/source/main/cStats.h 2008-10-27 18:23:57 UTC (rev 2888)
@@ -719,6 +719,7 @@
void PrintParasiteData(const cString& filename);
void PrintStatsData(const cString& filename);
void PrintCountData(const cString& filename);
+ void PrintMessageData(const cString& filename);
void PrintTotalsData(const cString& filename);
void PrintTasksData(const cString& filename);
void PrintTasksExeData(const cString& filename);
Modified: development/source/tools/cDataFile.cc
===================================================================
--- development/source/tools/cDataFile.cc 2008-10-27 17:07:01 UTC (rev 2887)
+++ development/source/tools/cDataFile.cc 2008-10-27 18:23:57 UTC (rev 2888)
@@ -70,7 +70,16 @@
m_fp << i << " ";
}
+void cDataFile::Write(unsigned int i, const char* descr)
+{
+ if (!m_descr_written) {
+ m_data += cStringUtil::Stringf("%u ", i);
+ WriteColumnDesc(descr);
+ } else
+ m_fp << i << " ";
+}
+
void cDataFile::Write(const char* data_str, const char* descr)
{
if (!m_descr_written) {
Modified: development/source/tools/cDataFile.h
===================================================================
--- development/source/tools/cDataFile.h 2008-10-27 17:07:01 UTC (rev 2887)
+++ development/source/tools/cDataFile.h 2008-10-27 18:23:57 UTC (rev 2888)
@@ -108,6 +108,7 @@
void Write(double x, const char* descr);
void Write(int i, const char* descr);
void Write(long i, const char* descr);
+ void Write(unsigned int i, const char* descr);
void Write(const char* data_str, const char* descr);
inline void WriteAnonymous(double x) { m_fp << x << " "; }
inline void WriteAnonymous(int i) { m_fp << i << " "; }
More information about the Avida-cvs
mailing list