[Avida-SVN] r3564 - in branches/biounit: . Avida.xcodeproj source/actions source/classification source/cpu source/main source/targets/avida-viewer
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Thu Dec 17 12:03:50 PST 2009
Author: brysonda
Date: 2009-12-17 15:03:49 -0500 (Thu, 17 Dec 2009)
New Revision: 3564
Added:
branches/biounit/source/main/cParasite.cc
branches/biounit/source/main/cParasite.h
Removed:
branches/biounit/source/classification/cInjectGenotype.cc
branches/biounit/source/classification/cInjectGenotype.h
branches/biounit/source/classification/cInjectGenotypeControl.cc
branches/biounit/source/classification/cInjectGenotypeControl.h
branches/biounit/source/classification/cInjectGenotypeElement.h
branches/biounit/source/classification/cInjectGenotypeQueue.cc
branches/biounit/source/classification/cInjectGenotypeQueue.h
branches/biounit/source/classification/cInjectGenotype_BirthData.h
branches/biounit/source/classification/nInjectGenotype.h
Modified:
branches/biounit/Avida.xcodeproj/project.pbxproj
branches/biounit/CMakeLists.txt
branches/biounit/source/actions/PrintActions.cc
branches/biounit/source/actions/SaveLoadActions.cc
branches/biounit/source/classification/cClassificationManager.cc
branches/biounit/source/classification/cClassificationManager.h
branches/biounit/source/cpu/cHardwareBase.h
branches/biounit/source/cpu/cHardwareCPU.h
branches/biounit/source/cpu/cHardwareExperimental.h
branches/biounit/source/cpu/cHardwareGX.h
branches/biounit/source/cpu/cHardwareSMT.cc
branches/biounit/source/cpu/cHardwareSMT.h
branches/biounit/source/cpu/cHardwareTransSMT.cc
branches/biounit/source/cpu/cHardwareTransSMT.h
branches/biounit/source/cpu/cTestCPU.cc
branches/biounit/source/cpu/cTestCPU.h
branches/biounit/source/cpu/cTestCPUInterface.cc
branches/biounit/source/cpu/cTestCPUInterface.h
branches/biounit/source/main/cOrgInterface.h
branches/biounit/source/main/cOrganism.cc
branches/biounit/source/main/cOrganism.h
branches/biounit/source/main/cPopulation.cc
branches/biounit/source/main/cPopulation.h
branches/biounit/source/main/cPopulationInterface.cc
branches/biounit/source/main/cPopulationInterface.h
branches/biounit/source/main/cStats.cc
branches/biounit/source/main/cStats.h
branches/biounit/source/targets/avida-viewer/cScreen.h
branches/biounit/source/targets/avida-viewer/cViewInfo.cc
branches/biounit/source/targets/avida-viewer/cViewInfo.h
Log:
Work towards biounit based tracking of parasite genotypes. This is incomplete at the moment and does not compile.
Modified: branches/biounit/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/biounit/Avida.xcodeproj/project.pbxproj 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/Avida.xcodeproj/project.pbxproj 2009-12-17 20:03:49 UTC (rev 3564)
@@ -109,9 +109,6 @@
7023EC690C0A431B00362B9C /* cHelpType.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0891808F7630100FC65FE /* cHelpType.cc */; };
7023EC6A0C0A431B00362B9C /* cHistogram.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0891908F7630100FC65FE /* cHistogram.cc */; };
7023EC6B0C0A431B00362B9C /* cInitFile.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0891A08F7630100FC65FE /* cInitFile.cc */; };
- 7023EC6C0C0A431B00362B9C /* cInjectGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70533364092A3DF4006BD186 /* cInjectGenotype.cc */; };
- 7023EC6D0C0A431B00362B9C /* cInjectGenotypeControl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70533366092A3DF4006BD186 /* cInjectGenotypeControl.cc */; };
- 7023EC6E0C0A431B00362B9C /* cInjectGenotypeQueue.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70533369092A3DF4006BD186 /* cInjectGenotypeQueue.cc */; };
7023EC6F0C0A431B00362B9C /* cInstruction.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70CA6EBF08DB7F8200068AC2 /* cInstruction.cc */; };
7023EC700C0A431B00362B9C /* cInstSet.cc in Sources */ = {isa = PBXBuildFile; fileRef = 706C6FFE0B83F265003174C1 /* cInstSet.cc */; };
7023EC710C0A431B00362B9C /* cIntegratedSchedule.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0891B08F7630100FC65FE /* cIntegratedSchedule.cc */; };
@@ -230,6 +227,8 @@
7073972E0D725B9F003855D3 /* cSemanticASTVisitor.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7073972C0D725B9D003855D3 /* cSemanticASTVisitor.cc */; };
7076FEB00D347FD000556CAF /* cAnalyzeTreeStats_CumulativeStemminess.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7076FEAE0D347FD000556CAF /* cAnalyzeTreeStats_CumulativeStemminess.cc */; };
7076FEB10D347FD000556CAF /* cAnalyzeTreeStats_Gamma.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7076FEAF0D347FD000556CAF /* cAnalyzeTreeStats_Gamma.cc */; };
+ 7090F57510D956A400ECFBA1 /* cParasite.h in Headers */ = {isa = PBXBuildFile; fileRef = 7090F57310D956A400ECFBA1 /* cParasite.h */; };
+ 7090F57610D956A400ECFBA1 /* cParasite.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7090F57410D956A400ECFBA1 /* cParasite.cc */; };
709A1EEB0EB6C42D006090AF /* cOrgMovementPredicate.h in Headers */ = {isa = PBXBuildFile; fileRef = 709A1EE90EB6C42D006090AF /* cOrgMovementPredicate.h */; };
709A1EEC0EB6C42D006090AF /* cResourceHistory.cc in Sources */ = {isa = PBXBuildFile; fileRef = 709A1EEA0EB6C42D006090AF /* cResourceHistory.cc */; };
70A33CF60D8DCBB4008EF976 /* ASCoreLib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70A33CF50D8DCBB4008EF976 /* ASCoreLib.cc */; };
@@ -602,16 +601,7 @@
7053324A0929764A006BD186 /* cSpeciesQueue.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cSpeciesQueue.cc; sourceTree = "<group>"; };
7053324B0929764A006BD186 /* cSpeciesQueue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cSpeciesQueue.h; sourceTree = "<group>"; };
7053325609297702006BD186 /* nSpecies.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = nSpecies.h; sourceTree = "<group>"; };
- 70533363092A3DF4006BD186 /* cInjectGenotype_BirthData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cInjectGenotype_BirthData.h; sourceTree = "<group>"; };
- 70533364092A3DF4006BD186 /* cInjectGenotype.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cInjectGenotype.cc; sourceTree = "<group>"; };
- 70533365092A3DF4006BD186 /* cInjectGenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cInjectGenotype.h; sourceTree = "<group>"; };
- 70533366092A3DF4006BD186 /* cInjectGenotypeControl.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cInjectGenotypeControl.cc; sourceTree = "<group>"; };
- 70533367092A3DF4006BD186 /* cInjectGenotypeControl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cInjectGenotypeControl.h; sourceTree = "<group>"; };
- 70533368092A3DF4006BD186 /* cInjectGenotypeElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cInjectGenotypeElement.h; sourceTree = "<group>"; };
- 70533369092A3DF4006BD186 /* cInjectGenotypeQueue.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cInjectGenotypeQueue.cc; sourceTree = "<group>"; };
- 7053336A092A3DF4006BD186 /* cInjectGenotypeQueue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cInjectGenotypeQueue.h; sourceTree = "<group>"; };
7053336B092A3DF4006BD186 /* nGenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = nGenotype.h; sourceTree = "<group>"; };
- 7053336C092A3DF4006BD186 /* nInjectGenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = nInjectGenotype.h; sourceTree = "<group>"; };
705333E5092A4B7C006BD186 /* cLineage.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cLineage.cc; sourceTree = "<group>"; };
705333E6092A4B7C006BD186 /* cLineage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cLineage.h; sourceTree = "<group>"; };
7054A16E09A8014600038658 /* cAnalyzeJobQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cAnalyzeJobQueue.h; sourceTree = "<group>"; };
@@ -692,6 +682,8 @@
708051BA0A1F66B400CBB8B6 /* cActionLibrary.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cActionLibrary.cc; sourceTree = "<group>"; };
708BF2FD0AB65DC700A923BF /* cEventList.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cEventList.cc; sourceTree = "<group>"; };
708BF3010AB65DD300A923BF /* cEventList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cEventList.h; sourceTree = "<group>"; };
+ 7090F57310D956A400ECFBA1 /* cParasite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cParasite.h; sourceTree = "<group>"; };
+ 7090F57410D956A400ECFBA1 /* cParasite.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cParasite.cc; sourceTree = "<group>"; };
70920C1C0A9CCE2C00757CDB /* analyze_samples.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html.documentation; path = analyze_samples.html; sourceTree = "<group>"; };
70920C1D0A9CCE2C00757CDB /* code_c++_intro.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html.documentation; path = "code_c++_intro.html"; sourceTree = "<group>"; };
70920C1E0A9CCE2C00757CDB /* code_death_birth.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html.documentation; path = code_death_birth.html; sourceTree = "<group>"; };
@@ -1496,16 +1488,7 @@
children = (
705333E5092A4B7C006BD186 /* cLineage.cc */,
705333E6092A4B7C006BD186 /* cLineage.h */,
- 70533363092A3DF4006BD186 /* cInjectGenotype_BirthData.h */,
- 70533364092A3DF4006BD186 /* cInjectGenotype.cc */,
- 70533365092A3DF4006BD186 /* cInjectGenotype.h */,
- 70533366092A3DF4006BD186 /* cInjectGenotypeControl.cc */,
- 70533367092A3DF4006BD186 /* cInjectGenotypeControl.h */,
- 70533368092A3DF4006BD186 /* cInjectGenotypeElement.h */,
- 70533369092A3DF4006BD186 /* cInjectGenotypeQueue.cc */,
- 7053336A092A3DF4006BD186 /* cInjectGenotypeQueue.h */,
7053336B092A3DF4006BD186 /* nGenotype.h */,
- 7053336C092A3DF4006BD186 /* nInjectGenotype.h */,
7053325609297702006BD186 /* nSpecies.h */,
705332480929764A006BD186 /* cSpecies.cc */,
705332490929764A006BD186 /* cSpecies.h */,
@@ -1733,6 +1716,8 @@
70447CA90F83DBC100E1BF72 /* cBirthDemeHandler.h */,
70447CAA0F83DBC100E1BF72 /* cBirthDemeHandler.cc */,
BBDE4FF80FC1B06600CC6170 /* cDemePredicate.h */,
+ 7090F57310D956A400ECFBA1 /* cParasite.h */,
+ 7090F57410D956A400ECFBA1 /* cParasite.cc */,
);
path = main;
sourceTree = "<group>";
@@ -1940,6 +1925,7 @@
70447CAB0F83DBC100E1BF72 /* cBirthDemeHandler.h in Headers */,
B462B5C10FA0F47D00F379D1 /* cPhenPlastSummary.h in Headers */,
702082900FB9F2DF00637AD6 /* cBitArray.h in Headers */,
+ 7090F57510D956A400ECFBA1 /* cParasite.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2239,9 +2225,6 @@
7023EC690C0A431B00362B9C /* cHelpType.cc in Sources */,
7023EC6A0C0A431B00362B9C /* cHistogram.cc in Sources */,
7023EC6B0C0A431B00362B9C /* cInitFile.cc in Sources */,
- 7023EC6C0C0A431B00362B9C /* cInjectGenotype.cc in Sources */,
- 7023EC6D0C0A431B00362B9C /* cInjectGenotypeControl.cc in Sources */,
- 7023EC6E0C0A431B00362B9C /* cInjectGenotypeQueue.cc in Sources */,
7023EC6F0C0A431B00362B9C /* cInstruction.cc in Sources */,
7023EC700C0A431B00362B9C /* cInstSet.cc in Sources */,
7023EC710C0A431B00362B9C /* cIntegratedSchedule.cc in Sources */,
@@ -2325,6 +2308,7 @@
701E746C10A37967006B6193 /* cBGGenotype.cc in Sources */,
701E748510A37DB2006B6193 /* cBioGroupManager.cc in Sources */,
70B547FD10AB22920013E999 /* cBGGenotypeManager.cc in Sources */,
+ 7090F57610D956A400ECFBA1 /* cParasite.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: branches/biounit/CMakeLists.txt
===================================================================
--- branches/biounit/CMakeLists.txt 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/CMakeLists.txt 2009-12-17 20:03:49 UTC (rev 3564)
@@ -150,9 +150,6 @@
${CLASSIFICATION_DIR}/cGenotype.cc
${CLASSIFICATION_DIR}/cGenotype_BirthData.cc
${CLASSIFICATION_DIR}/cGenotypeControl.cc
- ${CLASSIFICATION_DIR}/cInjectGenotype.cc
- ${CLASSIFICATION_DIR}/cInjectGenotypeControl.cc
- ${CLASSIFICATION_DIR}/cInjectGenotypeQueue.cc
${CLASSIFICATION_DIR}/cLineage.cc
${CLASSIFICATION_DIR}/cMutationSteps.cc
${CLASSIFICATION_DIR}/cSpecies.cc
Modified: branches/biounit/source/actions/PrintActions.cc
===================================================================
--- branches/biounit/source/actions/PrintActions.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/actions/PrintActions.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -38,7 +38,6 @@
#include "cHardwareBase.h"
#include "cHardwareManager.h"
#include "cHistogram.h"
-#include "cInjectGenotype.h"
#include "cInstSet.h"
#include "cOrganism.h"
#include "cPhenPlastGenotype.h"
@@ -54,7 +53,9 @@
#include <cerrno>
#include <map>
+class cBioGroup;
+
#define STATS_OUT_FILE(METHOD, DEFAULT) /* 1 */ \
class cAction ## METHOD : public cAction { /* 2 */ \
private: /* 3 */ \
@@ -496,37 +497,26 @@
};
/*
- Write the currently dominant injected genotype to disk.
-
- Parameters:
- filename (string)
- The name under which the genotype should be saved. If no
- filename is given, the genotype is saved into the directory
- archive, under the name that the archive has associated with
- this genotype.
+ Write the currently dominant parasite genotype to disk.
*/
class cActionPrintDominantParasiteGenotype : public cAction
{
-private:
- cString m_filename;
-
public:
- cActionPrintDominantParasiteGenotype(cWorld* world, const cString& args) : cAction(world, args), m_filename("")
+ cActionPrintDominantParasiteGenotype(cWorld* world, const cString& args) : cAction(world, args)
{
- cString largs(args);
- if (largs.GetSize()) m_filename = largs.PopWord();
}
- static const cString GetDescription() { return "Arguments: [string fname='']"; }
+ static const cString GetDescription() { return "Arguments: (none)"; }
void Process(cAvidaContext& ctx)
{
- cInjectGenotype* dom = m_world->GetClassificationManager().GetBestInjectGenotype();
+ // @TODO - get best parasite?
+ assert(false);
+ //cBioGroup* dom = m_world->GetClassificationManager().GetBestParasite();
+ cBioGroup* dom = NULL;
if (dom != NULL) {
- cString filename(m_filename);
- if (filename == "") filename.Set("archive/%s.para", static_cast<const char*>(dom->GetName()));
cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
- testcpu->PrintInjectGenome(ctx, dom, dom->GetGenome(), filename, m_world->GetStats().GetUpdate());
+ testcpu->PrintBioGroup(ctx, dom, "", m_world->GetStats().GetUpdate());
delete testcpu;
}
}
Modified: branches/biounit/source/actions/SaveLoadActions.cc
===================================================================
--- branches/biounit/source/actions/SaveLoadActions.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/actions/SaveLoadActions.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -331,9 +331,12 @@
void Process(cAvidaContext& ctx)
{
+ assert(false);
+ // @TODO - save parasite pop?
+
cString filename(m_filename);
if (filename == "") filename.Set("parasite-%d.pop", m_world->GetStats().GetUpdate());
- m_world->GetClassificationManager().DumpInjectDetailedSummary(filename, m_world->GetStats().GetUpdate());
+// m_world->GetClassificationManager().DumpInjectDetailedSummary(filename, m_world->GetStats().GetUpdate());
}
};
Modified: branches/biounit/source/classification/cClassificationManager.cc
===================================================================
--- branches/biounit/source/classification/cClassificationManager.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/classification/cClassificationManager.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -31,7 +31,6 @@
#include "cGenome.h"
#include "cGenotype.h"
#include "cHardwareManager.h"
-#include "cInjectGenotype.h"
#include "cLineage.h"
#include "cOrganism.h"
#include "cSpecies.h"
@@ -51,10 +50,6 @@
, m_genotype_prev_dom(-1)
, m_species_ctl(new cSpeciesControl(world))
, m_species_next_id(0)
- , m_inject_ctl(new cInjectGenotypeControl(world))
- , m_inject_next_id(1)
- , m_inject_dom_time(0)
- , m_inject_prev_dom(-1)
, m_best_lineage(NULL)
, m_max_fitness_lineage(NULL)
, m_dominant_lineage(NULL)
@@ -62,7 +57,6 @@
{
for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
m_genotype_count[i] = 0;
- m_inject_count[i] = 0;
}
RegisterBioGroupManager(new cBGGenotypeManager(world), "genotype");
@@ -72,7 +66,6 @@
{
delete m_genotype_ctl;
delete m_species_ctl;
- delete m_inject_ctl;
}
bool cClassificationManager::RegisterBioGroupManager(cBioGroupManager* bgm, const cString& role)
@@ -128,23 +121,6 @@
}
- cInjectGenotype* best_inject_genotype = GetBestInjectGenotype();
-
- if (best_inject_genotype) { // If there is a dominant parasite
- if (best_inject_genotype->GetID() != m_inject_prev_dom) {
- m_inject_dom_time = 0;
- m_inject_prev_dom = best_inject_genotype->GetID();
- } else {
- m_inject_dom_time++;
- if (m_inject_dom_time == m_world->GetConfig().GENOTYPE_PRINT_DOM.Get()) {
- cString filename;
- filename.Set("archive/%s", static_cast<const char*>(best_inject_genotype->GetName()));
- testcpu->PrintInjectGenome(m_world->GetDefaultContext(), best_inject_genotype, best_inject_genotype->GetGenome(),
- filename, m_world->GetStats().GetUpdate());
- }
- }
- }
-
delete testcpu;
}
@@ -506,11 +482,6 @@
fp << m_genotype_count[i] << " ";
}
- // Save the numbers of organisms we're up to at each size.
- fp << MAX_CREATURE_SIZE << " ";
- for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
- fp << m_inject_count[i] << " ";
- }
return true;
}
@@ -526,12 +497,6 @@
for (int i = 0; i < max_size && i < MAX_CREATURE_SIZE; i++) {
fp >> m_genotype_count[i];
}
-
- fp >> max_size;
- assert (max_size <= MAX_CREATURE_SIZE); // MAX_CREATURE_SIZE too small
- for (int i = 0; i < max_size && i < MAX_CREATURE_SIZE; i++) {
- fp >> m_inject_count[i];
- }
return true;
}
@@ -855,128 +820,6 @@
}
-
-void cClassificationManager::AddInjectGenotype(cInjectGenotype* in_inject_genotype, int in_list_num)
-{
- assert( in_inject_genotype != 0 );
-
- if ( in_list_num < 0 )
- in_list_num = FindCRC(in_inject_genotype->GetGenome()) % nInjectGenotype::HASH_SIZE;
-
- m_active_inject[in_list_num].Insert(*in_inject_genotype);
- m_inject_ctl->Insert(*in_inject_genotype);
-}
-
-
-cInjectGenotype* cClassificationManager::GetInjectGenotype(const cGenome& in_genome, cInjectGenotype* parent_genotype)
-{
- int list_num = FindCRC(in_genome) % nInjectGenotype::HASH_SIZE;
- cInjectGenotype * found_genotype;
-
- found_genotype = m_active_inject[list_num].Find(in_genome);
-
- if (!found_genotype) {
- found_genotype = new cInjectGenotype(m_world, m_world->GetStats().GetUpdate(), m_inject_next_id++);
- found_genotype->SetGenome(in_genome);
- found_genotype->SetParent(parent_genotype);
- if(parent_genotype!=NULL)
- {
- parent_genotype->SetCanReproduce();
- }
- AddInjectGenotype( found_genotype, list_num );
- }
- return found_genotype;
-}
-
-cInjectGenotype* cClassificationManager::FindInjectGenotype(const cGenome& in_genome) const
-{
- int list_num = FindCRC(in_genome) % nInjectGenotype::HASH_SIZE;
- return m_active_inject[list_num].Find(in_genome);
-}
-
-void cClassificationManager::RemoveInjectGenotype(cInjectGenotype& in_inject_genotype)
-{
- // If this genotype is still active, mark it no longer active and
- // take it out of the hash table so it doesn't have any new organisms
- // assigned to it.
-
- if (in_inject_genotype.GetActive() == true) {
- int list_num = FindCRC(in_inject_genotype.GetGenome()) % nInjectGenotype::HASH_SIZE;
- m_active_inject[list_num].Remove(in_inject_genotype);
- m_inject_ctl->Remove(in_inject_genotype);
- //in_inject_genotype.Deactivate(stats.GetUpdate());
- if (m_world->GetConfig().TRACK_MAIN_LINEAGE.Get()) {
- m_inject_ctl->InsertHistoric(in_inject_genotype);
- }
- }
-
- delete &in_inject_genotype;
-}
-
-void cClassificationManager::ThresholdInjectGenotype(cInjectGenotype& in_inject_genotype)
-{
- in_inject_genotype.SetName( GetLabel(in_inject_genotype.GetLength(),
- m_inject_count[in_inject_genotype.GetLength()]++) );
- in_inject_genotype.SetThreshold();
-}
-
-bool cClassificationManager::AdjustInjectGenotype(cInjectGenotype& in_inject_genotype)
-{
- if (!m_inject_ctl->Adjust(in_inject_genotype)) return false;
-
- if ((in_inject_genotype.GetNumInjected() >= m_world->GetConfig().THRESHOLD.Get() ||
- &in_inject_genotype == m_inject_ctl->GetBest()) &&
- !(in_inject_genotype.GetThreshold())) {
- ThresholdInjectGenotype(in_inject_genotype);
- }
-
- return true;
-}
-
-bool cClassificationManager::DumpInjectTextSummary(ofstream& fp)
-{
- m_inject_ctl->Reset(0);
- for (int i = 0; i < m_inject_ctl->GetSize(); i++) {
- cInjectGenotype * genotype = m_inject_ctl->Get(0);
- fp << genotype->GetGenome().AsString() << " "
- << genotype->GetNumInjected() << " "
- << genotype->GetID() << endl;
- m_inject_ctl->Next(0);
- }
-
- return true;
-}
-
-bool cClassificationManager::DumpInjectDetailedSummary(const cString & file, int update)
-{
- m_inject_ctl->Reset(0);
- for (int i = 0; i < m_inject_ctl->GetSize(); i++) {
- DumpInjectDetailedEntry(m_inject_ctl->Get(0), file, update);
- m_inject_ctl->Next(0);
- }
- return true;
-}
-
-void cClassificationManager::DumpInjectDetailedEntry(cInjectGenotype * genotype, const cString & filename, int update)
-{
- cDataFile & df = m_world->GetDataFile(filename);
-
- df.WriteComment( "Avida parasite dump data" );
- df.WriteTimeStamp();
-
- df.Write( genotype->GetID(), "parasite genotype ID");
- df.Write( genotype->GetName(), "parasite genotype name");
- df.Write( genotype->GetParentID(), "parasite parent ID");
- df.Write( genotype->GetNumInjected(), "current number of injected creatures with this genotype");
- df.Write( genotype->GetTotalInjected(), "total number of injected creatures with this genotype");
- df.Write( genotype->GetLength(), "genotype length");
- df.Write( genotype->GetUpdateBorn(), "update this genotype was born");
- df.Write( genotype->CanReproduce(), "has this genotype reproduced?");
- df.Write( genotype->GetGenome().AsString(), "genome of this genotype");
- df.Endl();
-}
-
-
cLineage* cClassificationManager::AddLineage(double start_fitness, int parent_lin_id, int id, double lineage_stat1, double lineage_stat2)
{
if (id < 0) id = m_lineage_next_id++;
@@ -1346,20 +1189,6 @@
}
-unsigned int cClassificationManager::FindInjectCRC(const cGenome & in_genome) const
-{
- unsigned int total = 13;
- int i;
-
- for (i = 0; i < in_genome.GetSize(); i++) {
- total *= in_genome[i].GetOp() + 10 + i << 6;
- total += 3;
- }
-
- return total;
-}
-
-
cString cClassificationManager::GetLabel(int in_size, int in_num)
{
char alpha[6];
Modified: branches/biounit/source/classification/cClassificationManager.h
===================================================================
--- branches/biounit/source/classification/cClassificationManager.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/classification/cClassificationManager.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -35,12 +35,6 @@
#ifndef cGenotypeControl_h
#include "cGenotypeControl.h"
#endif
-#ifndef cInjectGenotypeControl_h
-#include "cInjectGenotypeControl.h"
-#endif
-#ifndef cInjectGenotypeQueue_h
-#include "cInjectGenotypeQueue.h"
-#endif
#ifndef cSpeciesControl_h
#include "cSpeciesControl.h"
#endif
@@ -83,14 +77,6 @@
cSpeciesControl* m_species_ctl;
int m_species_next_id;
- // InjectGenotype Structures
- unsigned int m_inject_count[MAX_CREATURE_SIZE];
- cInjectGenotypeQueue m_active_inject[nInjectGenotype::HASH_SIZE];
- cInjectGenotypeControl* m_inject_ctl;
- int m_inject_next_id;
- int m_inject_dom_time;
- int m_inject_prev_dom;
-
// Lineage Structures
std::list<cLineage*> m_lineage_list;
cLineage* m_best_lineage; // the lineage with the highest average fitness
@@ -156,33 +142,6 @@
void DumpDetailedSexEntry(cGenotype* genotype, std::ofstream& fp);
- // InjectGenotype Manipulation
- cInjectGenotype* GetInjectGenotype(const cGenome& in_genome, cInjectGenotype* parent_inject_genotype = NULL);
- cInjectGenotype* FindInjectGenotype(const cGenome& in_genome) const;
- void RemoveInjectGenotype(cInjectGenotype & in_inject_genotype);
- void ThresholdInjectGenotype(cInjectGenotype & in_inject_genotype);
- bool AdjustInjectGenotype(cInjectGenotype & in_inject_genotype);
-
- int GetInjectGenotypeCount() const { return m_inject_ctl->GetSize(); }
- cInjectGenotype* GetBestInjectGenotype() const { return m_inject_ctl->GetBest(); }
- cInjectGenotype* GetCoalescentInjectGenotype() const { return m_inject_ctl->GetCoalescent(); }
-
- cInjectGenotype* GetInjectGenotype(int thread) const { return m_inject_ctl->Get(thread); }
- cInjectGenotype* NextInjectGenotype(int thread)
- {
- cInjectGenotype* next = m_inject_ctl->Next(thread);
- return (next == m_inject_ctl->GetBest()) ? NULL : next;
- }
- cInjectGenotype* ResetInjectThread(int thread) { return m_inject_ctl->Reset(thread); }
-
- int FindPos(cInjectGenotype& inject, int max_depth = -1) { return m_inject_ctl->FindPos(inject, max_depth); }
-
- // InjectGenotype Output
- bool DumpInjectTextSummary(std::ofstream& fp);
- bool DumpInjectDetailedSummary(const cString & file, int update);
- void DumpInjectDetailedEntry(cInjectGenotype * inject_genotype, const cString & file, int update);
-
-
// Species Accessors
cSpecies* GetFirstSpecies() const { return m_species_ctl->GetFirst(); }
int GetNumSpecies() const { return m_species_ctl->GetSize(); }
@@ -217,13 +176,10 @@
private:
void AddGenotype(cGenotype* in_genotype, int list_num = -1);
- void AddInjectGenotype(cInjectGenotype* in_inject_genotype, int in_list_num = -1);
void DumpDetailHeading(std::ofstream& fp, bool print_mut_steps = false);
void DumpDetailSexHeading (std::ofstream& fp);
unsigned int FindCRC(const cGenome& in_genome) const;
- unsigned int FindInjectCRC(const cGenome& in_genome) const;
cString GetLabel(int in_size, int in_num);
- cString GetInjectLabel(int in_size, int in_num) { return cString("p") + GetLabel(in_size, in_num); }
cLineage* AddLineage(double start_fitness, int parent_lin_id, int id = -1, double lineage_stat1 = 0.0, double lineage_stat2 = 0.0);
void UpdateLineages();
Deleted: branches/biounit/source/classification/cInjectGenotype.cc
===================================================================
--- branches/biounit/source/classification/cInjectGenotype.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/classification/cInjectGenotype.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -1,150 +0,0 @@
-/*
- * cInjectGenotype.cc
- * Avida
- *
- * Called "inject_genotype.cc" prior to 11/15/05.
- * Copyright 1999-2009 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "cInjectGenotype.h"
-
-#include "cTools.h"
-#include "cWorld.h"
-
-using namespace std;
-
-cInjectGenotype::cInjectGenotype(cWorld* world, int in_update_born, int in_id)
- : m_world(world)
- , genome(1)
- , name("p001-no_name")
- , flag_threshold(false)
- , is_active(true)
- , can_reproduce(false)
- , defer_adjust(0)
- , id_num(in_id)
- , symbol(0)
- , birth_data(in_update_born)
- , num_injected(0)
- , last_num_injected(0)
- , total_injected(0)
- , next(NULL)
- , prev(NULL)
-{
-}
-
-cInjectGenotype::~cInjectGenotype()
-{
- // Reset some of the variables to make sure program will crash if a deleted
- // cell is read!
- symbol = '!';
-
- num_injected = -1;
- total_injected = -1;
-
- next = NULL;
- prev = NULL;
-}
-
-bool cInjectGenotype::SaveClone(ofstream& fp)
-{
- fp << id_num << " ";
- fp << genome.GetSize() << " ";
-
- for (int i = 0; i < genome.GetSize(); i++) {
- fp << ((int) genome[i].GetOp()) << " ";
- }
-
- return true;
-}
-
-bool cInjectGenotype::LoadClone(ifstream & fp)
-{
- int genome_size = 0;
-
- fp >> id_num;
- fp >> genome_size;
-
- genome = cGenome(genome_size);
- for (int i = 0; i < genome_size; i++) {
- cInstruction temp_inst;
- int inst_op;
- fp >> inst_op;
- temp_inst.SetOp(static_cast<unsigned char>(inst_op));
- genome[i] = temp_inst;
- // @CAO add something here to load arguments for instructions.
- }
-
- return true;
-}
-
-bool cInjectGenotype::OK()
-{
- bool ret_value = true;
-
- // Check statistics
- assert( id_num >= 0 && num_injected >= 0 && total_injected >= 0 );
- assert( birth_data.update_born >= -1);
-
- return ret_value;
-}
-
-void cInjectGenotype::SetParent(cInjectGenotype * parent)
-{
- birth_data.parent_genotype = parent;
-
- // If we have a real parent genotype, collect other data about parent.
- if (parent == NULL) return;
- birth_data.parent_id = parent->GetID();
- birth_data.gene_depth = parent->GetDepth() + 1;
- parent->AddOffspringGenotype();
-}
-
-void cInjectGenotype::UpdateReset()
-{
- last_num_injected = num_injected;
- birth_data.birth_track.Next();
- birth_data.death_track.Next();
-}
-
-void cInjectGenotype::SetGenome(const cGenome & in_genome)
-{
- genome = in_genome;
-
- name.Set("p%03d-no_name", genome.GetSize());
-}
-
-void cInjectGenotype::Deactivate(int update)
-{
- is_active = false;
- birth_data.update_deactivated = update;
-}
-
-int cInjectGenotype::AddParasite()
-{
- total_injected++;
- return num_injected++;
-}
-
-int cInjectGenotype::RemoveParasite()
-{
- //birth_data.death_track.Inc();
- return num_injected--;
-}
-
Deleted: branches/biounit/source/classification/cInjectGenotype.h
===================================================================
--- branches/biounit/source/classification/cInjectGenotype.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/classification/cInjectGenotype.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -1,149 +0,0 @@
-/*
- * cInjectGenotype.h
- * Avida
- *
- * Called "inject_genotype.hh" prior to 11/15/05.
- * Copyright 1999-2009 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef cInjectGenotype_h
-#define cInjectGenotype_h
-
-#include <fstream>
-
-#ifndef cGenome_h
-#include "cGenome.h"
-#endif
-#ifndef cInjectGenotype_BirthData_h
-#include "cInjectGenotype_BirthData.h"
-#endif
-#ifndef cString_h
-#include "cString.h"
-#endif
-
-class cWorld;
-
-class cInjectGenotype {
-private:
- friend class cClassificationManager;
-
- cWorld* m_world;
- cGenome genome;
- cString name;
- bool flag_threshold;
- bool is_active; // Is this genotype still alive?
- bool can_reproduce; // Can this genotype reproduce?
- int defer_adjust; // Don't adjust in the archive until all are cleared.
-
- int id_num;
- char symbol;
-
- cInjectGenotype_BirthData birth_data;
-
- // Statistical info
- int num_injected;
- int last_num_injected;
- int total_injected;
-
- // Data Structure stuff...
- cInjectGenotype * next;
- cInjectGenotype * prev;
-
- void CalcTestStats() const;
-
- // Private Constructor
- cInjectGenotype(cWorld* world, int in_update_born = 0, int in_id = -1);
-
- cInjectGenotype(); // @not_implemented
- cInjectGenotype(const cInjectGenotype&); // @not_implemented
- cInjectGenotype& operator=(const cInjectGenotype&); // @not_implemented
-
-public:
- ~cInjectGenotype();
-
- bool SaveClone(std::ofstream& fp);
- bool LoadClone(std::ifstream & fp);
- bool OK();
- void UpdateReset();
-
- void SetGenome(const cGenome & in_genome);
-
- void SetParent(cInjectGenotype * parent);
- void SetUpdateBorn (int update) { birth_data.update_born = update; }
- void SetName(cString in_name) { name = in_name; }
- void SetNext(cInjectGenotype * in_next) { next = in_next; }
- void SetPrev(cInjectGenotype * in_prev) { prev = in_prev; }
- void SetSymbol(char in_symbol) { symbol = in_symbol; }
- void SetCanReproduce() { can_reproduce = true; }
- inline void SetThreshold();
- void IncDeferAdjust() { defer_adjust++; }
- void DecDeferAdjust() { defer_adjust--; assert(defer_adjust >= 0); }
-
- //// Properties Native to Genotype ////
- cGenome & GetGenome() { return genome; }
- const cGenome & GetGenome() const { return genome; }
- int GetLength() const { return genome.GetSize(); }
-
- // For tracking the genotype line back to the ancestor...
- cInjectGenotype * GetParentGenotype() { return birth_data.parent_genotype; }
- int GetNumOffspringGenotypes() const { return birth_data.num_offspring_genotypes; }
- void AddOffspringGenotype() { birth_data.num_offspring_genotypes++; }
- void RemoveOffspringGenotype() { birth_data.num_offspring_genotypes--; }
- bool GetActive() const { return is_active; }
- int GetUpdateDeactivated() { return birth_data.update_deactivated; }
- void Deactivate(int update);
-
- bool CanReproduce() { return can_reproduce; }
- int GetUpdateBorn() { return birth_data.update_born; }
- int GetParentID() { return birth_data.parent_id; }
- int GetDepth() { return birth_data.gene_depth; }
- cString & GetName() { return name; }
- cInjectGenotype * GetNext() { return next; }
- cInjectGenotype * GetPrev() { return prev; }
- bool GetThreshold() const { return flag_threshold; }
- int GetID() const { return id_num; }
- char GetSymbol() const { return symbol; }
-
- int AddParasite();
- int RemoveParasite();
- int GetNumInjected() { return num_injected; }
- int GetTotalInjected() { return total_injected; }
-};
-
-
-#ifdef ENABLE_UNIT_TESTS
-namespace nInjectGenotype {
- /**
- * Run unit tests
- *
- * @param full Run full test suite; if false, just the fast tests.
- **/
- void UnitTests(bool full = false);
-}
-#endif
-
-
-inline void cInjectGenotype::SetThreshold()
-{
- flag_threshold = true;
- if (symbol == '.') symbol = '+';
-}
-
-#endif
Deleted: branches/biounit/source/classification/cInjectGenotypeControl.cc
===================================================================
--- branches/biounit/source/classification/cInjectGenotypeControl.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/classification/cInjectGenotypeControl.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -1,295 +0,0 @@
-/*
- * cInjectGenotypeControl.cc
- * Avida
- *
- * Called "inject_genotype_control.cc" prior to 11/15/05.
- * Copyright 1999-2009 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "cInjectGenotypeControl.h"
-
-#include "defs.h"
-#include "cClassificationManager.h"
-#include "cInjectGenotype.h"
-#include "cWorld.h"
-
-cInjectGenotypeControl::cInjectGenotypeControl(cWorld* world) : m_world(world)
-{
- size = 0;
- best = NULL;
- coalescent = NULL;
- for (int i = 0; i < nInjectGenotype::THREADS; i++) threads[i] = NULL;
-
- historic_list = NULL;
- historic_count = 0;
-}
-
-cInjectGenotypeControl::~cInjectGenotypeControl()
-{
-}
-
-bool cInjectGenotypeControl::OK()
-{
- int ret_value = true;
-
- // Cycle through the list, making sure all connections are proper, size
- // is correct, and all genotypes are OK().
-
- cInjectGenotype * cur_pos = best;
- for (int i = 0; i < size; i++) {
- if (!cur_pos->OK()) ret_value = false;
- assert (cur_pos->GetNext()->GetPrev() == cur_pos);
- cur_pos = cur_pos->GetNext();
- }
-
- assert (cur_pos == best);
-
- return ret_value;
-}
-
-void cInjectGenotypeControl::Insert(cInjectGenotype & in_inject_genotype, cInjectGenotype * prev_genotype)
-{
- if (prev_genotype == NULL) {
- assert(size == 0); // Destroying a full genotype queue...
-
- best = &in_inject_genotype;
- best->SetNext(best);
- best->SetPrev(best);
- }
- else {
- in_inject_genotype.SetPrev(prev_genotype);
- in_inject_genotype.SetNext(prev_genotype->GetNext());
- prev_genotype->SetNext(&in_inject_genotype);
- in_inject_genotype.GetNext()->SetPrev(&in_inject_genotype);
- }
-
- size++;
-}
-
-void cInjectGenotypeControl::Remove(cInjectGenotype & in_inject_genotype)
-{
- if (size == 1) {
- best = NULL;
- }
- if (&in_inject_genotype == best) {
- best = best->GetNext();
- }
-
- in_inject_genotype.GetNext()->SetPrev(in_inject_genotype.GetPrev());
- in_inject_genotype.GetPrev()->SetNext(in_inject_genotype.GetNext());
- in_inject_genotype.SetNext(NULL);
- in_inject_genotype.SetPrev(NULL);
-
- size--;
-}
-
-void cInjectGenotypeControl::RemoveHistoric(cInjectGenotype & in_inject_genotype)
-{
- if (historic_count == 1) {
- historic_list = NULL;
- }
- if (&in_inject_genotype == historic_list) {
- historic_list = historic_list->GetNext();
- }
-
- in_inject_genotype.GetNext()->SetPrev(in_inject_genotype.GetPrev());
- in_inject_genotype.GetPrev()->SetNext(in_inject_genotype.GetNext());
- in_inject_genotype.SetNext(NULL);
- in_inject_genotype.SetPrev(NULL);
-
- historic_count--;
-}
-
-void cInjectGenotypeControl::InsertHistoric(cInjectGenotype & in_inject_genotype)
-{
- if (historic_count == 0) {
- in_inject_genotype.SetNext(&in_inject_genotype);
- in_inject_genotype.SetPrev(&in_inject_genotype);
- }
- else {
- in_inject_genotype.SetPrev(historic_list->GetPrev());
- in_inject_genotype.SetNext(historic_list);
- historic_list->GetPrev()->SetNext(&in_inject_genotype);
- historic_list->SetPrev(&in_inject_genotype);
- }
-
- historic_list = &in_inject_genotype;
- historic_count++;
-}
-
-/*int cInjectGenotypeControl::UpdateCoalescent()
-{
- // Test to see if any updating needs to be done...
- // Don't update active coalescent genotype, or if there is more than
- // one offspring.
- if (coalescent != NULL &&
- (coalescent->GetNumInjected() > 0) ||
- coalescent->GetNumOffspringGenotypes() > 1) ) {
- return coalescent->GetDepth();
- }
-
- // If there is no best, there is nothing to search through...
- if (best == NULL) return -1;
-
- // Find the new point...
- cInjectGenotype * test_gen = best;
- cInjectGenotype * found_gen = best;
- cInjectGenotype * parent_gen = best->GetParentGenotype();
-
- while (parent_gen != NULL) {
- // See if this genotype should be the new found genotype...
- if (test_gen->GetNumOrganisms() > 0 ||
- test_gen->GetNumOffspringGenotypes() > 1) {
- found_gen = test_gen;
- }
-
- // Move to the next genotype...
- test_gen = parent_gen;
- parent_gen = test_gen->GetParentGenotype();
- }
-
- coalescent = found_gen;
-
- return coalescent->GetDepth();
-}*/
-
-
-bool cInjectGenotypeControl::CheckPos(cInjectGenotype & in_inject_genotype)
-{
- int next_OK = false;
- int prev_OK = false;
-
- if (in_inject_genotype.GetNumInjected() >= in_inject_genotype.GetNext()->GetNumInjected()) {
- next_OK =true;
- }
- if (in_inject_genotype.GetNumInjected() <= in_inject_genotype.GetPrev()->GetNumInjected()) {
- prev_OK =true;
- }
-
- if ((&in_inject_genotype == best && next_OK) ||
- (next_OK && prev_OK) ||
- (&in_inject_genotype == best->GetPrev() && prev_OK)) {
- return true;
- }
-
- return false;
-}
-
-void cInjectGenotypeControl::Insert(cInjectGenotype & new_genotype)
-{
- // If there is nothing in the list, add this.
-
- if (size == 0) {
- Insert(new_genotype, NULL);
- }
-
- // Otherwise tack it on the end.
-
- else {
- Insert(new_genotype, best->GetPrev());
- }
-}
-
-bool cInjectGenotypeControl::Adjust(cInjectGenotype & in_inject_genotype)
-{
- //if (in_inject_genotype.GetDeferAdjust() == true) return true;
-
- cInjectGenotype * cur_inject_genotype = in_inject_genotype.GetPrev();
-
- // Check to see if this genotype should be removed completely.
-
- if (in_inject_genotype.GetNumInjected() == 0) {
- m_world->GetClassificationManager().RemoveInjectGenotype(in_inject_genotype);
- return false;
- }
-
- // Do not adjust if this was and still is the best genotype, or is
- // otherwise in the proper spot...
-
- if (CheckPos(in_inject_genotype)) {
- return true;
- }
-
- // Otherwise, remove it from the queue for just the moment.
-
- Remove(in_inject_genotype);
-
- // Also, if this genotype is the best, put it there.
-
- if (in_inject_genotype.GetNumInjected() > best->GetNumInjected()) {
- Insert(in_inject_genotype, best->GetPrev());
- best = &in_inject_genotype;
- return true;
- }
-
- // Finally, find out where this genotype *does* go.
-
- while (cur_inject_genotype->GetNumInjected() >= in_inject_genotype.GetNumInjected() &&
- cur_inject_genotype != best->GetPrev()) {
- cur_inject_genotype = cur_inject_genotype->GetNext();
- }
- while (cur_inject_genotype->GetNumInjected() < in_inject_genotype.GetNumInjected() &&
- cur_inject_genotype != best) {
- cur_inject_genotype = cur_inject_genotype->GetPrev();
- }
-
- Insert(in_inject_genotype, cur_inject_genotype);
-
- return true;
-}
-
-
-cInjectGenotype * cInjectGenotypeControl::Find(const cGenome & in_genome) const
-{
- int i;
- cInjectGenotype * cur_inject_genotype = best;
-
- for (i = 0; i < size; i++) {
- if (in_genome == cur_inject_genotype->GetGenome()) {
- return cur_inject_genotype;
- }
- cur_inject_genotype = cur_inject_genotype->GetNext();
- }
-
- return NULL;
-}
-
-int cInjectGenotypeControl::FindPos(cInjectGenotype & in_inject_genotype, int max_depth)
-{
- cInjectGenotype * temp_genotype = best;
- if (max_depth < 0 || max_depth > size) max_depth = size;
-
- for (int i = 0; i < max_depth; i++) {
- if (temp_genotype == &in_inject_genotype) return i;
- temp_genotype = temp_genotype->GetNext();
- }
-
- return -1;
-}
-
-cInjectGenotype * cInjectGenotypeControl::Next(int thread)
-{
- return threads[thread] = threads[thread]->GetNext();
-}
-
-cInjectGenotype * cInjectGenotypeControl::Prev(int thread)
-{
- return threads[thread] = threads[thread]->GetPrev();
-}
Deleted: branches/biounit/source/classification/cInjectGenotypeControl.h
===================================================================
--- branches/biounit/source/classification/cInjectGenotypeControl.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/classification/cInjectGenotypeControl.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -1,96 +0,0 @@
-/*
- * cInjectGenotypeControl.h
- * Avida
- *
- * Called "inject_genotype_control.hh" prior to 11/15/05.
- * Copyright 1999-2009 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef cInjectGenotypeControl_h
-#define cInjectGenotypeControl_h
-
-#ifndef nInjectGenotype_h
-#include "nInjectGenotype.h"
-#endif
-
-class cGenome;
-class cInjectGenotype;
-class cWorld;
-
-class cInjectGenotypeControl {
-private:
- cWorld* m_world;
- int size;
- cInjectGenotype* best;
- cInjectGenotype* coalescent;
- cInjectGenotype* threads[nInjectGenotype::THREADS];
-
- cInjectGenotype* historic_list;
- int historic_count;
-
- void Insert(cInjectGenotype& in_inject_genotype, cInjectGenotype* prev_inject_genotype);
- bool CheckPos(cInjectGenotype& in_inject_genotype);
-
- cInjectGenotypeControl(); // @not_implemented
- cInjectGenotypeControl(const cInjectGenotypeControl&); // @not_implemented
- cInjectGenotypeControl& operator=(const cInjectGenotypeControl&); // @not_implemented
-
-public:
- cInjectGenotypeControl(cWorld* world);
- ~cInjectGenotypeControl();
-
- bool OK();
- void Remove(cInjectGenotype & in_inject_genotype);
- void Insert(cInjectGenotype & new_inject_genotype);
- bool Adjust(cInjectGenotype & in_inject_genotype);
-
- void RemoveHistoric(cInjectGenotype & in_inject_genotype);
- void InsertHistoric(cInjectGenotype & in_inject_genotype);
- int GetHistoricCount() { return historic_count; }
-
- inline int GetSize() const { return size; }
- inline cInjectGenotype * GetBest() const { return best; }
- inline cInjectGenotype * GetCoalescent() const { return coalescent; }
-
- cInjectGenotype * Find(const cGenome & in_genome) const;
- int FindPos(cInjectGenotype & in_inject_genotype, int max_depth = -1);
-
- inline cInjectGenotype * Get(int thread) const { return threads[thread]; }
- inline cInjectGenotype * Reset(int thread)
- { return threads[thread] = best; }
- inline cInjectGenotype * ResetHistoric(int thread)
- { return threads[thread] = historic_list; }
- cInjectGenotype * Next(int thread);
- cInjectGenotype * Prev(int thread);
-};
-
-
-#ifdef ENABLE_UNIT_TESTS
-namespace nInjectGenotypeControl {
- /**
- * Run unit tests
- *
- * @param full Run full test suite; if false, just the fast tests.
- **/
- void UnitTests(bool full = false);
-}
-#endif
-
-#endif
Deleted: branches/biounit/source/classification/cInjectGenotypeElement.h
===================================================================
--- branches/biounit/source/classification/cInjectGenotypeElement.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/classification/cInjectGenotypeElement.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -1,68 +0,0 @@
-/*
- * cInjectGenotypeElement.h
- * Avida
- *
- * Called "inject_genotype_element.hh" prior to 11/30/05.
- * Copyright 1999-2009 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef cInjectGenotypeElement_h
-#define cInjectGenotypeElement_h
-
-#ifndef defs_h
-#include "defs.h"
-#endif
-
-class cInjectGenotype;
-
-class cInjectGenotypeElement {
-private:
- cInjectGenotype* inject_genotype;
- cInjectGenotypeElement* next;
- cInjectGenotypeElement* prev;
-
- cInjectGenotypeElement(const cInjectGenotypeElement&); // @not_implemented
- cInjectGenotypeElement& operator=(const cInjectGenotypeElement&); // @not_implemented
-public:
- cInjectGenotypeElement(cInjectGenotype* in_gen = NULL)
- : inject_genotype(in_gen), next(NULL), prev(NULL) { ; }
- ~cInjectGenotypeElement() { ; }
-
- cInjectGenotype* GetInjectGenotype() const { return inject_genotype; }
- cInjectGenotypeElement* GetNext() const { return next; }
- cInjectGenotypeElement* GetPrev() const { return prev; }
-
- void SetNext(cInjectGenotypeElement* in_next) { next = in_next; }
- void SetPrev(cInjectGenotypeElement* in_prev) { prev = in_prev; }
-};
-
-
-#ifdef ENABLE_UNIT_TESTS
-namespace nInjectGenotypeElement {
- /**
- * Run unit tests
- *
- * @param full Run full test suite; if false, just the fast tests.
- **/
- void UnitTests(bool full = false);
-}
-#endif
-
-#endif
Deleted: branches/biounit/source/classification/cInjectGenotypeQueue.cc
===================================================================
--- branches/biounit/source/classification/cInjectGenotypeQueue.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/classification/cInjectGenotypeQueue.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -1,115 +0,0 @@
-/*
- * cInjectGenotypeQueue.cc
- * Avida
- *
- * Called "inject_genotype_queue.cc" prior to 11/30/05.
- * Copyright 1999-2009 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "cInjectGenotypeQueue.h"
-
-#include "cInjectGenotype.h"
-
-#include <cassert>
-
-
-cInjectGenotypeQueue::cInjectGenotypeQueue()
-{
- size = 0;
- root.SetNext(&root);
- root.SetPrev(&root);
-}
-
-
-cInjectGenotypeQueue::~cInjectGenotypeQueue()
-{
- while (root.GetNext() != &root) {
- Remove(root.GetNext());
- }
-}
-
-bool cInjectGenotypeQueue::OK()
-{
- bool result = true;
- int count = 0;
-
- for (cInjectGenotypeElement * temp_element = root.GetNext();
- temp_element != &root;
- temp_element = temp_element->GetNext()) {
- assert (temp_element->GetNext()->GetPrev() == temp_element);
- assert (temp_element->GetInjectGenotype()->GetID() >= 0);
-
- count++;
- assert (count <= size);
- }
-
- assert (count == size);
-
- return result;
-}
-
-void cInjectGenotypeQueue::Insert(cInjectGenotype & in_inject_genotype)
-{
- cInjectGenotypeElement * new_element = new cInjectGenotypeElement(&in_inject_genotype);
- new_element->SetNext(root.GetNext());
- new_element->SetPrev(&root);
- root.GetNext()->SetPrev(new_element);
- root.SetNext(new_element);
- size++;
-}
-
-void cInjectGenotypeQueue::Remove(cInjectGenotype & in_inject_genotype)
-{
- cInjectGenotypeElement * cur_element;
-
- for (cur_element = root.GetNext();
- cur_element != &root;
- cur_element = cur_element->GetNext()) {
- if (cur_element->GetInjectGenotype() == &in_inject_genotype) break;
- }
-
- assert (cur_element != &root);
-
- Remove(cur_element);
-}
-
-void cInjectGenotypeQueue::Remove(cInjectGenotypeElement * in_element)
-{
- in_element->GetPrev()->SetNext(in_element->GetNext());
- in_element->GetNext()->SetPrev(in_element->GetPrev());
- in_element->SetNext(NULL);
- in_element->SetPrev(NULL);
- delete(in_element);
-
- size--;
-}
-
-cInjectGenotype * cInjectGenotypeQueue::Find(const cGenome & in_genome) const
-{
- for (cInjectGenotypeElement * cur_element = root.GetNext();
- cur_element != &root;
- cur_element = cur_element->GetNext()) {
- if (cur_element->GetInjectGenotype()->GetGenome() == in_genome) {
- return cur_element->GetInjectGenotype();
- }
- }
-
- return NULL;
-}
Deleted: branches/biounit/source/classification/cInjectGenotypeQueue.h
===================================================================
--- branches/biounit/source/classification/cInjectGenotypeQueue.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/classification/cInjectGenotypeQueue.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -1,69 +0,0 @@
-/*
- * cInjectGenotypeQueue.h
- * Avida
- *
- * Called "inject_genotype_queue.hh" prior to 11/30/05.
- * Copyright 1999-2009 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef cInjectGenotypeQueue_h
-#define cInjectGenotypeQueue_h
-
-#ifndef cInjectGenotypeElement_h
-#include "cInjectGenotypeElement.h"
-#endif
-
-class cInjectGenotype;
-class cGenome;
-
-class cInjectGenotypeQueue {
-private:
- int size;
- cInjectGenotypeElement root;
-
- void Remove(cInjectGenotypeElement* in_element);
-
- cInjectGenotypeQueue(const cInjectGenotypeQueue&); // @not_implemented
- cInjectGenotypeQueue& operator=(const cInjectGenotypeQueue&); // @not_implemented
-
-public:
- cInjectGenotypeQueue();
- ~cInjectGenotypeQueue();
-
- bool OK();
-
- void Insert(cInjectGenotype & in_inject_genotype);
- void Remove(cInjectGenotype & in_inject_genotype);
- cInjectGenotype * Find(const cGenome & in_genome) const;
-};
-
-
-#ifdef ENABLE_UNIT_TESTS
-namespace nInjectGenotypeQueue {
- /**
- * Run unit tests
- *
- * @param full Run full test suite; if false, just the fast tests.
- **/
- void UnitTests(bool full = false);
-}
-#endif
-
-#endif
Deleted: branches/biounit/source/classification/cInjectGenotype_BirthData.h
===================================================================
--- branches/biounit/source/classification/cInjectGenotype_BirthData.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/classification/cInjectGenotype_BirthData.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -1,79 +0,0 @@
-/*
- * cInjectGenotype_BirthData.h
- * Avida
- *
- * Called "inject_genotype_birth_data.hh" prior to 11/30/05.
- * Copyright 1999-2009 Michigan State University. All rights reserved.
- * Copyright 1999-2003 California Institute of Technology.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef cInjectGenotype_BirthData_h
-#define cInjectGenotype_BirthData_h
-
-#ifndef cCountTracker_h
-#include "cCountTracker.h"
-#endif
-
-class cInjectGenotype;
-
-class cInjectGenotype_BirthData {
-public:
- inline cInjectGenotype_BirthData(int in_update_born);
- ~cInjectGenotype_BirthData() { ; }
-
- cCountTracker birth_track;
- cCountTracker death_track;
- //cCountTracker breed_in_track;
- //cCountTracker breed_true_track;
- //cCountTracker breed_out_track;
-
- int update_born; // Update genotype was first created
- int parent_id; // ID of parent genotype
- //int parent_distance; // Genetic distance from parent genotype
- int gene_depth; // depth in the phylogenetic tree from ancestor
-
- int update_deactivated; // If not, when did it get deactivated?
- cInjectGenotype * parent_genotype; // Pointer to parent genotype...
- //cSpecies * parent_species;
- int num_offspring_genotypes; // Num offspring genotypes still in memory.
-};
-
-
-#ifdef ENABLE_UNIT_TESTS
-namespace nInjectGenotype_BirthData {
- /**
- * Run unit tests
- *
- * @param full Run full test suite; if false, just the fast tests.
- **/
- void UnitTests(bool full = false);
-}
-#endif
-
-inline cInjectGenotype_BirthData::cInjectGenotype_BirthData(int in_update_born)
-: update_born(in_update_born)
-, parent_id(-1)
-, gene_depth(0)
-, update_deactivated(-1)
-, parent_genotype(NULL)
-, num_offspring_genotypes(0)
-{
-}
-
-#endif
Deleted: branches/biounit/source/classification/nInjectGenotype.h
===================================================================
--- branches/biounit/source/classification/nInjectGenotype.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/classification/nInjectGenotype.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -1,33 +0,0 @@
-/*
- * nInjectGenotype.h
- * Avida
- *
- * Created by David on 10/5/05.
- * Copyright 1999-2009 Michigan State University. All rights reserved.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef nInjectGenotype_h
-#define nInjectGenotype_h
-
-namespace nInjectGenotype {
- const int HASH_SIZE = 307; // @CAO Is this an optimal number?
- const int THREADS = 2;
-}
-
-#endif
Modified: branches/biounit/source/cpu/cHardwareBase.h
===================================================================
--- branches/biounit/source/cpu/cHardwareBase.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/cpu/cHardwareBase.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -44,11 +44,11 @@
using namespace std;
class cAvidaContext;
+class cBioUnit;
class cCodeLabel;
class cCPUMemory;
class cHardwareTracer;
class cHeadCPU;
-class cInjectGenotype;
class cInstruction;
class cMutation;
class cOrganism;
@@ -165,8 +165,7 @@
virtual bool ThreadSelect(const cCodeLabel& in_label) = 0;
virtual void ThreadNext() = 0;
virtual void ThreadPrev() = 0;
- virtual cInjectGenotype* ThreadGetOwner() = 0;
- virtual void ThreadSetOwner(cInjectGenotype* in_genotype) = 0;
+ virtual cBioUnit* ThreadGetOwner() = 0;
virtual int GetNumThreads() const = 0;
virtual int GetCurThread() const = 0;
Modified: branches/biounit/source/cpu/cHardwareCPU.h
===================================================================
--- branches/biounit/source/cpu/cHardwareCPU.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/cpu/cHardwareCPU.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -72,7 +72,6 @@
* @see cHardwareCPU_Thread, cCPUStack, cCPUMemory, cInstSet
**/
-class cInjectGenotype;
class cInstLib;
class cInstSet;
class cMutation;
@@ -314,8 +313,7 @@
bool ThreadSelect(const cCodeLabel& in_label) { return false; } // Labeled threads not supported
inline void ThreadPrev(); // Shift the current thread in use.
inline void ThreadNext();
- cInjectGenotype* ThreadGetOwner() { return NULL; } // @DMB - cHardwareCPU does not really implement cInjectGenotype yet
- void ThreadSetOwner(cInjectGenotype* in_genotype) { return; }
+ cBioUnit* ThreadGetOwner() { return m_organism; } // @TODO - note cHardwareCPU does not implement parasites
int GetNumThreads() const { return m_threads.GetSize(); }
int GetCurThread() const { return m_cur_thread; }
Modified: branches/biounit/source/cpu/cHardwareExperimental.h
===================================================================
--- branches/biounit/source/cpu/cHardwareExperimental.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/cpu/cHardwareExperimental.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -70,7 +70,6 @@
* @see cCPUMemory, cInstSet
**/
-class cInjectGenotype;
class cInstLib;
class cInstSet;
class cMutation;
@@ -288,8 +287,7 @@
bool ThreadSelect(const cCodeLabel& in_label) { return false; } // Labeled threads not supported
inline void ThreadPrev(); // Shift the current thread in use.
inline void ThreadNext();
- cInjectGenotype* ThreadGetOwner() { return NULL; } // @DMB - cHardwareExperimental does not really implement cInjectGenotype yet
- void ThreadSetOwner(cInjectGenotype* in_genotype) { return; }
+ cBioUnit* ThreadGetOwner() { return m_organism; } // @TODO - cHardwareExperimental not implement parasites
int GetNumThreads() const { return m_threads.GetSize(); }
int GetCurThread() const { return m_cur_thread; }
Modified: branches/biounit/source/cpu/cHardwareGX.h
===================================================================
--- branches/biounit/source/cpu/cHardwareGX.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/cpu/cHardwareGX.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -63,7 +63,6 @@
#include "nHardware.h"
#include "tBuffer.h"
-class cInjectGenotype;
class cInstLib;
class cInstSet;
class cMutation;
@@ -364,8 +363,7 @@
virtual bool ThreadSelect(const cCodeLabel& in_label) { return false; }
virtual void ThreadPrev() { }
virtual void ThreadNext() { }
- virtual cInjectGenotype* ThreadGetOwner() { return 0; }
- virtual void ThreadSetOwner(cInjectGenotype* in_genotype) { }
+ virtual cBioUnit* ThreadGetOwner() { return m_organism; } // @TODO - cHardwareGX does not support parasites
virtual int GetNumThreads() const { return -1; }
virtual int GetCurThread() const { return -1; }
Modified: branches/biounit/source/cpu/cHardwareSMT.cc
===================================================================
--- branches/biounit/source/cpu/cHardwareSMT.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/cpu/cHardwareSMT.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -180,8 +180,13 @@
owner = NULL;
}
+cBioUnit* cHardwareSMT::ThreadGetOwner()
+{
+ return (m_threads[m_cur_thread].owner) ? m_threads[m_cur_thread].owner : m_organism;
+}
+
// This function processes the very next command in the genome, and is made
// to be as optimized as possible. This is the heart of avida.
bool cHardwareSMT::SingleProcess(cAvidaContext& ctx, bool speculative)
@@ -625,7 +630,10 @@
Inject_DoMutations(ctx, mut_multiplier, injected_code);
bool inject_signal = false;
- if (injected_code.GetSize() > 0) inject_signal = m_organism->InjectParasite(GetLabel(), injected_code);
+ if (injected_code.GetSize() > 0) {
+ cBioUnit* parent = (m_threads[m_cur_thread].owner) ? m_threads[m_cur_thread].owner : m_organism;
+ inject_signal = m_organism->InjectParasite(parent, GetLabel(), injected_code);
+ }
// reset the memory space that was injected
m_mem_array[mem_space_used] = cGenome("a");
Modified: branches/biounit/source/cpu/cHardwareSMT.h
===================================================================
--- branches/biounit/source/cpu/cHardwareSMT.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/cpu/cHardwareSMT.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -92,11 +92,11 @@
cCodeLabel next_label;
bool running;
- // If this thread was spawned by Inject, this will point to the genotype
- // of the parasite running the thread. Otherwise, it will be NULL.
- cInjectGenotype* owner;
+ // If this thread was spawned by Inject, this will point to the biounit of the parasite running the thread.
+ // Otherwise, it will be NULL.
+ cBioUnit* owner;
- cLocalThread(cHardwareBase* in_hardware = NULL) { Reset(in_hardware); }
+ cLocalThread(cHardwareBase* hw = NULL) { Reset(hw); }
~cLocalThread() { ; }
void Reset(cHardwareBase* in_hardware, int mem_space = 0);
@@ -255,8 +255,7 @@
inline bool ThreadSelect(const cCodeLabel& in_label);
inline void ThreadPrev(); // Shift the current thread in use.
inline void ThreadNext();
- cInjectGenotype* ThreadGetOwner() { return m_threads[m_cur_thread].owner; }
- void ThreadSetOwner(cInjectGenotype* in_genotype) { m_threads[m_cur_thread].owner = in_genotype; }
+ cBioUnit* ThreadGetOwner();
int GetNumThreads() const { return m_threads.GetSize(); }
int GetCurThread() const { return m_cur_thread; }
Modified: branches/biounit/source/cpu/cHardwareTransSMT.cc
===================================================================
--- branches/biounit/source/cpu/cHardwareTransSMT.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/cpu/cHardwareTransSMT.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -180,6 +180,10 @@
owner = NULL;
}
+cBioUnit* cHardwareTransSMT::ThreadGetOwner()
+{
+ return (m_threads[m_cur_thread].owner) ? m_threads[m_cur_thread].owner : m_organism;
+}
// This function processes the very next command in the genome, and is made
@@ -629,7 +633,10 @@
Inject_DoMutations(ctx, mut_multiplier, injected_code);
bool inject_signal = false;
- if (injected_code.GetSize() > 0) inject_signal = m_organism->InjectParasite(GetLabel(), injected_code);
+ if (injected_code.GetSize() > 0) {
+ cBioUnit* parent = (m_threads[m_cur_thread].owner) ? m_threads[m_cur_thread].owner : m_organism;
+ inject_signal = m_organism->InjectParasite(parent, GetLabel(), injected_code);
+ }
// reset the memory space that was injected
m_mem_array[mem_space_used] = cGenome("a");
Modified: branches/biounit/source/cpu/cHardwareTransSMT.h
===================================================================
--- branches/biounit/source/cpu/cHardwareTransSMT.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/cpu/cHardwareTransSMT.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -91,9 +91,9 @@
cCodeLabel next_label;
bool running;
- // If this thread was spawned by Inject, this will point to the genotype
- // of the parasite running the thread. Otherwise, it will be NULL.
- cInjectGenotype* owner;
+ // If this thread was spawned by Inject, this will point to the biounit of the parasite running the thread.
+ // Otherwise, it will be NULL.
+ cBioUnit* owner;
cLocalThread(cHardwareBase* in_hardware = NULL) { Reset(in_hardware); }
~cLocalThread() { ; }
@@ -253,8 +253,7 @@
inline bool ThreadSelect(const cCodeLabel& in_label);
inline void ThreadPrev(); // Shift the current thread in use.
inline void ThreadNext();
- cInjectGenotype* ThreadGetOwner() { return m_threads[m_cur_thread].owner; }
- void ThreadSetOwner(cInjectGenotype* in_genotype) { m_threads[m_cur_thread].owner = in_genotype; }
+ cBioUnit* ThreadGetOwner();
int GetNumThreads() const { return m_threads.GetSize(); }
int GetCurThread() const { return m_cur_thread; }
Modified: branches/biounit/source/cpu/cTestCPU.cc
===================================================================
--- branches/biounit/source/cpu/cTestCPU.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/cpu/cTestCPU.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -35,7 +35,6 @@
#include "cHardwareBase.h"
#include "cHardwareManager.h"
#include "cHardwareStatusPrinter.h"
-#include "cInjectGenotype.h"
#include "cInstSet.h"
#include "cOrganism.h"
#include "cPhenotype.h"
@@ -452,44 +451,10 @@
}
-void cTestCPU::PrintInjectGenome(cAvidaContext& ctx, cInjectGenotype* inject_genotype,
- const cGenome& genome, cString filename, int update)
+void cTestCPU::PrintBioGroup(cAvidaContext& ctx, cBioGroup* bg, cString filename, int update)
{
- if (filename == "") filename.Set("p%03d-unnamed", genome.GetSize());
-
- // Build the test info for printing.
- cCPUTestInfo test_info;
- TestGenome(ctx, test_info, genome);
-
- // Open the file...
- ofstream& fp = m_world->GetDataFileOFStream(filename);
-
- // @CAO Fix!!!!!!
- if( fp.good() == false ) {
- cerr << "Unable to open output file '" << filename << "'" << endl;
- return;
- }
-
- // Print the useful info at the top...
-
- fp << "# Filename........: " << filename << endl;
-
- if (update >= 0) fp << "# Update Output...: " << update << endl;
- else fp << "# Update Output...: N/A" << endl;
-
-
- if (inject_genotype != NULL) {
- fp << "# Update Created..: " << inject_genotype->GetUpdateBorn() << endl;
- fp << "# Genotype ID.....: " << inject_genotype->GetID() << endl;
- fp << "# Parent Gen ID...: " << inject_genotype->GetParentID() << endl;
- fp << "# Tree Depth......: " << inject_genotype->GetDepth() << endl;
- }
- fp << endl;
-
- // Display the genome
- cGenomeUtil::SaveGenome(fp, test_info.GetTestOrganism()->GetHardware().GetInstSet(), genome);
-
- m_world->GetDataFileManager().Remove(filename);
+ // @TODO - test cpu print bio group
+ assert(false);
}
Modified: branches/biounit/source/cpu/cTestCPU.h
===================================================================
--- branches/biounit/source/cpu/cTestCPU.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/cpu/cTestCPU.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -42,9 +42,9 @@
#endif
class cAvidaContext;
+class cBioGroup;
class cGenome;
class cGenotype;
-class cInjectGenotype;
class cInstSet;
class cMetaGenome;
class cResourceCount;
@@ -100,8 +100,7 @@
void PrintGenome(cAvidaContext& ctx, const cGenome& genome, cString filename,
cGenotype* genotype = NULL, int update = -1);
- void PrintInjectGenome(cAvidaContext& ctx, cInjectGenotype* inject_genotype,
- const cGenome& genome, cString filename = "", int update = -1);
+ void PrintBioGroup(cAvidaContext& ctx, cBioGroup* bg, cString filename = "", int update = -1);
inline int GetInput();
inline int GetInputAt(int & input_pointer);
Modified: branches/biounit/source/cpu/cTestCPUInterface.cc
===================================================================
--- branches/biounit/source/cpu/cTestCPUInterface.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/cpu/cTestCPUInterface.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -128,7 +128,7 @@
return m_testcpu->GetReceiveValue();
}
-bool cTestCPUInterface::InjectParasite(cOrganism* parent, const cCodeLabel& label, const cGenome& injected_code)
+bool cTestCPUInterface::InjectParasite(cOrganism* host, cBioUnit* parent, const cCodeLabel& label, const cGenome& injected_code)
{
return false;
}
Modified: branches/biounit/source/cpu/cTestCPUInterface.h
===================================================================
--- branches/biounit/source/cpu/cTestCPUInterface.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/cpu/cTestCPUInterface.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -89,7 +89,7 @@
int ReceiveValue();
void SellValue(const int data, const int label, const int sell_price, const int org_id);
int BuyValue(const int label, const int buy_price);
- bool InjectParasite(cOrganism* parent, const cCodeLabel& label, const cGenome& injected_code);
+ bool InjectParasite(cOrganism* host, cBioUnit* parent, const cCodeLabel& label, const cGenome& injected_code);
bool UpdateMerit(double new_merit);
bool TestOnDivide() { return false; }
int GetFacing() { return 0; }
Modified: branches/biounit/source/main/cOrgInterface.h
===================================================================
--- branches/biounit/source/main/cOrgInterface.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/main/cOrgInterface.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -35,6 +35,7 @@
#define cOrgInterface_h
class cAvidaContext;
+class cBioUnit;
class cCodeLabel;
class cDeme;
class cGenome;
@@ -100,7 +101,7 @@
virtual int ReceiveValue() = 0;
virtual void SellValue(const int data, const int label, const int sell_price, const int org_id) = 0;
virtual int BuyValue(const int label, const int buy_price) = 0;
- virtual bool InjectParasite(cOrganism* parent, const cCodeLabel& label, const cGenome& injected_code) = 0;
+ virtual bool InjectParasite(cOrganism* host, cBioUnit* parent, const cCodeLabel& label, const cGenome& injected_code) = 0;
virtual bool UpdateMerit(double new_merit) = 0;
virtual bool TestOnDivide() = 0;
virtual bool SendMessage(cOrgMessage& msg) = 0;
Modified: branches/biounit/source/main/cOrganism.cc
===================================================================
--- branches/biounit/source/main/cOrganism.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/main/cOrganism.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -35,7 +35,6 @@
#include "cGenotype.h"
#include "cHardwareBase.h"
#include "cHardwareManager.h"
-#include "cInjectGenotype.h"
#include "cInstSet.h"
#include "cOrgSinkMessage.h"
#include "cPopulationCell.h"
@@ -651,14 +650,26 @@
}
-bool cOrganism::InjectParasite(const cCodeLabel& label, const cGenome& injected_code)
+bool cOrganism::InjectParasite(cBioUnit* parent, const cCodeLabel& label, const cGenome& injected_code)
{
assert(m_interface);
- return m_interface->InjectParasite(this, label, injected_code);
+ return m_interface->InjectParasite(this, parent, label, injected_code);
}
-bool cOrganism::InjectHost(const cCodeLabel& label, const cGenome& injected_code)
+bool cOrganism::InjectHost(cBioUnit* parent, eBioUnitSource src, const cCodeLabel& label, const cGenome& injected_code)
{
+ cInjectGenotype* child_genotype = parent_genotype;
+
+ // If the parent genotype is not correct for the child, adjust it.
+ if (parent_genotype == NULL || parent_genotype->GetGenome() != injected_code) {
+ child_genotype = m_world->GetClassificationManager().GetInjectGenotype(injected_code, parent_genotype);
+ }
+
+ target_organism->AddParasite(child_genotype);
+ child_genotype->AddParasite();
+ child_cpu.ThreadSetOwner(child_genotype);
+
+
return m_hardware->InjectHost(label, injected_code);
}
Modified: branches/biounit/source/main/cOrganism.h
===================================================================
--- branches/biounit/source/main/cOrganism.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/main/cOrganism.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -84,7 +84,6 @@
class cEnvironment;
class cGenotype;
class cHardwareBase;
-class cInjectGenotype;
class cInstSet;
class cLineage;
class cOrgSinkMessage;
@@ -103,7 +102,7 @@
eBioUnitSource m_src;
cString m_src_args;
const cMetaGenome m_initial_genome; // Initial genome; can never be changed!
- tArray<cInjectGenotype*> m_parasites; // List of all parasites associated with this organism.
+ tArray<cBioUnit*> m_parasites; // List of all parasites associated with this organism.
cMutationRates m_mut_rates; // Rate of all possible mutations.
cLocalMutations m_mut_info; // Info about possible mutations;
cOrgInterface* m_interface; // Interface back to the population.
@@ -330,10 +329,9 @@
// -------- Parasite Interactions --------
- bool InjectParasite(const cCodeLabel& label, const cGenome& genome);
- bool InjectHost(const cCodeLabel& in_label, const cGenome& genome);
- void AddParasite(cInjectGenotype* cur) { m_parasites.Push(cur); }
- cInjectGenotype& GetParasite(int x) { return *m_parasites[x]; }
+ bool InjectParasite(cBioUnit* parent, const cCodeLabel& label, const cGenome& genome);
+ bool InjectHost(cBioUnit* parent, eBioUnitSource src, const cCodeLabel& in_label, const cGenome& genome);
+ void AddParasite(cBioUnit* cur) { m_parasites.Push(cur); }
int GetNumParasites() const { return m_parasites.GetSize(); }
void ClearParasites();
Added: branches/biounit/source/main/cParasite.cc
===================================================================
--- branches/biounit/source/main/cParasite.cc (rev 0)
+++ branches/biounit/source/main/cParasite.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -0,0 +1,32 @@
+/*
+ * cParasite.cc
+ * Avida
+ *
+ * Created by David on 12/16/09.
+ * Copyright 2009 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "cParasite.h"
+
+cParasite::cParasite(const cMetaGenome& genome, int parent_generation, eBioUnitSource src, const cString& src_args)
+ : m_src(src), m_src_args(src_args), m_initial_genome(genome)
+{
+ assert(false);
+ // @TODO - properly construct cPhenotype
+}
Added: branches/biounit/source/main/cParasite.h
===================================================================
--- branches/biounit/source/main/cParasite.h (rev 0)
+++ branches/biounit/source/main/cParasite.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -0,0 +1,72 @@
+/*
+ * cParasite.h
+ * Avida
+ *
+ * Created by David on 12/16/09.
+ * Copyright 2009 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef cParasite_h
+#define cParasite_h
+
+#ifndef cBioUnit_h
+#include "cBioUnit.h"
+#endif
+#ifndef cMetaGenome_h
+#include "cMetaGenome.h"
+#endif
+#ifndef cPhenotype_h
+#include "cPhenotype.h"
+#endif
+#ifndef cString_h
+#include "cString.h"
+#endif
+
+
+
+class cParasite : public cBioUnit
+{
+private:
+ eBioUnitSource m_src;
+ cString m_src_args;
+ const cMetaGenome m_initial_genome;
+ cPhenotype m_phenotype;
+
+
+ cParasite(); // @not_implemented
+ cParasite(const cParasite&); // @not_implemented
+ cParasite& operator=(const cParasite&); // @not_implemented
+
+
+public:
+ cParasite(const cMetaGenome& genome, int parent_generation, eBioUnitSource src, const cString& src_args);
+ ~cParasite() { ; }
+
+ // -------- cBioUnit Methods --------
+ eBioUnitSource GetUnitSource() const { return m_src; }
+ const cString& GetUnitSourceArgs() const { return m_src_args; }
+ const cMetaGenome& GetMetaGenome() const { return m_initial_genome; }
+ const cPhenotype& GetPhenotype() const { return m_phenotype; }
+
+ // -------- cParasite Methods --------
+ cPhenotype& GetPhenotype() { return m_phenotype; }
+
+};
+
+#endif
Modified: branches/biounit/source/main/cPopulation.cc
===================================================================
--- branches/biounit/source/main/cPopulation.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/main/cPopulation.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -42,7 +42,6 @@
#include "cHardwareBase.h"
#include "cHardwareManager.h"
#include "cInitFile.h"
-#include "cInjectGenotype.h"
#include "cInstSet.h"
#include "cIntegratedSchedule.h"
#include "cLineage.h"
@@ -103,11 +102,11 @@
const int num_cells = world_x * world_y * world_z;
const int geometry = world->GetConfig().WORLD_GEOMETRY.Get();
- if(m_world->GetConfig().ENERGY_CAP.Get() == -1) {
+ if (m_world->GetConfig().ENERGY_CAP.Get() == -1) {
m_world->GetConfig().ENERGY_CAP.Set(std::numeric_limits<double>::max());
}
- if(m_world->GetConfig().LOG_SLEEP_TIMES.Get() == 1) {
+ if (m_world->GetConfig().LOG_SLEEP_TIMES.Get() == 1) {
sleep_log = new tVector<pair<int,int> >[world_x*world_y];
}
// Print out world details
@@ -154,7 +153,7 @@
#ifdef DEBUG
const int birth_method = m_world->GetConfig().BIRTH_METHOD.Get();
- if(num_demes > 1) {
+ if (num_demes > 1) {
assert(birth_method != POSITION_OFFSPRING_FULL_SOUP_ELDEST);
}
#endif
@@ -242,7 +241,7 @@
//setting size of global and deme-level resources
for(int i = 0; i < resource_lib.GetSize(); i++) {
cResource * res = resource_lib.GetResource(i);
- if(res->GetDemeResource())
+ if (res->GetDemeResource())
num_deme_res++;
}
@@ -260,8 +259,8 @@
cResource * res = resource_lib.GetResource(i);
// check to see if this is the hgt resource:
- if(res->GetHGTMetabolize()) {
- if(m_hgt_resid != -1) {
+ if (res->GetHGTMetabolize()) {
+ if (m_hgt_resid != -1) {
m_world->GetDriver().RaiseFatalException(-1, "Only one HGT resource is currently supported.");
}
m_hgt_resid = i;
@@ -281,7 +280,7 @@
res->GetOutflowY2(), res->GetCellListPtr(),
res->GetCellIdListPtr(), world->GetVerbosity() );
m_world->GetStats().SetResourceName(global_res_index, res->GetName());
- } else if(res->GetDemeResource()) {
+ } else if (res->GetDemeResource()) {
deme_res_index++;
for(int j = 0; j < GetNumDemes(); j++) {
GetDeme(j).SetupDemeRes(deme_res_index, res, world->GetVerbosity());
@@ -294,7 +293,7 @@
}
// if HGT is on, make sure there's a resource for it:
- if(m_world->GetConfig().ENABLE_HGT.Get() && (m_hgt_resid == -1)) {
+ if (m_world->GetConfig().ENABLE_HGT.Get() && (m_hgt_resid == -1)) {
m_world->GetDriver().NotifyWarning("HGT is enabled, but no HGT resource is defined; add hgt=1 to a single resource in the environment file.");
}
@@ -379,12 +378,12 @@
THIS code will remove zero merit orgnaisms, thus never putting them into the scheduler.
WARNING: uncommenting this code will break consistancy, but will generalize the solution.
Currently, only asexual organisms that use the energy model are removed when they have zero merit.
- If this code gets added then remove the "if(merit_array[0].GetDouble() <= 0.0)" block from cBirthChamber::DoAsexBirth,
+ If this code gets added then remove the "if (merit_array[0].GetDouble() <= 0.0)" block from cBirthChamber::DoAsexBirth,
does not break consistancy for test energy_deme_level_res
- if(merit_array[i].GetDouble() <= 0.0) {
+ if (merit_array[i].GetDouble() <= 0.0) {
// no weaklings!
- if(child_array.GetSize() > 1) {
+ if (child_array.GetSize() > 1) {
child_array.Swap(i, child_array.GetSize()-1);
child_array = child_array.Subset(0, child_array.GetSize()-2);
} else {
@@ -453,7 +452,7 @@
// If we're not about to kill the parent, do some extra work on it.
if (parent_alive == true) {
- if(parent_phenotype.GetMerit().GetDouble() <= 0.0) {
+ if (parent_phenotype.GetMerit().GetDouble() <= 0.0) {
// no weakling parents either!
parent_organism->GetPhenotype().SetToDie();
parent_alive = false;
@@ -524,132 +523,97 @@
return parent_alive;
}
-bool cPopulation::ActivateParasite(cOrganism& parent, const cCodeLabel& label, const cGenome& injected_code)
+bool cPopulation::ActivateParasite(cOrganism* host, cBioUnit* parent, const cCodeLabel& label, const cGenome& injected_code)
{
- assert(&parent != NULL);
+ assert(parent != NULL);
+ // Quick check for empty parasites
if (injected_code.GetSize() == 0) return false;
- cHardwareBase& parent_cpu = parent.GetHardware();
- cInjectGenotype* parent_genotype = parent_cpu.ThreadGetOwner();
- const int parent_id = parent.GetOrgInterface().GetCellID();
- assert(parent_id >= 0 && parent_id < cell_array.GetSize());
- cPopulationCell& parent_cell = cell_array[ parent_id ];
+ // Pull the host cell
+ const int host_id = host->GetOrgInterface().GetCellID();
+ assert(host_id >= 0 && host_id < cell_array.GetSize());
+ cPopulationCell& host_cell = cell_array[host_id];
+
+ // Select a target organism
+ // @TODO - activate parasite target selection should account for hardware type
cOrganism* target_organism = NULL;
-
- if (m_world->GetConfig().BIRTH_METHOD.Get() == POSITION_OFFSPRING_FULL_SOUP_RANDOM)
- {
- target_organism = GetCell(m_world->GetRandom().GetUInt(cell_array.GetSize())).GetOrganism();
+ if (m_world->GetConfig().BIRTH_METHOD.Get() == POSITION_OFFSPRING_FULL_SOUP_RANDOM) {
+ target_organism = GetCell(m_world->GetRandom().GetUInt(cell_array.GetSize())).GetOrganism();
+ } else {
+ target_organism =
+ host_cell.ConnectionList().GetPos(m_world->GetRandom().GetUInt(host->GetNeighborhoodSize()))->GetOrganism();
}
- else
- {
- target_organism =
- parent_cell.ConnectionList().GetPos(m_world->GetRandom().GetUInt(parent.GetNeighborhoodSize()))->GetOrganism();
- }
-
if (target_organism == NULL) return false;
+
- cHardwareBase& child_cpu = target_organism->GetHardware();
+ // Pre-check target hardware
+ if (target_organism->GetHardware().GetNumThreads() == m_world->GetConfig().MAX_CPU_THREADS.Get()) return false;
- if (child_cpu.GetNumThreads() == m_world->GetConfig().MAX_CPU_THREADS.Get()) return false;
-
- tArray<int> task_counts = target_organism->GetPhenotype().GetCurTaskCount();
-
- int random_int = m_world->GetRandom().GetUInt(100);
-
- if (m_world->GetConfig().INJECT_PROB_FROM_TASKS.Get())
- {
-
+
+ // Handle probabilistic inject failure
+ if (m_world->GetConfig().INJECT_PROB_FROM_TASKS.Get()) {
+ tArray<int> task_counts = target_organism->GetPhenotype().GetCurTaskCount();
int last_task_count = target_organism->GetPhenotype().GetLastTaskCount()[0];
int total_count;
int task_count = last_task_count;
- if (task_count < task_counts[0])
- {
- task_count = task_counts[0];
- }
+ if (task_count < task_counts[0]) task_count = task_counts[0];
total_count = task_count;
- if (total_count > 0)
- {
- if (m_world->GetConfig().INJECT_PROB_SIGMOID.Get())
- {
+ if (total_count > 0) {
+ int random_int = m_world->GetRandom().GetUInt(100);
+ if (m_world->GetConfig().INJECT_PROB_SIGMOID.Get()) {
switch (total_count) {
case 1:
- if(random_int > 10)
- return false;
+ if (random_int > 10) return false;
break;
case 2:
- if(random_int > 30)
- return false;
+ if (random_int > 30) return false;
break;
case 3:
- if(random_int > 50)
- return false;
+ if (random_int > 50) return false;
break;
case 4:
- if(random_int > 70)
- return false;
+ if (random_int > 70) return false;
break;
case 5:
- if (random_int > 75)
- return false;
+ if (random_int > 75) return false;
break;
case 6:
- if (random_int > 80)
- return false;
+ if (random_int > 80) return false;
break;
case 7:
- if(random_int > 85)
- return false;
+ if (random_int > 85) return false;
break;
case 8:
- if(random_int > 90)
- return false;
+ if (random_int > 90) return false;
break;
case 9:
- if(random_int > 95)
- return false;
+ if (random_int > 95) return false;
break;
case 10:
break;
}
+ } else {
+ if (random_int > (total_count * 10)) return false;
}
- else
- {
- if (random_int > (total_count * 10))
- return false;
- }
- }
-
- else
+ } else {
return false;
-
- }
-
- if (target_organism->InjectHost(label, injected_code)) {
- cInjectGenotype* child_genotype = parent_genotype;
-
- // If the parent genotype is not correct for the child, adjust it.
- if (parent_genotype == NULL || parent_genotype->GetGenome() != injected_code) {
- child_genotype = m_world->GetClassificationManager().GetInjectGenotype(injected_code, parent_genotype);
}
-
- target_organism->AddParasite(child_genotype);
- child_genotype->AddParasite();
- child_cpu.ThreadSetOwner(child_genotype);
- m_world->GetClassificationManager().AdjustInjectGenotype(*child_genotype);
-
- if(m_world->GetConfig().INJECT_STERILIZES_HOST.Get())
- target_organism->GetPhenotype().Sterilize();
-
}
- else
- return false;
+
+ // Attempt actual parasite injection
+ if (!target_organism->InjectHost(parent, SRC_PARASITE_INJECT, label, injected_code)) return false;
+
+
+ // Handle post injection actions
+ if (m_world->GetConfig().INJECT_STERILIZES_HOST.Get()) target_organism->GetPhenotype().Sterilize();
+
return true;
}
@@ -751,13 +715,13 @@
int num_rewarded_instructions = 0;
int genome_length = in_organism->GetGenome().GetSize();
- if(rewarded_instruction == -1){
+ if (rewarded_instruction == -1){
//no key instruction, so no bonus
in_organism->GetPhenotype().SetCurBonusInstCount(0);
}
else{
for(int i = 1; i <= genome_length; i++){
- if(in_organism->GetGenome()[i-1].GetOp() == rewarded_instruction){
+ if (in_organism->GetGenome()[i-1].GetOp() == rewarded_instruction){
num_rewarded_instructions++;
}
}
@@ -868,14 +832,14 @@
int cellID = in_cell.GetID();
- if(organism->IsSleeping()) {
+ if (organism->IsSleeping()) {
organism->SetSleeping(false);
organism->GetOrgInterface().GetDeme()->DecSleepingCount();
}
- if(m_world->GetConfig().LOG_SLEEP_TIMES.Get() == 1) {
- if(sleep_log[cellID].Size() > 0) {
+ if (m_world->GetConfig().LOG_SLEEP_TIMES.Get() == 1) {
+ if (sleep_log[cellID].Size() > 0) {
pair<int,int> p = sleep_log[cellID][sleep_log[cellID].Size()-1];
- if(p.second == -1) {
+ if (p.second == -1) {
AddEndSleep(cellID,m_world->GetStats().GetUpdate());
}
}
@@ -896,12 +860,12 @@
}
// Return currently stored internal resources to the world
- if(m_world->GetConfig().USE_RESOURCE_BINS.Get() && m_world->GetConfig().RETURN_STORED_ON_DEATH.Get()) {
+ if (m_world->GetConfig().USE_RESOURCE_BINS.Get() && m_world->GetConfig().RETURN_STORED_ON_DEATH.Get()) {
organism->GetOrgInterface().UpdateResources(organism->GetRBins());
}
// make sure the group composition is updated.
- if(m_world->GetConfig().USE_FORM_GROUPS.Get() && organism->HasOpinion())
+ if (m_world->GetConfig().USE_FORM_GROUPS.Get() && organism->HasOpinion())
{
int opinion = organism->GetOpinion().first;
LeaveGroup(opinion);
@@ -914,7 +878,7 @@
num_organisms--;
// Handle deme updates.
- if(deme_array.GetSize() > 0) {
+ if (deme_array.GetSize() > 0) {
deme_array[in_cell.GetDemeID()].DecOrgCount();
deme_array[in_cell.GetDemeID()].OrganismDeath(in_cell);
}
@@ -924,7 +888,7 @@
// If HGT is turned on, this organism's genome needs to be split up into fragments
// and deposited in its cell. We then also have to add the size of this genome to
// the HGT resource.
- if(m_world->GetConfig().ENABLE_HGT.Get()) {
+ if (m_world->GetConfig().ENABLE_HGT.Get()) {
in_cell.AddGenomeFragments(organism->GetGenome());
}
@@ -1353,9 +1317,9 @@
// To prevent sterile demes from replicating, we're going to replace the fitness
// of all sterile demes with 0; this effectively makes it impossible for a sterile
// deme to be selected via fitness proportional selection.
- if(m_world->GetConfig().DEMES_PREVENT_STERILE.Get()) {
+ if (m_world->GetConfig().DEMES_PREVENT_STERILE.Get()) {
for(int i=0; i<deme_array.GetSize(); ++i) {
- if(deme_array[i].GetBirthCount() == 0) {
+ if (deme_array[i].GetBirthCount() == 0) {
fitness[i] = 0.0;
}
}
@@ -1366,13 +1330,13 @@
// This is to facilitate testing. Obviously we can't do competition if there's
// only one deme, but we do want the stat-tracking.
- if(fitness.size()==1) {
+ if (fitness.size()==1) {
return;
}
// to facilitate control runs, sometimes we want to know what the fitness values
// are, but we don't want competition to depend on them.
- if(m_world->GetConfig().DEMES_OVERRIDE_FITNESS.Get()) {
+ if (m_world->GetConfig().DEMES_OVERRIDE_FITNESS.Get()) {
for(int i=0; i<static_cast<int>(fitness.size()); ++i) {
fitness[i] = 1.0;
}
@@ -1398,7 +1362,7 @@
double target_sum = m_world->GetRandom().GetDouble(total_fitness);
for(int j=0; j<deme_array.GetSize(); ++j) {
running_sum += fitness[j];
- if(running_sum >= target_sum) {
+ if (running_sum >= target_sum) {
// j'th deme will be replicated.
++deme_counts[j];
break;
@@ -1417,13 +1381,13 @@
// pruning out sterile demes:
std::vector<int> deme_ids;
for(int i=0; i<deme_array.GetSize(); ++i) {
- if(!m_world->GetConfig().DEMES_PREVENT_STERILE.Get() || (deme_array[i].GetBirthCount() > 0)) {
+ if (!m_world->GetConfig().DEMES_PREVENT_STERILE.Get() || (deme_array[i].GetBirthCount() > 0)) {
deme_ids.push_back(i);
}
}
// better have more than deme tournament size, otherwise something is *really* screwed up:
- if(m_world->GetConfig().DEMES_TOURNAMENT_SIZE.Get() > static_cast<int>(deme_ids.size())) {
+ if (m_world->GetConfig().DEMES_TOURNAMENT_SIZE.Get() > static_cast<int>(deme_ids.size())) {
m_world->GetDriver().RaiseFatalException(-1, "The number of demes that can participate in a tournament is less than the deme tournament size.");
}
@@ -1440,7 +1404,7 @@
// then the winner is selected at random from the tournament.
std::pair<int, double> winner(tournament[m_world->GetRandom().GetInt(tournament.size())], 0.0);
for(std::vector<int>::iterator j=tournament.begin(); j!=tournament.end(); ++j) {
- if(fitness[*j] > winner.second) {
+ if (fitness[*j] > winner.second) {
winner = std::make_pair(*j, fitness[*j]);
}
}
@@ -1458,7 +1422,7 @@
// Housekeeping: re-inject demes with count of 1 back into self (energy-related).
for(int i = 0; i < (int)deme_counts.size(); i++) {
- if(deme_counts[i] == 1)
+ if (deme_counts[i] == 1)
ReplaceDeme(deme_array[i], deme_array[i]);
}
@@ -1468,19 +1432,19 @@
while(true) {
int source_id=0;
for(; source_id<(int)deme_counts.size(); ++source_id) {
- if(deme_counts[source_id] > 1) {
+ if (deme_counts[source_id] > 1) {
--deme_counts[source_id];
break;
}
}
- if(source_id == (int)deme_counts.size()) {
+ if (source_id == (int)deme_counts.size()) {
break; // All done; we looped through the whole list of counts, and didn't find any > 1.
}
int target_id=0;
for(; target_id<(int)deme_counts.size(); ++target_id) {
- if(deme_counts[target_id] == 0) {
+ if (deme_counts[target_id] == 0) {
++deme_counts[target_id];
break;
}
@@ -1525,12 +1489,12 @@
switch (rep_trigger) {
case 0: {
// Replicate all non-empty demes.
- if(source_deme.IsEmpty()) continue;
+ if (source_deme.IsEmpty()) continue;
break;
}
case 1: {
// Replicate all full demes.
- if(!source_deme.IsFull()) continue;
+ if (!source_deme.IsFull()) continue;
break;
}
case 2: {
@@ -1538,46 +1502,46 @@
// The first and last IDs represent the two corners.
const int id1 = source_deme.GetCellID(0);
const int id2 = source_deme.GetCellID(source_deme.GetSize() - 1);
- if(cell_array[id1].IsOccupied() == false ||
+ if (cell_array[id1].IsOccupied() == false ||
cell_array[id2].IsOccupied() == false) continue;
break;
}
case 3: {
// Replicate old demes.
- if(source_deme.GetAge() < m_world->GetConfig().DEMES_MAX_AGE.Get()) continue;
+ if (source_deme.GetAge() < m_world->GetConfig().DEMES_MAX_AGE.Get()) continue;
break;
}
case 4: {
// Replicate demes that have had a certain number of births.
- if(source_deme.GetBirthCount() < m_world->GetConfig().DEMES_MAX_BIRTHS.Get()) continue;
+ if (source_deme.GetBirthCount() < m_world->GetConfig().DEMES_MAX_BIRTHS.Get()) continue;
break;
}
case 5: {
- if(!(source_deme.MovPredSatisfiedPreviously())) continue;
+ if (!(source_deme.MovPredSatisfiedPreviously())) continue;
break;
}
case 6: {
int currentSlotSuccessful = 0;
double kill_ratio = 0.0;
- if(source_deme.GetSlotFlowRate() == 0)
+ if (source_deme.GetSlotFlowRate() == 0)
kill_ratio = 1.0;
else
kill_ratio = static_cast<double>(source_deme.GetEventsKilledThisSlot()) / static_cast<double>(source_deme.GetSlotFlowRate());
- if(kill_ratio >= m_world->GetConfig().DEMES_MIM_EVENTS_KILLED_RATIO.Get())
+ if (kill_ratio >= m_world->GetConfig().DEMES_MIM_EVENTS_KILLED_RATIO.Get())
currentSlotSuccessful = 1;
// Replicate demes that have killed a certain number of event.
- if(source_deme.GetConsecutiveSuccessfulEventPeriods()+currentSlotSuccessful < m_world->GetConfig().DEMES_MIM_SUCCESSFUL_EVENT_PERIODS.Get()) continue;
+ if (source_deme.GetConsecutiveSuccessfulEventPeriods()+currentSlotSuccessful < m_world->GetConfig().DEMES_MIM_SUCCESSFUL_EVENT_PERIODS.Get()) continue;
break;
}
case 7: {
- if(!(source_deme.MsgPredSatisfiedPreviously())) continue;
+ if (!(source_deme.MsgPredSatisfiedPreviously())) continue;
break;
}
case 8: {
- if(!(source_deme.DemePredSatisfiedPreviously())) continue;
+ if (!(source_deme.DemePredSatisfiedPreviously())) continue;
break;
}
default: {
@@ -1596,10 +1560,10 @@
void cPopulation::ReplicateDeme(cDeme & source_deme)
{
// Doesn't make sense to try and replicate a deme that *has no organisms*.
- if(source_deme.IsEmpty()) return;
+ if (source_deme.IsEmpty()) return;
// Prevent sterile demes from replicating.
- if(m_world->GetConfig().DEMES_PREVENT_STERILE.Get() && (source_deme.GetBirthCount() == 0)) {
+ if (m_world->GetConfig().DEMES_PREVENT_STERILE.Get() && (source_deme.GetBirthCount() == 0)) {
// assumes that all group level tasks cannot be solved by a single organism
source_deme.KillAll();
return;
@@ -1656,7 +1620,7 @@
}
// Write some logging information if LOG_DEMES_REPLICATE is set.
- if( (m_world->GetConfig().LOG_DEMES_REPLICATE.Get() == 1) &&
+ if ( (m_world->GetConfig().LOG_DEMES_REPLICATE.Get() == 1) &&
(m_world->GetStats().GetUpdate() >= m_world->GetConfig().DEMES_REPLICATE_LOG_START.Get()) ) {
cString tmpfilename = cStringUtil::Stringf("deme_replication.dat");
cDataFile& df = m_world->GetDataFile(tmpfilename);
@@ -1684,7 +1648,7 @@
// used to pass energy to offspring demes (set to zero if energy model is not enabled)
double source_deme_energy(0.0), deme_energy_decay(0.0), parent_deme_energy(0.0), offspring_deme_energy(0.0);
- if(m_world->GetConfig().ENERGY_ENABLED.Get()) {
+ if (m_world->GetConfig().ENERGY_ENABLED.Get()) {
double energyRemainingInSourceDeme = source_deme.CalculateTotalEnergy();
source_deme.SetEnergyRemainingInDemeAtReplication(energyRemainingInSourceDeme);
source_deme_energy = energyRemainingInSourceDeme + source_deme.GetTotalEnergyTestament();
@@ -1719,7 +1683,7 @@
// Reset both demes, in case they have any cleanup work to do.
// Must reset target first for stats to be correctly updated!
- if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
+ if (m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
// Transfer energy from source to target if we're using the energy model.
if (target_successfully_seeded) target_deme.DivideReset(source_deme, target_deme_resource_reset, offspring_deme_energy);
source_deme.DivideReset(source_deme, source_deme_resource_reset, parent_deme_energy);
@@ -1732,27 +1696,27 @@
// Are we using germlines? If so, we need to mutate the germline to get the
// genome that we're going to seed the target with.
- if(m_world->GetConfig().DEMES_USE_GERMLINE.Get() == 1) {
+ if (m_world->GetConfig().DEMES_USE_GERMLINE.Get() == 1) {
// @JEB Original germlines
cCPUMemory next_germ(source_deme.GetGermline().GetLatest());
const cInstSet& instset = m_world->GetHardwareManager().GetInstSet();
cAvidaContext ctx(m_world->GetRandom());
- if(m_world->GetConfig().GERMLINE_COPY_MUT.Get() > 0.0) {
+ if (m_world->GetConfig().GERMLINE_COPY_MUT.Get() > 0.0) {
for(int i=0; i<next_germ.GetSize(); ++i) {
- if(m_world->GetRandom().P(m_world->GetConfig().GERMLINE_COPY_MUT.Get())) {
+ if (m_world->GetRandom().P(m_world->GetConfig().GERMLINE_COPY_MUT.Get())) {
next_germ[i] = instset.GetRandomInst(ctx);
}
}
}
- if((m_world->GetConfig().GERMLINE_INS_MUT.Get() > 0.0)
+ if ((m_world->GetConfig().GERMLINE_INS_MUT.Get() > 0.0)
&& m_world->GetRandom().P(m_world->GetConfig().GERMLINE_INS_MUT.Get())) {
const unsigned int mut_line = ctx.GetRandom().GetUInt(next_germ.GetSize() + 1);
next_germ.Insert(mut_line, instset.GetRandomInst(ctx));
}
- if((m_world->GetConfig().GERMLINE_DEL_MUT.Get() > 0.0)
+ if ((m_world->GetConfig().GERMLINE_DEL_MUT.Get() > 0.0)
&& m_world->GetRandom().P(m_world->GetConfig().GERMLINE_DEL_MUT.Get())) {
const unsigned int mut_line = ctx.GetRandom().GetUInt(next_germ.GetSize());
next_germ.Remove(mut_line);
@@ -1776,7 +1740,7 @@
SeedDeme(target_deme, target_deme.GetGermline().GetLatest(), SRC_DEME_GERMLINE);
}
- } else if(m_world->GetConfig().DEMES_USE_GERMLINE.Get() == 2) {
+ } else if (m_world->GetConfig().DEMES_USE_GERMLINE.Get() == 2) {
// @JEB -- New germlines using cGenotype
// get germline genotype
@@ -1789,21 +1753,21 @@
const cInstSet& instset = m_world->GetHardwareManager().GetInstSet();
cAvidaContext ctx(m_world->GetRandom());
- if(m_world->GetConfig().GERMLINE_COPY_MUT.Get() > 0.0) {
+ if (m_world->GetConfig().GERMLINE_COPY_MUT.Get() > 0.0) {
for(int i=0; i<new_genome.GetSize(); ++i) {
- if(m_world->GetRandom().P(m_world->GetConfig().GERMLINE_COPY_MUT.Get())) {
+ if (m_world->GetRandom().P(m_world->GetConfig().GERMLINE_COPY_MUT.Get())) {
new_genome[i] = instset.GetRandomInst(ctx);
}
}
}
- if((m_world->GetConfig().GERMLINE_INS_MUT.Get() > 0.0)
+ if ((m_world->GetConfig().GERMLINE_INS_MUT.Get() > 0.0)
&& m_world->GetRandom().P(m_world->GetConfig().GERMLINE_INS_MUT.Get())) {
const unsigned int mut_line = ctx.GetRandom().GetUInt(new_genome.GetSize() + 1);
new_genome.Insert(mut_line, instset.GetRandomInst(ctx));
}
- if((m_world->GetConfig().GERMLINE_DEL_MUT.Get() > 0.0)
+ if ((m_world->GetConfig().GERMLINE_DEL_MUT.Get() > 0.0)
&& m_world->GetRandom().P(m_world->GetConfig().GERMLINE_DEL_MUT.Get())) {
const unsigned int mut_line = ctx.GetRandom().GetUInt(new_genome.GetSize());
new_genome.Remove(mut_line);
@@ -1831,7 +1795,7 @@
for (int i=0; i < target_deme.GetSize(); i++) {
int cellid = target_deme.GetCellID(i);
cPopulationCell& cell = m_world->GetPopulation().GetCell(cellid);
- if(cell.IsOccupied()) {
+ if (cell.IsOccupied()) {
cOrganism* organism = cell.GetOrganism();
cPhenotype& phenotype = organism->GetPhenotype();
phenotype.SetEnergy(phenotype.GetStoredEnergy() + offspring_deme_energy/static_cast<double>(target_deme.GetOrgCount()));
@@ -1847,7 +1811,7 @@
for (int i=0; i < source_deme.GetSize(); i++) {
int cellid = source_deme.GetCellID(i);
cPopulationCell& cell = m_world->GetPopulation().GetCell(cellid);
- if(cell.IsOccupied()) {
+ if (cell.IsOccupied()) {
cOrganism* organism = cell.GetOrganism();
cPhenotype& phenotype = organism->GetPhenotype();
phenotype.SetEnergy(phenotype.GetStoredEnergy() + parent_deme_energy/static_cast<double>(source_deme.GetOrgCount()));
@@ -1916,7 +1880,7 @@
// Check to see if we're doing probabilistic organism replication from source
// to target deme.
- if(m_world->GetConfig().DEMES_PROB_ORG_TRANSFER.Get() == 0.0) {
+ if (m_world->GetConfig().DEMES_PROB_ORG_TRANSFER.Get() == 0.0) {
//@JEB -- old method is default for consistency!
if (m_world->GetConfig().DEMES_SEED_METHOD.Get() == 0) {
@@ -1940,7 +1904,7 @@
// being selected more than once).
while((int)xfer.size() < m_world->GetConfig().DEMES_REPLICATE_SIZE.Get()) {
int cellid = source_deme.GetCellID(random.GetUInt(source_deme.GetSize()));
- if(cell_array[cellid].IsOccupied()) {
+ if (cell_array[cellid].IsOccupied()) {
xfer.push_back(std::make_pair(cell_array[cellid].GetOrganism()->GetGenome(),
cell_array[cellid].GetOrganism()->GetLineageLabel()));
}
@@ -1950,7 +1914,7 @@
case 1: { // Sequential selection, from the beginning. Good with DEMES_ORGANISM_PLACEMENT=3.
for(int i=0; i<m_world->GetConfig().DEMES_REPLICATE_SIZE.Get(); ++i) {
int cellid = source_deme.GetCellID(i);
- if(cell_array[cellid].IsOccupied()) {
+ if (cell_array[cellid].IsOccupied()) {
xfer.push_back(std::make_pair(cell_array[cellid].GetOrganism()->GetGenome(),
cell_array[cellid].GetOrganism()->GetLineageLabel()));
}
@@ -2029,14 +1993,14 @@
int count = 0;
for(int i=0; i<target_deme.GetSize(); ++i) {
int cell_id = target_deme.GetCellID(i);
- if(cell_array[cell_id].IsOccupied()) count++;
+ if (cell_array[cell_id].IsOccupied()) count++;
}
cout << "Initial orgs in target deme: " << count << endl;
count = 0;
for(int i=0; i<source_deme.GetSize(); ++i) {
int cell_id = source_deme.GetCellID(i);
- if(cell_array[cell_id].IsOccupied()) count++;
+ if (cell_array[cell_id].IsOccupied()) count++;
}
cout << "Initial orgs in source deme: " << count << endl;
*/
@@ -2048,7 +2012,7 @@
tArray<cOrganism*> founders; // List of organisms we're going to transfer.
while(founders.GetSize() < m_world->GetConfig().DEMES_REPLICATE_SIZE.Get()) {
int cellid = source_deme.GetCellID(random.GetUInt(source_deme.GetSize()));
- if(cell_array[cellid].IsOccupied()) {
+ if (cell_array[cellid].IsOccupied()) {
founders.Push(cell_array[cellid].GetOrganism());
}
}
@@ -2060,7 +2024,7 @@
tArray<cOrganism*> founders; // List of organisms we're going to transfer.
for(int i=0; i<m_world->GetConfig().DEMES_REPLICATE_SIZE.Get(); ++i) {
int cellid = source_deme.GetCellID(i);
- if(cell_array[cellid].IsOccupied()) {
+ if (cell_array[cellid].IsOccupied()) {
founders.Push(cell_array[cellid].GetOrganism());
}
}
@@ -2155,7 +2119,7 @@
while(founders.GetSize() < 2) {
int cellid = source_deme.GetCellID(random.GetUInt(source_deme.GetSize()));
- if( cell_array[cellid].IsOccupied() ) {
+ if ( cell_array[cellid].IsOccupied() ) {
cOrganism * org = cell_array[cellid].GetOrganism();
bool found = false;
for(int i=0; i< founders.GetSize(); i++) {
@@ -2249,7 +2213,7 @@
for(int i=0; i<source_deme.GetSize(); ++i) {
int cell_id = source_deme.GetCellID(i);
- if(cell_array[cell_id].IsOccupied()) {
+ if (cell_array[cell_id].IsOccupied()) {
cOrganism * org = cell_array[cell_id].GetOrganism();
old_source_organisms.Push(org);
org->SetRunning(true);
@@ -2267,7 +2231,7 @@
for(int i=0; i<target_deme.GetSize(); ++i) {
int cell_id = target_deme.GetCellID(i);
- if(cell_array[cell_id].IsOccupied()) {
+ if (cell_array[cell_id].IsOccupied()) {
cOrganism * org = cell_array[cell_id].GetOrganism();
old_target_organisms.Push(org);
org->SetRunning(true);
@@ -2351,14 +2315,14 @@
count = 0;
for(int i=0; i<target_deme.GetSize(); ++i) {
int cell_id = target_deme.GetCellID(i);
- if(cell_array[cell_id].IsOccupied()) count++;
+ if (cell_array[cell_id].IsOccupied()) count++;
}
cout << "Final orgs in target deme: " << count << endl;
count = 0;
for(int i=0; i<source_deme.GetSize(); ++i) {
int cell_id = source_deme.GetCellID(i);
- if(cell_array[cell_id].IsOccupied()) count++;
+ if (cell_array[cell_id].IsOccupied()) count++;
}
cout << "Final orgs in source deme: " << count << endl;
@@ -2435,7 +2399,7 @@
int source_cellid = source_deme.GetCellID(i);
// Does this organism stay with the source or move to the target?
- if(cell_array[source_cellid].IsOccupied() && random.P(m_world->GetConfig().DEMES_PROB_ORG_TRANSFER.Get())) {
+ if (cell_array[source_cellid].IsOccupied() && random.P(m_world->GetConfig().DEMES_PROB_ORG_TRANSFER.Get())) {
// Moves to the target; save the genome and lineage label of organism being transfered.
cOrganism* seed = cell_array[source_cellid].GetOrganism();
cGenome genome = seed->GetGenome();
@@ -2825,23 +2789,23 @@
}
void cPopulation::AddDemePred(cString type, int times) {
- if(type == "EventReceivedCenter") {
+ if (type == "EventReceivedCenter") {
for (int deme_id = 0; deme_id < deme_array.GetSize(); deme_id++) {
deme_array[deme_id].AddEventReceivedCenterPred(times);
}
- } else if(type == "EventReceivedLeftSide") {
+ } else if (type == "EventReceivedLeftSide") {
for (int deme_id = 0; deme_id < deme_array.GetSize(); deme_id++) {
deme_array[deme_id].AddEventReceivedLeftSidePred(times);
}
- } else if(type == "EventMovedIntoCenter") {
+ } else if (type == "EventMovedIntoCenter") {
for (int deme_id = 0; deme_id < deme_array.GetSize(); deme_id++) {
deme_array[deme_id].AddEventMoveCenterPred(times);
}
- } else if(type == "EventMovedBetweenTargets") {
+ } else if (type == "EventMovedBetweenTargets") {
for (int deme_id = 0; deme_id < deme_array.GetSize(); deme_id++) {
deme_array[deme_id].AddEventMoveBetweenTargetsPred(times);
}
- } else if(type == "EventNUniqueIndividualsMovedIntoTarget") {
+ } else if (type == "EventNUniqueIndividualsMovedIntoTarget") {
for (int deme_id = 0; deme_id < deme_array.GetSize(); deme_id++) {
deme_array[deme_id].AddEventEventNUniqueIndividualsMovedIntoTargetPred(times);
}
@@ -2878,7 +2842,7 @@
PrintDemeResource();
PrintDemeInstructions();
- if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
+ if (m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
PrintDemeSpatialEnergyData();
PrintDemeSpatialSleepData();
}
@@ -2945,9 +2909,9 @@
int cur_cell = cur_deme.GetCellID(i);
if (cell_array[cur_cell].IsOccupied() == false) continue;
cPhenotype & phenotype = GetCell(cur_cell).GetOrganism()->GetPhenotype();
- if(phenotype.IsEnergyRequestor()) num_requestors++;
- if(phenotype.IsEnergyDonor()) num_donors++;
- if(phenotype.IsEnergyReceiver()) num_receivers++;
+ if (phenotype.IsEnergyRequestor()) num_requestors++;
+ if (phenotype.IsEnergyDonor()) num_donors++;
+ if (phenotype.IsEnergyReceiver()) num_receivers++;
num_donations += phenotype.GetNumEnergyDonations();
num_receptions += phenotype.GetNumEnergyReceptions();
num_applications += phenotype.GetNumEnergyApplications();
@@ -3318,7 +3282,7 @@
for(int j = 0; j < res.GetSize(); j++) {
const char * tmp = res.GetResName(j);
df_resources.Write(res.Get(j), cStringUtil::Stringf("Deme %d Resource %s", deme_id, tmp)); //comment);
- if((res.GetResourcesGeometry())[j] != nGeometry::GLOBAL && (res.GetResourcesGeometry())[j] != nGeometry::PARTIAL) {
+ if ((res.GetResourcesGeometry())[j] != nGeometry::GLOBAL && (res.GetResourcesGeometry())[j] != nGeometry::PARTIAL) {
PrintDemeSpatialResData(res, j, deme_id);
}
}
@@ -3347,7 +3311,7 @@
df.WriteBlockElement(deme_id, 0, num_res + 1);
for(int r = 0; r < num_res; r++) {
- if(!res.IsSpatial(r)) {
+ if (!res.IsSpatial(r)) {
df.WriteBlockElement(res.Get(r), r + 1, num_res + 1);
}
@@ -3377,7 +3341,7 @@
// write grid to file
for (int j = 0; j < gridsize; j++) {
cPopulationCell& cell = m_world->GetPopulation().GetCell(cellID);
- if(cell.IsOccupied()) {
+ if (cell.IsOccupied()) {
df.WriteBlockElement(cell.GetOrganism()->GetPhenotype().GetStoredEnergy(), j, xsize);
} else {
df.WriteBlockElement(0.0, j, xsize);
@@ -3426,7 +3390,7 @@
// write grid to file
for (int j = 0; j < gridsize; j++) {
cPopulationCell cell = m_world->GetPopulation().GetCell(cellID);
- if(cell.IsOccupied()) {
+ if (cell.IsOccupied()) {
df.WriteBlockElement(cell.GetOrganism()->IsSleeping(), j, xsize);
} else {
df.WriteBlockElement(0.0, j, xsize);
@@ -3481,7 +3445,7 @@
for(int i=0; i<deme_array.GetSize(); i++) {
- if(deme_array[i].IsEmpty()) continue;
+ if (deme_array[i].IsEmpty()) continue;
tArray<int>& deme_founders = deme_array[i].GetFounderGenotypeIDs();
@@ -3592,7 +3556,7 @@
//if the -unadjusted- id is above the excluded id, bump it up one
//insures uniform prob of landing in any deme but the parent's
- if(rnd_deme_id >= deme_id) rnd_deme_id++;
+ if (rnd_deme_id >= deme_id) rnd_deme_id++;
//set the new deme_id
deme_id = rnd_deme_id;
@@ -3858,7 +3822,7 @@
//if the -unadjusted- id is above the excluded id, bump it up one
//insures uniform prob of landing in any deme but the parent's
- if(rnd_deme_id >= deme_id) rnd_deme_id++;
+ if (rnd_deme_id >= deme_id) rnd_deme_id++;
//set the new deme_id
deme_id = rnd_deme_id;
@@ -4138,7 +4102,7 @@
for(int i = 0; i < GetNumDemes(); i++) {
cDeme& deme = GetDeme(i);
- if(deme.IsEmpty()) // ignore empty demes
+ if (deme.IsEmpty()) // ignore empty demes
{
continue;
}
@@ -4314,7 +4278,7 @@
if (phenotype.IsMultiThread()) num_multi_thread++;
else num_single_thread++;
- if(phenotype.IsModified()) num_modified++;
+ if (phenotype.IsModified()) num_modified++;
cHardwareBase& hardware = organism->GetHardware();
stats.SumMemSize().Add(hardware.GetMemory().GetSize());
@@ -4474,20 +4438,6 @@
stats.SetDomSequence(dom_genotype->GetGenome().AsString());
}
-void cPopulation::UpdateDominantParaStats()
-{
- cStats& stats = m_world->GetStats();
- cInjectGenotype * dom_inj_genotype = m_world->GetClassificationManager().GetBestInjectGenotype();
- if (dom_inj_genotype == NULL) return;
-
- stats.SetDomInjGenotype(dom_inj_genotype);
-
- stats.SetDomInjSize(dom_inj_genotype->GetLength());
- stats.SetDomInjID(dom_inj_genotype->GetID());
- stats.SetDomInjName(dom_inj_genotype->GetName());
- stats.SetDomInjAbundance(dom_inj_genotype->GetNumInjected());
- stats.SetDomInjSequence(dom_inj_genotype->GetGenome().AsString());
-}
void cPopulation::ProcessPostUpdate(cAvidaContext& ctx)
{
@@ -4502,7 +4452,6 @@
UpdateGenotypeStats();
UpdateSpeciesStats();
UpdateDominantStats();
- UpdateDominantParaStats();
// Do any final calculations...
stats.SetNumCreatures(GetNumOrganisms());
@@ -5092,15 +5041,15 @@
//@JEB This section is very messy to maintain consistency with other deme ways.
- if(m_world->GetConfig().DEMES_SEED_METHOD.Get() == 0) {
- if(m_world->GetConfig().DEMES_USE_GERMLINE.Get() == 1) {
- if(deme.GetGermline().Size()==0) {
+ if (m_world->GetConfig().DEMES_SEED_METHOD.Get() == 0) {
+ if (m_world->GetConfig().DEMES_USE_GERMLINE.Get() == 1) {
+ if (deme.GetGermline().Size()==0) {
deme.GetGermline().Add(GetCell(cell_id).GetOrganism()->GetGenome());
}
}
}
- else if(m_world->GetConfig().DEMES_SEED_METHOD.Get() == 1) {
- if(m_world->GetConfig().DEMES_USE_GERMLINE.Get() == 2) {
+ else if (m_world->GetConfig().DEMES_SEED_METHOD.Get() == 1) {
+ if (m_world->GetConfig().DEMES_USE_GERMLINE.Get() == 2) {
//find the genotype we just created from the genome, and save it
cGenotype * genotype = GetCell(cell_id).GetOrganism()->GetGenotype();
deme.ReplaceGermline(*genotype);
@@ -5121,7 +5070,7 @@
}
}
- else if(m_world->GetConfig().DEMES_USE_GERMLINE.Get() == 2) {
+ else if (m_world->GetConfig().DEMES_USE_GERMLINE.Get() == 2) {
//find the genotype we just created from the genome, and save it
cDeme& deme = deme_array[GetCell(cell_id).GetDemeID()];
cGenotype * genotype = m_world->GetClassificationManager().FindGenotype(genome, lineage_label);
@@ -5135,17 +5084,9 @@
if (target_organism == NULL) return;
- cHardwareBase& child_cpu = target_organism->GetHardware();
- if (child_cpu.GetNumThreads() == m_world->GetConfig().MAX_CPU_THREADS.Get()) return;
+ if (target_organism->GetHardware().GetNumThreads() == m_world->GetConfig().MAX_CPU_THREADS.Get()) return;
- if (target_organism->InjectHost(label, injected_code)) {
- cInjectGenotype* child_genotype = m_world->GetClassificationManager().GetInjectGenotype(injected_code, NULL);
-
- target_organism->AddParasite(child_genotype);
- child_genotype->AddParasite();
- child_cpu.ThreadSetOwner(child_genotype);
- m_world->GetClassificationManager().AdjustInjectGenotype(*child_genotype);
- }
+ target_organism->InjectHost(NULL, SRC_PARASITE_FILE_LOAD, label, injected_code);
}
@@ -5262,7 +5203,7 @@
// Set the genotype...
new_organism->SetGenotype(new_genotype);
- if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
+ if (m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
phenotype.SetMerit(cMerit(phenotype.ConvertEnergyToMerit(phenotype.GetStoredEnergy())));
} else {
phenotype.SetMerit(cMerit(new_genotype->GetTestMerit(ctx)));
@@ -5980,7 +5921,7 @@
//setting size of global and deme-level resources
for(int i = 0; i < resource_lib.GetSize(); i++) {
cResource * res = resource_lib.GetResource(i);
- if(res->GetDemeResource())
+ if (res->GetDemeResource())
num_deme_res++;
}
@@ -6005,7 +5946,7 @@
res->GetOutflowY2(), res->GetCellListPtr(),
res->GetCellIdListPtr(), Verbosity);
m_world->GetStats().SetResourceName(global_res_index, res->GetName());
- } else if(res->GetDemeResource()) {
+ } else if (res->GetDemeResource()) {
deme_res_index++;
for(int j = 0; j < GetNumDemes(); j++) {
GetDeme(j).SetupDemeRes(deme_res_index, res, Verbosity);
@@ -6060,7 +6001,7 @@
/*! Modify current level of the HGT resource.
*/
void cPopulation::AdjustHGTResource(double delta) {
- if(m_hgt_resid != -1) {
+ if (m_hgt_resid != -1) {
resource_count.Modify(m_hgt_resid, delta);
}
}
@@ -6091,7 +6032,7 @@
// Reset the organism pointers of all cells:
for(int i=0; i<cell_array.GetSize(); ++i) {
cell_array[i].RemoveOrganism();
- if(population[i] == 0) {
+ if (population[i] == 0) {
AdjustSchedule(cell_array[i], cMerit(0));
} else {
cell_array[i].InsertOrganism(population[i]);
Modified: branches/biounit/source/main/cPopulation.h
===================================================================
--- branches/biounit/source/main/cPopulation.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/main/cPopulation.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -70,6 +70,7 @@
#include "cInstSet.h"
class cAvidaContext;
+class cBioUnit;
class cCodeLabel;
class cChangeList;
class cEnvironment;
@@ -137,7 +138,7 @@
// Activate the offspring of an organism in the population
bool ActivateOffspring(cAvidaContext& ctx, const cMetaGenome& offspring_genome, cOrganism* parent_organism);
- bool ActivateParasite(cOrganism& parent, const cCodeLabel& label, const cGenome& injected_code);
+ bool ActivateParasite(cOrganism* host, cBioUnit* parent, const cCodeLabel& label, const cGenome& injected_code);
// Inject an organism from the outside world.
void Inject(const cGenome& genome, eBioUnitSource src, int cell_id = -1, double merit = -1, int lineage_label = 0, double neutral_metric = 0);
@@ -335,7 +336,6 @@
void UpdateGenotypeStats();
void UpdateSpeciesStats();
void UpdateDominantStats();
- void UpdateDominantParaStats();
/**
* Attention: InjectGenotype does *not* add the genotype to the archive.
Modified: branches/biounit/source/main/cPopulationInterface.cc
===================================================================
--- branches/biounit/source/main/cPopulationInterface.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/main/cPopulationInterface.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -266,12 +266,12 @@
return value;
}
-bool cPopulationInterface::InjectParasite(cOrganism* parent, const cCodeLabel& label, const cGenome& injected_code)
+bool cPopulationInterface::InjectParasite(cOrganism* host, cBioUnit* parent, const cCodeLabel& label, const cGenome& injected_code)
{
assert(parent != NULL);
- assert(m_world->GetPopulation().GetCell(m_cell_id).GetOrganism() == parent);
+ assert(m_world->GetPopulation().GetCell(m_cell_id).GetOrganism() == host);
- return m_world->GetPopulation().ActivateParasite(*parent, label, injected_code);
+ return m_world->GetPopulation().ActivateParasite(host, parent, label, injected_code);
}
bool cPopulationInterface::UpdateMerit(double new_merit)
Modified: branches/biounit/source/main/cPopulationInterface.h
===================================================================
--- branches/biounit/source/main/cPopulationInterface.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/main/cPopulationInterface.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -110,7 +110,7 @@
int ReceiveValue();
void SellValue(const int data, const int label, const int sell_price, const int org_id);
int BuyValue(const int label, const int buy_price);
- bool InjectParasite(cOrganism* parent, const cCodeLabel& label, const cGenome& injected_code);
+ bool InjectParasite(cOrganism* host, cBioUnit* parent, const cCodeLabel& label, const cGenome& injected_code);
bool UpdateMerit(double new_merit);
bool TestOnDivide();
//! Send a message to the faced organism.
Modified: branches/biounit/source/main/cStats.cc
===================================================================
--- branches/biounit/source/main/cStats.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/main/cStats.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -325,13 +325,6 @@
data_manager.Add("dom_depth", "Tree Depth of Dominant Genotype", &cStats::GetDomGeneDepth);
data_manager.Add("dom_sequence", "Sequence of Dominant Genotype", &cStats::GetDomSequence);
- // Dominant Inject Genotype Stats
- data_manager.Add("dom_inj_size", "Genome Length of Dominant Parasite", &cStats::GetDomInjSize);
- data_manager.Add("dom_inj_ID", "ID of Dominant Parasite", &cStats::GetDomInjID);
- data_manager.Add("dom_inj_name", "Nameof Dominant Parasite", &cStats::GetDomInjName);
- data_manager.Add("dom_inj_births", "Birth Count of Dominant Parasite", &cStats::GetDomInjBirths);
- data_manager.Add("dom_inj_abundance", "Abundance of Dominant Parasite", &cStats::GetDomInjAbundance);
- data_manager.Add("dom_inj_sequence", "Sequence of Dominant Parasite", &cStats::GetDomInjSequence);
// Current Counts...
data_manager.Add("num_births", "Count of Births in Population", &cStats::GetNumBirths);
@@ -809,10 +802,11 @@
df.Write(m_update, "Update");
df.Write(num_parasites, "Number of Extant Parasites");
- df.Write(dom_inj_size, "Size of Dominant Parasite Genotype");
- df.Write(dom_inj_abundance, "Abundance of Dominant Parasite Genotype");
- df.Write(dom_inj_genotype_id, "Genotype ID of Dominant Parasite Genotype");
- df.Write(dom_inj_name, "Name of the Dominant Parasite Genotype");
+// @TODO - parasite stats output?
+// df.Write(dom_inj_size, "Size of Dominant Parasite Genotype");
+// df.Write(dom_inj_abundance, "Abundance of Dominant Parasite Genotype");
+// df.Write(dom_inj_genotype_id, "Genotype ID of Dominant Parasite Genotype");
+// df.Write(dom_inj_name, "Name of the Dominant Parasite Genotype");
df.Endl();
}
Modified: branches/biounit/source/main/cStats.h
===================================================================
--- branches/biounit/source/main/cStats.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/main/cStats.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -77,7 +77,6 @@
class cGenotype;
-class cInjectGenotype;
class cWorld;
class cOrganism;
class cOrgMessage;
@@ -199,15 +198,6 @@
cString dom_sequence;
int coal_depth;
- // Dominant Parasite
- cInjectGenotype * dom_inj_genotype;
- int dom_inj_size;
- int dom_inj_genotype_id;
- cString dom_inj_name;
- int dom_inj_births;
- int dom_inj_abundance;
- cString dom_inj_sequence;
-
int num_births;
int num_deaths;
int num_breed_in;
@@ -388,14 +378,6 @@
int GetDomGeneDepth() const { return dom_gene_depth; }
const cString & GetDomSequence() const { return dom_sequence; }
- cInjectGenotype * GetDomInjGenotype() const { return dom_inj_genotype; }
- int GetDomInjSize() const { return dom_inj_size; }
- int GetDomInjID() const { return dom_inj_genotype_id; }
- const cString & GetDomInjName() const { return dom_inj_name; }
- int GetDomInjBirths() const { return dom_inj_births; }
- int GetDomInjAbundance() const { return dom_inj_abundance; }
- const cString & GetDomInjSequence() const { return dom_inj_sequence; }
-
int GetSenseSize() const { return sense_size; }
// Settings...
@@ -418,14 +400,6 @@
void SetDomGeneDepth(int in_depth) { dom_gene_depth = in_depth; }
void SetDomSequence(const cString & in_seq) { dom_sequence = in_seq; }
- void SetDomInjGenotype(cInjectGenotype * in_inj_genotype) { dom_inj_genotype = in_inj_genotype; }
- void SetDomInjSize(int in_inj_size) { dom_inj_size = in_inj_size; }
- void SetDomInjID(int in_inj_ID) { dom_inj_genotype_id = in_inj_ID; }
- void SetDomInjName(const cString & in_name) { dom_inj_name = in_name; }
- void SetDomInjBirths(int in_births) { dom_inj_births = in_births; }
- void SetDomInjAbundance(int in_inj_abundance) { dom_inj_abundance = in_inj_abundance; }
- void SetDomInjSequence(const cString & in_inj_sequence) { dom_inj_sequence = in_inj_sequence; }
-
void SetGenoMapElement(int i, int in_geno) { genotype_map[i] = in_geno; }
void SetCoalescentGenotypeDepth(int in_depth) {coal_depth = in_depth;}
Modified: branches/biounit/source/targets/avida-viewer/cScreen.h
===================================================================
--- branches/biounit/source/targets/avida-viewer/cScreen.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/targets/avida-viewer/cScreen.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -30,7 +30,6 @@
class cPopulation;
class cPopulationCell;
class cOrganism;
-class cInjectGenotype;
#define NUM_SYMBOLS 12
#define SYMBOL_THRESHOLD 10
Modified: branches/biounit/source/targets/avida-viewer/cViewInfo.cc
===================================================================
--- branches/biounit/source/targets/avida-viewer/cViewInfo.cc 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/targets/avida-viewer/cViewInfo.cc 2009-12-17 20:03:49 UTC (rev 3564)
@@ -12,7 +12,6 @@
#include "cClassificationManager.h"
#include "cSpecies.h"
#include "cGenotype.h"
-#include "cInjectGenotype.h"
#include "cPopulation.h"
#include "cPopulationCell.h"
#include "cOrganism.h"
@@ -66,17 +65,6 @@
}
}
-void cViewInfo::AddInjectGenChart(cInjectGenotype * in_gen)
-{
- for (int i = 0; i < NUM_SYMBOLS; i++) {
- if (inject_genotype_chart[i] == NULL) {
- inject_genotype_chart[i] = in_gen;
- in_gen->SetSymbol(symbol_chart[i]);
- break;
- }
- }
-}
-
void cViewInfo::SetupSymbolMaps(int map_mode, bool use_color)
{
typedef char (*SymbolMethod)(const cPopulationCell & cell);
Modified: branches/biounit/source/targets/avida-viewer/cViewInfo.h
===================================================================
--- branches/biounit/source/targets/avida-viewer/cViewInfo.h 2009-12-17 19:39:57 UTC (rev 3563)
+++ branches/biounit/source/targets/avida-viewer/cViewInfo.h 2009-12-17 20:03:49 UTC (rev 3564)
@@ -20,7 +20,6 @@
class cPopulation;
class cPopulationCell;
class cOrganism;
-class cInjectGenotype;
#define NUM_SYMBOLS 12
#define SYMBOL_THRESHOLD 10
@@ -68,7 +67,6 @@
// Symbol information
cGenotype * genotype_chart[NUM_SYMBOLS];
cSpecies * species_chart[NUM_SYMBOLS];
- cInjectGenotype * inject_genotype_chart[NUM_SYMBOLS];
char symbol_chart[NUM_SYMBOLS];
tArray<char> map;
@@ -76,10 +74,9 @@
inline bool InGenChart(cGenotype * in_gen);
inline bool InSpeciesChart(cSpecies * in_species);
- inline bool InInjectGenChart(cInjectGenotype * in_gen);
void AddGenChart(cGenotype * in_gen);
void AddSpeciesChart(cSpecies * in_species);
- void AddInjectGenChart(cInjectGenotype * in_gen);
+
public:
cViewInfo(cWorld* world, cView_Base * view);
~cViewInfo() { ; }
@@ -106,7 +103,6 @@
int GetNumSymbols() { return NUM_SYMBOLS; }
cGenotype * GetGenotype(int index) { return genotype_chart[index]; }
cSpecies * GetSpecies(int index) { return species_chart[index]; }
- cInjectGenotype * GetInjectGenotype(int index) { return inject_genotype_chart[index]; }
cPopulationCell * GetActiveCell() { return active_cell; }
@@ -163,12 +159,4 @@
return false;
}
-inline bool cViewInfo::InInjectGenChart(cInjectGenotype * in_gen)
-{
- for (int i = 0; i < NUM_SYMBOLS; i++) {
- if (inject_genotype_chart[i] == in_gen) return true;
- }
- return false;
-}
-
#endif
More information about the Avida-cvs
mailing list