[Avida-SVN] r1099 - branches/coopcomm/source/main

dknoester at myxo.css.msu.edu dknoester at myxo.css.msu.edu
Fri Nov 24 12:50:36 PST 2006


Author: dknoester
Date: 2006-11-24 15:50:30 -0500 (Fri, 24 Nov 2006)
New Revision: 1099

Modified:
   branches/coopcomm/source/main/cPopulation.cc
   branches/coopcomm/source/main/cStats.cc
   branches/coopcomm/source/main/cStats.h
Log:
Altered CompeteDemes to use population-size-proportional fitness for leader-selection.

Modified: branches/coopcomm/source/main/cPopulation.cc
===================================================================
--- branches/coopcomm/source/main/cPopulation.cc	2006-11-24 18:46:53 UTC (rev 1098)
+++ branches/coopcomm/source/main/cPopulation.cc	2006-11-24 20:50:30 UTC (rev 1099)
@@ -783,17 +783,13 @@
           }
         }
 
-        if(org_count > 0) {
-          m_world->GetStats().Demes_Leadership((double)max/org_count);
-          deme_fitness[cur_deme] = (double)max/org_count;
+//        if(org_count > 0) {
+          m_world->GetStats().Demes_Leadership(max, org_count);//(double)max/org_count);
+          deme_fitness[cur_deme] = (double)max;///org_count;
           total_fitness += deme_fitness[cur_deme];
-        } else {
-          deme_fitness[cur_deme] = 0;
-        }
-        
-        // Pull out the max number that have voted for an organism 
-
-        
+//        } else {
+//          deme_fitness[cur_deme] = 0;
+//        }
       }
       break;      
     }

Modified: branches/coopcomm/source/main/cStats.cc
===================================================================
--- branches/coopcomm/source/main/cStats.cc	2006-11-24 18:46:53 UTC (rev 1098)
+++ branches/coopcomm/source/main/cStats.cc	2006-11-24 20:50:30 UTC (rev 1099)
@@ -98,7 +98,8 @@
   , m_data_is_sender(0)
   , m_data_is_id_and_grt_sender(0)
   , m_data_is_leader(0)
-  , m_max_deme_leadership(0.0)
+  , m_max_deme_leadership(0)
+  , m_max_deme_count(0)
 {
   task_cur_count.Resize( m_world->GetNumTasks() );
   task_last_count.Resize( m_world->GetNumTasks() );
@@ -923,10 +924,12 @@
 
 /*! This captures information related to using demes to elect a leader.
 */
-void cStats::Demes_Leadership(double maxPct)
+void cStats::Demes_Leadership(unsigned int max, unsigned int org_count)//double maxPct)
 {
-  if(maxPct > m_max_deme_leadership)
-    m_max_deme_leadership = maxPct;
+  if(max > m_max_deme_leadership) {
+    m_max_deme_leadership = max;
+    m_max_deme_count = org_count;
+  }
 }
 
 
@@ -1010,13 +1013,15 @@
   df.Write(m_data_is_id_and_grt_sender, "Count of messages where the data field carries an ID, and is greater than the sender's ID.");
   df.Write(m_data_is_leader, "Count of messages where the data field is the leader's ID.");
   df.Write(m_data_is_id_not_sender.Ave(), "Mean of message data fields where the data field is an ID that is not the sender's ID.");
-  df.Write(m_max_deme_leadership, "Maximum pct of organisms that agreed on a leader.");
+  df.Write(m_max_deme_leadership, "Maximum number of organisms that agreed on a leader.");
+  df.Write(m_max_deme_count, "Size of deme corresponding to max. that agreed on leader.");
   df.Endl();
   
   m_msg_data.Clear();
   m_data_is_id_not_sender.Clear();
   m_count_msgs = m_max_id = m_data_is_id = m_data_is_sender = m_data_is_id_and_grt_sender = m_data_is_leader = 0;
-  m_max_deme_leadership = 0.0;
+  m_max_deme_leadership = 0;
+  m_max_deme_count = 0;
 }
 
 

Modified: branches/coopcomm/source/main/cStats.h
===================================================================
--- branches/coopcomm/source/main/cStats.h	2006-11-24 18:46:53 UTC (rev 1098)
+++ branches/coopcomm/source/main/cStats.h	2006-11-24 20:50:30 UTC (rev 1099)
@@ -258,8 +258,8 @@
   cDoubleSum m_data_is_id_not_sender; //!< Sum of message data fields where the data field is an ID that is not the sender's ID.
   std::set<int> m_cell_sent_leader; //!< Set of all cells that sent a message carrying the leader's ID.
   t_predicate_list m_predicate_list; //!< The list of predicates used to choose which messages to track.
-  double m_max_deme_leadership; //!< The maximum percentage of organisms agreeing on a leader.
-  
+  unsigned int m_max_deme_leadership; //!< The maximum percentage of organisms agreeing on a leader.
+  unsigned int m_max_deme_count; //!< Count of organisms that selected a leader.
   cStats(); // @not_implemented
   cStats(const cStats&); // @not_implemented
   cStats& operator=(const cStats&); // @not_implemented
@@ -607,7 +607,7 @@
   //! Capture information related to sending a message.
   void SentMessage(cOrgMessage& msg);
   //! Info about leadership demes.
-  void Demes_Leadership(double maxPct);
+  void Demes_Leadership(unsigned int max, unsigned int org_count);//double maxPct);
   //! Capture information related to organism death.
   void OrganismDeath(cOrganism* org);
   //! Log leadership-specific data.




More information about the Avida-cvs mailing list