[Avida-SVN] r2522 - in branches/jobScheduling/source: actions cpu main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Mon Apr 7 13:36:31 PDT 2008
Author: beckma24
Date: 2008-04-07 16:36:30 -0400 (Mon, 07 Apr 2008)
New Revision: 2522
Modified:
branches/jobScheduling/source/actions/PrintActions.cc
branches/jobScheduling/source/cpu/cHardwareCPU.cc
branches/jobScheduling/source/main/cDeme.cc
branches/jobScheduling/source/main/cPhenotype.h
branches/jobScheduling/source/main/cPopulation.cc
branches/jobScheduling/source/main/cPopulation.h
branches/jobScheduling/source/main/cStats.h
Log:
Added testament logging
Modified: branches/jobScheduling/source/actions/PrintActions.cc
===================================================================
--- branches/jobScheduling/source/actions/PrintActions.cc 2008-04-07 17:54:19 UTC (rev 2521)
+++ branches/jobScheduling/source/actions/PrintActions.cc 2008-04-07 20:36:30 UTC (rev 2522)
@@ -118,6 +118,7 @@
POP_OUT_FILE(PrintPhenotypeData, phenotype_count.dat );
POP_OUT_FILE(PrintPhenotypeStatus, phenotype_status.dat);
+POP_OUT_FILE(PrintDemeTestamentStats, deme_testament.dat );
class cActionPrintData : public cAction
@@ -2672,6 +2673,8 @@
action_lib->Register<cActionPrintPhenotypeData>("PrintPhenotypeData");
action_lib->Register<cActionPrintPhenotypeStatus>("PrintPhenotypeStatus");
+ action_lib->Register<cActionPrintDemeTestamentStats>("PrintDemeTestamentStats");
+
// deme output files
action_lib->Register<cActionPrintDemeAllStats>("PrintDemeAllStats");
action_lib->Register<cActionPrintDemeAllStats>("PrintDemeStats"); //duplicate of previous
Modified: branches/jobScheduling/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/jobScheduling/source/cpu/cHardwareCPU.cc 2008-04-07 17:54:19 UTC (rev 2521)
+++ branches/jobScheduling/source/cpu/cHardwareCPU.cc 2008-04-07 20:36:30 UTC (rev 2522)
@@ -2727,6 +2727,7 @@
if(deme == NULL)
return false; // in test CPU
deme->IncreaseTotalEnergyTestament(stored_energy);
+ m_world->GetStats().SumEnergyTestamentToFutureDeme().Add(stored_energy);
organism->Die();
return true;
}
@@ -2749,12 +2750,12 @@
for(int i = 0; i < organism->GetNeighborhoodSize(); i++) {
if(organism->IsNeighborCellOccupied()) {
// give energy testament to neighboring organisms
- organism->GetPhenotype().EnergyTestament(stored_energy/numOcuppiedNeighbors);
+ organism->GetNeighbor()->GetPhenotype().EnergyTestament(stored_energy/numOcuppiedNeighbors);
}
organism->Rotate(1);
}
assert(organism->GetFacing() == orginalFacing);
-
+ m_world->GetStats().SumEnergyTestamentToNeighborOrganisms().Add(stored_energy);
organism->Die();
return true;
}
@@ -2764,7 +2765,7 @@
// put stored energy into toBeApplied energy pool of neighbor organisms
organism->DivideOrgTestamentAmongDeme(stored_energy);
-
+ m_world->GetStats().SumEnergyTestamentToDemeOrganisms().Add(stored_energy);
organism->Die();
return true;
}
Modified: branches/jobScheduling/source/main/cDeme.cc
===================================================================
--- branches/jobScheduling/source/main/cDeme.cc 2008-04-07 17:54:19 UTC (rev 2521)
+++ branches/jobScheduling/source/main/cDeme.cc 2008-04-07 20:36:30 UTC (rev 2522)
@@ -294,7 +294,7 @@
cell_events[cell_events_size-k-1] = demeEvent;
}
}
-
+
// setup stats.flow_rate_tuples
cStats& stats = m_world->GetStats();
for(int i = m_total_events_per_slot_min; i <= m_total_events_per_slot_max; i+=flow_level_increment) {
Modified: branches/jobScheduling/source/main/cPhenotype.h
===================================================================
--- branches/jobScheduling/source/main/cPhenotype.h 2008-04-07 17:54:19 UTC (rev 2521)
+++ branches/jobScheduling/source/main/cPhenotype.h 2008-04-07 20:36:30 UTC (rev 2522)
@@ -457,7 +457,7 @@
void HalfEnergyUsage();
void RefreshEnergy();
void ApplyToEnergyStore();
- void EnergyTestament(double value) { energy_tobe_applied += value; } //! external energy given to organism
+ void EnergyTestament(double value) { assert(value > 0.0); energy_tobe_applied += value; } //! external energy given to organism
double ExtractParentEnergy();
bool operator<(const cPhenotype& rhs) const;
Modified: branches/jobScheduling/source/main/cPopulation.cc
===================================================================
--- branches/jobScheduling/source/main/cPopulation.cc 2008-04-07 17:54:19 UTC (rev 2521)
+++ branches/jobScheduling/source/main/cPopulation.cc 2008-04-07 20:36:30 UTC (rev 2522)
@@ -2035,6 +2035,23 @@
}
}
+void cPopulation::PrintDemeTestamentStats(const cString& filename) {
+ cStats& stats = m_world->GetStats();
+
+ cDataFile& df = m_world->GetDataFile(filename);
+ df.WriteTimeStamp();
+ df.Write(m_world->GetStats().GetUpdate(), "Update");
+ df.Write(stats.SumEnergyTestamentToDemeOrganisms().Average(), "Energy Testament To Deme Organisms");
+ df.Write(stats.SumEnergyTestamentToFutureDeme().Average(), "Energy Testament To Future Deme");
+ df.Write(stats.SumEnergyTestamentToNeighborOrganisms().Average(), "Energy Testament To Neighbor Organisms");
+ df.Endl();
+
+
+ stats.SumEnergyTestamentToDemeOrganisms().Clear();
+ stats.SumEnergyTestamentToFutureDeme().Clear();
+ stats.SumEnergyTestamentToNeighborOrganisms().Clear();
+}
+
void cPopulation::PrintDemeDonor() {
cStats& stats = m_world->GetStats();
const int num_demes = deme_array.GetSize();
@@ -2837,7 +2854,7 @@
stats.SumDemeNormalizedTimeUsed().Clear();
stats.SumDemeMerit().Clear();
stats.SumDemeEventsKilled().Clear();
-
+
for(int i = 0; i < GetNumDemes(); i++) {
cDeme& deme = GetDeme(i);
if(deme.IsEmpty()) // ignore empty demes
Modified: branches/jobScheduling/source/main/cPopulation.h
===================================================================
--- branches/jobScheduling/source/main/cPopulation.h 2008-04-07 17:54:19 UTC (rev 2521)
+++ branches/jobScheduling/source/main/cPopulation.h 2008-04-07 20:36:30 UTC (rev 2522)
@@ -217,6 +217,7 @@
// Deme-related stats methods
void PrintDemeAllStats();
+ void PrintDemeTestamentStats(const cString& filename);
void PrintDemeDonor();
void PrintDemeFitness();
void PrintDemeGestationTime();
Modified: branches/jobScheduling/source/main/cStats.h
===================================================================
--- branches/jobScheduling/source/main/cStats.h 2008-04-07 17:54:19 UTC (rev 2521)
+++ branches/jobScheduling/source/main/cStats.h 2008-04-07 20:36:30 UTC (rev 2522)
@@ -276,6 +276,10 @@
cDoubleSum sum_deme_merit;
cIntSum sum_deme_events_killed;
+ cDoubleSum EnergyTestamentToFutureDeme;
+ cDoubleSum EnergyTestamentToNeighborOrganisms;
+ cDoubleSum EnergyTestamentToDemeOrganisms;
+
//(event flow rate, (deme pop size, events killed))
std::map<int, std::pair<cIntSum, cIntSum> > flow_rate_tuple;
@@ -424,6 +428,11 @@
cDoubleSum& SumDemeMerit() { return sum_deme_merit; }
cIntSum& SumDemeEventsKilled() { return sum_deme_events_killed; }
+ cDoubleSum& SumEnergyTestamentToFutureDeme() { return EnergyTestamentToFutureDeme;}
+ cDoubleSum& SumEnergyTestamentToNeighborOrganisms() { return EnergyTestamentToNeighborOrganisms; }
+ cDoubleSum& SumEnergyTestamentToDemeOrganisms() { return EnergyTestamentToDemeOrganisms; }
+
+
std::map<int, std::pair<cIntSum, cIntSum> >& FlowRateTuple() { return flow_rate_tuple; }
#if INSTRUCTION_COUNT
@@ -466,6 +475,11 @@
const cDoubleSum& SumDemeNormalizedTimeUsed() const { return sum_deme_normalized_time_used; }
const cDoubleSum& SumDemeMerit() const { return sum_deme_merit; }
const cIntSum& SumDemeEventsKilled() const { return sum_deme_events_killed; }
+
+ const cDoubleSum& SumEnergyTestamentToFutureDeme() const { return EnergyTestamentToFutureDeme;}
+ const cDoubleSum& SumEnergyTestamentToNeighborOrganisms() const { return EnergyTestamentToNeighborOrganisms; }
+ const cDoubleSum& SumEnergyTestamentToDemeOrganisms() const { return EnergyTestamentToDemeOrganisms; }
+
const std::map<int, std::pair<cIntSum, cIntSum> >& FlowRateTuple() const { return flow_rate_tuple; }
More information about the Avida-cvs
mailing list