[Avida-SVN] r1174 - in branches/coopcomm: documentation/coopcomm source/main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Mon Jan 8 07:43:26 PST 2007


Author: beckma24
Date: 2007-01-08 10:43:26 -0500 (Mon, 08 Jan 2007)
New Revision: 1174

Modified:
   branches/coopcomm/documentation/coopcomm/CoopCommAdditionsToAvida.tex
   branches/coopcomm/source/main/cOrganism.cc
   branches/coopcomm/source/main/cOrganism.h
   branches/coopcomm/source/main/cTaskLib.cc
   branches/coopcomm/source/main/cTaskLib.h
Log:
Added tasks send-id-exponential and send-id-not-self-exponential, which Exponentially reward the sending of an ID, and the sending of an ID (excluding the sender's ID) as the data field of a message, respectively.

Modified: branches/coopcomm/documentation/coopcomm/CoopCommAdditionsToAvida.tex
===================================================================
--- branches/coopcomm/documentation/coopcomm/CoopCommAdditionsToAvida.tex	2007-01-08 01:31:06 UTC (rev 1173)
+++ branches/coopcomm/documentation/coopcomm/CoopCommAdditionsToAvida.tex	2007-01-08 15:43:26 UTC (rev 1174)
@@ -1,4 +1,5 @@
-\documentclass[12pt,english]{article}
+%\documentclass[12pt, onecolumn, draftcls, english]{IEEEtran} % draftcls
+\documentclass[12pt,english,draft]{article}
 \usepackage[T1]{fontenc}
 \pagestyle{plain}
 
@@ -8,6 +9,7 @@
 \usepackage{babel}
 \usepackage{setspace}
 \usepackage{graphicx}
+%\usepackage{draftcopy}
 %\doublespacing
 \makeatother
 
@@ -16,9 +18,8 @@
 
 \begin{document}
 
+\title{Coopcomm Additions to \avida \footnote{DRAFT \today}}
 
-\title{Coopcomm Additions to \avida}
-
 \author{Benjamin Beckmann\\ Dave Knoester}
 \affiliation{Computer Science and Engineering\\
 Michigan State University}
@@ -27,9 +28,10 @@
 
 \maketitle
 
+\bb{Add sections as needed.}
+
 \tableofcontents
 
-\bb{Add sections as needed.}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %	Environment.cfg
@@ -53,6 +55,20 @@
 \subsection{Messaging Tasks}
 \begin{description}
 
+\item[send-id-exponential](Revision ??)
+%
+Exponentially reward the sending of an ID as the data field of a message.
+%
+This task is identical to send-id, however the reward grows exponentially.
+
+
+\item[send-id-not-self-exponential](Revision ??)
+%
+Exponentially reward the sending of an ID (excluding the sender's ID) as the data field of a message.
+%
+This task is identical to send-id-not-self, however the reward grows exponentially.
+
+
 \item[send-id-not-self] (Revision 1102)
 %
 Rewards organisms for sending IDs of other organisms.
@@ -61,7 +77,7 @@
 %%%%%%%%%%%%%%%%%%%%% Sink Tree Tasks
 \subsection{Sink Tree Tasks}
 \begin{description}
-\item[send-non-self-toward-sink] (Revision ??)
+\item[send-non-self-toward-sink] (Revision 1168)
 %
 This task rewards an organism for sending another organism's random cell ID in a message to a neighbor that is closer to a base station.
 %
@@ -73,7 +89,7 @@
 %
 Distance is measured in hops between organism and base station.
 
-\item[send-self-toward-sink] (Revision ??)
+\item[send-self-toward-sink] (Revision 1168)
 %
 This task rewards an organism for sending its random cell ID in a message to a neighbor that is closer to a base station.
 %
@@ -108,7 +124,7 @@
 %
 Logs data that reaches a base station.
 
-\item[MoveBaseStation] (Revision ??)
+\item[MoveBaseStation] (Revision 1168)
 %
 This event relocates an existing base station.
 %
@@ -200,7 +216,7 @@
 \subsection{Organism Identity}
 \begin{description}
 
-\item[am-i-base-station] (Revision ??)
+\item[am-i-base-station] (Revision 1168)
 %
 Sets the call organism's ?BX? register to $1$ if it is currently a base station, $0$ otherwise.
 

Modified: branches/coopcomm/source/main/cOrganism.cc
===================================================================
--- branches/coopcomm/source/main/cOrganism.cc	2007-01-08 01:31:06 UTC (rev 1173)
+++ branches/coopcomm/source/main/cOrganism.cc	2007-01-08 15:43:26 UTC (rev 1174)
@@ -553,7 +553,7 @@
     last_cell_sent_to = msg.GetReceiver()->GetCellID();
     // Stat-tracking.
     m_world->GetStats().SentMessage(msg);
-    sent_to.insert(msg.GetReceiver()->GetCellID());
+    //sent_to.insert(msg.GetReceiver()->GetCellID());
 
     int old_size = m_sent_messages.size();
   

Modified: branches/coopcomm/source/main/cOrganism.h
===================================================================
--- branches/coopcomm/source/main/cOrganism.h	2007-01-08 01:31:06 UTC (rev 1173)
+++ branches/coopcomm/source/main/cOrganism.h	2007-01-08 15:43:26 UTC (rev 1174)
@@ -15,6 +15,7 @@
 #include <vector>
 #include <map>
 #include <set>
+//#include <pair>
 
 
 #ifndef cCPUMemory_h
@@ -320,7 +321,9 @@
   //! Returns Cell ID of last cell sent to.
   int getLastSent(){ return last_cell_sent_to; }
   //! Returns a set of all organism who have receive a message from this organism
-  std::set<int> getSentTo() {return sent_to;}
+  std::set<int> GetSentTo() {return sent_to;}
+  
+  bool InsertSentTo(int receiver) {return (sent_to.insert(receiver)).second;}
   //! Set the leader of this organism to the organism currently faced.
   bool SetLeader();
   //! Get the cOrganism that is currently the leader of this organism.

Modified: branches/coopcomm/source/main/cTaskLib.cc
===================================================================
--- branches/coopcomm/source/main/cTaskLib.cc	2007-01-08 01:31:06 UTC (rev 1173)
+++ branches/coopcomm/source/main/cTaskLib.cc	2007-01-08 15:43:26 UTC (rev 1174)
@@ -350,8 +350,12 @@
     NewTask(name, "Rewards sending max(received data, organism ID) iff data is a cell ID.", &cTaskLib::Task_MaxID);
   else if(name == "send-id")
     NewTask(name, "Reward the sending of an ID as the data field of a message.", &cTaskLib::Task_SendID);
+  else if(name == "send-id-exponential")
+    NewTask(name, "Exponentially reward the sending of an ID as the data field of a message.", &cTaskLib::Task_SendIDExponential);
   else if(name == "send-id-not-self")
     NewTask(name, "Reward the sending of an ID (excluding the sender's ID) as the data field of a message.", &cTaskLib::Task_SendIDNotSelf);
+  else if(name == "send-id-not-self-exponential")
+    NewTask(name, "Exponentially reward the sending of an ID (excluding the sender's ID) as the data field of a message.", &cTaskLib::Task_SendIDNotSelfExponential);
   else if(name == "send-non-id")
     NewTask(name, "Reward sending a message that does NOT have an ID as the data field.", &cTaskLib::Task_SendNonID);
   else if(name == "send-self")
@@ -1963,7 +1967,36 @@
   return 0.0;
 }
 
+/*! This task is identical to Task_SendIDNotSelf, however the reward grows exponentially.
+*/
+double cTaskLib::Task_SendIDNotSelfExponential(cTaskContext* ctx) const
+{
+  cOrgMessage* msg = ctx->GetMessage();
+  if(msg==NULL) return 0.0;
+    
+  if(msg->GetData() != msg->GetSender()->GetRandomCellID() &&
+     cPopulationCell::IsRandomCellID(msg->GetData()) &&
+     msg->GetSender()->InsertSentTo(msg->GetData())) {
+    return msg->GetSender()->GetSentTo().size();
+  }
+  return 0.0;
+}
 
+/*! This task is identical to Task_SendID, however the reward grows exponentially.
+*/
+double cTaskLib::Task_SendIDExponential(cTaskContext* ctx) const
+{
+  cOrgMessage* msg = ctx->GetMessage();
+  if(msg==NULL) return 0.0;
+    
+  if(cPopulationCell::IsRandomCellID(msg->GetData()) &&
+     msg->GetSender()->InsertSentTo(msg->GetData())) {
+    return msg->GetSender()->GetSentTo().size();
+  }
+  return 0.0;
+}
+
+
 /*! This task 'rewards' an organism for sending a message where the data field of
 the message is not an ID.  This task is usually configured as a penalty, e.g., 
 "process:value=.25:type=mult" in the environment file.
@@ -2056,6 +2089,12 @@
   return 0.0;
 }
 
+
+/******************************************/
+/******************************************/
+/*               Not done                 */
+/******************************************/
+/******************************************/
 //! Reward an organism for sending a message containing another organism's ID closer to the sink
 double cTaskLib::Task_SendMultipleNonSelfTowardSink(cTaskContext* ctx) const{
   std::set<int> IDForwarded;
@@ -2090,7 +2129,7 @@
     return 0.0;
   }
   
-  std::set<int> senderSentTo = ctx->GetMessage()->GetSender()->getSentTo();
+  std::set<int> senderSentTo = ctx->GetMessage()->GetSender()->GetSentTo();
   if(senderSentTo.size() <= 1) {
     return 0.0;
   }

Modified: branches/coopcomm/source/main/cTaskLib.h
===================================================================
--- branches/coopcomm/source/main/cTaskLib.h	2007-01-08 01:31:06 UTC (rev 1173)
+++ branches/coopcomm/source/main/cTaskLib.h	2007-01-08 15:43:26 UTC (rev 1174)
@@ -235,7 +235,9 @@
   // Coop-comm Tasks
   double Task_MaxID(cTaskContext* ctx) const; //!< Rewards an organism for sending its max known ID.
   double Task_SendID(cTaskContext* ctx) const; //!< Rewards an organism for sending an ID.
+  double Task_SendIDExponential(cTaskContext* ctx) const; //!< Exponentially rewards an organism for sending an ID.
   double Task_SendIDNotSelf(cTaskContext* ctx) const; //!< Rewards an organism for sending an ID that is not its own.
+  double Task_SendIDNotSelfExponential(cTaskContext* ctx) const; //!< Exponentially rewards an organism for sending an ID that is not its own.
   double Task_SendNonID(cTaskContext* ctx) const; //!< Rewards an organism for not sending an ID.
   double Task_SendSelf(cTaskContext* ctx) const; //!< Rewards an organism for sending its ID.
   




More information about the Avida-cvs mailing list