[Avida-cvs] [avida-svn] r804 - development/source/analyze
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Thu Jul 6 10:55:09 PDT 2006
Author: brysonda
Date: 2006-07-06 13:55:09 -0400 (Thu, 06 Jul 2006)
New Revision: 804
Modified:
development/source/analyze/cAnalyze.cc
development/source/analyze/cAnalyze.h
Log:
Add analyze command TruncateLineage. This command performs a find lineage, recalculates the batch, and then truncates the lineage after a particular point. Currently the only truncation option is the emergence of a task, the default being the last task in the environment. The first organism performing the task is left at the end of the lineage within the current batch.
TruncateLineage [task task_id='last in env'] [lineage_type='num_cpus']
Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc 2006-07-05 15:26:09 UTC (rev 803)
+++ development/source/analyze/cAnalyze.cc 2006-07-06 17:55:09 UTC (rev 804)
@@ -1565,8 +1565,38 @@
batch[cur_batch].SetAligned(false);
}
+void cAnalyze::TruncateLineage(cString cur_string)
+{
+ cString type("task");
+ int arg_i = -1;
+ if (cur_string.GetSize()) type = cur_string.PopWord();
+ if (type == "task") {
+ if (cur_string.GetSize()) arg_i = cur_string.PopWord().AsInt();
+ const int env_size = m_world->GetEnvironment().GetTaskLib().GetSize();
+ if (arg_i < 0 || arg_i >= env_size) arg_i = env_size - 1;
+ }
+ cString lin_type("num_cpus");
+ if (cur_string.GetSize()) lin_type = cur_string.PopWord();
+ FindLineage(lin_type);
+ BatchRecalculate("");
+ if (type == "task") {
+ bool found = false;
+ tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
+ cAnalyzeGenotype* genotype = NULL;
+
+ while (genotype = batch_it.Next()) {
+ if (found) {
+ batch_it.Remove();
+ delete genotype;
+ continue;
+ }
+ if (genotype->GetTaskCount(arg_i)) found = true;
+ }
+ }
+}
+
//////////////// Output Commands...
void cAnalyze::CommandPrint(cString cur_string)
@@ -7662,6 +7692,7 @@
AddLibraryDef("SAMPLE_ORGANISMS", &cAnalyze::SampleOrganisms);
AddLibraryDef("SAMPLE_GENOTYPES", &cAnalyze::SampleGenotypes);
AddLibraryDef("KEEP_TOP", &cAnalyze::KeepTopGenotypes);
+ AddLibraryDef("TRUNCATELINEAGE", &cAnalyze::TruncateLineage);
// Direct output commands...
AddLibraryDef("PRINT", &cAnalyze::CommandPrint);
Modified: development/source/analyze/cAnalyze.h
===================================================================
--- development/source/analyze/cAnalyze.h 2006-07-05 15:26:09 UTC (rev 803)
+++ development/source/analyze/cAnalyze.h 2006-07-06 17:55:09 UTC (rev 804)
@@ -160,6 +160,7 @@
void SampleOrganisms(cString cur_string);
void SampleGenotypes(cString cur_string);
void KeepTopGenotypes(cString cur_string);
+ void TruncateLineage(cString cur_string);
// Direct Output Commands...
void CommandPrint(cString cur_string);
More information about the Avida-cvs
mailing list