[Avida-SVN] r3206 - in development: documentation source/analyze source/main
ruppmatt at myxo.css.msu.edu
ruppmatt at myxo.css.msu.edu
Sat Apr 11 16:47:19 PDT 2009
Author: ruppmatt
Date: 2009-04-11 19:47:19 -0400 (Sat, 11 Apr 2009)
New Revision: 3206
Modified:
development/documentation/analyze.html
development/source/analyze/cAnalyzeGenotype.cc
development/source/analyze/cAnalyzeGenotype.h
development/source/main/cPhenPlastGenotype.cc
development/source/main/cPhenPlastGenotype.h
Log:
Added task probability measures in cAnalyzeGenotype and cPhenPlastGenotype.
Modified: development/documentation/analyze.html
===================================================================
--- development/documentation/analyze.html 2009-04-10 17:39:16 UTC (rev 3205)
+++ development/documentation/analyze.html 2009-04-11 23:47:19 UTC (rev 3206)
@@ -773,6 +773,9 @@
<td><strong>phen_likely_freq</strong> (Most Likely Phenotype Frequency)</td>
<td><strong>phen_likely_fitness</strong> (Fitness of the Most Likely Phenotype)</td>
</tr>
+<tr>
+ <td><strong>task_prob.n</strong> (Probability of task n being performed) </td>
+</tr>
</table>
</div>
Modified: development/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- development/source/analyze/cAnalyzeGenotype.cc 2009-04-10 17:39:16 UTC (rev 3205)
+++ development/source/analyze/cAnalyzeGenotype.cc 2009-04-11 23:47:19 UTC (rev 3206)
@@ -326,7 +326,10 @@
("task", &cAnalyzeGenotype::DescTask, &cAnalyzeGenotype::GetTaskCount, 5));
dcm->Add("env_input", new tDataEntryOfType<cAnalyzeGenotype, int (int)>
("env_input", &cAnalyzeGenotype::DescEnvInput, &cAnalyzeGenotype::GetEnvInput));
-
+ dcm->Add("task_prob", new tDataEntryOfType<cAnalyzeGenotype, double (int)>
+ ("task_prob", &cAnalyzeGenotype::DescTaskProb, &cAnalyzeGenotype::GetTaskProbability, 5));
+
+
// The remaining values should actually go in a seperate list called
// "population_data_list", but for the moment we're going to put them
// here so that we only need to worry about a single system to load and
@@ -350,11 +353,17 @@
cString cAnalyzeGenotype::DescTask(int task_id) const
{
- if (task_id > task_counts.GetSize()) return "";
+ if (task_id > m_world->GetEnvironment().GetNumTasks()) return "";
return m_world->GetEnvironment().GetTask(task_id).GetDesc();
}
+cString cAnalyzeGenotype::DescTaskProb(int task_id) const
+{
+ if (task_id > m_world->GetEnvironment().GetNumTasks()) return "";
+ return DescTask(task_id) + " (Probability)";
+}
+
cAnalyzeGenotype::sGenotypeDatastore::~sGenotypeDatastore()
{
for (tArrayMap<int, cGenotypeData*>::iterator it = dmap.begin(); it != dmap.end(); it++) delete it->Value();
@@ -555,8 +564,14 @@
void cAnalyzeGenotype::SummarizePhenotypicPlasticity(const cPhenPlastGenotype& pp) const
{
- if (m_phenplast_stats == NULL)
+ if (m_phenplast_stats == NULL){
m_phenplast_stats = new cAnalyzePhenPlast;
+ cerr << id_num << " " << pp.GetNumPhenotypes();
+ for (int k = 0; k < pp.GetTaskProbabilities().GetSize(); k++){
+ cerr << " " << pp.GetTaskProbabilities()[k];
+ }
+ cerr << endl;
+ }
m_phenplast_stats->m_recalculate_trials = pp.GetNumTrials();
m_phenplast_stats->m_max_fitness = pp.GetMaximumFitness();
m_phenplast_stats->m_avg_fitness = pp.GetAverageFitness();
@@ -567,6 +582,7 @@
m_phenplast_stats->m_min_fit_frequency = pp.GetMinimumFitnessFrequency();
m_phenplast_stats->m_likely_fitness = pp.GetLikelyFitness();
m_phenplast_stats->m_num_phenotypes = pp.GetNumPhenotypes();
+ m_phenplast_stats->m_task_probabilities = pp.GetTaskProbabilities();
}
void cAnalyzeGenotype::CalcLandscape(cAvidaContext& ctx)
Modified: development/source/analyze/cAnalyzeGenotype.h
===================================================================
--- development/source/analyze/cAnalyzeGenotype.h 2009-04-10 17:39:16 UTC (rev 3205)
+++ development/source/analyze/cAnalyzeGenotype.h 2009-04-11 23:47:19 UTC (rev 3206)
@@ -226,6 +226,7 @@
double m_likely_frequency;
double m_min_fit_frequency;
double m_max_fit_frequency;
+ tArray<double> m_task_probabilities;
};
mutable cAnalyzePhenPlast* m_phenplast_stats;
@@ -389,8 +390,15 @@
double GetLikelyFrequency() const { CheckPhenPlast(); return m_phenplast_stats->m_likely_frequency; }
double GetLikelyFitness() const { CheckPhenPlast(); return m_phenplast_stats->m_likely_fitness; }
int GetNumTrials() const { CheckPhenPlast(); return m_phenplast_stats->m_recalculate_trials; }
+ double GetTaskProbability(int task_id) const {
+ if (task_id >= m_world->GetEnvironment().GetNumTasks()) return 0.0;
+ CheckPhenPlast();
+ return m_phenplast_stats->m_task_probabilities[task_id];
+ }
+ cString DescTaskProb(int task_id) const;
+
+
-
double GetFitnessRatio() const { return fitness_ratio; }
double GetEfficiencyRatio() const { return efficiency_ratio; }
double GetCompMeritRatio() const { return comp_merit_ratio; }
@@ -424,6 +432,7 @@
}
const tArray<double>& GetTaskQualities() const { return task_qualities; }
+
// number of different tasks performed
int GetTotalTaskCount() const {
int total_task_count = 0;
Modified: development/source/main/cPhenPlastGenotype.cc
===================================================================
--- development/source/main/cPhenPlastGenotype.cc 2009-04-10 17:39:16 UTC (rev 3205)
+++ development/source/main/cPhenPlastGenotype.cc 2009-04-11 23:47:19 UTC (rev 3206)
@@ -68,6 +68,8 @@
// Update statistics
UniquePhenotypes::iterator uit = m_unique.begin();
+ int num_tasks = world->GetEnvironment().GetNumTasks();
+ m_task_probabilities.Resize(num_tasks, 0.0);
m_max_fitness = -1.0;
m_avg_fitness = 0.0;
m_likely_fitness = -1.0;
@@ -94,6 +96,10 @@
}
m_avg_fitness += freq * fit;
m_phenotypic_entropy -= freq * log(freq) / log(2.0);
+
+ for (int i = 0; i < num_tasks; i++)
+ m_task_probabilities[i] += freq * ((this_phen->GetLastTaskCount()[i] > 0) ? 1 : 0);
+
++uit;
}
Modified: development/source/main/cPhenPlastGenotype.h
===================================================================
--- development/source/main/cPhenPlastGenotype.h 2009-04-10 17:39:16 UTC (rev 3205)
+++ development/source/main/cPhenPlastGenotype.h 2009-04-11 23:47:19 UTC (rev 3206)
@@ -45,6 +45,9 @@
#ifndef cWorld_h
#include "cWorld.h"
#endif
+#ifndef cEnvironment_h
+#include "cEnvironment.h"
+#endif
#ifndef cWorldDriver_h
#include "cWorldDriver.h"
#endif
@@ -52,6 +55,7 @@
class cAvidaContext;
class cTestCPU;
class cWorld;
+class cEnvironment;
/**
* This class examines a genotype for evidence of phenotypic plasticity.
@@ -78,7 +82,10 @@
double m_max_fit_freq;
double m_min_fit_freq;
double m_min_fitness;
+ tArray<double> m_task_probabilities;
+
+
void Process(cCPUTestInfo& test_info, cWorld* world, cAvidaContext& ctx);
public:
@@ -99,8 +106,8 @@
const cPlasticPhenotype* GetPlasticPhenotype(int num) const;
const cPlasticPhenotype* GetMostLikelyPhenotype() const;
const cPlasticPhenotype* GetHighestFitnessPhenotype() const;
+ tArray<double> GetTaskProbabilities() const { return m_task_probabilities; }
-
};
#endif
More information about the Avida-cvs
mailing list