[Avida-SVN] r3009 - in development: Avida.xcodeproj source/classification source/main
ruppmatt at myxo.css.msu.edu
ruppmatt at myxo.css.msu.edu
Mon Dec 8 09:22:10 PST 2008
Author: ruppmatt
Date: 2008-12-08 12:22:09 -0500 (Mon, 08 Dec 2008)
New Revision: 3009
Modified:
development/Avida.xcodeproj/project.pbxproj
development/source/classification/cClassificationManager.cc
development/source/classification/cGenotype.h
development/source/classification/cGenotypeControl.cc
development/source/classification/cGenotype_BirthData.cc
development/source/classification/cGenotype_BirthData.h
development/source/main/cPhenotype.cc
development/source/main/cPhenotype.h
development/source/main/cPopulation.cc
Log:
Added generation created genotype statistic.
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2008-12-08 15:56:29 UTC (rev 3008)
+++ development/Avida.xcodeproj/project.pbxproj 2008-12-08 17:22:09 UTC (rev 3009)
@@ -1872,7 +1872,6 @@
DCC30C4D0762532C008F7A48 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 702442D70859E0B00059BD9B /* Build configuration list for PBXProject "Avida" */;
- compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 0;
mainGroup = DCC30C490762532C008F7A48;
productRefGroup = DCC3164E07626CF3008F7A48 /* Products */;
Modified: development/source/classification/cClassificationManager.cc
===================================================================
--- development/source/classification/cClassificationManager.cc 2008-12-08 15:56:29 UTC (rev 3008)
+++ development/source/classification/cClassificationManager.cc 2008-12-08 17:22:09 UTC (rev 3009)
@@ -133,6 +133,7 @@
in_genotype->SetSpecies(parent_species);
if (parent_species != NULL) parent_species->AddGenotype();
+
}
@@ -526,6 +527,8 @@
bool print_depth = false;
bool print_lineage = false;
bool print_sequence = false;
+ bool print_exec_time_born = false;
+ bool print_generation_born = false;
cStringList fields(data_fields, ',');
if (fields.HasString("id") == true) print_id = true;
@@ -543,11 +546,14 @@
if (fields.HasString("depth") == true) print_depth = true;
if (fields.HasString("lineage") == true) print_lineage = true;
if (fields.HasString("sequence") == true) print_sequence = true;
+ if (fields.HasString("exec_time_born") == true) print_exec_time_born = true;
+ if (fields.HasString("generation_born") == true) print_generation_born = true;
if (fields.HasString("all") == true) {
print_id = print_parent_id = print_parent2_id = print_parent_dist = true;
print_num_cpus = print_total_cpus = print_length = print_merit = true;
print_gest_time = print_fitness = print_update_born = true;
print_update_dead = print_depth = print_lineage = print_sequence = true;
+ print_exec_time_born = true;
}
// Print all of the header information...
@@ -569,6 +575,8 @@
if (print_depth == true) fp << "depth ";
if (print_lineage == true) fp << "lineage ";
if (print_sequence == true) fp << "sequence ";
+ if (print_exec_time_born == true) fp << "exec_time_born";
+ if (print_generation_born == true) fp << "generation_born";
fp << endl;
// Print extra information about what data is in this file...
@@ -595,6 +603,8 @@
if (print_depth) fp << "# " << cur_col++ << ": depth in phylogentic tree" << endl;
if (print_lineage) fp << "# " << cur_col++ << ": lineage label of genotype" << endl;
if (print_sequence) fp << "# " << cur_col++ << ": genome of genotype" << endl;
+ if (print_exec_time_born) fp << "#" << cur_col++ << ": number of instructions executed at birth since ancestor injection" << endl;
+ if (print_generation_born) fp << "#" << cur_col++ << ": first generation number of genotype" << endl;
fp << endl;
// Print the current population....
@@ -617,6 +627,8 @@
if (print_depth) fp << genotype->GetDepth() << " ";
if (print_lineage) fp << genotype->GetLineageLabel() << " ";
if (print_sequence) fp << genotype->GetGenome().AsString() << " ";
+ if (print_exec_time_born) fp << genotype->GetExecTimeBorn() << " ";
+ if (print_generation_born) fp << genotype->GetGenerationBorn() << " ";
fp << endl;
m_genotype_ctl->Next(0);
}
@@ -653,6 +665,8 @@
if (print_depth) fp << genotype->GetDepth() << " ";
if (print_lineage) fp << genotype->GetLineageLabel() << " ";
if (print_sequence) fp << genotype->GetGenome().AsString() << " ";
+ if (print_exec_time_born) fp << genotype->GetExecTimeBorn() << " ";
+ if (print_generation_born) fp << genotype->GetGenerationBorn() << " ";
fp << endl;
// Move to the next genotype...
Modified: development/source/classification/cGenotype.h
===================================================================
--- development/source/classification/cGenotype.h 2008-12-08 15:56:29 UTC (rev 3008)
+++ development/source/classification/cGenotype.h 2008-12-08 17:22:09 UTC (rev 3009)
@@ -143,6 +143,8 @@
void IncDeferAdjust() { defer_adjust++; }
void DecDeferAdjust() { defer_adjust--; assert(defer_adjust >= 0); }
void SetLineageLabel(int in_label) { birth_data.lineage_label = in_label; }
+ void SetExecTimeBorn(int in_exec_born) { birth_data.exec_born = in_exec_born;} //@MRR
+ void SetGenerationBorn(int in_gen_born) {birth_data.generation_born = in_gen_born;} //@MRR
// Setting New Stats
void AddCopiedSize(int in) { sum_copied_size.Add(in); }
@@ -220,7 +222,9 @@
bool GetThreshold() const { return flag_threshold; }
int GetID() const { return id_num; }
char GetSymbol() const { return symbol; }
- int GetMapColor() const { return map_color_id; }
+ int GetMapColor() const { return map_color_id; }
+ int GetExecTimeBorn() const { return birth_data.exec_born; } //@MRR
+ int GetGenerationBorn() const { return birth_data.generation_born; } //@MRR
// Calculate a crude phylogentic distance based off of tracking parents
// and grand-parents, including sexual tracking.
Modified: development/source/classification/cGenotypeControl.cc
===================================================================
--- development/source/classification/cGenotypeControl.cc 2008-12-08 15:56:29 UTC (rev 3008)
+++ development/source/classification/cGenotypeControl.cc 2008-12-08 17:22:09 UTC (rev 3009)
@@ -80,6 +80,11 @@
in_genotype.GetNext()->SetPrev(&in_genotype);
}
+ if (!CheckPos(in_genotype))
+ cerr << "Genotype insertion fail! @MRR -- \n"
+ << "Best Genotype: " << best << " " << best->GetNumOrganisms() << " prev: " << best->GetPrev() << " next: " << best->GetNext() << endl
+ << "In Genotype: " << &in_genotype << " " << in_genotype.GetNumOrganisms() << " prev: " << in_genotype.GetPrev() << " next: " << in_genotype.GetNext() << endl
+ << "Prev Genotype: " << prev_genotype << " " << prev_genotype->GetNumOrganisms() << " prev: " << prev_genotype->GetPrev() << " next: " << prev_genotype->GetNext() << endl;
size++;
}
Modified: development/source/classification/cGenotype_BirthData.cc
===================================================================
--- development/source/classification/cGenotype_BirthData.cc 2008-12-08 15:56:29 UTC (rev 3008)
+++ development/source/classification/cGenotype_BirthData.cc 2008-12-08 17:22:09 UTC (rev 3009)
@@ -29,6 +29,8 @@
: update_born(in_update_born)
, parent_distance(-1)
, gene_depth(0)
+ , exec_born(-1)
+ , generation_born(-1)
, update_deactivated(-1)
, parent_genotype(NULL)
, parent_species(NULL)
Modified: development/source/classification/cGenotype_BirthData.h
===================================================================
--- development/source/classification/cGenotype_BirthData.h 2008-12-08 15:56:29 UTC (rev 3008)
+++ development/source/classification/cGenotype_BirthData.h 2008-12-08 17:22:09 UTC (rev 3009)
@@ -51,7 +51,9 @@
int parent_distance; // Genetic distance from parent genotype
int gene_depth; // depth in the phylogenetic tree from ancestor
int lineage_label; // Unique label for the lineage of this genotype.
-
+ int exec_born; // @MRR Number of instruction executions from start
+ int generation_born; // @MRR Generation genotype created
+
int update_deactivated; // If not, when did it get deactivated?
cGenotype* parent_genotype; // Pointer to parent genotype...
cGenotype* parent2_genotype; // Pointer to secondary parent genotype...
Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc 2008-12-08 15:56:29 UTC (rev 3008)
+++ development/source/main/cPhenotype.cc 2008-12-08 17:22:09 UTC (rev 3009)
@@ -173,7 +173,8 @@
fault_desc = in_phen.fault_desc;
neutral_metric = in_phen.neutral_metric;
life_fitness = in_phen.life_fitness;
-
+ exec_time_born = in_phen.exec_time_born;
+ birth_update = in_phen.birth_update;
// 5. Status Flags... (updated at each divide)
to_die = in_phen.to_die;
@@ -371,7 +372,9 @@
fault_desc = "";
neutral_metric = parent_phenotype.neutral_metric + m_world->GetRandom().GetRandNormal();
life_fitness = fitness;
-
+ exec_time_born = parent_phenotype.exec_time_born; //@MRR treating offspring and parent as siblings; already set in DivideReset
+ birth_update = parent_phenotype.birth_update;
+
num_thresh_gb_donations = 0;
num_thresh_gb_donations_last = parent_phenotype.num_thresh_gb_donations_last;
num_quanta_thresh_gb_donations = 0;
@@ -526,7 +529,9 @@
age = 0;
fault_desc = "";
neutral_metric = 0;
- life_fitness = 0;
+ life_fitness = 0;
+ exec_time_born = 0;
+ birth_update = m_world->GetStats().GetUpdate();
num_thresh_gb_donations = 0;
num_thresh_gb_donations_last = 0;
@@ -683,6 +688,8 @@
fault_desc = "";
(void) neutral_metric;
life_fitness = fitness;
+ exec_time_born += gestation_time; //@MRR Treating organism as sibling
+ birth_update = m_world->GetStats().GetUpdate();
num_thresh_gb_donations_last = num_thresh_gb_donations;
num_thresh_gb_donations = 0;
@@ -839,6 +846,8 @@
(void) fault_desc;
(void) neutral_metric;
life_fitness = fitness;
+ exec_time_born += gestation_time; //@MRR See DivideReset
+ birth_update = m_world->GetStats().GetUpdate();
num_thresh_gb_donations_last = num_thresh_gb_donations;
num_thresh_gb_donations = 0;
@@ -988,6 +997,8 @@
fault_desc = "";
neutral_metric = clone_phenotype.neutral_metric + m_world->GetRandom().GetRandNormal();
life_fitness = fitness;
+ exec_time_born = 0;
+ birth_update = m_world->GetStats().GetUpdate();
num_thresh_gb_donations_last = clone_phenotype.num_thresh_gb_donations_last;
num_thresh_gb_donations = clone_phenotype.num_thresh_gb_donations;
@@ -1515,6 +1526,7 @@
fault_desc = "";
(void) neutral_metric;
life_fitness = fitness;
+
num_thresh_gb_donations_last = num_thresh_gb_donations;
num_thresh_gb_donations = 0;
Modified: development/source/main/cPhenotype.h
===================================================================
--- development/source/main/cPhenotype.h 2008-12-08 15:56:29 UTC (rev 3008)
+++ development/source/main/cPhenotype.h 2008-12-08 17:22:09 UTC (rev 3009)
@@ -169,7 +169,10 @@
double neutral_metric; // Undergoes drift (gausian 0,1) per generation
double life_fitness; // Organism fitness during its lifetime,
// calculated based on merit just before the divide
-
+ int exec_time_born; // @MRR number of instructions since seed ancestor start
+ double gmu_exec_time_born; //@MRR mutation-rate and gestation time scaled time of birth
+ int birth_update; // @MRR update *organism* born
+
// 5. Status Flags... (updated at each divide)
bool to_die; // Has organism has triggered something fatal?
bool to_delete; // Should this organism be deleted when finished?
@@ -316,6 +319,13 @@
int GetDiscreteEnergyLevel() const;
double GetEnergyInBufferAmount() const { return energy_received_buffer; }
+ //@MRR Organism-specific birth tracking
+ double GetGMuExecTimeBorn() const {return gmu_exec_time_born;}
+ int GetExecTimeBorn() const {return exec_time_born;}
+ int GetUpdateBorn() const {return birth_update;}
+
+
+
bool GetToDie() const { assert(initialized == true); return to_die; }
bool GetToDelete() const { assert(initialized == true); return to_delete; }
int GetCurNumErrors() const { assert(initialized == true); return cur_num_errors; }
Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc 2008-12-08 15:56:29 UTC (rev 3008)
+++ development/source/main/cPopulation.cc 2008-12-08 17:22:09 UTC (rev 3009)
@@ -525,6 +525,17 @@
in_genotype->AddOrganism();
+ //@MRR If this is a new genotype, then store it's exec_birth here
+ //Assuming that all new genotypes must go through this function, AddOrganism()
+ //above should increment a new genotype's total organism count to 1
+ //The in_genotype's phenotype should have been set by cPhenotype::SetupOffspring
+ //by this point.
+ if (in_genotype->GetTotalOrganisms() == 1)
+ {
+ in_genotype->SetExecTimeBorn(in_organism->GetPhenotype().GetExecTimeBorn());
+ in_genotype->SetGenerationBorn(in_organism->GetPhenotype().GetGeneration());
+ }
+
if (old_genotype != NULL) {
old_genotype->DecDeferAdjust();
m_world->GetClassificationManager().AdjustGenotype(*old_genotype);
More information about the Avida-cvs
mailing list