[Avida-SVN] r1324 - development/source/analyze
barrick at myxo.css.msu.edu
barrick at myxo.css.msu.edu
Tue Feb 13 10:36:42 PST 2007
Author: barrick
Date: 2007-02-13 13:36:42 -0500 (Tue, 13 Feb 2007)
New Revision: 1324
Modified:
development/source/analyze/cAnalyze.cc
development/source/analyze/cAnalyzeGenotype.cc
development/source/analyze/cAnalyzeGenotype.h
Log:
(1) Added new TestCPU resource options to a few more analyze commands.
(2) Analyze can now output "-_+" containing strings that report whether each instruction was executed. The stat names are "executed_flags" and "alignment_executed_flags".
Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc 2007-02-13 14:08:21 UTC (rev 1323)
+++ development/source/analyze/cAnalyze.cc 2007-02-13 18:36:42 UTC (rev 1324)
@@ -445,18 +445,18 @@
// Process the resource.dat, currently assuming this is the only possible
// input file
ifstream resourceFile(filename, ios::in);
- assert(resourceFile);
+ assert(resourceFile.good());
// Read in each line of the resource file and process it
char line[2048];
while(!resourceFile.eof()) {
resourceFile.getline(line, 2047);
- if(line[0] == '\0') { continue; }
-
+
// Get rid of the whitespace at the beginning of the stream, then
// see if the line begins with a #, if so move on to the next line.
stringstream ss;
- ss << line; ss >> ws; if(ss.peek() == '#') { continue; }
+ ss << line; ss >> ws;
+ if( (ss.peek() == '#') || (!ss.good()) ) { continue; }
// Read the update number from the stream
int update;
@@ -4281,7 +4281,9 @@
cStringList arg_list(cur_string);
cout << "Found " << arg_list.GetSize() << " args." << endl;
-
+
+ int useResources = 0;
+
// Check for some command specific variables.
if (arg_list.PopString("0") != "") print_mode = 0;
if (arg_list.PopString("1") != "") print_mode = 1;
@@ -4289,7 +4291,11 @@
if (arg_list.PopString("html") != "") file_type = FILE_TYPE_HTML;
if (arg_list.PopString("link_maps") != "") link_maps = true;
if (arg_list.PopString("link_insts") != "") link_insts = true;
-
+ if (arg_list.PopString("use_resources=2") != "")
+ {
+ useResources = 2;
+ }
+
cout << "There are " << arg_list.GetSize() << " column args." << endl;
LoadGenotypeDataList(arg_list, output_list);
@@ -4355,8 +4361,9 @@
}
// Calculate the stats for the genotype we're working with...
+ m_testcpu->InitResources(useResources, &resources);
genotype->Recalculate(m_ctx, m_testcpu);
-
+
// Headers...
if (file_type == FILE_TYPE_TEXT) {
fp << "-1 " << batch[cur_batch].Name() << " "
@@ -4474,6 +4481,7 @@
mod_genome[line_num] = null_inst;
cAnalyzeGenotype test_genotype(m_world, mod_genome, map_inst_set);
+ m_testcpu->InitResources(useResources, &resources);
test_genotype.Recalculate(m_ctx, m_testcpu);
if (file_type == FILE_TYPE_HTML) fp << "<tr><td align=right>";
@@ -4498,6 +4506,10 @@
data_command->SetTarget(&test_genotype);
test_genotype.SetSpecialArgs(data_command->GetArgs());
int compare = data_command->Compare(genotype);
+
+ // BUG! Either of the next two conditional print commands can
+ // cause landscaping to be triggered in a context that causes a crash,
+ // notably, if you don't provide any column parameters to MapTasks.. @JEB
if (file_type == FILE_TYPE_HTML) {
data_command->HTMLPrint(fp, compare,
!(data_command->HasArg("blank")));
@@ -7801,7 +7813,7 @@
genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
("sequence", "Genome Sequence",
&cAnalyzeGenotype::GetSequence, &cAnalyzeGenotype::SetSequence,
- &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
+ &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, const cString &>
("alignment", "Aligned Sequence",
&cAnalyzeGenotype::GetAlignedSequence,
@@ -7809,6 +7821,17 @@
&cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
+ ("executed_flags", "Executed Flags",
+ &cAnalyzeGenotype::GetExecutedFlags,
+ (void (cAnalyzeGenotype::*)(cString)) NULL,
+ &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
+ genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
+ ("alignment_executed_flags", "Alignment Executed Flags",
+ &cAnalyzeGenotype::GetAlignmentExecutedFlags,
+ (void (cAnalyzeGenotype::*)(cString)) NULL,
+ &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
+
+ genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
("task_list", "List of all tasks performed",
&cAnalyzeGenotype::GetTaskList,
(void (cAnalyzeGenotype::*)(cString)) NULL,
Modified: development/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- development/source/analyze/cAnalyzeGenotype.cc 2007-02-13 14:08:21 UTC (rev 1323)
+++ development/source/analyze/cAnalyzeGenotype.cc 2007-02-13 18:36:42 UTC (rev 1324)
@@ -27,6 +27,7 @@
#include "cAvidaContext.h"
#include "cCPUTestInfo.h"
+#include "cHardwareBase.h"
#include "cHardwareManager.h"
#include "cInstSet.h"
#include "cOrganism.h"
@@ -387,6 +388,8 @@
cOrganism* test_organism = test_info->GetTestOrganism();
cPhenotype& test_phenotype = test_organism->GetPhenotype();
+ SetExecutedFlags(test_organism->GetHardware().GetMemory());
+
length = test_organism->GetGenome().GetSize();
copy_length = test_phenotype.GetCopiedSize();
exe_length = test_phenotype.GetExecutedSize();
@@ -428,6 +431,32 @@
genome = new_genome;
}
+void cAnalyzeGenotype::SetExecutedFlags(cCPUMemory & cpu_memory)
+{
+ cString new_executed_flags;
+ for (int i=0; i<cpu_memory.GetSize(); i++)
+ {
+ new_executed_flags += (cpu_memory.FlagExecuted(i)) ? "+" : "-";
+ }
+ executed_flags = new_executed_flags;
+}
+
+
+cString cAnalyzeGenotype::GetAlignmentExecutedFlags() const
+{
+ // Make this on the fly from executed flags
+ // and the genome sequence, inserting gaps...
+ cString aligned_executed_flags = GetExecutedFlags();
+ cString aligned_seq = GetAlignedSequence();
+
+ for (int i=0; i<aligned_seq.GetSize(); i++)
+ {
+ if (aligned_seq[i] == '_') aligned_executed_flags.Insert("_", i);
+ }
+
+ return aligned_executed_flags;
+}
+
int cAnalyzeGenotype::GetKO_DeadCount() const
{
CalcKnockouts(false); // Make sure knockouts are calculated
Modified: development/source/analyze/cAnalyzeGenotype.h
===================================================================
--- development/source/analyze/cAnalyzeGenotype.h 2007-02-13 14:08:21 UTC (rev 1323)
+++ development/source/analyze/cAnalyzeGenotype.h 2007-02-13 18:36:42 UTC (rev 1324)
@@ -31,6 +31,9 @@
#ifndef functions_h
#include "functions.h"
#endif
+#ifndef cCPUMemory_h
+#include "cCPUMemory.h"
+#endif
#ifndef cGenome_h
#include "cGenome.h"
#endif
@@ -124,7 +127,7 @@
int errors;
double div_type;
int mate_id;
-
+ cString executed_flags; // converted into a string
tArray<int> task_counts;
// Group 3 : Stats requiring parental genotype (Also from test CPUs)
@@ -211,7 +214,7 @@
// Set...
void SetSequence(cString _sequence);
-
+ void SetExecutedFlags(cCPUMemory & cpu_memory);
void SetName(const cString & _name) { name = _name; }
void SetAlignedSequence(const cString & _seq) { aligned_sequence = _seq; }
void SetTag(const cString & _tag) { tag = _tag; }
@@ -251,6 +254,8 @@
const cGenome & GetGenome() const { return genome; }
const cString & GetName() const { return name; }
const cString & GetAlignedSequence() const { return aligned_sequence; }
+ cString GetExecutedFlags() const { return executed_flags; }
+ cString GetAlignmentExecutedFlags() const;
const cString & GetTag() const { return tag; }
bool GetViable() const { return viable; }
More information about the Avida-cvs
mailing list