[Avida-SVN] r1849 - branches/dkdev/source/main
dknoester at myxo.css.msu.edu
dknoester at myxo.css.msu.edu
Wed Jul 25 10:25:05 PDT 2007
Author: dknoester
Date: 2007-07-25 13:25:04 -0400 (Wed, 25 Jul 2007)
New Revision: 1849
Modified:
branches/dkdev/source/main/cAvidaConfig.h
branches/dkdev/source/main/cBirthChamber.cc
branches/dkdev/source/main/cPopulation.cc
branches/dkdev/source/main/cStats.cc
branches/dkdev/source/main/cStats.h
Log:
New clustering merit.
Modified: branches/dkdev/source/main/cAvidaConfig.h
===================================================================
--- branches/dkdev/source/main/cAvidaConfig.h 2007-07-25 02:06:13 UTC (rev 1848)
+++ branches/dkdev/source/main/cAvidaConfig.h 2007-07-25 17:25:04 UTC (rev 1849)
@@ -168,6 +168,7 @@
CONFIG_ADD_VAR(GERMLINE_REPLACES_SOURCE, int, 0, "Whether the source germline is updated on replication; 0=no.");
CONFIG_ADD_VAR(GERMLINE_RANDOM_PLACEMENT, int, 0, "Whether the seed for a germline is placed randomly within the deme; 0=no.");
CONFIG_ADD_VAR(MAX_DEME_AGE, int, 500, "The maximum age of a deme (in updates) to be used for age-based replication (default=500).");
+ CONFIG_ADD_VAR(TRACK_GENOTYPES, int, 0, "Whether genotypes are tracked graphically.");
CONFIG_ADD_VAR(RANDOM_SEED, int, 0, "Random number seed (0 for based on time)");
CONFIG_ADD_VAR(HARDWARE_TYPE, int, 0, "0 = Original CPUs\n1 = New SMT CPUs\n2 = Transitional SMT");
Modified: branches/dkdev/source/main/cBirthChamber.cc
===================================================================
--- branches/dkdev/source/main/cBirthChamber.cc 2007-07-25 02:06:13 UTC (rev 1848)
+++ branches/dkdev/source/main/cBirthChamber.cc 2007-07-25 17:25:04 UTC (rev 1849)
@@ -149,6 +149,10 @@
parent.GetGenotype()->SetBreedStats(*child_genotype);
child_genotype->IncDeferAdjust();
+
+ if(m_world->GetConfig().TRACK_GENOTYPES.Get()) {
+ m_world->GetStats().TrackGenotypes(child_genotype, parent.GetGenotype());
+ }
return true;
}
Modified: branches/dkdev/source/main/cPopulation.cc
===================================================================
--- branches/dkdev/source/main/cPopulation.cc 2007-07-25 02:06:13 UTC (rev 1848)
+++ branches/dkdev/source/main/cPopulation.cc 2007-07-25 17:25:04 UTC (rev 1849)
@@ -1034,7 +1034,11 @@
//double target_clustering_coeff=50.0;
double target_clustering_coeff=25.0;
- source_germline_merit = pow(target_clustering_coeff - abs(target_clustering_coeff-clustering_coeff) + 1, 2);
+ // What we need here is an exponentially-decreasing function of target to both
+ // low and high-range limits.
+ clustering_coeff = std::min(100.0, clustering_coeff);
+ clustering_coeff = std::max(0.0, clustering_coeff);
+ source_germline_merit = pow(100.0-abs(clustering_coeff-target_clustering_coeff)+1, 2);
break;
}
case 11: {
Modified: branches/dkdev/source/main/cStats.cc
===================================================================
--- branches/dkdev/source/main/cStats.cc 2007-07-25 02:06:13 UTC (rev 1848)
+++ branches/dkdev/source/main/cStats.cc 2007-07-25 17:25:04 UTC (rev 1849)
@@ -18,6 +18,7 @@
#include "cWorldDriver.h"
#include "cGenome.h"
#include "cPopulation.h"
+#include "cGenotype.h"
#include <float.h>
#include <math.h>
@@ -1048,3 +1049,14 @@
df.Write(cell_ids_collected.Average(), "mean cell ids collected (per deme)");
df.Endl();
}
+
+
+void cStats::TrackGenotypes(cGenotype* child, cGenotype* parent) {
+ typedef GenotypeNetwork::edge_descriptor edge_descriptor;
+
+ std::pair<edge_descriptor, bool> i=boost::add_edge(child->GetID(), parent->GetID(), _genotype_net);
+ if(!i.second) {
+ // Edge already exists; increment its count.
+ ++boost::get(boost::edge_bundle, _genotype_net)[i.first];
+ }
+}
Modified: branches/dkdev/source/main/cStats.h
===================================================================
--- branches/dkdev/source/main/cStats.h 2007-07-25 02:06:13 UTC (rev 1848)
+++ branches/dkdev/source/main/cStats.h 2007-07-25 17:25:04 UTC (rev 1849)
@@ -14,6 +14,7 @@
#include <assert.h>
#include <fstream>
#include <iostream>
+#include <boost/graph/adjacency_list.hpp>
#include "defs.h"
#include "cDoubleSum.h"
@@ -578,6 +579,29 @@
// Satellite
void PrintCollectionData(const cString& filename);
+
+ // Attractor
+public:
+ struct edge_properties {
+ edge_properties() : _count(1) { }
+ edge_properties& operator++() { ++_count; return *this; }
+ unsigned int _count;
+ };
+
+ //! An ease-of-use typedef to support the distributed construction of a network.
+ typedef boost::adjacency_list<
+ boost::setS, // out-edge list
+ boost::vecS, // vertex list
+ boost::directedS, // directed graph
+ boost::no_property, // no vertex properties
+ edge_properties // edge properties
+ > GenotypeNetwork;
+
+ void TrackGenotypes(cGenotype* child, cGenotype* parent);
+
+private:
+ GenotypeNetwork _genotype_net;
+
};
More information about the Avida-cvs
mailing list