[Avida-SVN] r3054 - in development/source: actions main
goingssh at myxo.css.msu.edu
goingssh at myxo.css.msu.edu
Tue Dec 16 16:50:26 PST 2008
Author: goingssh
Date: 2008-12-16 19:50:26 -0500 (Tue, 16 Dec 2008)
New Revision: 3054
Modified:
development/source/actions/EnvironmentActions.cc
development/source/actions/PrintActions.cc
development/source/main/cStats.cc
development/source/main/cStats.h
development/source/main/cTaskLib.cc
Log:
added action to print max and min Fx for optimize task
improved action to set max and min Fx for optimize task
fixed bug in optimize task for special case
Modified: development/source/actions/EnvironmentActions.cc
===================================================================
--- development/source/actions/EnvironmentActions.cc 2008-12-16 22:39:19 UTC (rev 3053)
+++ development/source/actions/EnvironmentActions.cc 2008-12-17 00:50:26 UTC (rev 3054)
@@ -798,13 +798,21 @@
cEnvironment& env = m_world->GetEnvironment();
for (int j=0; j<env.GetNumTasks(); j++)
{
- double maxFx=0, minFx=10000;
+ double maxFx, minFx;
+ bool first=true;
for (int i = 0; i < m_world->GetPopulation().GetSize(); i++)
{
cPopulationCell& cell = m_world->GetPopulation().GetCell(i);
if (cell.IsOccupied() == false) continue;
const cPhenotype& phen = cell.GetOrganism()->GetPhenotype();
double val = phen.GetLastTaskValue()[j];
+ if (first)
+ {
+ minFx=val;
+ maxFx=val;
+ first=false;
+ continue;
+ }
if (val < minFx)
minFx = val;
if (val > maxFx)
Modified: development/source/actions/PrintActions.cc
===================================================================
--- development/source/actions/PrintActions.cc 2008-12-16 22:39:19 UTC (rev 3053)
+++ development/source/actions/PrintActions.cc 2008-12-17 00:50:26 UTC (rev 3054)
@@ -123,6 +123,7 @@
// @WRE: Added output event for collected visit counts
STATS_OUT_FILE(PrintCellVisitsData, visits.dat );
STATS_OUT_FILE(PrintFlowRateTuples, flow_rate_tuples.dat);
+STATS_OUT_FILE(PrintDynamicMaxMinData, maxmin.dat );
#define POP_OUT_FILE(METHOD, DEFAULT) /* 1 */ \
@@ -2719,6 +2720,7 @@
action_lib->Register<cActionPrintInternalTasksQualData>("PrintInternalTasksQualData");
action_lib->Register<cActionPrintSleepData>("PrintSleepData");
action_lib->Register<cActionPrintCompetitionData>("PrintCompetitionData");
+ action_lib->Register<cActionPrintDynamicMaxMinData>("PrintDynamicMaxMinData");
// @WRE: Added printing of visit data
action_lib->Register<cActionPrintCellVisitsData>("PrintCellVisitsData");
Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc 2008-12-16 22:39:19 UTC (rev 3053)
+++ development/source/main/cStats.cc 2008-12-17 00:50:26 UTC (rev 3054)
@@ -945,6 +945,23 @@
df.Endl();
}
+void cStats::PrintDynamicMaxMinData(const cString& filename)
+{
+ cDataFile& df = m_world->GetDataFile(filename);
+
+ df.WriteComment("Avida dynamic max min data");
+ df.WriteTimeStamp();
+ df.WriteComment("First column gives the current update, 2nd and 3rd give max and min Fx");
+ df.Write(m_update, "Update");
+ for(int i = 0; i < task_last_count.GetSize(); i++) {
+ double max = m_world->GetEnvironment().GetTask(i).GetArguments().GetDouble(1);
+ double min = m_world->GetEnvironment().GetTask(i).GetArguments().GetDouble(2);
+ df.Write(max, task_names[i] + " Max");
+ df.Write(min, task_names[i] + " Min");
+ }
+ df.Endl();
+}
+
void cStats::PrintReactionData(const cString& filename)
{
cDataFile& df = m_world->GetDataFile(filename);
Modified: development/source/main/cStats.h
===================================================================
--- development/source/main/cStats.h 2008-12-16 22:39:19 UTC (rev 3053)
+++ development/source/main/cStats.h 2008-12-17 00:50:26 UTC (rev 3054)
@@ -745,6 +745,7 @@
void PrintTasksData(const cString& filename);
void PrintTasksExeData(const cString& filename);
void PrintTasksQualData(const cString& filename);
+ void PrintDynamicMaxMinData(const cString& filename);
void PrintReactionData(const cString& filename);
void PrintReactionExeData(const cString& filename);
void PrintCurrentReactionData(const cString& filename);
Modified: development/source/main/cTaskLib.cc
===================================================================
--- development/source/main/cTaskLib.cc 2008-12-16 22:39:19 UTC (rev 3053)
+++ development/source/main/cTaskLib.cc 2008-12-17 00:50:26 UTC (rev 3054)
@@ -2294,7 +2294,7 @@
{
int numOnes=0;
int patFound=0;
- for (int i=0; i<args.GetInt(2)-4; i++)
+ for (int i=0; i<args.GetInt(2)-3; i++)
{
if (ctx.GetOutputBuffer()[i]==1)
numOnes++;
More information about the Avida-cvs
mailing list