[Avida-SVN] r1421 - development/source/analyze
goingssh at myxo.css.msu.edu
goingssh at myxo.css.msu.edu
Thu Mar 22 11:48:17 PDT 2007
Author: goingssh
Date: 2007-03-22 14:48:17 -0400 (Thu, 22 Mar 2007)
New Revision: 1421
Modified:
development/source/analyze/cAnalyze.cc
development/source/analyze/cAnalyze.h
development/source/analyze/cAnalyzeGenotype.cc
development/source/analyze/cAnalyzeGenotype.h
Log:
Added Print_Tasks_Quality command in analyze mode that works exactly like Print_Tasks except instead of printing # times a genotype completes each task it prints the total sum quality for each task for all the times it is completed by each genotype
Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc 2007-03-22 03:08:37 UTC (rev 1420)
+++ development/source/analyze/cAnalyze.cc 2007-03-22 18:48:17 UTC (rev 1421)
@@ -1709,6 +1709,27 @@
}
}
+void cAnalyze::CommandPrintTasksQuality(cString cur_string)
+{
+ if (m_world->GetVerbosity() >= VERBOSE_ON) cout << "Printing task qualities in batch " << cur_batch << endl;
+ else cout << "Printing task qualities..." << endl;
+
+ // Load in the variables...
+ cString filename("tasksquality.dat");
+ if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
+
+ ofstream& fp = m_world->GetDataFileOFStream(filename);
+
+ // Loop through all of the genotypes in this batch...
+ tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
+ cAnalyzeGenotype * genotype = NULL;
+ while ((genotype = batch_it.Next()) != NULL) {
+ fp << genotype->GetID() << " ";
+ genotype->PrintTasksQuality(fp);
+ fp << endl;
+ }
+}
+
void cAnalyze::CommandDetail(cString cur_string)
{
if (m_world->GetVerbosity() >= VERBOSE_ON) cout << "Detailing batch " << cur_batch << endl;
@@ -7981,6 +8002,7 @@
AddLibraryDef("PRINT", &cAnalyze::CommandPrint);
AddLibraryDef("TRACE", &cAnalyze::CommandTrace);
AddLibraryDef("PRINT_TASKS", &cAnalyze::CommandPrintTasks);
+ AddLibraryDef("PRINT_TASKS_QUALITY", &cAnalyze::CommandPrintTasksQuality);
AddLibraryDef("DETAIL", &cAnalyze::CommandDetail);
AddLibraryDef("DETAIL_TIMELINE", &cAnalyze::CommandDetailTimeline);
AddLibraryDef("DETAIL_BATCHES", &cAnalyze::CommandDetailBatches);
Modified: development/source/analyze/cAnalyze.h
===================================================================
--- development/source/analyze/cAnalyze.h 2007-03-22 03:08:37 UTC (rev 1420)
+++ development/source/analyze/cAnalyze.h 2007-03-22 18:48:17 UTC (rev 1421)
@@ -198,6 +198,7 @@
void CommandTrace(cString cur_string);
void CommandTraceWithResources(cString cur_string);
void CommandPrintTasks(cString cur_string);
+ void CommandPrintTasksQuality(cString cur_string);
void CommandDetail(cString cur_string);
void CommandDetailTimeline(cString cur_string);
void CommandDetailBatches(cString cur_string);
Modified: development/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- development/source/analyze/cAnalyzeGenotype.cc 2007-03-22 03:08:37 UTC (rev 1420)
+++ development/source/analyze/cAnalyzeGenotype.cc 2007-03-22 18:48:17 UTC (rev 1421)
@@ -64,6 +64,7 @@
, fitness(0.0)
, errors(0)
, task_counts(0)
+ , task_qualities(0)
, fitness_ratio(0.0)
, efficiency_ratio(0.0)
, comp_merit_ratio(0.0)
@@ -109,6 +110,7 @@
, fitness(0.0)
, errors(0)
, task_counts(0)
+ , task_qualities(0)
, fitness_ratio(0.0)
, efficiency_ratio(0.0)
, comp_merit_ratio(0.0)
@@ -144,6 +146,7 @@
, fitness(_gen.fitness)
, errors(_gen.errors)
, task_counts(_gen.task_counts)
+ , task_qualities(_gen.task_qualities)
, fitness_ratio(_gen.fitness_ratio)
, efficiency_ratio(_gen.efficiency_ratio)
, comp_merit_ratio(_gen.comp_merit_ratio)
@@ -400,6 +403,7 @@
div_type = test_phenotype.GetDivType();
mate_id = test_phenotype.MateSelectID();
task_counts = test_phenotype.GetLastTaskCount();
+ task_qualities = test_phenotype.GetLastTaskQuality();
// Setup a new parent stats if we have a parent to work with.
if (parent_genotype != NULL) {
@@ -425,6 +429,15 @@
}
}
+void cAnalyzeGenotype::PrintTasksQuality(ofstream& fp, int min_task, int max_task)
+{
+ if (max_task == -1) max_task = task_counts.GetSize();
+
+ for (int i = min_task; i < max_task; i++) {
+ fp << task_qualities[i] << " ";
+ }
+}
+
void cAnalyzeGenotype::SetSequence(cString _sequence)
{
cGenome new_genome(_sequence);
Modified: development/source/analyze/cAnalyzeGenotype.h
===================================================================
--- development/source/analyze/cAnalyzeGenotype.h 2007-03-22 03:08:37 UTC (rev 1420)
+++ development/source/analyze/cAnalyzeGenotype.h 2007-03-22 18:48:17 UTC (rev 1421)
@@ -129,6 +129,7 @@
int mate_id;
cString executed_flags; // converted into a string
tArray<int> task_counts;
+ tArray<double> task_qualities;
// Group 3 : Stats requiring parental genotype (Also from test CPUs)
double fitness_ratio;
@@ -210,6 +211,7 @@
void Recalculate(cAvidaContext& ctx, cTestCPU* testcpu, cAnalyzeGenotype* parent_genotype = NULL, cCPUTestInfo* test_info = NULL);
void PrintTasks(std::ofstream& fp, int min_task = 0, int max_task = -1);
+ void PrintTasksQuality(std::ofstream& fp, int min_task = 0, int max_task = -1);
void CalcLandscape(cAvidaContext& ctx);
// Set...
@@ -331,6 +333,14 @@
return task_counts;
}
+ double GetTaskQuality(int task_id) const {
+ if (task_id >= task_counts.GetSize()) return 0;
+ return task_qualities[task_id];
+ }
+ const tArray<double> & GetTaskQualities() const {
+ return task_qualities;
+ }
+
// Comparisons... Compares a genotype to the "previous" one, which is
// passed in, in one specified phenotype.
// Return values are:
More information about the Avida-cvs
mailing list