[Avida-SVN] r2953 - in development/source: actions main
connel42 at myxo.css.msu.edu
connel42 at myxo.css.msu.edu
Wed Nov 19 18:17:30 PST 2008
Author: connel42
Date: 2008-11-19 21:17:30 -0500 (Wed, 19 Nov 2008)
New Revision: 2953
Modified:
development/source/actions/PopulationActions.cc
development/source/actions/PrintActions.cc
development/source/main/cStats.cc
development/source/main/cStats.h
Log:
* removed my competedemesecho action\n* added Matt McGill's cActionCompeteDemesByTaskCount action
Modified: development/source/actions/PopulationActions.cc
===================================================================
--- development/source/actions/PopulationActions.cc 2008-11-19 17:21:07 UTC (rev 2952)
+++ development/source/actions/PopulationActions.cc 2008-11-20 02:17:30 UTC (rev 2953)
@@ -1526,7 +1526,43 @@
int _replace; //!< Number of cell datas that will be replaced on successful consensus.
};
+/*! This class competes demes based on the total number of times that a
+ * given task has been completed by an organism in the deme since the
+ * deme was initialized. This action takes one integer parameter representing
+ * the number of the task that is to be used for competition. If no parameter
+ * is supplied, the class uses the first task defined in the environment file
+ * to compete the demes.
+ */
+class cActionCompeteDemesByTaskCount : public cAbstractCompeteDemes {
+private:
+ int _task_num; // the task num to use when calculating fitness,
+ // defaults to 0 (the first task)
+public:
+ cActionCompeteDemesByTaskCount(cWorld* world, const cString& args)
+ : cAbstractCompeteDemes(world, args) {
+ if (args.GetSize() > 0) {
+ cString largs(args);
+ _task_num = largs.PopWord().AsInt();
+ assert(_task_num >= 0);
+ assert(_task_num < m_world->GetEnvironment().GetNumTasks());
+ } else {
+ _task_num = 0;
+ }
+ }
+ ~cActionCompeteDemesByTaskCount() {}
+ static const cString GetDescription() {
+ return "Competes demes according to the number of times a given task has been completed within that deme";
+ }
+
+ virtual double Fitness(const cDeme& deme) {
+ double fitness = deme.GetCurTaskExeCount()[_task_num]^2;///deme.GetInjectedCount());
+ if (fitness == 0.0) fitness = 0.1;
+ return fitness;
+ }
+};
+
+
/*! Send an artificial flash to a single organism in each deme in the population
at a specified period.
@@ -1631,48 +1667,7 @@
};
-/*! Compete demes based on the number of times they've completed the echo task.
- Fitness is 2^#echos
- */
-class cActionCompeteDemesEcho : public cAbstractCompeteDemes {
-public:
- //! Constructor.
- cActionCompeteDemesEcho(cWorld* world, const cString& args) : cAbstractCompeteDemes(world, args) { }
-
- //! Destructor.
- virtual ~cActionCompeteDemesEcho() { }
-
- //! Description of this event.
- static const cString GetDescription() { return "No Arguments"; }
-
- virtual double Fitness(const cDeme& deme) {
- int num_echos = 0;
- const int num_task = m_world->GetEnvironment().GetNumTasks();
- for(int i=0; i < deme.GetSize(); i++) {
- int cur_cell = deme.GetCellID(i);
-
- // Since we only count echos from living organisms, this also creates a pressure
- // for all of the organisms to stay alive
- if (m_world->GetPopulation().GetCell(cur_cell).IsOccupied() == false) continue;
-
- cPhenotype & phenotype = m_world->GetPopulation().GetCell(cur_cell).GetOrganism()->GetPhenotype();
-
- for (int j = 0; j < num_task; j++) {
- if( (strcasecmp(m_world->GetEnvironment().GetTask(j).GetName(), "echo") == 0) &&
- (phenotype.GetLastTaskCount()[j] > 0) ) {
- num_echos += phenotype.GetLastTaskCount()[j];
- }
- }
-
- }
-
- return (double) (2^num_echos);
- }
-
-}; //End cActionCompeteDemesEcho
-
-
/*! Compete demes based on the ability of their constituent organisms
to synchronize their flashes to a common period, and yet distribute themselves
throughout phase-space (phase desynchronization).
@@ -2436,7 +2431,6 @@
action_lib->Register<cActionIteratedConsensus>("IteratedConsensus");
action_lib->Register<cActionSynchronization>("Synchronization");
action_lib->Register<cActionDesynchronization>("Desynchronization");
- action_lib->Register<cActionCompeteDemesEcho>("CompeteDemesEcho");
action_lib->Register<cActionNewTrial>("NewTrial");
action_lib->Register<cActionCompeteOrganisms>("CompeteOrganisms");
@@ -2450,6 +2444,8 @@
action_lib->Register<cActionDisconnectCells>("DisconnectCells");
action_lib->Register<cActionSwapCells>("SwapCells");
+ action_lib->Register<cActionCompeteDemesByTaskCount>("CompeteDemesByTaskCount");
+
// @DMB - The following actions are DEPRECATED aliases - These will be removed in 2.7.
action_lib->Register<cActionInject>("inject");
action_lib->Register<cActionInjectRandom>("inject_random");
Modified: development/source/actions/PrintActions.cc
===================================================================
--- development/source/actions/PrintActions.cc 2008-11-19 17:21:07 UTC (rev 2952)
+++ development/source/actions/PrintActions.cc 2008-11-20 02:17:30 UTC (rev 2953)
@@ -109,6 +109,7 @@
STATS_OUT_FILE(PrintDemeOrgTasksData, deme_org_tasks.dat );
STATS_OUT_FILE(PrintDemeOrgTasksExeData, deme_org_tasks_exe.dat );
STATS_OUT_FILE(PrintDemeOrgReactionData, deme_org_reactions.dat );
+STATS_OUT_FILE(PrintDemeCurrentTaskExeData, deme_cur_task_exe.dat );
STATS_OUT_FILE(PrintGermlineData, germline.dat );
STATS_OUT_FILE(PrintPredicatedMessages, messages.dat );
STATS_OUT_FILE(PrintCellData, cell_data.dat );
@@ -2740,6 +2741,7 @@
action_lib->Register<cActionPrintDemeOrgTasksData>("PrintDemeOrgTasksData");
action_lib->Register<cActionPrintDemeOrgTasksExeData>("PrintDemeOrgTasksExeData");
action_lib->Register<cActionPrintDemeOrgReactionData>("PrintDemeOrgReactionData");
+ action_lib->Register<cActionPrintDemeCurrentTaskExeData>("PrintDemeCurrentTaskExeData");
action_lib->Register<cActionPrintPerDemeGenPerFounderData>("PrintPerDemeGenPerFounderData");
//Coalescence Clade Actions
Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc 2008-11-19 17:21:07 UTC (rev 2952)
+++ development/source/main/cStats.cc 2008-11-20 02:17:30 UTC (rev 2953)
@@ -1750,6 +1750,27 @@
df.Endl();
}
+void cStats::PrintDemeCurrentTaskExeData(const cString& filename) {
+ cDataFile& df = m_world->GetDataFile(filename);
+ df.WriteComment("Avida deme current task exe data");
+ df.WriteTimeStamp();
+ df.WriteComment("First column gives update number, next columns give the number");
+ df.WriteComment("of times a given task has been executed in a given deme by");
+ df.WriteComment("some organism in that deme.");
+
+ const int num_tasks = m_world->GetEnvironment().GetNumTasks();
+ df.Write(m_update, "Update");
+ for (int deme_num=0; deme_num < m_world->GetPopulation().GetNumDemes(); ++deme_num) {
+ cDeme& deme = m_world->GetPopulation().GetDeme(deme_num);
+ for (int task_num=0; task_num < num_tasks; task_num++) {
+ df.Write( deme.GetCurTaskExeCount()[task_num],
+ cStringUtil::Stringf("%i.", deme_num)+task_names[task_num]);
+ }
+ }
+
+ df.Endl();
+}
+
void cStats::PrintDemeOrgReactionData(const cString& filename){
cDataFile& df = m_world->GetDataFile(filename);
df.WriteComment("Avida deme org reactions data");
Modified: development/source/main/cStats.h
===================================================================
--- development/source/main/cStats.h 2008-11-19 17:21:07 UTC (rev 2952)
+++ development/source/main/cStats.h 2008-11-20 02:17:30 UTC (rev 2953)
@@ -846,6 +846,7 @@
void PrintDemeOrgTasksData(const cString& filename);
void PrintDemeOrgTasksExeData(const cString& filename);
void PrintDemeOrgReactionData(const cString& filename);
+ void PrintDemeCurrentTaskExeData(const cString& filename);
void PrintPerDemeGenPerFounderData(const cString& filename);
void IncNumOccupiedDemes() { m_num_occupied_demes++; }
More information about the Avida-cvs
mailing list