[Avida-SVN] r2589 - in branches/matt/CladeTracking/source: classification main
matt at myxo.css.msu.edu
matt at myxo.css.msu.edu
Wed May 21 12:11:03 PDT 2008
Author: matt
Date: 2008-05-21 15:11:02 -0400 (Wed, 21 May 2008)
New Revision: 2589
Modified:
branches/matt/CladeTracking/source/classification/cClassificationManager.cc
branches/matt/CladeTracking/source/classification/cGenotypeControl.cc
branches/matt/CladeTracking/source/classification/cGenotypeControl.h
branches/matt/CladeTracking/source/main/cStats.cc
branches/matt/CladeTracking/source/main/cStats.h
Log:
Added support to gather coalescence time and genotype ID to the cStats object.
Modified: branches/matt/CladeTracking/source/classification/cClassificationManager.cc
===================================================================
--- branches/matt/CladeTracking/source/classification/cClassificationManager.cc 2008-05-20 19:47:26 UTC (rev 2588)
+++ branches/matt/CladeTracking/source/classification/cClassificationManager.cc 2008-05-21 19:11:02 UTC (rev 2589)
@@ -274,8 +274,8 @@
parent->RemoveOffspringGenotype();
// Test to see if we need to update the coalescent genotype.
- const int new_coal = m_genotype_ctl->UpdateCoalescent();
- m_world->GetStats().SetCoalescentGenotypeDepth(new_coal);
+ const cGenotype* new_coal = m_genotype_ctl->UpdateCoalescent();
+ m_world->GetStats().SetCoalescentGenotype(new_coal);
if (parent->GetNumOrganisms() == 0) {
// Regardless, run RemoveGenotype on the parent.
@@ -287,8 +287,8 @@
parent2->RemoveOffspringGenotype();
// Test to see if we need to update the coalescent genotype.
- const int new_coal = m_genotype_ctl->UpdateCoalescent();
- m_world->GetStats().SetCoalescentGenotypeDepth(new_coal);
+ const cGenotype* new_coal = m_genotype_ctl->UpdateCoalescent();
+ m_world->GetStats().SetCoalescentGenotype(new_coal);
if (parent2->GetNumOrganisms() == 0) {
// Regardless, run RemoveGenotype on the parent.
Modified: branches/matt/CladeTracking/source/classification/cGenotypeControl.cc
===================================================================
--- branches/matt/CladeTracking/source/classification/cGenotypeControl.cc 2008-05-20 19:47:26 UTC (rev 2588)
+++ branches/matt/CladeTracking/source/classification/cGenotypeControl.cc 2008-05-21 19:11:02 UTC (rev 2589)
@@ -132,17 +132,17 @@
}
-int cGenotypeControl::UpdateCoalescent()
+const cGenotype* cGenotypeControl::UpdateCoalescent()
{
// Test to see if any updating needs to be done...
// Don't update active coalescent genotype, or if there is more than
// one offspring.
if (coalescent != NULL && (coalescent->GetNumOrganisms() > 0 || coalescent->GetNumOffspringGenotypes() > 1)) {
- return coalescent->GetDepth();
+ return coalescent;
}
// If there is no best, there is nothing to search through...
- if (best == NULL) return -1;
+ if (best == NULL) return NULL;
// Find the new point...
cGenotype* test_gen = best;
@@ -162,7 +162,7 @@
coalescent = found_gen;
- return coalescent->GetDepth();
+ return coalescent;
}
Modified: branches/matt/CladeTracking/source/classification/cGenotypeControl.h
===================================================================
--- branches/matt/CladeTracking/source/classification/cGenotypeControl.h 2008-05-20 19:47:26 UTC (rev 2588)
+++ branches/matt/CladeTracking/source/classification/cGenotypeControl.h 2008-05-21 19:11:02 UTC (rev 2589)
@@ -65,7 +65,7 @@
void InsertHistoric(cGenotype & in_genotype);
int GetHistoricCount() { return historic_count; }
- int UpdateCoalescent();
+ const cGenotype* UpdateCoalescent();
inline int GetSize() const { return size; }
inline cGenotype * GetBest() const { return best; }
Modified: branches/matt/CladeTracking/source/main/cStats.cc
===================================================================
--- branches/matt/CladeTracking/source/main/cStats.cc 2008-05-20 19:47:26 UTC (rev 2588)
+++ branches/matt/CladeTracking/source/main/cStats.cc 2008-05-21 19:11:02 UTC (rev 2589)
@@ -84,7 +84,10 @@
, dom_abundance(0)
, dom_gene_depth(-1)
, dom_sequence("")
+ , coal_genotype(NULL)
+ , coal_genotype_id(-1)
, coal_depth(0)
+ , coal_time(-1)
, num_births(0)
, num_deaths(0)
, num_breed_in(0)
@@ -231,6 +234,34 @@
SetupPrintDatabase();
}
+/*
+ * cStats:SetCoalescentGenotype
+ *
+ * Set the current coalescent genotype. All updates handling
+ * information about this genotype in cStats should be set by this
+ * method in order to maintain consistancy throughout the cStats object.
+ * If the genotype pointer is NULL, then set the genotype statistics
+ * to their default (invalid) values. If the coalescent genotype is
+ * ID is identical to the current one, do nothing.
+ * @MRR May 2008
+ *
+*/
+void cStats::SetCoalescentGenotype(const cGenotype* gen)
+{
+ if (gen != NULL && gen->GetID() != coal_genotype_id){
+ coal_genotype = gen;
+ coal_genotype_id = gen->GetID();
+ coal_depth = gen->GetDepth();
+ coal_time = GetUpdate();
+ }
+ else{
+ coal_genotype = NULL;
+ coal_genotype_id = -1;
+ coal_depth = -1;
+ coal_time = -1;
+ }
+}
+
void cStats::SetupPrintDatabase()
{
// Load in all the keywords, descriptions, and associated functions for
@@ -248,6 +279,8 @@
data_manager.Add("richness", "Number of Different Genotypes (Richness)", &cStats::GetNumGenotypes);
data_manager.Add("eveness", "Equitability of Genotype Distribution (Evenness)", &cStats::GetEvenness);
data_manager.Add("coal_depth", "Depth of Coalescent Genotype", &cStats::GetCoalescentDepth);
+ data_manager.Add("coal_time", "Time of Most Recent Coalescence", &cStats::GetCoalescentTime);
+ data_manager.Add("coal_gen_id", "Genotype ID of Most Recent Common Ancestor", &cStats::GetCoalescentGenotypeID);
data_manager.Add("num_resamplings", "Total Number of resamplings this time step", &cStats::GetResamplings);
data_manager.Add("num_failedResamplings", "Total Number of divide commands that reached the resampling hard-cap this time step", &cStats::GetFailedResamplings);
Modified: branches/matt/CladeTracking/source/main/cStats.h
===================================================================
--- branches/matt/CladeTracking/source/main/cStats.h 2008-05-20 19:47:26 UTC (rev 2588)
+++ branches/matt/CladeTracking/source/main/cStats.h 2008-05-21 19:11:02 UTC (rev 2589)
@@ -174,7 +174,10 @@
int dom_abundance;
int dom_gene_depth;
cString dom_sequence;
+ const cGenotype* coal_genotype;
+ int coal_genotype_id;
int coal_depth;
+ int coal_time;
// Dominant Parasite
cInjectGenotype * dom_inj_genotype;
@@ -363,8 +366,12 @@
void SetDomInjSequence(const cString & in_inj_sequence) { dom_inj_sequence = in_inj_sequence; }
void SetGenoMapElement(int i, int in_geno) { genotype_map[i] = in_geno; }
+ void SetCoalescentGenotypeID(int gid) {coal_genotype_id = gid;}
void SetCoalescentGenotypeDepth(int in_depth) {coal_depth = in_depth;}
-
+ void SetCoalescentGenotypeTime(int in_time) {coal_time = in_time;}
+ void SetCoalescentGenotype(const cGenotype* in_genotype);
+
+
inline void SetNumGenotypes(int new_genotypes);
inline void SetNumCreatures(int new_creatures);
inline void SetNumThreshSpecies(int new_thresh_species);
@@ -620,8 +627,10 @@
double GetSpeciesEntropy() const { return species_entropy; }
double GetEnergy() const { return energy; }
double GetEvenness() const { return entropy / Log(num_genotypes); }
- int GetCoalescentDepth() const { return coal_depth; }
-
+ int GetCoalescentGenotypeID() const { return coal_genotype_id; }
+ int GetCoalescentDepth() const { return coal_depth; }
+ int GetCoalescentTime() const { return coal_time; }
+
double GetAveThresholdAge() const { return sum_threshold_age.Average(); }
double GetAveSpeciesAge() const { return sum_species_age.Average(); }
More information about the Avida-cvs
mailing list