[Avida-SVN] r1989 - in branches/energy/source: actions main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Thu Aug 23 08:51:30 PDT 2007
Author: beckma24
Date: 2007-08-23 11:51:30 -0400 (Thu, 23 Aug 2007)
New Revision: 1989
Modified:
branches/energy/source/actions/PrintActions.cc
branches/energy/source/main/cPhenotype.h
Log:
Added DumpExecutionRatioGrid print action
Modified: branches/energy/source/actions/PrintActions.cc
===================================================================
--- branches/energy/source/actions/PrintActions.cc 2007-08-23 14:33:23 UTC (rev 1988)
+++ branches/energy/source/actions/PrintActions.cc 2007-08-23 15:51:30 UTC (rev 1989)
@@ -2139,7 +2139,7 @@
for (int i = 0; i < m_world->GetPopulation().GetWorldX(); i++) {
for (int j = 0; j < m_world->GetPopulation().GetWorldY(); j++) {
cPopulationCell& cell = m_world->GetPopulation().GetCell(j * m_world->GetPopulation().GetWorldX() + i);
- int cell_energy = (cell.IsOccupied()) ? cell.GetOrganism()->GetPhenotype().GetStoredEnergy() : 0.0;
+ double cell_energy = (cell.IsOccupied()) ? cell.GetOrganism()->GetPhenotype().GetStoredEnergy() : 0.0;
fp << cell_energy << " ";
}
fp << endl;
@@ -2148,6 +2148,36 @@
}
};
+class cActionDumpExecutionRatioGrid : public cAction
+{
+private:
+ cString m_filename;
+
+public:
+ cActionDumpExecutionRatioGrid(cWorld* world, const cString& args) : cAction(world, args), m_filename("")
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_filename = largs.PopWord();
+ }
+ static const cString GetDescription() { return "Arguments: [string fname='']"; }
+ void Process(cAvidaContext& ctx)
+ {
+ cString filename(m_filename);
+ if (filename == "") filename.Set("grid_exe_ratio.%d.dat", m_world->GetStats().GetUpdate());
+ ofstream& fp = m_world->GetDataFileOFStream(filename);
+
+ for (int i = 0; i < m_world->GetPopulation().GetWorldX(); i++) {
+ for (int j = 0; j < m_world->GetPopulation().GetWorldY(); j++) {
+ cPopulationCell& cell = m_world->GetPopulation().GetCell(j * m_world->GetPopulation().GetWorldX() + i);
+ double cell_executionRatio = (cell.IsOccupied()) ? cell.GetOrganism()->GetPhenotype().GetExecutionRatio() : 0.0;
+ fp << cell_executionRatio << " ";
+ }
+ fp << endl;
+ }
+ m_world->GetDataFileManager().Remove(filename);
+ }
+};
+
class cActionDumpFitnessGrid : public cAction
{
private:
@@ -2587,6 +2617,7 @@
action_lib->Register<cActionDumpDonorGrid>("DumpDonorGrid");
action_lib->Register<cActionDumpReceiverGrid>("DumpReceiverGrid");
action_lib->Register<cActionDumpEnergyGrid>("DumpEnergyGrid");
+ action_lib->Register<cActionDumpExecutionRatioGrid>("DumpExecutionRatioGrid");
// Print Settings
action_lib->Register<cActionSetVerbose>("SetVerbose");
Modified: branches/energy/source/main/cPhenotype.h
===================================================================
--- branches/energy/source/main/cPhenotype.h 2007-08-23 14:33:23 UTC (rev 1988)
+++ branches/energy/source/main/cPhenotype.h 2007-08-23 15:51:30 UTC (rev 1989)
@@ -467,6 +467,7 @@
void DoubleEnergyUsage() { executionRatio *= 2.0; }
void HalfEnergyUsage() { executionRatio *= 0.5; }
+ double GetEnergyUsage() { return executionRatio; }
void RefreshEnergy();
void ApplyToEnergyStore();
double ExtractParentEnergy();
More information about the Avida-cvs
mailing list