[Avida-SVN] r1398 - in branches/dkdev/source: actions drivers main
dknoester at myxo.css.msu.edu
dknoester at myxo.css.msu.edu
Mon Mar 12 17:18:52 PDT 2007
Author: dknoester
Date: 2007-03-12 20:18:51 -0400 (Mon, 12 Mar 2007)
New Revision: 1398
Added:
branches/dkdev/source/main/cGermline.cc
branches/dkdev/source/main/cGermline.h
Modified:
branches/dkdev/source/actions/PopulationActions.cc
branches/dkdev/source/drivers/cDefaultRunDriver.cc
branches/dkdev/source/main/cAvidaConfig.h
branches/dkdev/source/main/cDeme.cc
branches/dkdev/source/main/cDeme.h
branches/dkdev/source/main/cPopulation.cc
Log:
This commit adds a new flavor of ReplicateDemes, where demes of a certain age (in updates) are replicated. This is intended to work with deme germlines, in order to bootstrap the whole thing. Also, looks like I forgot to actually add the cGermline.* files from last commit. Oops.
Modified: branches/dkdev/source/actions/PopulationActions.cc
===================================================================
--- branches/dkdev/source/actions/PopulationActions.cc 2007-03-12 15:16:42 UTC (rev 1397)
+++ branches/dkdev/source/actions/PopulationActions.cc 2007-03-13 00:18:51 UTC (rev 1398)
@@ -893,6 +893,7 @@
else if (in_trigger == "full_deme") m_rep_trigger = 1;
else if (in_trigger == "corners") m_rep_trigger = 2;
else if (in_trigger == "topo-connected") m_rep_trigger = 3;
+ else if (in_trigger == "deme-age") m_rep_trigger = 4;
else {
cString err("Unknown replication trigger '");
err += in_trigger;
Modified: branches/dkdev/source/drivers/cDefaultRunDriver.cc
===================================================================
--- branches/dkdev/source/drivers/cDefaultRunDriver.cc 2007-03-12 15:16:42 UTC (rev 1397)
+++ branches/dkdev/source/drivers/cDefaultRunDriver.cc 2007-03-13 00:18:51 UTC (rev 1398)
@@ -90,10 +90,13 @@
population.ProcessStep(ctx, step_size);
}
-
- // end of update stats...
+ // end of update stats...
population.CalcUpdateStats();
+ // Process the update for each deme.
+ for(int i=0; i<population.GetNumDemes(); ++i) {
+ population.GetDeme(i).ProcessUpdate();
+ }
// No viewer; print out status for this update....
if (m_world->GetVerbosity() > VERBOSE_SILENT) {
Modified: branches/dkdev/source/main/cAvidaConfig.h
===================================================================
--- branches/dkdev/source/main/cAvidaConfig.h 2007-03-12 15:16:42 UTC (rev 1397)
+++ branches/dkdev/source/main/cAvidaConfig.h 2007-03-13 00:18:51 UTC (rev 1398)
@@ -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(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)");
CONFIG_ADD_VAR(HARDWARE_TYPE, int, 0, "0 = Original CPUs\n1 = New SMT CPUs\n2 = Transitional SMT");
Modified: branches/dkdev/source/main/cDeme.cc
===================================================================
--- branches/dkdev/source/main/cDeme.cc 2007-03-12 15:16:42 UTC (rev 1397)
+++ branches/dkdev/source/main/cDeme.cc 2007-03-13 00:18:51 UTC (rev 1398)
@@ -12,6 +12,7 @@
: width(0)
, birth_count(0)
, org_count(0)
+, _age(0)
{
}
@@ -54,6 +55,7 @@
birth_count = 0;
m_network = Network();
m_cvMap = CellVertexMap();
+ _age = 0;
}
Modified: branches/dkdev/source/main/cDeme.h
===================================================================
--- branches/dkdev/source/main/cDeme.h 2007-03-12 15:16:42 UTC (rev 1397)
+++ branches/dkdev/source/main/cDeme.h 2007-03-13 00:18:51 UTC (rev 1398)
@@ -74,6 +74,10 @@
cGermline& GetGermline() { return _germline; }
void ReplaceGermline(const cGermline& germline);
+ // -= Update support =-
+ void ProcessUpdate() { ++_age; }
+ int GetAge() const { return _age; }
+
private:
tArray<int> cell_ids;
int width; // How wide is the deme?
@@ -84,6 +88,7 @@
CellVertexMap m_cvMap; //!< A map of cell IDs to vertex descriptors.
cGermline _germline; //!< The germline for this deme, if used.
+ int _age; //!< How old this deme is, in updates.
};
#endif
Added: branches/dkdev/source/main/cGermline.cc
===================================================================
--- branches/dkdev/source/main/cGermline.cc 2007-03-12 15:16:42 UTC (rev 1397)
+++ branches/dkdev/source/main/cGermline.cc 2007-03-13 00:18:51 UTC (rev 1398)
@@ -0,0 +1,21 @@
+#include "cGermline.h"
+
+
+//cGermline::cGermline() {
+//}
+//
+//
+//cGermline::cGermline(const cGermline& that) {
+//}
+//
+//
+//cOrganism& cGermline::GetLatest() {
+//}
+//
+//
+//void cGermline::Add(cOrganism& organism) {
+//}
+//
+//
+//unsigned int cGermline::Size() const {
+//}
Added: branches/dkdev/source/main/cGermline.h
===================================================================
--- branches/dkdev/source/main/cGermline.h 2007-03-12 15:16:42 UTC (rev 1397)
+++ branches/dkdev/source/main/cGermline.h 2007-03-13 00:18:51 UTC (rev 1398)
@@ -0,0 +1,22 @@
+#ifndef _C_GERMLINE_H_
+#define _C_GERMLINE_H_
+
+#include <vector>
+
+#include "cGenome.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(); }
+
+protected:
+ std::vector<cGenome> _germline;
+};
+
+#endif
Modified: branches/dkdev/source/main/cPopulation.cc
===================================================================
--- branches/dkdev/source/main/cPopulation.cc 2007-03-12 15:16:42 UTC (rev 1397)
+++ branches/dkdev/source/main/cPopulation.cc 2007-03-13 00:18:51 UTC (rev 1398)
@@ -782,7 +782,7 @@
// Loop through all candidate demes...
for (int deme_id = 0; deme_id < num_demes; deme_id++) {
cDeme & source_deme = deme_array[deme_id];
-
+
// Test this deme to determine if it should be replicated. If not,
// continue on to the next deme.
switch (rep_trigger) {
@@ -816,13 +816,21 @@
// stats tracking now.
m_world->GetStats().ConnectedTopology(source_deme);
break;
- }
+ }
+ case 4: {
+ // Replicates old demes.
+ if(source_deme.GetAge() < m_world->GetConfig().MAX_DEME_AGE.Get()) continue;
+ break;
+ }
default:
cerr << "ERROR: Invalid replication trigger " << rep_trigger
<< " in cPopulation::ReplicateDemes()" << endl;
continue;
}
+ // Doesn't make sense to try and replicate a deme that *has no organisms*.
+ if(source_deme.IsEmpty()) continue;
+
// -- If we made it this far, we should replicate this deme --
cRandom& random = m_world->GetRandom();
@@ -863,7 +871,12 @@
const cGenome& next_germ = test_cpu.GetOffspringGenome();
source_germline.Add(next_germ);
target_deme.ReplaceGermline(source_germline);
-
+
+ // Kill all the organisms in the source deme.
+ for (int i=0; i<source_deme.GetSize(); i++) {
+ KillOrganism(cell_array[source_deme.GetCellID(i)]);
+ }
+
// Lineage label is wrong here...
InjectGenome(source_deme.GetCellID(source_deme.GetSize()/2), next_germ, 0);
InjectGenome(target_deme.GetCellID(target_deme.GetSize()/2), next_germ, 0);
More information about the Avida-cvs
mailing list