[Avida-SVN] r3294 - in branches/matt/CompeteInstSet/source: actions cpu main
ruppmatt at myxo.css.msu.edu
ruppmatt at myxo.css.msu.edu
Sat Jun 6 12:57:32 PDT 2009
Author: ruppmatt
Date: 2009-06-06 15:57:32 -0400 (Sat, 06 Jun 2009)
New Revision: 3294
Modified:
branches/matt/CompeteInstSet/source/actions/DriverActions.cc
branches/matt/CompeteInstSet/source/actions/PopulationActions.cc
branches/matt/CompeteInstSet/source/actions/PrintActions.cc
branches/matt/CompeteInstSet/source/cpu/cHardwareManager.cc
branches/matt/CompeteInstSet/source/main/cPopulation.cc
branches/matt/CompeteInstSet/source/main/cPopulation.h
branches/matt/CompeteInstSet/source/main/cStats.cc
branches/matt/CompeteInstSet/source/main/cStats.h
Log:
Provided some additional actions and stats tracking of inst_set counts.
Modified: branches/matt/CompeteInstSet/source/actions/DriverActions.cc
===================================================================
--- branches/matt/CompeteInstSet/source/actions/DriverActions.cc 2009-06-05 21:04:52 UTC (rev 3293)
+++ branches/matt/CompeteInstSet/source/actions/DriverActions.cc 2009-06-06 19:57:32 UTC (rev 3294)
@@ -80,12 +80,37 @@
}
};
+class cActionExitIfSingleInstSetPresent : public cAction
+ {
+ private:
+
+ public:
+ cActionExitIfSingleInstSetPresent(cWorld* world, const cString& args) : cAction(world, args)
+ {
+ }
+
+ static const cString GetDescription() { return "Arguments: <double threshold>"; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ tArray<int> inst_set_orgs = m_world->GetStats().GetInstSetCounts();
+ int count = 0;
+ for (int k = 0; k < inst_set_orgs.GetSize(); k++)
+ count += (inst_set_orgs[k] > 0) ? 1 : 0;
+ if (count == 1)
+ m_world->GetDriver().SetDone();
+ }
+ };
+
+
void RegisterDriverActions(cActionLibrary* action_lib)
{
action_lib->Register<cActionExit>("Exit");
action_lib->Register<cActionExitAveLineageLabelGreater>("ExitAveLineageLabelGreater");
action_lib->Register<cActionExitAveLineageLabelLess>("ExitAveLineageLabelLess");
+
+ action_lib->Register<cActionExitIfSingleInstSetPresent>("ExitIfSingleInstSetPresent");
// @DMB - The following actions are DEPRECATED aliases - These will be removed in 2.7.
action_lib->Register<cActionExit>("exit");
Modified: branches/matt/CompeteInstSet/source/actions/PopulationActions.cc
===================================================================
--- branches/matt/CompeteInstSet/source/actions/PopulationActions.cc 2009-06-05 21:04:52 UTC (rev 3293)
+++ branches/matt/CompeteInstSet/source/actions/PopulationActions.cc 2009-06-06 19:57:32 UTC (rev 3294)
@@ -62,8 +62,9 @@
double m_merit;
int m_lineage_label;
double m_neutral_metric;
+ int m_inst_set_id;
public:
- cActionInject(cWorld* world, const cString& args) : cAction(world, args), m_cell_id(0), m_merit(-1), m_lineage_label(0), m_neutral_metric(0)
+ cActionInject(cWorld* world, const cString& args) : cAction(world, args), m_cell_id(0), m_merit(-1), m_lineage_label(0), m_neutral_metric(0), m_inst_set_id(0)
{
cString largs(args);
if (!largs.GetSize()) m_filename = "START_CREATURE"; else m_filename = largs.PopWord();
@@ -71,16 +72,17 @@
if (largs.GetSize()) m_merit = largs.PopWord().AsDouble();
if (largs.GetSize()) m_lineage_label = largs.PopWord().AsInt();
if (largs.GetSize()) m_neutral_metric = largs.PopWord().AsDouble();
-
+ if (largs.GetSize()) m_inst_set_id = largs.PopWord().AsInt();
+
if (m_filename == "START_CREATURE") m_filename = m_world->GetConfig().START_CREATURE.Get();
}
- static const cString GetDescription() { return "Arguments: [string fname=\"START_CREATURE\"] [int cell_id=0] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+ static const cString GetDescription() { return "Arguments: [string fname=\"START_CREATURE\"] [int cell_id=0] [double merit=-1] [int lineage_label=0] [double neutral_metric=0] [inst_set_id=0]"; }
void Process(cAvidaContext& ctx)
{
- cGenome genome = cGenomeUtil::LoadGenome(m_filename, m_world->GetHardwareManager().GetInstSet());
- m_world->GetPopulation().Inject(genome, m_cell_id, m_merit, m_lineage_label, m_neutral_metric);
+ cGenome genome = cGenomeUtil::LoadGenome(m_filename, m_world->GetHardwareManager().GetInstSet(m_inst_set_id));
+ m_world->GetPopulation().Inject(genome, m_cell_id, m_merit, m_lineage_label, m_neutral_metric, m_inst_set_id);
}
};
@@ -108,8 +110,9 @@
double m_merit;
int m_lineage_label;
double m_neutral_metric;
+ int m_inst_set_id;
public:
- cActionInjectRandom(cWorld* world, const cString& args) : cAction(world, args), m_cell_id(0), m_merit(-1), m_lineage_label(0), m_neutral_metric(0)
+ cActionInjectRandom(cWorld* world, const cString& args) : cAction(world, args), m_cell_id(0), m_merit(-1), m_lineage_label(0), m_neutral_metric(0), m_inst_set_id(0)
{
cString largs(args);
m_length = largs.PopWord().AsInt();
@@ -117,14 +120,15 @@
if (largs.GetSize()) m_merit = largs.PopWord().AsDouble();
if (largs.GetSize()) m_lineage_label = largs.PopWord().AsInt();
if (largs.GetSize()) m_neutral_metric = largs.PopWord().AsDouble();
+ if (largs.GetSize()) m_inst_set_id = largs.PopWord().AsInt();
}
static const cString GetDescription() { return "Arguments: <int length> [int cell_id=0] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
void Process(cAvidaContext& ctx)
{
- cGenome genome = cGenomeUtil::RandomGenome(ctx, m_length, m_world->GetHardwareManager().GetInstSet());
- m_world->GetPopulation().Inject(genome, m_cell_id, m_merit, m_lineage_label, m_neutral_metric);
+ cGenome genome = cGenomeUtil::RandomGenome(ctx, m_length, m_world->GetHardwareManager().GetInstSet(m_inst_set_id));
+ m_world->GetPopulation().Inject(genome, m_cell_id, m_merit, m_lineage_label, m_neutral_metric, m_inst_set_id);
}
};
@@ -151,23 +155,25 @@
double m_merit;
int m_lineage_label;
double m_neutral_metric;
+ int m_inst_set_id;
public:
- cActionInjectAllRandomRepro(cWorld* world, const cString& args) : cAction(world, args), m_merit(-1), m_lineage_label(0), m_neutral_metric(0)
+ cActionInjectAllRandomRepro(cWorld* world, const cString& args) : cAction(world, args), m_merit(-1), m_lineage_label(0), m_neutral_metric(0), m_inst_set_id(0)
{
cString largs(args);
m_length = largs.PopWord().AsInt();
if (largs.GetSize()) m_merit = largs.PopWord().AsDouble();
if (largs.GetSize()) m_lineage_label = largs.PopWord().AsInt();
if (largs.GetSize()) m_neutral_metric = largs.PopWord().AsDouble();
+ if (largs.GetSize()) m_inst_set_id = largs.PopWord().AsInt();
}
- static const cString GetDescription() { return "Arguments: <int length> [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+ static const cString GetDescription() { return "Arguments: <int length> [double merit=-1] [int lineage_label=0] [double neutral_metric=0] [int inst_set_id=0]"; }
void Process(cAvidaContext& ctx)
{
for (int i = 0; i < m_world->GetPopulation().GetSize(); i++)
{
- cGenome genome = cGenomeUtil::RandomGenomeWithoutZeroRedundantsPlusRepro(ctx, m_length, m_world->GetHardwareManager().GetInstSet());
+ cGenome genome = cGenomeUtil::RandomGenomeWithoutZeroRedundantsPlusRepro(ctx, m_length, m_world->GetHardwareManager().GetInstSet(m_inst_set_id));
m_world->GetPopulation().Inject(genome, i, m_merit, m_lineage_label, m_neutral_metric);
}
}
@@ -195,25 +201,27 @@
double m_merit;
int m_lineage_label;
double m_neutral_metric;
+ int m_inst_set_id;
public:
- cActionInjectAll(cWorld* world, const cString& args) : cAction(world, args), m_merit(-1), m_lineage_label(0), m_neutral_metric(0)
+ cActionInjectAll(cWorld* world, const cString& args) : cAction(world, args), m_merit(-1), m_lineage_label(0), m_neutral_metric(0), m_inst_set_id(0)
{
cString largs(args);
if (!largs.GetSize()) m_filename = "START_CREATURE"; else m_filename = largs.PopWord();
if (largs.GetSize()) m_merit = largs.PopWord().AsDouble();
if (largs.GetSize()) m_lineage_label = largs.PopWord().AsInt();
if (largs.GetSize()) m_neutral_metric = largs.PopWord().AsDouble();
+ if (largs.GetSize()) m_inst_set_id = largs.PopWord().AsInt();
if (m_filename == "START_CREATURE") m_filename = m_world->GetConfig().START_CREATURE.Get();
}
- static const cString GetDescription() { return "Arguments: [string fname=\"START_CREATURE\"] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+ static const cString GetDescription() { return "Arguments: [string fname=\"START_CREATURE\"] [double merit=-1] [int lineage_label=0] [double neutral_metric=0] [int inst_set_id=0]"; }
void Process(cAvidaContext& ctx)
{
- cGenome genome = cGenomeUtil::LoadGenome(m_filename, m_world->GetHardwareManager().GetInstSet());
+ cGenome genome = cGenomeUtil::LoadGenome(m_filename, m_world->GetHardwareManager().GetInstSet(m_inst_set_id));
for (int i = 0; i < m_world->GetPopulation().GetSize(); i++)
- m_world->GetPopulation().Inject(genome, i, m_merit, m_lineage_label, m_neutral_metric);
+ m_world->GetPopulation().Inject(genome, i, m_merit, m_lineage_label, m_neutral_metric, m_inst_set_id);
}
};
@@ -245,9 +253,10 @@
double m_merit;
int m_lineage_label;
double m_neutral_metric;
+ int m_inst_set_id;
public:
cActionInjectRange(cWorld* world, const cString& args)
- : cAction(world, args), m_cell_start(0), m_cell_end(-1), m_merit(-1), m_lineage_label(0), m_neutral_metric(0)
+ : cAction(world, args), m_cell_start(0), m_cell_end(-1), m_merit(-1), m_lineage_label(0), m_neutral_metric(0), m_inst_set_id(0)
{
cString largs(args);
if (!largs.GetSize()) m_filename = "START_CREATURE"; else m_filename = largs.PopWord();
@@ -256,21 +265,22 @@
if (largs.GetSize()) m_merit = largs.PopWord().AsDouble();
if (largs.GetSize()) m_lineage_label = largs.PopWord().AsInt();
if (largs.GetSize()) m_neutral_metric = largs.PopWord().AsDouble();
+ if (largs.GetSize()) m_inst_set_id = largs.PopWord().AsInt();
if (m_filename == "START_CREATURE") m_filename = m_world->GetConfig().START_CREATURE.Get();
if (m_cell_end == -1) m_cell_end = m_cell_start + 1;
}
- static const cString GetDescription() { return "Arguments: [string fname=\"START_CREATURE\"] [int cell_start=0] [int cell_end=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+ static const cString GetDescription() { return "Arguments: [string fname=\"START_CREATURE\"] [int cell_start=0] [int cell_end=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0] [int inst_set_id=0]"; }
void Process(cAvidaContext& ctx)
{
if (m_cell_start < 0 || m_cell_end > m_world->GetPopulation().GetSize() || m_cell_start >= m_cell_end) {
m_world->GetDriver().NotifyWarning("InjectRange has invalid range!");
} else {
- cGenome genome = cGenomeUtil::LoadGenome(m_filename, m_world->GetHardwareManager().GetInstSet());
+ cGenome genome = cGenomeUtil::LoadGenome(m_filename, m_world->GetHardwareManager().GetInstSet(m_inst_set_id));
for (int i = m_cell_start; i < m_cell_end; i++) {
- m_world->GetPopulation().Inject(genome, i, m_merit, m_lineage_label, m_neutral_metric);
+ m_world->GetPopulation().Inject(genome, i, m_merit, m_lineage_label, m_neutral_metric, m_inst_set_id);
}
m_world->GetPopulation().SetSyncEvents(true);
}
@@ -304,9 +314,10 @@
double m_merit;
int m_lineage_label;
double m_neutral_metric;
+ double m_inst_set_id;
public:
cActionInjectSequence(cWorld* world, const cString& args)
- : cAction(world, args), m_cell_start(0), m_cell_end(-1), m_merit(-1), m_lineage_label(0), m_neutral_metric(0)
+ : cAction(world, args), m_cell_start(0), m_cell_end(-1), m_merit(-1), m_lineage_label(0), m_neutral_metric(0), m_inst_set_id(0)
{
cString largs(args);
m_sequence = largs.PopWord();
@@ -315,11 +326,12 @@
if (largs.GetSize()) m_merit = largs.PopWord().AsDouble();
if (largs.GetSize()) m_lineage_label = largs.PopWord().AsInt();
if (largs.GetSize()) m_neutral_metric = largs.PopWord().AsDouble();
+ if (largs.GetSize()) m_inst_set_id = largs.PopWord().AsInt();
if (m_cell_end == -1) m_cell_end = m_cell_start + 1;
}
- static const cString GetDescription() { return "Arguments: <string sequence> [int cell_start=0] [int cell_end=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+ static const cString GetDescription() { return "Arguments: <string sequence> [int cell_start=0] [int cell_end=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0] [int inst_set_id=0]"; }
void Process(cAvidaContext& ctx)
{
@@ -328,7 +340,7 @@
} else {
cGenome genome(m_sequence);
for (int i = m_cell_start; i < m_cell_end; i++) {
- m_world->GetPopulation().Inject(genome, i, m_merit, m_lineage_label, m_neutral_metric);
+ m_world->GetPopulation().Inject(genome, i, m_merit, m_lineage_label, m_neutral_metric, m_inst_set_id);
}
m_world->GetPopulation().SetSyncEvents(true);
}
@@ -477,27 +489,29 @@
double m_merit;
int m_lineage_label;
double m_neutral_metric;
+ int m_inst_set_id;
public:
- cActionInjectDemes(cWorld* world, const cString& args) : cAction(world, args), m_merit(-1), m_lineage_label(0), m_neutral_metric(0)
+ cActionInjectDemes(cWorld* world, const cString& args) : cAction(world, args), m_merit(-1), m_lineage_label(0), m_neutral_metric(0), m_inst_set_id(0)
{
cString largs(args);
if (!largs.GetSize()) m_filename = "START_CREATURE"; else m_filename = largs.PopWord();
if (largs.GetSize()) m_merit = largs.PopWord().AsDouble();
if (largs.GetSize()) m_lineage_label = largs.PopWord().AsInt();
if (largs.GetSize()) m_neutral_metric = largs.PopWord().AsDouble();
+ if (largs.GetSize()) m_inst_set_id = largs.PopWord().AsInt();
if (m_filename == "START_CREATURE") m_filename = m_world->GetConfig().START_CREATURE.Get();
}
- static const cString GetDescription() { return "Arguments: [string fname=\"START_CREATURE\"] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+ static const cString GetDescription() { return "Arguments: [string fname=\"START_CREATURE\"] [double merit=-1] [int lineage_label=0] [double neutral_metric=0] [inst_set_id=0]"; }
void Process(cAvidaContext& ctx)
{
- cGenome genome = cGenomeUtil::LoadGenome(m_filename, m_world->GetHardwareManager().GetInstSet());
+ cGenome genome = cGenomeUtil::LoadGenome(m_filename, m_world->GetHardwareManager().GetInstSet(m_inst_set_id));
if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
for(int i=1; i<m_world->GetPopulation().GetNumDemes(); ++i) { // first org has already been injected
m_world->GetPopulation().Inject(genome,
m_world->GetPopulation().GetDeme(i).GetCellID(0),
- m_merit, m_lineage_label, m_neutral_metric);
+ m_merit, m_lineage_label, m_neutral_metric, m_inst_set_id);
}
} else {
for(int i=0; i<m_world->GetPopulation().GetNumDemes(); ++i) {
@@ -505,7 +519,7 @@
// calling this will overwrite it.
m_world->GetPopulation().Inject(genome,
m_world->GetPopulation().GetDeme(i).GetCellID(0),
- m_merit, m_lineage_label, m_neutral_metric);
+ m_merit, m_lineage_label, m_neutral_metric, m_inst_set_id);
}
}
}
@@ -1591,6 +1605,8 @@
action_lib->Register<cActionSetOptimizeMinMax>("SetOptimizeMinMax");
action_lib->Register<cActionSwapCells>("SwapCells");
+ action_lib->Register<cActionAddInstSet>("AddInstSet");
+
// @DMB - The following actions are DEPRECATED aliases - These will be removed in 2.7.
action_lib->Register<cActionInject>("inject");
action_lib->Register<cActionInjectRandom>("inject_random");
@@ -1623,5 +1639,5 @@
action_lib->Register<cActionDisconnectCells>("disconnect_cells");
action_lib->Register<cActionSwapCells>("swap_cells");
- action_lib->Register<cActionAddInstSet>("add_inst_set");
+
}
Modified: branches/matt/CompeteInstSet/source/actions/PrintActions.cc
===================================================================
--- branches/matt/CompeteInstSet/source/actions/PrintActions.cc 2009-06-05 21:04:52 UTC (rev 3293)
+++ branches/matt/CompeteInstSet/source/actions/PrintActions.cc 2009-06-06 19:57:32 UTC (rev 3294)
@@ -2598,8 +2598,31 @@
};
+class cActionPrintInstSetCounts : public cAction
+{
+ private:
+ cString m_filename;
+ public:
+ cActionPrintInstSetCounts(cWorld* world, const cString& args) : cAction(world, args)
+ {
+ cString largs(args);
+ m_filename = (largs.GetSize()) ? largs.PopWord() : "inst_set_count.dat";
+ }
+ static const cString GetDescription() { return "Arguments: [string verbosity='']"; }
+ void Process(cAvidaContext& ctx)
+ {
+ ofstream& fot = m_world->GetDataFileOFStream(m_filename);
+ int update = m_world->GetStats().GetUpdate();
+ fot << update << " ";
+ for (int k=0; k < m_world->GetStats().GetInstSetCounts().GetSize(); k++)
+ fot << m_world->GetStats().GetInstSetCounts()[k] << " ";
+ fot << endl;
+ }
+
+};
+
void RegisterPrintActions(cActionLibrary* action_lib)
{
// Stats Out Files
@@ -2686,6 +2709,9 @@
action_lib->Register<cActionDumpCellDataGrid>("DumpCellDataGrid");
action_lib->Register<cActionDumpSleepGrid>("DumpSleepGrid");
+ //@MRR Instset Competition Functions
+ action_lib->Register<cActionPrintInstSetCounts>("PrintInstSetCount");
+
// Print Settings
action_lib->Register<cActionSetVerbose>("SetVerbose");
Modified: branches/matt/CompeteInstSet/source/cpu/cHardwareManager.cc
===================================================================
--- branches/matt/CompeteInstSet/source/cpu/cHardwareManager.cc 2009-06-05 21:04:52 UTC (rev 3293)
+++ branches/matt/CompeteInstSet/source/cpu/cHardwareManager.cc 2009-06-06 19:57:32 UTC (rev 3294)
@@ -35,6 +35,7 @@
#include "cWorldDriver.h"
#include "cOrganism.h"
#include "tDictionary.h"
+#include "cStats.h"
cHardwareManager::cHardwareManager(cWorld* world)
: m_world(world), m_type(world->GetConfig().HARDWARE_TYPE.Get()) /*, m_testres(world) */
@@ -110,6 +111,7 @@
m_inst_sets[id] = new_inst_set;
} else{ //If we have to resize the array to accomodate the ID
m_inst_sets.Resize(id+1, NULL);
+ m_world->GetStats().GetInstSetCounts().Resize(id+1,0);
m_inst_sets[id] = new_inst_set;
}
} else{ //Our instruction set is incompatible
@@ -125,6 +127,7 @@
assert(in_org != NULL);
int inst_id = in_org->GetInstSetID();
+ assert(inst_id <= m_inst_sets.GetSize()-1);
switch (m_type)
{
case HARDWARE_TYPE_CPU_ORIGINAL:
Modified: branches/matt/CompeteInstSet/source/main/cPopulation.cc
===================================================================
--- branches/matt/CompeteInstSet/source/main/cPopulation.cc 2009-06-05 21:04:52 UTC (rev 3293)
+++ branches/matt/CompeteInstSet/source/main/cPopulation.cc 2009-06-06 19:57:32 UTC (rev 3294)
@@ -490,7 +490,7 @@
// Statistics...
m_world->GetStats().RecordBirth(target_cell.GetID(), in_genotype->GetID(),
- in_organism->GetPhenotype().ParentTrue());
+ in_organism->GetPhenotype().ParentTrue(), in_organism->GetInstSetID());
// @MRR Do coalescence clade set up for new organisms.
CCladeSetupOrganism(in_organism );
@@ -614,7 +614,7 @@
// Statistics...
cOrganism* organism = in_cell.GetOrganism();
cGenotype* genotype = organism->GetGenotype();
- m_world->GetStats().RecordDeath();
+ m_world->GetStats().RecordDeath(organism->GetInstSetID());
int cellID = in_cell.GetID();
@@ -2685,7 +2685,7 @@
* this organism.
**/
-void cPopulation::Inject(const cGenome & genome, int cell_id, double merit, int lineage_label, double neutral)
+void cPopulation::Inject(const cGenome & genome, int cell_id, double merit, int lineage_label, double neutral, int inst_id)
{
// If an invalid cell was given, choose a new ID for it.
if (cell_id < 0) {
@@ -2697,7 +2697,7 @@
}
}
- InjectGenome(cell_id, genome, lineage_label);
+ InjectGenome(cell_id, genome, lineage_label, inst_id);
cPhenotype& phenotype = GetCell(cell_id).GetOrganism()->GetPhenotype();
phenotype.SetNeutralMetric(neutral);
@@ -2887,13 +2887,13 @@
// This function injects a new organism into the population at cell_id based
// on the genotype passed in.
-void cPopulation::InjectGenotype(int cell_id, cGenotype *new_genotype)
+void cPopulation::InjectGenotype(int cell_id, cGenotype *new_genotype, int inst_set)
{
assert(cell_id >= 0 && cell_id < cell_array.GetSize());
cAvidaContext& ctx = m_world->GetDefaultContext();
- cOrganism* new_organism = new cOrganism(m_world, ctx, new_genotype->GetGenome());
+ cOrganism* new_organism = new cOrganism(m_world, ctx, new_genotype->GetGenome(), inst_set);
//Coalescense Clade Setup
new_organism->SetCCladeLabel(-1);
@@ -2942,7 +2942,7 @@
cAvidaContext& ctx = m_world->GetDefaultContext();
- cOrganism* new_organism = new cOrganism(m_world, ctx, orig_org.GetGenome());
+ cOrganism* new_organism = new cOrganism(m_world, ctx, orig_org.GetGenome(), orig_org.GetInstSetID());
// Set the genotype...
new_organism->SetGenotype(orig_org.GetGenotype());
@@ -3031,13 +3031,13 @@
}
-void cPopulation::InjectGenome(int cell_id, const cGenome& genome, int lineage_label)
+void cPopulation::InjectGenome(int cell_id, const cGenome& genome, int lineage_label, int inst_set_id)
{
// Setup the genotype...
cGenotype* new_genotype = m_world->GetClassificationManager().GetGenotypeInjected(genome, lineage_label);
// The rest is done by InjectGenotype();
- InjectGenotype( cell_id, new_genotype );
+ InjectGenotype( cell_id, new_genotype, inst_set_id );
}
Modified: branches/matt/CompeteInstSet/source/main/cPopulation.h
===================================================================
--- branches/matt/CompeteInstSet/source/main/cPopulation.h 2009-06-05 21:04:52 UTC (rev 3293)
+++ branches/matt/CompeteInstSet/source/main/cPopulation.h 2009-06-06 19:57:32 UTC (rev 3294)
@@ -132,8 +132,8 @@
* Attention: InjectGenotype does *not* add the genotype to the archive.
* It assumes that's where you got the genotype from.
**/
- void InjectGenotype(int cell_id, cGenotype* genotype);
- void InjectGenome(int cell_id, const cGenome& genome, int lineage_label);
+ void InjectGenotype(int cell_id, cGenotype* genotype, int inst_set_id=0);
+ void InjectGenome(int cell_id, const cGenome& genome, int lineage_label, int inst_set_id=0);
void InjectClone(int cell_id, cOrganism& orig_org);
void InjectChild(int cell_id, cOrganism& orig_org);
@@ -159,7 +159,7 @@
// Inject an organism from the outside world.
void Inject(const cGenome& genome, int cell_id = -1, double merit = -1, int lineage_label = 0,
- double neutral_metric = 0);
+ double neutral_metric = 0, int inst_set_id=0);
void InjectParasite(const cCodeLabel& label, const cGenome& injected_code, int cell_id);
// Deactivate an organism in the population (required for deactivations)
Modified: branches/matt/CompeteInstSet/source/main/cStats.cc
===================================================================
--- branches/matt/CompeteInstSet/source/main/cStats.cc 2009-06-05 21:04:52 UTC (rev 3293)
+++ branches/matt/CompeteInstSet/source/main/cStats.cc 2009-06-06 19:57:32 UTC (rev 3294)
@@ -370,11 +370,13 @@
dom_fidelity = base_fidelity * pow(1.0 - true_cm_rate, dom_size);
}
-void cStats::RecordBirth(int cell_id, int genotype_id, bool breed_true)
+void cStats::RecordBirth(int cell_id, int genotype_id, bool breed_true, int inst_set_id)
{
tot_organisms++;
num_births++;
+ inst_set_orgs[inst_set_id]++;
+
if (m_world->GetConfig().LOG_CREATURES.Get()) {
cDataFile& df = m_world->GetDataFile("creature.log");
df.Write(m_update, "Update");
Modified: branches/matt/CompeteInstSet/source/main/cStats.h
===================================================================
--- branches/matt/CompeteInstSet/source/main/cStats.h 2009-06-05 21:04:52 UTC (rev 3293)
+++ branches/matt/CompeteInstSet/source/main/cStats.h 2009-06-06 19:57:32 UTC (rev 3294)
@@ -232,11 +232,16 @@
tArray<cString> reaction_names;
tArray<cString> resource_names;
+ // Count of organisms using particular instruction sets
+ tArray<int> inst_set_orgs;
+
// Resampling Statistics @AWC - 06/29/06
int num_resamplings;
int num_failedResamplings;
+
+
// State variables
int last_update;
@@ -421,8 +426,8 @@
void CalcEnergy();
void CalcFidelity();
- void RecordBirth(int cell_id, int genotype_id, bool breed_true);
- void RecordDeath() { num_deaths++; }
+ void RecordBirth(int cell_id, int genotype_id, bool breed_true, int inst_set_id);
+ void RecordDeath(int inst_set_id) { num_deaths++; inst_set_orgs[inst_set_id]--;}
void AddGenotype() { tot_genotypes++; }
void RemoveGenotype(int id_num, int parent_id,
int parent_distance, int depth, int max_abundance,
@@ -512,6 +517,8 @@
int GetTotSpecies() const { return tot_species; }
int GetTotThreshSpecies() const { return tot_thresh_species; }
int GetTotLineages() const { return tot_lineages; }
+
+ tArray<int>& GetInstSetCounts() {return inst_set_orgs;}
int GetTaskCurCount(int task_num) const { return task_cur_count[task_num]; }
double GetTaskCurQuality(int task_num) const { return task_cur_quality[task_num]/(double)task_cur_count[task_num]; }
More information about the Avida-cvs
mailing list