[Avida-SVN] r1401 - in branches/dkdev/source: main tools
dknoester at myxo.css.msu.edu
dknoester at myxo.css.msu.edu
Thu Mar 15 07:07:35 PDT 2007
Author: dknoester
Date: 2007-03-15 10:07:34 -0400 (Thu, 15 Mar 2007)
New Revision: 1401
Modified:
branches/dkdev/source/main/cAvidaConfig.h
branches/dkdev/source/main/cGermline.h
branches/dkdev/source/main/cPopulation.cc
branches/dkdev/source/tools/cMerit.h
Log:
Testing the addition of merit to demes.
Modified: branches/dkdev/source/main/cAvidaConfig.h
===================================================================
--- branches/dkdev/source/main/cAvidaConfig.h 2007-03-14 13:35:27 UTC (rev 1400)
+++ branches/dkdev/source/main/cAvidaConfig.h 2007-03-15 14:07:34 UTC (rev 1401)
@@ -162,6 +162,7 @@
CONFIG_ADD_VAR(WORLD_GEOMETRY, int, 2, "1 = Bounded Grid\n2 = Torus");
CONFIG_ADD_VAR(NUM_DEMES, int, 0, "Number of independed groups in the population; 0=off");
CONFIG_ADD_VAR(DEMES_USE_GERMLINE, int, 0, "Whether or not demes use a distinct germline; 0=off");
+ CONFIG_ADD_VAR(DEMES_HAVE_MERIT, int, 0, "Whether or not demes apply a merit to their members; 0=off");
CONFIG_ADD_VAR(GERMLINE_COPY_MUT, double, 0.0075, "Probability of copy mutations occuring during germline replication.");
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(RANDOM_SEED, int, 0, "Random number seed (0 for based on time)");
Modified: branches/dkdev/source/main/cGermline.h
===================================================================
--- branches/dkdev/source/main/cGermline.h 2007-03-14 13:35:27 UTC (rev 1400)
+++ branches/dkdev/source/main/cGermline.h 2007-03-15 14:07:34 UTC (rev 1401)
@@ -4,19 +4,20 @@
#include <vector>
#include "cGenome.h"
+#include "cMerit.h"
-
class cGermline {
public:
-// cGermline();
-// cGermline(const cGermline& that);
-
cGenome& GetLatest() { return _germline.back(); }
void Add(const cGenome& genome) { _germline.push_back(genome); }
unsigned int Size() const { return _germline.size(); }
+
+ const cMerit& GetMerit() { return _merit; }
+ void UpdateMerit(double v) { _merit = v; }
protected:
std::vector<cGenome> _germline;
+ cMerit _merit;
};
#endif
Modified: branches/dkdev/source/main/cPopulation.cc
===================================================================
--- branches/dkdev/source/main/cPopulation.cc 2007-03-14 13:35:27 UTC (rev 1400)
+++ branches/dkdev/source/main/cPopulation.cc 2007-03-15 14:07:34 UTC (rev 1401)
@@ -236,7 +236,15 @@
// If we're not about to kill the parent, do some extra work on it.
if (parent_alive == true) {
- schedule->Adjust(parent_cell.GetID(), parent_phenotype.GetMerit());
+ // We're going to try something a little different here, and also take into
+ // account a per-germline merit, if we're configured to do such.
+ if(m_world->GetConfig().DEMES_USE_GERMLINE.Get() &&
+ m_world->GetConfig().DEMES_HAVE_MERIT.Get()) {
+ schedule->Adjust(parent_cell.GetID(), parent_phenotype.GetMerit()
+ + deme_array[parent_cell.GetDemeID()].GetGermline().GetMerit());
+ } else {
+ schedule->Adjust(parent_cell.GetID(), parent_phenotype.GetMerit());
+ }
// In a local run, face the child toward the parent.
if (m_world->GetConfig().BIRTH_METHOD.Get() < NUM_LOCAL_POSITION_CHILD) {
@@ -350,8 +358,16 @@
m_world->GetClassificationManager().AdjustGenotype(*in_genotype);
// Initialize the time-slice for this new organism.
- schedule->Adjust(target_cell.GetID(), in_organism->GetPhenotype().GetMerit());
-
+ // We're going to try something a little different here, and also take into
+ // account a per-germline merit, if we're configured to do such.
+ if(m_world->GetConfig().DEMES_USE_GERMLINE.Get() &&
+ m_world->GetConfig().DEMES_HAVE_MERIT.Get()) {
+ schedule->Adjust(target_cell.GetID(), in_organism->GetPhenotype().GetMerit()
+ + deme_array[target_cell.GetDemeID()].GetGermline().GetMerit());
+ } else {
+ schedule->Adjust(target_cell.GetID(), in_organism->GetPhenotype().GetMerit());
+ }
+
// Special handling for certain birth methods.
if (m_world->GetConfig().BIRTH_METHOD.Get() == POSITION_CHILD_FULL_SOUP_ELDEST) {
reaper_queue.Push(&target_cell);
@@ -814,6 +830,16 @@
// Hm, ok, well we now have connected deme. We should really do some
// stats tracking now.
m_world->GetStats().ConnectedTopology(source_deme);
+
+ // Check to see if we need to update the deme's merit.
+ if(m_world->GetConfig().DEMES_USE_GERMLINE.Get() &&
+ m_world->GetConfig().DEMES_HAVE_MERIT.Get()) {
+ // This is just a hack to see if this approach will work; if so, it
+ // definitely needs refactoring.
+ cGermline& source_germline = source_deme.GetGermline();
+ const double f=1.0;
+ source_germline.UpdateMerit(pow(f*(72 - boost::num_edges(network) + 1), 2));
+ }
break;
}
case 4: {
Modified: branches/dkdev/source/tools/cMerit.h
===================================================================
--- branches/dkdev/source/tools/cMerit.h 2007-03-14 13:35:27 UTC (rev 1400)
+++ branches/dkdev/source/tools/cMerit.h 2007-03-15 14:07:34 UTC (rev 1401)
@@ -46,7 +46,6 @@
void operator=(double _merit) { UpdateValue(_merit); }
void operator+=(const cMerit & _m){ UpdateValue(value + _m.GetDouble()); }
-
int operator>(const cMerit & _m) const { return value > _m.GetDouble(); }
int operator<(const cMerit & _m) const { return value < _m.GetDouble(); }
int operator>=(const cMerit & _m) const { return value >= _m.GetDouble(); }
@@ -60,6 +59,13 @@
int operator!=(const double _m) const { return value != _m; }
int operator!=(const unsigned int _m) const { return (offset!=0 || base!=_m); }
+ //! Operator overload for this cMerit + that cMerit.
+ cMerit operator+(const cMerit& that) const {
+ cMerit r(*this);
+ r += that;
+ return r;
+ }
+
void Clear() { value = 0; base = 0; offset = 0; bits = 0; }
// @TCC - This function fails for values > UINT_MAX...
More information about the Avida-cvs
mailing list