[Avida-SVN] r2251 - branches/energy/source/main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Fri Jan 4 10:22:35 PST 2008


Author: beckma24
Date: 2008-01-04 13:22:35 -0500 (Fri, 04 Jan 2008)
New Revision: 2251

Modified:
   branches/energy/source/main/cAvidaConfig.h
   branches/energy/source/main/cOrganism.cc
   branches/energy/source/main/cPopulationInterface.cc
   branches/energy/source/main/cStats.cc
Log:
added config option to limit in and out box size

Modified: branches/energy/source/main/cAvidaConfig.h
===================================================================
--- branches/energy/source/main/cAvidaConfig.h	2008-01-04 02:13:01 UTC (rev 2250)
+++ branches/energy/source/main/cAvidaConfig.h	2008-01-04 18:22:35 UTC (rev 2251)
@@ -452,6 +452,8 @@
   CONFIG_ADD_VAR(LOG_SLEEP_TIMES, bool, 0, "Log sleep start and end times. 0/1 (off/on)\nWARNING: may use lots of memory.");
   //  CONFIG_ADD_VAR(FIX_METABOLIC_RATE, bool, 0, "When activated the metabolic rate of all orgiansims are equal. 0/1 (off/on)"); // TODO - check for correctness
   CONFIG_ADD_VAR(BCAST_HOPS, int, 1, "Distance a message will travel");
+  CONFIG_ADD_VAR(INBOX_SIZE, int, 10, "Size of organism inbox");
+  CONFIG_ADD_VAR(OUTBOX_SIZE, int, 10, "Size of organism outbox");
   CONFIG_ADD_VAR(LOG_REP_LOCATION, bool, 0, "Log position of organisms in deme when it replicates. 0/1 (off/on)");
 
 

Modified: branches/energy/source/main/cOrganism.cc
===================================================================
--- branches/energy/source/main/cOrganism.cc	2008-01-04 02:13:01 UTC (rev 2250)
+++ branches/energy/source/main/cOrganism.cc	2008-01-04 18:22:35 UTC (rev 2251)
@@ -663,6 +663,9 @@
   if(m_interface->SendMessageMultiHop(msg)) {
     // save it...
     m_msg->sent.push_back(msg);
+    if(m_msg->sent.size() > (unsigned int)m_world->GetConfig().OUTBOX_SIZE.Get())
+      m_msg->sent.erase(m_msg->sent.begin());
+    
     // stat-tracking...
     m_world->GetStats().SentMessageMultiHop(msg);
     // check to see if we've performed any tasks...
@@ -680,6 +683,11 @@
   InitMessaging();  
   msg.SetReceiver(this);
   m_msg->received.push_back(msg);
+  if(m_msg->received.size() > (unsigned int)m_world->GetConfig().INBOX_SIZE.Get()) {
+    m_msg->received.erase(m_msg->received.begin());
+    if(m_msg->retrieve_index > 0)
+      m_msg->retrieve_index--;
+  }
   m_world->GetStats().IncMsgReceived();
   return true;
 }

Modified: branches/energy/source/main/cPopulationInterface.cc
===================================================================
--- branches/energy/source/main/cPopulationInterface.cc	2008-01-04 02:13:01 UTC (rev 2250)
+++ branches/energy/source/main/cPopulationInterface.cc	2008-01-04 18:22:35 UTC (rev 2251)
@@ -260,6 +260,7 @@
 bool cPopulationInterface::SendMessageMultiHop(cOrgMessage& msg) {
   cPopulationCell& cell = m_world->GetPopulation().GetCell(GetCellID());
   assert(cell.IsOccupied()); // This organism; sanity.
+
   cDeme& deme = m_world->GetPopulation().GetDeme(GetDemeID());
   bool successfully_sent = false;
   m_world->GetStats().IncMsgSent();

Modified: branches/energy/source/main/cStats.cc
===================================================================
--- branches/energy/source/main/cStats.cc	2008-01-04 02:13:01 UTC (rev 2250)
+++ branches/energy/source/main/cStats.cc	2008-01-04 18:22:35 UTC (rev 2251)
@@ -1165,7 +1165,8 @@
     (**i)(msg); // Predicate is responsible for tracking info about messages.
   }
   
-  from_to_message_list[msg.GetSender()->GetCellID()] = msg.GetReceiver()->GetCellID();
+// make configerable
+//  from_to_message_list[msg.GetSender()->GetCellID()] = msg.GetReceiver()->GetCellID();
 }
 
 void cStats::SentMessageMultiHop(const cOrgMessage& msg)
@@ -1176,7 +1177,8 @@
     (**i)(msg); // Predicate is responsible for tracking info about messages.
   }
   
-  from_to_message_list[msg.GetSender()->GetCellID()] = msg.GetReceiver()->GetCellID();
+// make configerable
+//  from_to_message_list[msg.GetSender()->GetCellID()] = msg.GetReceiver()->GetCellID();
 }
 
 /*! This method is called whenever an organism moves.*/




More information about the Avida-cvs mailing list