[Avida-SVN] r3142 - in branches/interrupt/source: actions main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Fri Feb 6 06:09:14 PST 2009
Author: beckma24
Date: 2009-02-06 09:09:14 -0500 (Fri, 06 Feb 2009)
New Revision: 3142
Modified:
branches/interrupt/source/actions/PrintActions.cc
branches/interrupt/source/main/cOrganism.h
branches/interrupt/source/main/cStats.cc
branches/interrupt/source/main/cStats.h
Log:
Added print action DumpInterruptGrid, removed print action PrintOrgsLocationAndInterrupt
Modified: branches/interrupt/source/actions/PrintActions.cc
===================================================================
--- branches/interrupt/source/actions/PrintActions.cc 2009-02-05 20:53:44 UTC (rev 3141)
+++ branches/interrupt/source/actions/PrintActions.cc 2009-02-06 14:09:14 UTC (rev 3142)
@@ -115,7 +115,6 @@
STATS_OUT_FILE(PrintDemeCurrentTaskExeData, deme_cur_task_exe.dat );
STATS_OUT_FILE(PrintDemeMigrationSuicidePoints, deme_mig_suicide_points.dat );
STATS_OUT_FILE(PrintDemeInterrupt, deme_interrupt.dat );
-STATS_OUT_FILE(PrintOrgsLocationAndInterrupt, orgs_locationAndInterrupt.dat );
STATS_OUT_FILE(PrintCurrentTaskCounts, curr_task_counts.dat);
STATS_OUT_FILE(PrintGermlineData, germline.dat );
@@ -2349,6 +2348,36 @@
}
};
+class cActionDumpInterruptGrid : public cAction {
+private:
+ cString m_filename;
+
+public:
+ cActionDumpInterruptGrid(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_interrupt.%d.dat", m_world->GetStats().GetUpdate());
+ ofstream& fp = m_world->GetDataFileOFStream(filename);
+
+ for (int i = 0; i < m_world->GetPopulation().GetWorldY(); i++) {
+ for (int j = 0; j < m_world->GetPopulation().GetWorldX(); j++) {
+ cPopulationCell& cell = m_world->GetPopulation().GetCell(i * m_world->GetPopulation().GetWorldX() + j);
+ if(!cell.IsOccupied())
+ fp << -1 << " ";
+ else
+ fp << cell.GetOrganism()->isInterrupted() << " ";
+ }
+ fp << endl;
+ }
+ m_world->GetDataFileManager().Remove(filename);
+ }
+};
class cActionDumpLineageGrid : public cAction
{
@@ -2771,7 +2800,7 @@
action_lib->Register<cActionPrintPerDemeGenPerFounderData>("PrintPerDemeGenPerFounderData");
action_lib->Register<cActionPrintDemeMigrationSuicidePoints>("PrintDemeMigrationSuicidePoints");
action_lib->Register<cActionPrintDemeInterrupt>("PrintDemeInterrupt");
- action_lib->Register<cActionPrintOrgsLocationAndInterrupt>("PrintOrgsLocationAndInterrupt");
+ action_lib->Register<cActionDumpInterruptGrid>("DumpInterruptGrid");
//Coalescence Clade Actions
Modified: branches/interrupt/source/main/cOrganism.h
===================================================================
--- branches/interrupt/source/main/cOrganism.h 2009-02-05 20:53:44 UTC (rev 3141)
+++ branches/interrupt/source/main/cOrganism.h 2009-02-06 14:09:14 UTC (rev 3142)
@@ -71,6 +71,9 @@
#include "tSmartArray.h"
#endif
+#ifndef cHardwareCPU_h //TODO: make cLocalThread its own header file
+#include "cHardwareCPU.h"
+#endif
class cAvidaContext;
class cCodeLabel;
@@ -435,6 +438,11 @@
/***** context switch********/
+ bool isInterrupted() {
+ // retruns true if current thread is interrupted
+ cLocalThread* currentThread = static_cast<cHardwareCPU*>(m_hardware)->GetThread(m_hardware->GetCurThread());
+ return currentThread->isInterrupted();
+ }
bool BcastAlarmMSG(cAvidaContext& ctx, int jump_label, int bcast_range);
void moveIPtoAlarmLabel(int jump_label);
Modified: branches/interrupt/source/main/cStats.cc
===================================================================
--- branches/interrupt/source/main/cStats.cc 2009-02-05 20:53:44 UTC (rev 3141)
+++ branches/interrupt/source/main/cStats.cc 2009-02-06 14:09:14 UTC (rev 3142)
@@ -1963,32 +1963,6 @@
df.Endl();
}
-void cStats::PrintOrgsLocationAndInterrupt(const cString& filename){
- cDataFile& df = m_world->GetDataFile(filename);
- df.WriteComment("Organism interrupt data use to make large scale movie");
- df.WriteComment("Assumes each organism only contains a single thread!");
- df.WriteTimeStamp();
-
- int numDemes = m_world->GetPopulation().GetNumDemes();
- for(int i=0; i<numDemes; ++i) {
- cDeme& deme = m_world->GetPopulation().GetDeme(i);
- for(int j = 0; j < deme.GetSize() ; ++j) {
- cOrganism* org = deme.GetOrganism(j);
- if(org != NULL) {
- int absolute_cell_ID = org->GetCellID();
- std::pair<int, int> pos = deme.GetCellPosition(absolute_cell_ID);
- cLocalThread* currentThread = static_cast<cHardwareCPU*>(org->GetHardware(false))->GetThread(org->GetHardware(false)->GetCurThread());
- df.Write(m_update, "Update");
- df.Write(org->GetID(), "Organism ID" );
- df.Write(pos.first, "X coordinate" );
- df.Write(pos.second, "Y coordinate" );
- df.Write(currentThread->isInterrupted(), "In organisms interruped?" );
- df.Endl();
- }
- }
- }
-}
-
void cStats::CompeteDemes(const std::vector<double>& fitness) {
m_deme_fitness = fitness;
}
Modified: branches/interrupt/source/main/cStats.h
===================================================================
--- branches/interrupt/source/main/cStats.h 2009-02-05 20:53:44 UTC (rev 3141)
+++ branches/interrupt/source/main/cStats.h 2009-02-06 14:09:14 UTC (rev 3142)
@@ -843,7 +843,6 @@
void PrintPerDemeGenPerFounderData(const cString& filename);
void PrintDemeMigrationSuicidePoints(const cString& filename);
void PrintDemeInterrupt(const cString& filename);
- void PrintOrgsLocationAndInterrupt(const cString& filename);
More information about the Avida-cvs
mailing list