[Avida-SVN] r2179 - branches/dkdev/source/main
dknoester at myxo.css.msu.edu
dknoester at myxo.css.msu.edu
Sat Nov 3 07:13:14 PDT 2007
Author: dknoester
Date: 2007-11-03 10:13:14 -0400 (Sat, 03 Nov 2007)
New Revision: 2179
Modified:
branches/dkdev/source/main/cAvidaConfig.h
branches/dkdev/source/main/cGermline.h
branches/dkdev/source/main/cPopulation.cc
Log:
Added germline merit window, and removed debugging output.
Modified: branches/dkdev/source/main/cAvidaConfig.h
===================================================================
--- branches/dkdev/source/main/cAvidaConfig.h 2007-11-03 13:21:46 UTC (rev 2178)
+++ branches/dkdev/source/main/cAvidaConfig.h 2007-11-03 14:13:14 UTC (rev 2179)
@@ -167,6 +167,7 @@
CONFIG_ADD_VAR(FILL_DEME_ON_REPLICATE, int, 0, "Whether to fill the source and target demes upon replication.");
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(GERMLINE_MERIT_WINDOW_SIZE, int, 1, "The size of the germline merit accumulation window; >=1.");
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(TWOCELLS_MIN_REGION_RATIO, double, 0.2, "Ratio of size of two-cells region to environment size.");
Modified: branches/dkdev/source/main/cGermline.h
===================================================================
--- branches/dkdev/source/main/cGermline.h 2007-11-03 13:21:46 UTC (rev 2178)
+++ branches/dkdev/source/main/cGermline.h 2007-11-03 14:13:14 UTC (rev 2179)
@@ -2,6 +2,8 @@
#define _C_GERMLINE_H_
#include <vector>
+#include <deque>
+#include <numeric>
#include "cGenome.h"
#include "cMerit.h"
@@ -12,11 +14,22 @@
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; }
+ const cMerit& GetMerit() {
+ _merit = std::accumulate(_merit_window.begin(), _merit_window.end(), 0.0);
+ return _merit;
+ }
+ void UpdateMerit(double v) { UpdateWindowedMerit(v, 1); }
+ void UpdateWindowedMerit(double v, int window_size) {
+ assert(window_size >= 1);
+ if(_merit_window.size() > window_size) {
+ _merit_window.pop_front();
+ }
+ _merit_window.push_back(v);
+ }
protected:
std::vector<cGenome> _germline;
+ std::deque<double> _merit_window;
cMerit _merit;
};
Modified: branches/dkdev/source/main/cPopulation.cc
===================================================================
--- branches/dkdev/source/main/cPopulation.cc 2007-11-03 13:21:46 UTC (rev 2178)
+++ branches/dkdev/source/main/cPopulation.cc 2007-11-03 14:13:14 UTC (rev 2179)
@@ -107,18 +107,18 @@
std::pair<int,int> cell1_xy = _deme.GetCellPosition(cells.first);
std::pair<int,int> self_xy = _deme.GetCellPosition(organism->GetCellID());
- std::cout << "Organism " << organism->GetCellID() << " @ (" << self_xy.first << "," << self_xy.second << ") declares "
- << organism->GetRegion() << " for cell1 @ (" << cell1_xy.first << "," << cell1_xy.second << ");";
+// std::cout << "Organism " << organism->GetCellID() << " @ (" << self_xy.first << "," << self_xy.second << ") declares "
+// << organism->GetRegion() << " for cell1 @ (" << cell1_xy.first << "," << cell1_xy.second << ");";
// Has the organism declared correctly or not? If so, increment result.
if((self_xy.second >= (cell1_xy.second)) && (organism->GetRegionCount() > 0)) {
result += 1.0;
- std::cout << " up.";
+// std::cout << " up.";
} else if((self_xy.second <= (cell1_xy.second)) && (organism->GetRegionCount() < 0)) {
result += 1.0;
- std::cout << " down.";
+// std::cout << " down.";
}
- std::cout << endl;
+// std::cout << endl;
// All done.
return result;
@@ -1255,7 +1255,7 @@
// Check to see if we should update the source deme's germline merit.
if(m_world->GetConfig().DEMES_USE_GERMLINE.Get() && m_world->GetConfig().DEMES_HAVE_MERIT.Get()) {
- source_deme.GetGermline().UpdateMerit(source_germline_merit);
+ source_deme.GetGermline().UpdateWindowedMerit(source_germline_merit, m_world->GetConfig().GERMLINE_MERIT_WINDOW_SIZE.Get());
}
m_world->GetStats().DemeReplication(source_deme);
cRandom& random = m_world->GetRandom();
More information about the Avida-cvs
mailing list