[Avida-cvs] [Avida2-svn] r385 - in development: Avida.xcodeproj source/analyze source/event source/main source/support source/tools
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Wed Nov 9 16:01:26 PST 2005
Author: brysonda
Date: 2005-11-09 19:01:25 -0500 (Wed, 09 Nov 2005)
New Revision: 385
Modified:
development/Avida.xcodeproj/project.pbxproj
development/source/analyze/cAnalyze.cc
development/source/analyze/cAnalyze.h
development/source/analyze/cAnalyzeUtil.cc
development/source/analyze/cAnalyzeUtil.h
development/source/event/cEventManager.cc
development/source/main/cAvidaDriver_Population.cc
development/source/main/cGenebank.cc
development/source/main/cGenebank.h
development/source/main/cInjectGenebank.cc
development/source/main/cInjectGenebank.h
development/source/main/cLineageControl.cc
development/source/main/cLineageControl.h
development/source/main/cPopulation.cc
development/source/main/cPopulation.h
development/source/main/cPopulationInterface.cc
development/source/main/cStats.cc
development/source/main/cStats.h
development/source/main/cWorld.cc
development/source/main/cWorld.h
development/source/support/avida.cfg
development/source/tools/cDataFileManager.cc
development/source/tools/cDataFileManager.h
development/source/tools/cDataManager_Base.cc
development/source/tools/cDataManager_Base.h
Log:
Convert Data File management over to the cWorld contained manager. Move cStats to cWorld. Change old, unused DEFAULT_DIR option to a DATA_DIR option, now used the by data file manager.
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2005-11-09 21:58:15 UTC (rev 384)
+++ development/Avida.xcodeproj/project.pbxproj 2005-11-10 00:01:25 UTC (rev 385)
@@ -26,9 +26,7 @@
700E2B87085DE54400CF158A /* viewer in CopyFiles */ = {isa = PBXBuildFile; fileRef = 700E2B83085DE50C00CF158A /* viewer */; };
701384340900A45B0087ED2E /* organism.smtx in CopyFiles */ = {isa = PBXBuildFile; fileRef = 701384330900A45B0087ED2E /* organism.smtx */; };
701384350900A45B0087ED2E /* organism.smtx in CopyFiles */ = {isa = PBXBuildFile; fileRef = 701384330900A45B0087ED2E /* organism.smtx */; };
- 7013846109028B3E0087ED2E /* cAvidaConfig.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7013845F09028B3E0087ED2E /* cAvidaConfig.h */; };
7013846209028B3E0087ED2E /* cAvidaConfig.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7013846009028B3E0087ED2E /* cAvidaConfig.cc */; };
- 7013846309028B3E0087ED2E /* cAvidaConfig.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7013845F09028B3E0087ED2E /* cAvidaConfig.h */; };
7013846409028B3E0087ED2E /* cAvidaConfig.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7013846009028B3E0087ED2E /* cAvidaConfig.cc */; };
7013852D0902E36B0087ED2E /* avida.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7013852C0902E36B0087ED2E /* avida.cfg */; };
7013852E0902E36B0087ED2E /* avida.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7013852C0902E36B0087ED2E /* avida.cfg */; };
@@ -45,7 +43,6 @@
702D4F4B08DA61FE007BA469 /* cBirthChamber.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4F3F08DA61FE007BA469 /* cBirthChamber.cc */; };
7040CF1C0906A52E00AA820F /* cEventManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7040CF1A0906A52E00AA820F /* cEventManager.cc */; };
7040CF1E0906A52E00AA820F /* cEventManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7040CF1A0906A52E00AA820F /* cEventManager.cc */; };
- 7040CF1F0906A52E00AA820F /* cEventManager.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7040CF1B0906A52E00AA820F /* cEventManager.h */; };
7040D36E09095E5900AA820F /* cAvidaDriver_Analyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4EF908DA5341007BA469 /* cAvidaDriver_Analyze.cc */; };
7040D3A6090964D100AA820F /* cMxCodeArray.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865808F4974300FC65FE /* cMxCodeArray.cc */; };
70422A28091B141000A5E67F /* cAnalyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A1C091B141000A5E67F /* cAnalyze.cc */; };
@@ -241,12 +238,9 @@
70C1F19A08C6A11100F50912 /* cEventListIterator.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F19008C6A11100F50912 /* cEventListIterator.cc */; };
70C1F19B08C6A11100F50912 /* cEventTriggers.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1F19108C6A11100F50912 /* cEventTriggers.cc */; };
70C5BC6509059A970028A785 /* cWorld.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C5BC6309059A970028A785 /* cWorld.cc */; };
- 70C5BC6609059A970028A785 /* cWorld.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 70C5BC6209059A970028A785 /* cWorld.h */; };
70C5BC6709059A970028A785 /* cWorld.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C5BC6309059A970028A785 /* cWorld.cc */; };
70C5BD6B0905CE5F0028A785 /* cHardwareManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C5BD690905CE5F0028A785 /* cHardwareManager.cc */; };
- 70C5BD6C0905CE5F0028A785 /* cHardwareManager.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 70C5BD6A0905CE5F0028A785 /* cHardwareManager.h */; };
70C5BD6D0905CE5F0028A785 /* cHardwareManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C5BD690905CE5F0028A785 /* cHardwareManager.cc */; };
- 70C5BD6E0905CE5F0028A785 /* cHardwareManager.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 70C5BD6A0905CE5F0028A785 /* cHardwareManager.h */; };
70CA6EC308DB7F8200068AC2 /* cGenebank.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70CA6EB308DB7F8200068AC2 /* cGenebank.cc */; };
70CA6EC408DB7F8200068AC2 /* cGenome.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70CA6EB408DB7F8200068AC2 /* cGenome.cc */; };
70CA6EC508DB7F8200068AC2 /* cGenomeUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70CA6EB508DB7F8200068AC2 /* cGenomeUtil.cc */; };
@@ -315,7 +309,7 @@
700E2B6D085DE50C00CF158A /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
- dstPath = Avida2.work;
+ dstPath = Avida.work;
dstSubfolderSpec = 16;
files = (
700E2B87085DE54400CF158A /* viewer in CopyFiles */,
@@ -334,18 +328,14 @@
700E2B7C085DE50C00CF158A /* genesis.smt in CopyFiles */,
700E2B7D085DE50C00CF158A /* inst_set.smt in CopyFiles */,
701384340900A45B0087ED2E /* organism.smtx in CopyFiles */,
- 7013846109028B3E0087ED2E /* cAvidaConfig.h in CopyFiles */,
7013852E0902E36B0087ED2E /* avida.cfg in CopyFiles */,
- 70C5BC6609059A970028A785 /* cWorld.h in CopyFiles */,
- 70C5BD6E0905CE5F0028A785 /* cHardwareManager.h in CopyFiles */,
- 7040CF1F0906A52E00AA820F /* cEventManager.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
70486B9508267145009328F0 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
- dstPath = Avida2.work;
+ dstPath = Avida.work;
dstSubfolderSpec = 16;
files = (
700E2996085A1F6000CF158A /* primitive in CopyFiles */,
@@ -364,9 +354,7 @@
706D33110854A7D700D7DC8F /* genesis.smt in CopyFiles */,
706D33280854A90D00D7DC8F /* inst_set.smt in CopyFiles */,
701384350900A45B0087ED2E /* organism.smtx in CopyFiles */,
- 7013846309028B3E0087ED2E /* cAvidaConfig.h in CopyFiles */,
7013852D0902E36B0087ED2E /* avida.cfg in CopyFiles */,
- 70C5BD6C0905CE5F0028A785 /* cHardwareManager.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/analyze/cAnalyze.cc 2005-11-10 00:01:25 UTC (rev 385)
@@ -104,7 +104,6 @@
cAnalyze::~cAnalyze()
{
- data_file_manager.FlushAll();
while (genotype_data_list.GetSize()) delete genotype_data_list.Pop();
while (command_list.GetSize()) delete command_list.Pop();
while (function_list.GetSize()) delete function_list.Pop();
@@ -1536,7 +1535,7 @@
cString filename("tasks.dat");
if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
// Loop through all of the genotypes in this batch...
tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
@@ -1573,7 +1572,7 @@
CommandDetail_Header(cout, file_type, output_it);
CommandDetail_Body(cout, file_type, output_it);
} else {
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
CommandDetail_Header(fp, file_type, output_it);
CommandDetail_Body(fp, file_type, output_it);
}
@@ -1618,7 +1617,7 @@
CommandDetail_Header(cout, file_type, output_it, time_step);
CommandDetail_Body(cout, file_type, output_it, time_step, max_time);
} else {
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
CommandDetail_Header(fp, file_type, output_it, time_step);
CommandDetail_Body(fp, file_type, output_it, time_step, max_time);
}
@@ -1793,9 +1792,9 @@
LoadGenotypeDataList(cur_string, output_list);
// check if file is already in use.
- bool file_active = data_file_manager.IsOpen(filename);
+ bool file_active = m_world->GetDataFileManager().IsOpen(filename);
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
// if it's a new file print out the header
if (file_active == false) {
@@ -1850,7 +1849,7 @@
while (file_extension.Find('.') != -1) file_extension.Pop('.');
if (file_extension == "html") file_type = FILE_TYPE_HTML;
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
// Write out the header on the file
if (file_type == FILE_TYPE_TEXT) {
@@ -2109,7 +2108,7 @@
CommandHistogram_Header(cout, file_type, output_it);
CommandHistogram_Body(cout, file_type, output_it);
} else {
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
CommandHistogram_Header(fp, file_type, output_it);
CommandHistogram_Body(fp, file_type, output_it);
}
@@ -2301,7 +2300,7 @@
// Print out the results...
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
fp << "# 1: Number of organisms of this phenotype" << endl
<< "# 2: Number of genotypes of this phenotye" << endl
@@ -2425,7 +2424,7 @@
}
// Print out the results...
- cDataFile & df = data_file_manager.Get(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
for (int i = 0; i < num_tasks; i++) {
df.Write(i, "# 1: Task ID");
@@ -3290,7 +3289,7 @@
if (cur_string.GetSize() != 0) num_test=cur_string.PopWord().AsInt();
// If we're given a file, write to it.
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
// Loop through all of the genotypes in this batch...
tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
@@ -3315,7 +3314,7 @@
if (cur_string.GetSize() != 0) test_num = cur_string.PopWord().AsInt();
// If we're given a file, write to it.
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
// Loop through all of the genotypes in this batch...
tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
@@ -3491,7 +3490,7 @@
if (filename == "none") return;
- cDataFile & df = data_file_manager.Get(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Mate selection information" );
df.WriteTimeStamp();
@@ -3571,7 +3570,7 @@
}
// Open up the file and prepare it for output.
- cDataFile & df = data_file_manager.Get(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "An analyze of expected complexity changes between parent and offspring" );
df.WriteTimeStamp();
@@ -3661,7 +3660,7 @@
if (cur_string.GetSize() > 0) max_knockouts = cur_string.PopWord().AsInt();
// Open up the data file...
- cDataFile & df = data_file_manager.Get(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Analysis of knockouts in genomes" );
df.WriteTimeStamp();
@@ -4103,7 +4102,7 @@
cout << endl;
}
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
// printing the headers
// not done by default since many dumps may be analyzed at the same time
@@ -4717,7 +4716,7 @@
cout << "max_depth = " << max_depth << endl;
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
cout << "Output to " << filename << endl;
tArray<int> depth_array(max_depth+1);
@@ -4792,7 +4791,7 @@
double ave_dist = (double) total_dist / (double) total_count;
cout << " ave distance = " << ave_dist << endl;
- cDataFile & df = data_file_manager.Get(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Hamming distance information" );
df.WriteTimeStamp();
@@ -4858,7 +4857,7 @@
double ave_dist = (double) total_dist / (double) total_count;
cout << " ave distance = " << ave_dist << endl;
- cDataFile & df = data_file_manager.Get(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Levenstein distance information" );
df.WriteTimeStamp();
@@ -4976,7 +4975,7 @@
<< " in " << total_count
<< " tests." << endl;
- cDataFile & df = data_file_manager.Get(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Species information" );
df.WriteTimeStamp();
@@ -5265,7 +5264,7 @@
if (cur_string.GetSize() != 0) num_cells = cur_string.PopWord().AsInt();
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
// Start up again at update zero...
fp << "0 ";
@@ -5324,7 +5323,7 @@
if (cur_string.GetSize() != 0) start_cell = cur_string.PopWord().AsInt();
if (cur_string.GetSize() != 0) lineage = cur_string.PopWord().AsInt();
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
int org_count = 0;
tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
@@ -5377,7 +5376,7 @@
return;
}
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
// Count the number of organisms in each batch...
cAnalyzeGenotype * genotype = NULL;
@@ -5497,7 +5496,7 @@
cString & last_seq = sequences[num_sequences - 1];
// Print out the header...
- ofstream & fp = data_file_manager.GetOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
fp << "# " << sequences[0] << endl;
fp << "# " << sequences[num_sequences - 1] << endl;
fp << "# ";
Modified: development/source/analyze/cAnalyze.h
===================================================================
--- development/source/analyze/cAnalyze.h 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/analyze/cAnalyze.h 2005-11-10 00:01:25 UTC (rev 385)
@@ -10,9 +10,6 @@
#include <vector>
-#ifndef DATA_FILE_MANAGER_HH
-#include "cDataFileManager.h"
-#endif
#ifndef GENOTYPE_BATCH_HH
#include "cGenotypeBatch.h"
#endif
@@ -39,7 +36,6 @@
class cAnalyzeFunction;
class cAnalyzeCommandDefBase;
class cString; // aggregate
-class cDataFileManager; // aggregate
template <class T> class tDataEntryBase;
class cInstSet;
class cRandom; // aggregate
@@ -73,7 +69,6 @@
bool verbose; // Should details be output to command line?
int interactive_depth; // How nested are we if in interactive mode?
- cDataFileManager data_file_manager;
tList< tDataEntryBase<cAnalyzeGenotype> > genotype_data_list;
cRandom random;
Modified: development/source/analyze/cAnalyzeUtil.cc
===================================================================
--- development/source/analyze/cAnalyzeUtil.cc 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/analyze/cAnalyzeUtil.cc 2005-11-10 00:01:25 UTC (rev 385)
@@ -198,7 +198,7 @@
{
cPopulation* population = &world->GetPopulation();
const int num_inst = world->GetHardwareManager().GetInstSet().GetSize();
- const int update = population->GetStats().GetUpdate();
+ const int update = world->GetStats().GetUpdate();
cGenebank & genebank = population->GetGenebank();
// Setup the histogtams...
@@ -394,7 +394,7 @@
cString creature_name;
if ( genotype->GetThreshold() ) creature_name = genotype->GetName();
else creature_name.Set("%03d-no_name-u%i-c%i", genotype->GetLength(),
- pop->GetStats().GetUpdate(), i );
+ world->GetStats().GetUpdate(), i );
fp << i << " " // 1 cell ID
<< creature_name() << " " // 2 name
@@ -451,8 +451,8 @@
bool print_fitness_histo, double hist_fmax, double hist_fstep)
{
cPopulation* pop = &world->GetPopulation();
- const int update = pop->GetStats().GetUpdate();
- const double generation = pop->GetStats().SumGeneration().Average();
+ const int update = world->GetStats().GetUpdate();
+ const double generation = world->GetStats().SumGeneration().Average();
// the histogram variables
vector<int> histo;
@@ -604,7 +604,7 @@
hamming_m1 /= (double) count;
hamming_m2 /= (double) count;
- fp << pop->GetStats().GetUpdate() << " " // 1 update
+ fp << world->GetStats().GetUpdate() << " " // 1 update
<< hamming_m1 << " " // ave. Hamming dist
<< sqrt( ( hamming_m2 - hamming_m1*hamming_m1 ) / (double) count )
<< " " // std. error
@@ -788,7 +788,7 @@
}
}
- fp << pop->GetStats().GetUpdate();
+ fp << world->GetStats().GetUpdate();
for (it = tasks.begin(); it != tasks.end(); it++) fp << " " << (*it);
fp<<endl;
}
@@ -811,8 +811,9 @@
}
-void cAnalyzeUtil::PrintDepthHistogram(ofstream & fp, cPopulation * pop)
+void cAnalyzeUtil::PrintDepthHistogram(cWorld* world, ofstream & fp)
{
+ cPopulation* pop = &world->GetPopulation();
// Output format: update min max histogram_values...
int min = INT_MAX;
int max = 0;
@@ -842,7 +843,7 @@
}
// Actual output
- fp << pop->GetStats().GetUpdate() << " "
+ fp << world->GetStats().GetUpdate() << " "
<< min << " "
<< max;
@@ -851,9 +852,9 @@
}
-void cAnalyzeUtil::PrintGenotypeAbundanceHistogram(ofstream & fp,
- cPopulation * pop)
+void cAnalyzeUtil::PrintGenotypeAbundanceHistogram(cWorld* world, ofstream& fp)
{
+ cPopulation* pop = &world->GetPopulation();
assert(fp.good());
// Allocate array for the histogram & zero it
@@ -870,15 +871,15 @@
}
// Actual output
- fp << pop->GetStats().GetUpdate() << " ";
+ fp << world->GetStats().GetUpdate() << " ";
for (int i = 0; i < hist.GetSize(); i++) fp<<hist[i]<<" ";
fp << endl;
}
-void cAnalyzeUtil::PrintSpeciesAbundanceHistogram(ofstream & fp,
- cPopulation * pop)
+void cAnalyzeUtil::PrintSpeciesAbundanceHistogram(cWorld* world, ofstream &fp)
{
+ cPopulation* pop = &world->GetPopulation();
int max = 0;
assert(fp.good());
@@ -906,7 +907,7 @@
}
// Actual output
- fp << pop->GetStats().GetUpdate() << " ";
+ fp << world->GetStats().GetUpdate() << " ";
for (int i = 0; i < hist.GetSize(); i++) fp<<hist[i]<<" ";
fp<<endl;
}
Modified: development/source/analyze/cAnalyzeUtil.h
===================================================================
--- development/source/analyze/cAnalyzeUtil.h 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/analyze/cAnalyzeUtil.h 2005-11-10 00:01:25 UTC (rev 385)
@@ -61,9 +61,9 @@
static void PrintViableTasksData(cWorld* world, std::ofstream &fp);
static void PrintTreeDepths(cPopulation * pop, std::ofstream & fp);
- static void PrintDepthHistogram(std::ofstream &fp, cPopulation * pop);
- static void PrintGenotypeAbundanceHistogram(std::ofstream &fp, cPopulation * pop);
- static void PrintSpeciesAbundanceHistogram(std::ofstream &fp, cPopulation * pop);
+ static void PrintDepthHistogram(cWorld* world, std::ofstream& fp);
+ static void PrintGenotypeAbundanceHistogram(cWorld* world, std::ofstream& fp);
+ static void PrintSpeciesAbundanceHistogram(cWorld* world, std::ofstream& fp);
// this adds support for evan dorn's InstructionHistogramEvent. -- kgn
static void PrintInstructionAbundanceHistogram(cWorld* world, std::ofstream &fp);
Modified: development/source/event/cEventManager.cc
===================================================================
--- development/source/event/cEventManager.cc 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/event/cEventManager.cc 2005-11-10 00:01:25 UTC (rev 385)
@@ -69,7 +69,7 @@
}
///// exit_if_generation_greater_than /////
void Process(){
- if( m_world->GetPopulation().GetGeneration() > max_generation ){
+ if( m_world->GetStats().SumGeneration().Average() > max_generation ){
cAvidaDriver_Base::main_driver->SetDone();
}
}
@@ -103,7 +103,7 @@
}
///// exit_if_update_greater_than /////
void Process(){
- if( m_world->GetPopulation().GetUpdate() > max_update ){
+ if( m_world->GetStats().GetUpdate() > max_update ){
cAvidaDriver_Base::main_driver->SetDone();
}
}
@@ -137,7 +137,7 @@
}
///// exit_if_ave_lineage_label_smaller /////
void Process(){
- if( m_world->GetPopulation().GetStats().GetAveLineageLabel() < lineage_label_crit_value ){
+ if( m_world->GetStats().GetAveLineageLabel() < lineage_label_crit_value ){
cAvidaDriver_Base::main_driver->SetDone();
}
}
@@ -171,7 +171,7 @@
}
///// exit_if_ave_lineage_label_larger /////
void Process(){
- if( m_world->GetPopulation().GetStats().GetAveLineageLabel() > lineage_label_crit_value ){
+ if( m_world->GetStats().GetAveLineageLabel() > lineage_label_crit_value ){
cAvidaDriver_Base::main_driver->SetDone();
}
}
@@ -206,7 +206,7 @@
void Process(){
if( mesg == "" ){
mesg.Set("Echo : Update = %f\t AveGeneration = %f",
- m_world->GetPopulation().GetUpdate(), m_world->GetPopulation().GetGeneration());
+ m_world->GetStats().GetUpdate(), m_world->GetStats().SumGeneration().Average());
}
cAvidaDriver_Base::main_driver->NotifyComment(mesg);
}
@@ -243,7 +243,7 @@
}
///// print_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintDataFile(filename, format, ',');
+ m_world->GetStats().PrintDataFile(filename, format, ',');
}
};
@@ -274,7 +274,7 @@
}
///// print_average_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintAverageData(fname);
+ m_world->GetStats().PrintAverageData(fname);
}
};
@@ -305,7 +305,7 @@
}
///// print_error_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintErrorData(fname);
+ m_world->GetStats().PrintErrorData(fname);
}
};
@@ -336,7 +336,7 @@
}
///// print_variance_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintVarianceData(fname);
+ m_world->GetStats().PrintVarianceData(fname);
}
};
@@ -367,7 +367,7 @@
}
///// print_dominant_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintDominantData(fname);
+ m_world->GetStats().PrintDominantData(fname);
}
};
@@ -398,7 +398,7 @@
}
///// print_stats_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintStatsData(fname);
+ m_world->GetStats().PrintStatsData(fname);
}
};
@@ -429,7 +429,7 @@
}
///// print_count_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintCountData(fname);
+ m_world->GetStats().PrintCountData(fname);
}
};
@@ -460,7 +460,7 @@
}
///// print_totals_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintTotalsData(fname);
+ m_world->GetStats().PrintTotalsData(fname);
}
};
@@ -492,7 +492,7 @@
}
///// print_tasks_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintTasksData(fname);
+ m_world->GetStats().PrintTasksData(fname);
}
};
@@ -518,7 +518,7 @@
}
///// print_tasks_exe_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintTasksExeData(fname);
+ m_world->GetStats().PrintTasksExeData(fname);
}
};
@@ -544,7 +544,7 @@
}
///// print_resource_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintResourceData(fname);
+ m_world->GetStats().PrintResourceData(fname);
}
};
@@ -575,7 +575,7 @@
}
///// print_time_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintTimeData(fname);
+ m_world->GetStats().PrintTimeData(fname);
}
};
@@ -601,7 +601,7 @@
}
///// print_mutation_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintMutationData(fname);
+ m_world->GetStats().PrintMutationData(fname);
}
};
@@ -630,7 +630,7 @@
}
///// print_mutation_rate_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintMutationRateData(fname);
+ m_world->GetStats().PrintMutationRateData(fname);
}
};
@@ -659,7 +659,7 @@
}
///// print_divide_mut_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintDivideMutData(fname);
+ m_world->GetStats().PrintDivideMutData(fname);
}
};
@@ -690,7 +690,7 @@
}
///// print_dom_parasite_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintDominantParaData(fname);
+ m_world->GetStats().PrintDominantParaData(fname);
}
};
@@ -719,7 +719,7 @@
}
///// print_instruction_data /////
void Process(){
- m_world->GetPopulation().GetStats().PrintInstructionData(fname);
+ m_world->GetStats().PrintInstructionData(fname);
}
};
@@ -752,7 +752,7 @@
}
///// print_instruction_abundance_histogram /////
void Process(){
- ofstream & fp = m_world->GetPopulation().GetStats().GetDataFileOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
cAnalyzeUtil::PrintInstructionAbundanceHistogram(m_world, fp);
}
};
@@ -779,8 +779,8 @@
}
///// print_depth_histogram /////
void Process(){
- ofstream & fp = m_world->GetPopulation().GetStats().GetDataFileOFStream(filename);
- cAnalyzeUtil::PrintDepthHistogram(fp, &m_world->GetPopulation());
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
+ cAnalyzeUtil::PrintDepthHistogram(m_world, fp);
}
};
@@ -811,8 +811,8 @@
}
///// print_genotype_abundance_histogram /////
void Process(){
- ofstream & fp = m_world->GetPopulation().GetStats().GetDataFileOFStream(filename);
- cAnalyzeUtil::PrintGenotypeAbundanceHistogram(fp, &m_world->GetPopulation());
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
+ cAnalyzeUtil::PrintGenotypeAbundanceHistogram(m_world, fp);
}
};
@@ -843,8 +843,8 @@
}
///// print_species_abundance_histogram /////
void Process(){
- ofstream & fp = m_world->GetPopulation().GetStats().GetDataFileOFStream(filename);
- cAnalyzeUtil::PrintSpeciesAbundanceHistogram(fp, &m_world->GetPopulation());
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
+ cAnalyzeUtil::PrintSpeciesAbundanceHistogram(m_world, fp);
}
};
@@ -875,7 +875,7 @@
static bool msg_printed = false;
if (m_world->GetPopulation().GetLineageControl() == NULL) {
if ( msg_printed == false ){
- ofstream & fp = m_world->GetPopulation().GetStats().GetDataFileOFStream(fname);
+ ofstream & fp = m_world->GetDataFileOFStream(fname);
fp << "No lineage data available!" << endl;
msg_printed = true;
}
@@ -912,7 +912,7 @@
static bool msg_printed = false;
if (m_world->GetPopulation().GetLineageControl() == NULL) {
if ( msg_printed == false ){
- ofstream & fp = m_world->GetPopulation().GetStats().GetDataFileOFStream(fname);
+ ofstream & fp = m_world->GetDataFileOFStream(fname);
fp << "No lineage data available!" << endl;
msg_printed = true;
}
@@ -959,7 +959,7 @@
cGenotype * dom = m_world->GetPopulation().GetGenebank().GetBestGenotype();
cString filename(in_filename);
if (filename == "") filename.Set("genebank/%s", dom->GetName()());
- cTestUtil::PrintGenome(m_world, dom->GetGenome(), filename, dom, m_world->GetPopulation().GetUpdate());
+ cTestUtil::PrintGenome(m_world, dom->GetGenome(), filename, dom, m_world->GetStats().GetUpdate());
}
};
@@ -1022,7 +1022,7 @@
if (dom!=NULL) {
cString filename(in_filename);
if (filename == "") filename.Set("genebank/%s", dom->GetName()());
- cTestUtil::PrintGenome(m_world, dom, dom->GetGenome(), filename, m_world->GetPopulation().GetUpdate()); }
+ cTestUtil::PrintGenome(m_world, dom, dom->GetGenome(), filename, m_world->GetStats().GetUpdate()); }
}
};
@@ -1049,7 +1049,7 @@
}
///// print_genotype_map /////
void Process(){
- m_world->GetPopulation().GetStats().PrintGenotypeMap(fname);
+ m_world->GetStats().PrintGenotypeMap(fname);
}
};
@@ -1141,7 +1141,7 @@
void Process(){
cString filename;
if( fname == "" ){
- filename.Set("save_pop.%d", m_world->GetPopulation().GetUpdate());
+ filename.Set("save_pop.%d", m_world->GetStats().GetUpdate());
}
ofstream fp(filename());
m_world->GetPopulation().SavePopulation(fp);
@@ -1204,7 +1204,7 @@
void Process(){
cString filename;
if( fname == "" ){
- filename.Set("clone.%d", m_world->GetPopulation().GetUpdate());
+ filename.Set("clone.%d", m_world->GetStats().GetUpdate());
}
ofstream fp(filename());
m_world->GetPopulation().SaveClone(fp);
@@ -1300,7 +1300,7 @@
void Process(){
cString filename;
if( fname == "" ){
- filename.Set("dump.%d", m_world->GetPopulation().GetUpdate());
+ filename.Set("dump.%d", m_world->GetStats().GetUpdate());
}
ofstream fp(filename());
m_world->GetPopulation().GetGenebank().DumpTextSummary(fp);
@@ -1349,7 +1349,7 @@
void Process(){
cString filename = fname;
if (filename == "") {
- filename.Set("genotypes-%d.dat", m_world->GetPopulation().GetUpdate());
+ filename.Set("genotypes-%d.dat", m_world->GetStats().GetUpdate());
}
ofstream fp(filename());
m_world->GetPopulation().GetGenebank().PrintGenotypes(fp, data_fields, historic);
@@ -1385,7 +1385,7 @@
void Process(){
cString filename;
if( fname == "" ){
- filename.Set("detail_pop.%d", m_world->GetPopulation().GetUpdate());
+ filename.Set("detail_pop.%d", m_world->GetStats().GetUpdate());
}
ofstream fp(filename());
m_world->GetPopulation().GetGenebank().DumpDetailedSummary(fp);
@@ -1422,7 +1422,7 @@
void Process(){
cString filename;
if( fname == "" ){
- filename.Set("detail_pop.%d", m_world->GetPopulation().GetUpdate());
+ filename.Set("detail_pop.%d", m_world->GetStats().GetUpdate());
}
ofstream fp(filename());
m_world->GetPopulation().GetGenebank().DumpDetailedSexSummary(fp);
@@ -1458,10 +1458,10 @@
void Process(){
cString filename;
if( fname == "" ){
- filename.Set("detail_parasite_pop.%d", m_world->GetPopulation().GetUpdate());
+ filename.Set("detail_parasite_pop.%d", m_world->GetStats().GetUpdate());
}
//ofstream fp(filename());
- m_world->GetPopulation().GetInjectGenebank().DumpDetailedSummary(filename, m_world->GetPopulation().GetUpdate());
+ m_world->GetPopulation().GetInjectGenebank().DumpDetailedSummary(filename, m_world->GetStats().GetUpdate());
}
};
@@ -1502,7 +1502,7 @@
void Process(){
cString filename;
if( fname == "" ){
- filename.Set("historic_dump.%d", m_world->GetPopulation().GetUpdate());
+ filename.Set("historic_dump.%d", m_world->GetStats().GetUpdate());
}
ofstream fp(filename());
m_world->GetPopulation().GetGenebank().DumpHistoricSummary(fp, back_dist);
@@ -1539,7 +1539,7 @@
void Process(){
cString filename;
if( fname == "" ){
- filename.Set("historic_dump.%d", m_world->GetPopulation().GetUpdate());
+ filename.Set("historic_dump.%d", m_world->GetStats().GetUpdate());
}
ofstream fp(filename());
m_world->GetPopulation().GetGenebank().DumpHistoricSexSummary(fp);
@@ -1571,7 +1571,7 @@
void Process(){
cString filename;
if (fname == "") {
- filename.Set("memory_dump.%d", m_world->GetPopulation().GetUpdate());
+ filename.Set("memory_dump.%d", m_world->GetStats().GetUpdate());
}
ofstream fp(filename());
m_world->GetPopulation().DumpMemorySummary(fp);
@@ -2350,7 +2350,7 @@
if (sample_size == 0) sample_size = m_world->GetHardwareManager().GetInstSet().GetSize() - 1;
landscape.SampleProcess(sample_size);
static ofstream fp("land-sample.dat");
- landscape.PrintStats(fp, m_world->GetPopulation().GetUpdate());
+ landscape.PrintStats(fp, m_world->GetStats().GetUpdate());
}
};
@@ -2389,7 +2389,7 @@
landscape.RandomProcess(sample_size, landscape_dist, min_found,
max_sample_size, print_if_found);
static ofstream fp("land-random.dat");
- landscape.PrintStats(fp, m_world->GetPopulation().GetUpdate());
+ landscape.PrintStats(fp, m_world->GetStats().GetUpdate());
}
};
@@ -2422,7 +2422,7 @@
cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
cAnalyzeUtil::AnalyzeLandscape(m_world, genome, m_world->GetHardwareManager().GetInstSet(),
sample_size, min_found, max_sample_size,
- m_world->GetPopulation().GetUpdate());
+ m_world->GetStats().GetUpdate());
}
};
@@ -2450,7 +2450,7 @@
///// pairtest_landscape /////
void Process(){
cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
- cAnalyzeUtil::PairTestLandscape(m_world, genome, m_world->GetHardwareManager().GetInstSet(), sample_size, m_world->GetPopulation().GetUpdate());
+ cAnalyzeUtil::PairTestLandscape(m_world, genome, m_world->GetHardwareManager().GetInstSet(), sample_size, m_world->GetStats().GetUpdate());
}
};
@@ -2474,7 +2474,7 @@
void Process(){
cGenome & genome = m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome();
static ofstream fp("dom-test.dat");
- cAnalyzeUtil::TestGenome(m_world, genome, m_world->GetHardwareManager().GetInstSet(), fp, m_world->GetPopulation().GetUpdate());
+ cAnalyzeUtil::TestGenome(m_world, genome, m_world->GetHardwareManager().GetInstSet(), fp, m_world->GetStats().GetUpdate());
}
};
@@ -2510,7 +2510,7 @@
if( filename == "" )
auto_filename = true;
if ( auto_filename )
- filename.Set("population_info_%d.dat",m_world->GetPopulation().GetUpdate());
+ filename.Set("population_info_%d.dat",m_world->GetStats().GetUpdate());
ofstream population_info(filename());
cAnalyzeUtil::AnalyzePopulation(m_world, population_info, sample_prob, landscape, save_genotype);
}
@@ -2624,7 +2624,7 @@
if( filename == "" || filename == "AUTO" )
auto_filename = true;
if ( auto_filename )
- filename.Set("pop_dump_%d.dat",m_world->GetPopulation().GetUpdate());
+ filename.Set("pop_dump_%d.dat",m_world->GetStats().GetUpdate());
ofstream popdump(filename());
cAnalyzeUtil::GeneticDistancePopDump(m_world, popdump, creature_name(), save_genotype );
}
@@ -2656,7 +2656,7 @@
if( filename == "" )
auto_filename = true;
if ( auto_filename )
- filename.Set("tasks_%d.dat",m_world->GetPopulation().GetUpdate());
+ filename.Set("tasks_%d.dat",m_world->GetStats().GetUpdate());
ofstream snapshot_file(filename());
cAnalyzeUtil::TaskSnapshot(m_world, snapshot_file);
}
@@ -2833,7 +2833,7 @@
}
///// rate_kill /////
void Process(){
- double ave_merit = m_world->GetPopulation().GetStats().SumMerit().Average();
+ double ave_merit = m_world->GetStats().SumMerit().Average();
if ( ave_merit <= 0 )
ave_merit = 1; // make sure that we don't get NAN's or negative numbers
ave_merit /= m_world->GetConfig().AVE_TIME_SLICE.Get();
@@ -3130,11 +3130,11 @@
}
///// test_size_change_robustness /////
void Process(){
- ofstream & fp = m_world->GetPopulation().GetStats().GetDataFileOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
cAnalyzeUtil::TestInsSizeChangeRobustness(m_world, fp,
m_world->GetHardwareManager().GetInstSet(),
m_world->GetPopulation().GetGenebank().GetBestGenotype()->GetGenome(),
- num_trials, m_world->GetPopulation().GetUpdate());
+ num_trials, m_world->GetStats().GetUpdate());
}
};
@@ -3210,7 +3210,7 @@
///// dump_fitness_grid /////
void Process(){
cString filename;
- filename.Set("fgrid.%05d.out", m_world->GetPopulation().GetUpdate());
+ filename.Set("fgrid.%05d.out", m_world->GetStats().GetUpdate());
ofstream fp(filename());
for (int i = 0; i < m_world->GetPopulation().GetWorldX(); i++) {
for (int j = 0; j < m_world->GetPopulation().GetWorldY(); j++) {
@@ -3249,7 +3249,7 @@
///// dump_genotype_grid /////
void Process(){
cString filename;
- filename.Set("idgrid.%05d.out", m_world->GetPopulation().GetUpdate());
+ filename.Set("idgrid.%05d.out", m_world->GetStats().GetUpdate());
ofstream fp(filename());
for (int i = 0; i < m_world->GetPopulation().GetWorldX(); i++) {
for (int j = 0; j < m_world->GetPopulation().GetWorldY(); j++) {
@@ -3286,7 +3286,7 @@
///// dump_task_grid /////
void Process(){
cString filename;
- filename.Set("task_grid_%d.dat",m_world->GetPopulation().GetUpdate());
+ filename.Set("task_grid_%d.dat",m_world->GetStats().GetUpdate());
ofstream fp(filename());
cAnalyzeUtil::TaskGrid(m_world, fp );
}
@@ -3317,7 +3317,7 @@
///// dump_donor_grid /////
void Process(){
cString filename;
- filename.Set("donor_grid.%05d.out", m_world->GetPopulation().GetUpdate());
+ filename.Set("donor_grid.%05d.out", m_world->GetStats().GetUpdate());
ofstream fp(filename());
for (int i = 0; i < m_world->GetPopulation().GetWorldX(); i++) {
for (int j = 0; j < m_world->GetPopulation().GetWorldY(); j++) {
@@ -3355,7 +3355,7 @@
///// dump_receiver_grid /////
void Process(){
cString filename;
- filename.Set("receiver_grid.%05d.out", m_world->GetPopulation().GetUpdate());
+ filename.Set("receiver_grid.%05d.out", m_world->GetStats().GetUpdate());
ofstream fp(filename());
for (int i = 0; i < m_world->GetPopulation().GetWorldX(); i++) {
for (int j = 0; j < m_world->GetPopulation().GetWorldY(); j++) {
@@ -3392,7 +3392,7 @@
}
///// print_tree_depths /////
void Process(){
- if (filename == "") filename.Set("tree_depth.%d.dat", m_world->GetPopulation().GetUpdate());
+ if (filename == "") filename.Set("tree_depth.%d.dat", m_world->GetStats().GetUpdate());
ofstream fp(filename);
cAnalyzeUtil::PrintTreeDepths(&m_world->GetPopulation(), fp);
}
@@ -3858,7 +3858,7 @@
}
///// inject_scaled_resource /////
void Process(){
- double ave_merit = m_world->GetPopulation().GetStats().SumMerit().Average();
+ double ave_merit = m_world->GetStats().SumMerit().Average();
if ( ave_merit <= 0 )
ave_merit = 1; // make sure that we don't get NAN's or negative numbers
ave_merit /= m_world->GetConfig().AVE_TIME_SLICE.Get();
@@ -3893,7 +3893,7 @@
}
void Process()
{
- double ave_merit = m_world->GetPopulation().GetStats().SumMerit().Average();
+ double ave_merit = m_world->GetStats().SumMerit().Average();
if ( ave_merit <= 0 )
ave_merit = 1; // make sure that we don't get NAN's or negative numbers
ave_merit /= m_world->GetConfig().AVE_TIME_SLICE.Get();
Modified: development/source/main/cAvidaDriver_Population.cc
===================================================================
--- development/source/main/cAvidaDriver_Population.cc 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cAvidaDriver_Population.cc 2005-11-10 00:01:25 UTC (rev 385)
@@ -14,6 +14,7 @@
#include "cGenotype.h"
#include "cPopulationCell.h"
#include "cOrganism.h"
+#include "cStats.h"
#include "cHardwareBase.h"
#include <iostream>
@@ -43,7 +44,7 @@
if (done_flag == true) return true;
// Increment the Update.
- cStats& stats = m_world->GetPopulation().GetStats();
+ cStats& stats = m_world->GetStats();
stats.IncCurrentUpdate();
cPopulation* population = &m_world->GetPopulation();
@@ -115,7 +116,7 @@
population->CalcUpdateStats();
// No viewer; print out status for this update....
- cStats & stats = population->GetStats();
+ cStats & stats = m_world->GetStats();
cout.setf(ios::left);
cout.setf(ios::showpoint);
cout << "UD: " << setw(6) << stats.GetUpdate() << " "
Modified: development/source/main/cGenebank.cc
===================================================================
--- development/source/main/cGenebank.cc 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cGenebank.cc 2005-11-10 00:01:25 UTC (rev 385)
@@ -17,8 +17,8 @@
using namespace std;
-cGenebank::cGenebank(cWorld* world, cStats & _stats)
- : m_world(world), stats(_stats)
+cGenebank::cGenebank(cWorld* world)
+ : m_world(world), stats(world->GetStats())
{
for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
genotype_count[i] = 0;
Modified: development/source/main/cGenebank.h
===================================================================
--- development/source/main/cGenebank.h 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cGenebank.h 2005-11-10 00:01:25 UTC (rev 385)
@@ -51,7 +51,7 @@
// disabled copy constructor.
cGenebank(const cGenebank &);
public:
- cGenebank(cWorld* world, cStats & _stats);
+ cGenebank(cWorld* world);
~cGenebank();
void UpdateReset();
Modified: development/source/main/cInjectGenebank.cc
===================================================================
--- development/source/main/cInjectGenebank.cc 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cInjectGenebank.cc 2005-11-10 00:01:25 UTC (rev 385)
@@ -20,8 +20,8 @@
// cInjectGenebank
////////////////////
-cInjectGenebank::cInjectGenebank(cWorld* world, cStats & in_stats)
- : m_world(world), stats(in_stats)
+cInjectGenebank::cInjectGenebank(cWorld* world)
+ : m_world(world), stats(world->GetStats())
{
for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
inject_genotype_count[i] = 0;
@@ -271,7 +271,7 @@
{
//if(genotype->CanReproduce())
// {
- cDataFile & df = stats.GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Avida parasite dump data" );
df.WriteTimeStamp();
Modified: development/source/main/cInjectGenebank.h
===================================================================
--- development/source/main/cInjectGenebank.h 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cInjectGenebank.h 2005-11-10 00:01:25 UTC (rev 385)
@@ -49,7 +49,7 @@
cString GetLabel(int in_size, int in_num);
public:
- cInjectGenebank(cWorld* world, cStats & stats);
+ cInjectGenebank(cWorld* world);
~cInjectGenebank();
void UpdateReset();
Modified: development/source/main/cLineageControl.cc
===================================================================
--- development/source/main/cLineageControl.cc 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cLineageControl.cc 2005-11-10 00:01:25 UTC (rev 385)
@@ -25,13 +25,13 @@
// cLineageControl
/////////////////////
-cLineageControl::cLineageControl(cWorld* world, cGenebank& genebank, cStats& stats )
+cLineageControl::cLineageControl(cWorld* world, cGenebank& genebank)
: m_world(world)
, m_best_lineage(NULL)
, m_max_fitness_lineage(NULL)
, m_dominant_lineage(NULL)
, m_genebank( genebank )
- , m_stats(stats)
+ , m_stats(world->GetStats())
{
}
@@ -312,7 +312,7 @@
void cLineageControl::PrintLineageTotals(const cString &filename, bool verbose)
{
- ofstream & fp = m_stats.GetDataFileOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
assert(fp.good());
fp << m_stats.GetUpdate();
@@ -371,7 +371,7 @@
void cLineageControl::PrintLineageCurCounts(const cString & filename)
{
- ofstream & fp = m_stats.GetDataFileOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
assert(fp.good());
fp << m_stats.GetUpdate() << " ";
Modified: development/source/main/cLineageControl.h
===================================================================
--- development/source/main/cLineageControl.h 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cLineageControl.h 2005-11-10 00:01:25 UTC (rev 385)
@@ -52,7 +52,7 @@
cLineageControl( const cLineageControl & );
cLineageControl & operator=( const cLineageControl & );
public:
- cLineageControl(cWorld* world, cGenebank& genebank, cStats& stats);
+ cLineageControl(cWorld* world, cGenebank& genebank);
~cLineageControl();
Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cPopulation.cc 2005-11-10 00:01:25 UTC (rev 385)
@@ -50,19 +50,18 @@
, schedule(NULL)
, resource_count(world->GetEnvironment().GetResourceLib().GetSize())
, birth_chamber(world)
-, stats(world)
, environment(world->GetEnvironment())
, num_organisms(0)
, sync_events(false)
{
// Setup the genebank.
- genebank = new cGenebank(world, stats);
- inject_genebank = new cInjectGenebank(world, stats);
+ genebank = new cGenebank(world);
+ inject_genebank = new cInjectGenebank(world);
birth_chamber.SetGenebank(genebank);
// are we logging lineages?
if (world->GetConfig().LOG_LINEAGES.Get()) {
- lineage_control = new cLineageControl(world, *genebank, stats );
+ lineage_control = new cLineageControl(world, *genebank);
}
else lineage_control = NULL; // no lineage logging
@@ -180,19 +179,19 @@
res->GetInflowY2(), res->GetOutflowX1(),
res->GetOutflowX2(), res->GetOutflowY1(),
res->GetOutflowY2() );
- stats.SetResourceName(i, res->GetName());
+ m_world->GetStats().SetResourceName(i, res->GetName());
}
// Give stats information about the environment...
const cTaskLib & task_lib = environment.GetTaskLib();
for (int i = 0; i < task_lib.GetSize(); i++) {
const cTaskEntry & cur_task = task_lib.GetTask(i);
- stats.SetTaskName(i, cur_task.GetDesc());
+ m_world->GetStats().SetTaskName(i, cur_task.GetDesc());
}
const cInstSet & inst_set = world->GetHardwareManager().GetInstSet();
for (int i = 0; i < inst_set.GetSize(); i++) {
- stats.SetInstName(i, inst_set.GetName(i));
+ m_world->GetStats().SetInstName(i, inst_set.GetName(i));
}
// Load a clone if one is provided, otherwise setup start organism.
@@ -550,7 +549,7 @@
num_organisms++;
// Statistics...
- stats.RecordBirth(target_cell.GetID(), in_genotype->GetID(),
+ m_world->GetStats().RecordBirth(target_cell.GetID(), in_genotype->GetID(),
in_organism->GetPhenotype().ParentTrue());
}
@@ -564,7 +563,7 @@
// Statistics...
cOrganism * organism = in_cell.GetOrganism();
cGenotype * genotype = organism->GetGenotype();
- stats.RecordDeath(in_cell.GetID(), genotype->GetID(),
+ m_world->GetStats().RecordDeath(in_cell.GetID(), genotype->GetID(),
organism->GetPhenotype().GetAge());
@@ -876,13 +875,15 @@
void cPopulation::PrintDemeStats()
{
- cDataFile & df_fit = stats.GetDataFile("deme_fitness.dat");
- cDataFile & df_life_fit = stats.GetDataFile("deme_lifetime_fitness.dat");
- cDataFile & df_merit = stats.GetDataFile("deme_merit.dat");
- cDataFile & df_gest = stats.GetDataFile("deme_gest_time.dat");
- cDataFile & df_task = stats.GetDataFile("deme_task.dat");
- cDataFile & df_donor = stats.GetDataFile("deme_donor.dat");
- cDataFile & df_receiver = stats.GetDataFile("deme_receiver.dat");
+ cStats& stats = m_world->GetStats();
+
+ cDataFile & df_fit = m_world->GetDataFile("deme_fitness.dat");
+ cDataFile & df_life_fit = m_world->GetDataFile("deme_lifetime_fitness.dat");
+ cDataFile & df_merit = m_world->GetDataFile("deme_merit.dat");
+ cDataFile & df_gest = m_world->GetDataFile("deme_gest_time.dat");
+ cDataFile & df_task = m_world->GetDataFile("deme_task.dat");
+ cDataFile & df_donor = m_world->GetDataFile("deme_donor.dat");
+ cDataFile & df_receiver = m_world->GetDataFile("deme_receiver.dat");
df_fit.WriteComment("Average fitnesses for each deme in the population");
df_life_fit.WriteComment("Average life fitnesses for each deme in the population");
@@ -900,13 +901,13 @@
df_donor.WriteTimeStamp();
df_receiver.WriteTimeStamp();
- df_fit.Write(GetUpdate(), "update");
- df_life_fit.Write(GetUpdate(), "update");
- df_merit.Write(GetUpdate(), "update");
- df_gest.Write(GetUpdate(), "update");
- df_task.Write(GetUpdate(), "update");
- df_donor.Write(GetUpdate(), "update");
- df_receiver.Write(GetUpdate(), "update");
+ df_fit.Write(stats.GetUpdate(), "update");
+ df_life_fit.Write(stats.GetUpdate(), "update");
+ df_merit.Write(stats.GetUpdate(), "update");
+ df_gest.Write(stats.GetUpdate(), "update");
+ df_task.Write(stats.GetUpdate(), "update");
+ df_donor.Write(stats.GetUpdate(), "update");
+ df_receiver.Write(stats.GetUpdate(), "update");
const int num_inst = m_world->GetNumInstructions();
const int num_task = environment.GetTaskLib().GetSize();
@@ -914,13 +915,13 @@
for (int cur_deme = 0; cur_deme < num_demes; cur_deme++) {
cString filename;
filename.Set("deme_instruction-%d.dat", cur_deme);
- cDataFile & df_inst = stats.GetDataFile(filename);
+ cDataFile & df_inst = m_world->GetDataFile(filename);
cString comment;
comment.Set("Number of times each instruction is exectued in deme %d",
cur_deme);
df_inst.WriteComment(comment);
df_inst.WriteTimeStamp();
- df_inst.Write(GetUpdate(), "update");
+ df_inst.Write(stats.GetUpdate(), "update");
cDoubleSum single_deme_fitness;
cDoubleSum single_deme_life_fitness;
@@ -1113,20 +1114,12 @@
cPopulationCell & cell = GetCell(cell_id);
assert(cell.IsOccupied()); // Unoccupied cell getting processor time!
- // static ofstream debug_fp("debug.trace");
- // debug_fp << stats.GetUpdate() << " "
- // << cell.GetOrganism()->GetCellID() << " "
- // << cell.GetOrganism()->GetGenotype()->GetID() << " "
- // << m_world->GetRandom().GetDouble() << " "
- // << cell.GetOrganism()->GetHardware().GetMemory().AsString() << " "
- // << endl;
-
cOrganism * cur_org = cell.GetOrganism();
cur_org->GetHardware().SingleProcess();
if (cur_org->GetPhenotype().GetToDelete() == true) {
delete cur_org;
}
- stats.IncExecuted();
+ m_world->GetStats().IncExecuted();
resource_count.Update(step_size);
}
@@ -1142,6 +1135,8 @@
// Loop through all the cells getting stats and doing calculations
// which must be done on a creature by creature basis.
+ cStats& stats = m_world->GetStats();
+
// Clear out organism sums...
stats.SumFitness().Clear();
stats.SumGestation().Clear();
@@ -1278,13 +1273,15 @@
stats.SetResources(resource_count.GetResources());
stats.SetSpatialRes(resource_count.GetSpatialRes());
stats.SetResourcesGeometry(resource_count.GetResourcesGeometry());
- }
+}
void cPopulation::UpdateGenotypeStats()
{
// Loop through all genotypes, finding stats and doing calcuations.
+ cStats& stats = m_world->GetStats();
+
// Clear out genotype sums...
stats.SumGenotypeAge().Clear();
stats.SumAbundance().Clear();
@@ -1328,6 +1325,7 @@
void cPopulation::UpdateSpeciesStats()
{
+ cStats& stats = m_world->GetStats();
double species_entropy = 0.0;
stats.SumSpeciesAge().Clear();
@@ -1374,6 +1372,7 @@
void cPopulation::UpdateDominantStats()
{
+ cStats& stats = m_world->GetStats();
cGenotype * dom_genotype = genebank->GetBestGenotype();
if (dom_genotype == NULL) return;
@@ -1399,6 +1398,7 @@
void cPopulation::UpdateDominantParaStats()
{
+ cStats& stats = m_world->GetStats();
cInjectGenotype * dom_inj_genotype = inject_genebank->GetBestInjectGenotype();
if (dom_inj_genotype == NULL) return;
@@ -1424,6 +1424,7 @@
void cPopulation::CalcUpdateStats()
{
+ cStats& stats = m_world->GetStats();
// Reset the Genebank to prepare it for stat collection.
genebank->UpdateReset();
@@ -1449,7 +1450,7 @@
if (fp.good() == false) return false;
// Save the current update
- fp << stats.GetUpdate() << " ";
+ fp << m_world->GetStats().GetUpdate() << " ";
// Save the genebank info.
genebank->SaveClone(fp);
@@ -1486,7 +1487,7 @@
int cur_update;
fp >> cur_update;
- stats.SetCurrentUpdate(cur_update);
+ m_world->GetStats().SetCurrentUpdate(cur_update);
// Clear out the population
for (int i = 0; i < cell_array.GetSize(); i++) KillOrganism(cell_array[i]);
@@ -1552,7 +1553,7 @@
{
// set the update if requested
if ( update >= 0 )
- stats.SetCurrentUpdate(update);
+ m_world->GetStats().SetCurrentUpdate(update);
// Clear out the population
for (int i = 0; i < cell_array.GetSize(); i++) KillOrganism(cell_array[i]);
@@ -1593,10 +1594,10 @@
cGenome genome( cur_line.PopWord() );
// we don't allow birth or death times larger than the current update
- if ( stats.GetUpdate() > tmp.update_born )
- tmp.update_born = stats.GetUpdate();
- if ( stats.GetUpdate() > tmp.update_dead )
- tmp.update_dead = stats.GetUpdate();
+ if ( m_world->GetStats().GetUpdate() > tmp.update_born )
+ tmp.update_born = m_world->GetStats().GetUpdate();
+ if ( m_world->GetStats().GetUpdate() > tmp.update_dead )
+ tmp.update_dead = m_world->GetStats().GetUpdate();
tmp.genotype =
new cGenotype(m_world, tmp.update_born, tmp.id_num);
@@ -1627,7 +1628,7 @@
(*it).genotype->SetParent( parent, NULL );
}
- int cur_update = stats.GetUpdate();
+ int cur_update = m_world->GetStats().GetUpdate();
int current_cell = 0;
bool soup_full = false;
it = genotype_vect.begin();
@@ -1637,9 +1638,9 @@
// remove immediately, so that it gets transferred into the
// historic database. We change the update temporarily to the
// true death time of this organism, so that all stats are correct.
- stats.SetCurrentUpdate( (*it).update_dead );
+ m_world->GetStats().SetCurrentUpdate( (*it).update_dead );
genebank->RemoveGenotype( *(*it).genotype );
- stats.SetCurrentUpdate( cur_update );
+ m_world->GetStats().SetCurrentUpdate( cur_update );
}
else{ // otherwise, we insert as many organisms as we need
for ( int i=0; i<(*it).num_cpus; i++ ){
@@ -1682,7 +1683,7 @@
if (fp.good() == false) return false;
// Save the update
- fp << stats.GetUpdate() << endl;
+ fp << m_world->GetStats().GetUpdate() << endl;
// looping through all cells saving state.
for (int i = 0; i < cell_array.GetSize(); i++) cell_array[i].SaveState(fp);
@@ -1698,7 +1699,7 @@
// Load Update...
int cur_update;
fp >> cur_update;
- stats.SetCurrentUpdate(cur_update);
+ m_world->GetStats().SetCurrentUpdate(cur_update);
// Clear out the current population
for (int i = 0; i < cell_array.GetSize(); i++) KillOrganism( cell_array[i] );
@@ -2025,7 +2026,7 @@
{
ofstream outfile;
outfile.open("debug.out", ofstream::app);
- outfile << stats.GetUpdate() << endl;
+ outfile << m_world->GetStats().GetUpdate() << endl;
int total=0;
cInjectGenotype * temp;
for(int x=0; x<cell_array.GetSize(); x++)
@@ -2071,17 +2072,17 @@
}
ofstream outfile;
outfile.open(filename, ofstream::app);
- outfile << stats.GetUpdate() << "\t" << ids.size() << endl;
+ outfile << m_world->GetStats().GetUpdate() << "\t" << ids.size() << endl;
outfile.close();
}
void cPopulation::PrintPhenotypeStatus(const cString & filename)
{
- cDataFile & df_phen = stats.GetDataFile(filename);
+ cDataFile & df_phen = m_world->GetDataFile(filename);
df_phen.WriteComment("Num orgs doing each task for each deme in population");
df_phen.WriteTimeStamp();
- df_phen.Write(GetUpdate(), "update");
+ df_phen.Write(m_world->GetStats().GetUpdate(), "update");
cString comment;
Modified: development/source/main/cPopulation.h
===================================================================
--- development/source/main/cPopulation.h 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cPopulation.h 2005-11-10 00:01:25 UTC (rev 385)
@@ -19,10 +19,7 @@
#ifndef RESOURCE_COUNT_HH
#include "cResourceCount.h"
#endif
-#ifndef STATS_HH
-#include "cStats.h"
-#endif
-#ifndef STRING_HH
+#ifndef cString_h
#include "cString.h"
#endif
#ifndef cWorld_h
@@ -52,7 +49,6 @@
class cPopulationInterface; // aggregate
class cPopulationCell;
class cResourceCount; // aggregate
-class cStats; // aggregate
class cString; // aggregate
class cPopulation {
@@ -67,7 +63,6 @@
cBirthChamber birth_chamber; // Global birth chamber.
// Data Tracking...
- cStats stats; // Main statistics object...
cGenebank * genebank; // Tracks genotypes
cInjectGenebank * inject_genebank; // Tracks all injected code
cLineageControl * lineage_control; // Tracks Linages
@@ -172,8 +167,6 @@
int GetSize() { return cell_array.GetSize(); }
int GetWorldX() { return world_x; }
int GetWorldY() { return world_y; }
- int GetUpdate() { return stats.GetUpdate(); }
- double GetGeneration() { return stats.SumGeneration().Average(); }
cPopulationCell & GetCell(int in_num);
const tArray<double> & GetResources() const
@@ -190,7 +183,6 @@
double GetResource(int id) const {
return resource_count.Get(id); }
- cStats & GetStats() { return stats; }
cGenebank & GetGenebank() { return *genebank; }
cInjectGenebank & GetInjectGenebank() { return *inject_genebank; }
cLineageControl * GetLineageControl() { return lineage_control; }
Modified: development/source/main/cPopulationInterface.cc
===================================================================
--- development/source/main/cPopulationInterface.cc 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cPopulationInterface.cc 2005-11-10 00:01:25 UTC (rev 385)
@@ -13,6 +13,7 @@
#include "cOrgMessage.h"
#include "cPopulation.h"
#include "cPopulationCell.h"
+#include "cStats.h"
#include "cTestCPU.h"
#include <assert.h>
@@ -139,7 +140,7 @@
if (InTestPop()) return false;
mess.SetSenderID(cell_id);
- mess.SetTime(m_world->GetPopulation().GetUpdate());
+ mess.SetTime(m_world->GetStats().GetUpdate());
cPopulationCell& cell = m_world->GetPopulation().GetCell(cell_id);
if(cell.ConnectionList().GetFirst() == NULL)
return false;
Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cStats.cc 2005-11-10 00:01:25 UTC (rev 385)
@@ -221,9 +221,6 @@
cout << "Closing stats object..."<<endl;
// Close all the statistics files.
-
- data_file_manager.FlushAll();
-
fp_creature_log.close();
fp_genotype_log.close();
fp_threshold_log.close();
@@ -401,18 +398,6 @@
max_fitness = 0.0;
}
-
-void cStats::FlushFP(){
- data_file_manager.FlushAll();
-
- fp_creature_log.flush();
- fp_genotype_log.flush();
- fp_threshold_log.flush();
- fp_species_log.flush();
- fp_lineage_log.flush();
-}
-
-
void cStats::RemoveLineage(int id_num, int parent_id, int update_born,
double generation_born,
int total_CPUs, int total_genotypes, double fitness,
@@ -457,14 +442,14 @@
void cStats::PrintDataFile(const cString & filename, const cString & format,
char sep)
{
- cDataFile & data_file = GetDataFile(filename);
+ cDataFile & data_file = m_world->GetDataFile(filename);
data_manager.PrintRow(data_file, format, sep);
}
void cStats::PrintAverageData(const cString & filename)
{
- cDataFile & df = GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Avida average data" );
df.WriteTimeStamp();
@@ -494,7 +479,7 @@
void cStats::PrintErrorData(const cString & filename)
{
- ofstream & fp = GetDataFileOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
assert(fp.good());
fp<< GetUpdate() << " " // 1
<< sum_merit.StdError() << " " // 2
@@ -516,7 +501,7 @@
void cStats::PrintVarianceData(const cString & filename)
{
- ofstream & fp = GetDataFileOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
assert(fp.good());
fp<<GetUpdate() << " " // 1
<< sum_merit.Variance() << " " // 2
@@ -539,7 +524,7 @@
void cStats::PrintDominantData(const cString & filename)
{
- cDataFile & df = GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Avida dominant data" );
df.WriteTimeStamp();
@@ -565,7 +550,7 @@
void cStats::PrintDominantParaData(const cString & filename)
{
- cDataFile & df = GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Avida dominant parasite data" );
df.WriteTimeStamp();
@@ -584,7 +569,7 @@
const double log_ave_fid = (ave_fidelity > 0) ? -Log(ave_fidelity) : 0.0;
const double log_dom_fid = (dom_fidelity > 0) ? -Log(dom_fidelity) : 0.0;
- cDataFile & df = GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Generic Statistics Data" );
df.WriteTimeStamp();
@@ -605,7 +590,7 @@
void cStats::PrintCountData(const cString & filename)
{
- cDataFile & df = GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Avida count data" );
df.WriteTimeStamp();
@@ -633,7 +618,7 @@
void cStats::PrintTotalsData(const cString & filename)
{
- ofstream & fp = GetDataFileOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
assert(fp.good());
fp << GetUpdate() << " " // 1
<< (tot_executed+num_executed) << " " // 2
@@ -648,7 +633,7 @@
void cStats::PrintTasksData(const cString & filename)
{
- cDataFile & df = GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Avida tasks data" );
df.WriteTimeStamp();
@@ -666,7 +651,7 @@
void cStats::PrintTasksExeData(const cString & filename)
{
- cDataFile & df = GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Avida tasks data" );
df.WriteTimeStamp();
@@ -684,7 +669,7 @@
void cStats::PrintReactionData(const cString & filename)
{
- cDataFile & df = GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Avida tasks data" );
df.WriteTimeStamp();
@@ -701,7 +686,7 @@
void cStats::PrintResourceData(const cString & filename)
{
- cDataFile & df = GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Avida resource data" );
df.WriteTimeStamp();
@@ -725,7 +710,7 @@
cString tmpfilename = "resource_";
tmpfilename += resource_names[i] + ".m";
- cDataFile & df = GetDataFile(tmpfilename);
+ cDataFile & df = m_world->GetDataFile(tmpfilename);
cString UpdateStr = resource_names[i] +
cStringUtil::Stringf( "%07i", GetUpdate() ) + " = [ ...";
@@ -745,7 +730,7 @@
void cStats::PrintTimeData(const cString & filename)
{
- cDataFile & df = GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Avida time data" );
df.WriteTimeStamp();
@@ -760,7 +745,7 @@
void cStats::PrintMutationData(const cString & filename)
{
- ofstream & fp = GetDataFileOFStream(filename);
+ ofstream & fp = m_world->GetDataFileOFStream(filename);
assert(fp.good());
fp << GetUpdate() << " " // 1
<< isum_parent_dist.Ave() << " " // 2
@@ -806,7 +791,7 @@
void cStats::PrintMutationRateData(const cString & filename)
{
- cDataFile & df = GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Avida copy mutation rate data" );
df.WriteTimeStamp();
@@ -830,7 +815,7 @@
void cStats::PrintDivideMutData(const cString & filename)
{
- cDataFile & df = GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Avida divide mutation rate data" );
df.WriteTimeStamp();
@@ -853,7 +838,7 @@
void cStats::PrintInstructionData(const cString & filename)
{
- cDataFile & df = GetDataFile(filename);
+ cDataFile & df = m_world->GetDataFile(filename);
df.WriteComment( "Avida instruction execution data" );
df.WriteTimeStamp();
@@ -872,7 +857,7 @@
void cStats::PrintGenotypeMap(const cString & filename)
{
- cDataFile & df = cStats::GetDataFile(filename);
+ cDataFile& df = m_world->GetDataFile(filename);
cString UpdateStr =
cStringUtil::Stringf( "GenoID%07i", GetUpdate() ) + " = [ ...";
df.WriteRaw(UpdateStr);
Modified: development/source/main/cStats.h
===================================================================
--- development/source/main/cStats.h 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cStats.h 2005-11-10 00:01:25 UTC (rev 385)
@@ -15,9 +15,6 @@
#ifndef DEFS_HH
#include "defs.h"
#endif
-#ifndef cDataFileManager_h
-#include "cDataFileManager.h"
-#endif
#ifndef DOUBLE_SUM_HH
#include "cDoubleSum.h"
#endif
@@ -46,7 +43,6 @@
class cGenotype;
class cString; // aggregate
class cInjectGenotype;
-class cDataFile;
class cWorld;
class cStats {
@@ -63,9 +59,6 @@
// The data manager handles printing user-formated output files.
tDataManager<cStats> data_manager;
- // Log files are recorded every time a specified event occurs.
- cDataFileManager data_file_manager;
-
std::ofstream fp_creature_log;
std::ofstream fp_genotype_log;
std::ofstream fp_threshold_log;
@@ -260,8 +253,6 @@
bool OK() { return true; } // @CAO FIX!!!!
- void FlushFP(); // Flush all the files
-
// Accessors...
int GetUpdate() const { return current_update; }
int GetSubUpdate() const { return sub_update; }
@@ -547,13 +538,6 @@
// still stay up.
double GetMaxViableFitness() const { return max_viable_fitness; }
- // Access to data_file_manager (so cPopulation can output files)
- std::ofstream & GetDataFileOFStream(const cString & fname){
- return data_file_manager.GetOFStream(fname); }
- cDataFile & GetDataFile(const cString & fname){
- return data_file_manager.Get(fname); }
-
-
// User-defined datafile...
void PrintDataFile(const cString & filename, const cString & format,
char sep=' ');
Modified: development/source/main/cWorld.cc
===================================================================
--- development/source/main/cWorld.cc 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cWorld.cc 2005-11-10 00:01:25 UTC (rev 385)
@@ -12,12 +12,13 @@
#include "avida.h"
#include "cAvidaTriggers.h"
#include "cEnvironment.h"
+#include "cEventList.h"
#include "cEventManager.h"
#include "cHardwareManager.h"
+#include "cInitFile.h"
#include "cPopulation.h"
+#include "cStats.h"
#include "cTestCPU.h"
-#include "cEventList.h"
-#include "cInitFile.h"
#include "cTools.h"
cWorld::~cWorld()
@@ -31,6 +32,7 @@
delete m_event_list;
delete m_hw_mgr;
delete m_pop;
+ delete m_stats;
delete m_test_cpu;
}
@@ -62,11 +64,12 @@
}
m_test_cpu = new cTestCPU(this);
+ m_stats = new cStats(this);
m_pop = new cPopulation(this);
//Setup Event List
m_event_mgr = new cEventManager(this);
- m_event_list = new cEventList(m_event_mgr, new cAvidaTriggers(m_pop->GetStats()) );
+ m_event_list = new cEventList(m_event_mgr, new cAvidaTriggers(*m_stats) );
ReadEventListFile(m_conf->EVENT_FILE.Get());
Modified: development/source/main/cWorld.h
===================================================================
--- development/source/main/cWorld.h 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/main/cWorld.h 2005-11-10 00:01:25 UTC (rev 385)
@@ -25,6 +25,7 @@
class cEventList;
class cHardwareManager;
class cPopulation;
+class cStats;
class cTestCPU;
class cWorld
@@ -37,6 +38,7 @@
cEventList* m_event_list;
cHardwareManager* m_hw_mgr;
cPopulation* m_pop;
+ cStats* m_stats;
cTestCPU* m_test_cpu;
cRandom m_rng;
@@ -55,10 +57,12 @@
// General Object Accessors
cAvidaConfig& GetConfig() { return *m_conf; }
+ cDataFileManager& GetDataFileManager() { return *m_data_mgr; }
cEnvironment& GetEnvironment() { return *m_env; }
cHardwareManager& GetHardwareManager() { return *m_hw_mgr; }
cPopulation& GetPopulation() { return *m_pop; }
cRandom& GetRandom() { return m_rng; }
+ cStats& GetStats() { return *m_stats; }
cTestCPU& GetTestCPU() { return *m_test_cpu; }
// Access to Data File Manager
Modified: development/source/support/avida.cfg
===================================================================
--- development/source/support/avida.cfg 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/support/avida.cfg 2005-11-10 00:01:25 UTC (rev 385)
@@ -33,7 +33,7 @@
### CONFIG_FILE_GROUP ###
# Configuration Files
-DATA_DIR . # Directory in which config files are found
+DATA_DIR data # Directory in which config files are found
INST_SET inst_set.smt # File containing instruction set
EVENT_FILE events.cfg # File containing list of events during run
ANALYZE_FILE analyze.cfg # File used for analysis mode
Modified: development/source/tools/cDataFileManager.cc
===================================================================
--- development/source/tools/cDataFileManager.cc 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/tools/cDataFileManager.cc 2005-11-10 00:01:25 UTC (rev 385)
@@ -27,7 +27,7 @@
cDataFile* found_file;
// If it hasn't been found, create it...
- if (m_datafiles.Find(name, found_file)) {
+ if (!m_datafiles.Find(name, found_file)) {
found_file = new cDataFile(m_target_dir + name);
m_datafiles.Add(name, found_file);
}
Modified: development/source/tools/cDataFileManager.h
===================================================================
--- development/source/tools/cDataFileManager.h 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/tools/cDataFileManager.h 2005-11-10 00:01:25 UTC (rev 385)
@@ -13,6 +13,9 @@
#include <fstream>
+#ifndef cTools_h
+#include "cTools.h"
+#endif
#ifndef cDataFile_h
#include "cDataFile.h"
#endif
@@ -69,6 +72,7 @@
if (m_target_dir.GetSize() > 0) {
char dir_tail = m_target_dir[m_target_dir.GetSize() - 1];
if (dir_tail != '\\' && dir_tail != '/') m_target_dir += "/";
+ cTools::MkDir(m_target_dir, true);
}
}
Modified: development/source/tools/cDataManager_Base.cc
===================================================================
--- development/source/tools/cDataManager_Base.cc 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/tools/cDataManager_Base.cc 2005-11-10 00:01:25 UTC (rev 385)
@@ -5,46 +5,36 @@
// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
//////////////////////////////////////////////////////////////////////////////
-#ifndef DATA_MANAGER_BASE_HH
#include "cDataManager_Base.h"
-#endif
#include "cDataFile.h"
-
using namespace std;
-
-cDataManager_Base::~cDataManager_Base()
+bool cDataManager_Base::PrintRow(cDataFile& data_file, cString row_entries, char sep)
{
-}
-
-
-bool cDataManager_Base::PrintRow(cDataFile & data_file,
- cString row_entries, char sep)
-{
bool result = true;
-
+
row_entries.CompressWhitespace();
-
+
// If we haven't output the header for this file yet, do so.
if ( data_file.HeaderDone() == false ) {
// Setup the format string for the top...
cString format(row_entries);
cString out_filetype(filetype);
-
+
// Make sure its space seperated...
if (sep != ' ') {
int pos = -1;
while ( (pos = format.Find(sep)) != -1 ) format[pos] = ' ';
}
-
+
// Write out the filetype and format strip
out_filetype.Insert("#filetype ");
format.Insert("#format ");
data_file.WriteRawComment(out_filetype);
data_file.WriteRawComment(format);
-
+
// Setup the human-readable description...
cString header_entries(row_entries);
cString cur_desc;
@@ -53,29 +43,29 @@
while (header_entries.GetSize() > 0) {
cString cur_entry( header_entries.Pop(sep) );
if ( GetDesc(cur_entry, cur_desc) == false ) {
- result = false;
- continue;
+ result = false;
+ continue;
}
data_file.WriteColumnDesc(cur_desc);
}
data_file.FlushComments();
data_file.Endl();
}
-
-
+
+
ofstream & fp = data_file.GetOFStream();
while (row_entries.GetSize() > 0) {
cString cur_entry( row_entries.Pop(sep) );
if ( Print(cur_entry, fp) == false ) {
cerr << "Data manager unable to find entry '"
- << cur_entry << "'" << endl;
+ << cur_entry << "'" << endl;
result = false;
continue;
}
fp << " ";
}
fp << endl;
-
+
return result;
}
Modified: development/source/tools/cDataManager_Base.h
===================================================================
--- development/source/tools/cDataManager_Base.h 2005-11-09 21:58:15 UTC (rev 384)
+++ development/source/tools/cDataManager_Base.h 2005-11-10 00:01:25 UTC (rev 385)
@@ -22,14 +22,14 @@
cString filetype;
public:
cDataManager_Base(const cString & in_filetype) : filetype(in_filetype) { ; }
- virtual ~cDataManager_Base();
+ virtual ~cDataManager_Base() { ; }
- const cString & GetFiletype() const { return filetype; }
+ const cString& GetFiletype() const { return filetype; }
- virtual bool Print(const cString & name, std::ostream & fp) = 0;
- virtual bool GetDesc(const cString & name, cString & out_desc) = 0;
+ virtual bool Print(const cString& name, std::ostream& fp) = 0;
+ virtual bool GetDesc(const cString& name, cString& out_desc) = 0;
- bool PrintRow(cDataFile & data_file, cString row_entries, char sep=' ');
+ bool PrintRow(cDataFile& data_file, cString row_entries, char sep=' ');
};
#endif
More information about the Avida-cvs
mailing list