[Avida-SVN] r3526 - in branches/biounit: Avida.xcodeproj source/classification

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Wed Nov 11 11:40:42 PST 2009


Author: brysonda
Date: 2009-11-11 14:40:41 -0500 (Wed, 11 Nov 2009)
New Revision: 3526

Added:
   branches/biounit/source/classification/cBGGenotypeManager.cc
   branches/biounit/source/classification/cBGGenotypeManager.h
Removed:
   branches/biounit/source/classification/cGenotype_BirthData.cc
   branches/biounit/source/classification/cGenotype_BirthData.h
   branches/biounit/source/classification/cGenotype_TestData.h
Modified:
   branches/biounit/Avida.xcodeproj/project.pbxproj
   branches/biounit/source/classification/cBGGenotype.cc
   branches/biounit/source/classification/cBGGenotype.h
   branches/biounit/source/classification/cBioGroup.cc
   branches/biounit/source/classification/cBioGroup.h
   branches/biounit/source/classification/cBioGroupManager.cc
   branches/biounit/source/classification/cBioGroupManager.h
   branches/biounit/source/classification/cBioUnit.cc
   branches/biounit/source/classification/cBioUnit.h
   branches/biounit/source/classification/cClassificationManager.cc
   branches/biounit/source/classification/cClassificationManager.h
   branches/biounit/source/classification/cGenotype.cc
   branches/biounit/source/classification/cGenotype.h
Log:
Fill out some more biounit class definitions.  Add stub cBGGenotypeManager class.  Condense existing cGenotype class for easier comprehension of it's current functions.

Modified: branches/biounit/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/biounit/Avida.xcodeproj/project.pbxproj	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/Avida.xcodeproj/project.pbxproj	2009-11-11 19:40:41 UTC (rev 3526)
@@ -99,7 +99,6 @@
 		7023EC590C0A431B00362B9C /* cGenome.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70CA6EB408DB7F8200068AC2 /* cGenome.cc */; };
 		7023EC5A0C0A431B00362B9C /* cGenomeUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70CA6EB508DB7F8200068AC2 /* cGenomeUtil.cc */; };
 		7023EC5B0C0A431B00362B9C /* cGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70F7DC9E09293E6F009E311D /* cGenotype.cc */; };
-		7023EC5C0C0A431B00362B9C /* cGenotype_BirthData.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70F7DE700929678E009E311D /* cGenotype_BirthData.cc */; };
 		7023EC5D0C0A431B00362B9C /* cGenotypeControl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70F7DE6809296613009E311D /* cGenotypeControl.cc */; };
 		7023EC5E0C0A431B00362B9C /* cHardwareBase.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1EFA308C39F2100F50912 /* cHardwareBase.cc */; };
 		7023EC5F0C0A431B00362B9C /* cHardwareCPU.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1EFA508C39F2100F50912 /* cHardwareCPU.cc */; };
@@ -243,6 +242,8 @@
 		70AD4FA00F194F4D00AA50AC /* cGenotypeData.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70AD4F9E0F194DD400AA50AC /* cGenotypeData.cc */; };
 		70B1A7430B7E3FFD00067486 /* instset-experimental.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 70B1A7420B7E3FFD00067486 /* instset-experimental.cfg */; };
 		70B1A75A0B7E431F00067486 /* experimental.org in CopyFiles */ = {isa = PBXBuildFile; fileRef = 70B1A7590B7E431F00067486 /* experimental.org */; };
+		70B547FC10AB22920013E999 /* cBGGenotypeManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 70B547FA10AB22920013E999 /* cBGGenotypeManager.h */; };
+		70B547FD10AB22920013E999 /* cBGGenotypeManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B547FB10AB22920013E999 /* cBGGenotypeManager.cc */; };
 		70B6514F0BEA6FCC002472ED /* main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 701EF27E0BEA5D2300DAE168 /* main.cc */; };
 		70B651B70BEA9AEC002472ED /* unit-tests in CopyFiles */ = {isa = PBXBuildFile; fileRef = 70B6514C0BEA6FAD002472ED /* unit-tests */; };
 		70BB2A2B0E9FA12F008269D2 /* ASAvidaLib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70BB2A2A0E9FA12F008269D2 /* ASAvidaLib.cc */; };
@@ -887,6 +888,8 @@
 		70B1A7420B7E3FFD00067486 /* instset-experimental.cfg */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = "instset-experimental.cfg"; sourceTree = "<group>"; };
 		70B1A7590B7E431F00067486 /* experimental.org */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = experimental.org; sourceTree = "<group>"; };
 		70B3984E0947B29D0018F09D /* tManagedPointerArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tManagedPointerArray.h; sourceTree = "<group>"; };
+		70B547FA10AB22920013E999 /* cBGGenotypeManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cBGGenotypeManager.h; sourceTree = "<group>"; };
+		70B547FB10AB22920013E999 /* cBGGenotypeManager.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cBGGenotypeManager.cc; sourceTree = "<group>"; };
 		70B6514C0BEA6FAD002472ED /* unit-tests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "unit-tests"; sourceTree = BUILT_PRODUCTS_DIR; };
 		70B984220EBB5B7F00A828B1 /* tDMSingleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tDMSingleton.h; sourceTree = "<group>"; };
 		70B9842B0EBB5D4C00A828B1 /* cDMObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cDMObject.h; sourceTree = "<group>"; };
@@ -987,9 +990,6 @@
 		70F7DE6909296613009E311D /* cGenotypeControl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cGenotypeControl.h; sourceTree = "<group>"; };
 		70F7DE6A09296613009E311D /* cSpeciesControl.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cSpeciesControl.cc; sourceTree = "<group>"; };
 		70F7DE6B09296613009E311D /* cSpeciesControl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cSpeciesControl.h; sourceTree = "<group>"; };
-		70F7DE700929678E009E311D /* cGenotype_BirthData.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cGenotype_BirthData.cc; sourceTree = "<group>"; };
-		70F7DE710929678E009E311D /* cGenotype_BirthData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cGenotype_BirthData.h; sourceTree = "<group>"; };
-		70F7DE730929678E009E311D /* cGenotype_TestData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cGenotype_TestData.h; sourceTree = "<group>"; };
 		70F7DE76092967A8009E311D /* cGenotypeBatch.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cGenotypeBatch.h; sourceTree = "<group>"; };
 		70F9FD990C4E89C40083B788 /* tAutoRelease.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tAutoRelease.h; sourceTree = "<group>"; };
 		70FB86A908BFAFEC00BDF589 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
@@ -1516,9 +1516,6 @@
 				705332490929764A006BD186 /* cSpecies.h */,
 				7053324A0929764A006BD186 /* cSpeciesQueue.cc */,
 				7053324B0929764A006BD186 /* cSpeciesQueue.h */,
-				70F7DE700929678E009E311D /* cGenotype_BirthData.cc */,
-				70F7DE710929678E009E311D /* cGenotype_BirthData.h */,
-				70F7DE730929678E009E311D /* cGenotype_TestData.h */,
 				70F7DE6809296613009E311D /* cGenotypeControl.cc */,
 				70F7DE6909296613009E311D /* cGenotypeControl.h */,
 				70F7DE6A09296613009E311D /* cSpeciesControl.cc */,
@@ -1537,6 +1534,8 @@
 				701E746A10A37967006B6193 /* cBGGenotype.cc */,
 				701E748210A37DB2006B6193 /* cBioGroupManager.h */,
 				701E748310A37DB2006B6193 /* cBioGroupManager.cc */,
+				70B547FA10AB22920013E999 /* cBGGenotypeManager.h */,
+				70B547FB10AB22920013E999 /* cBGGenotypeManager.cc */,
 			);
 			path = classification;
 			sourceTree = "<group>";
@@ -1949,6 +1948,7 @@
 				702244C3107D168F0079CD25 /* cBioGroup.h in Headers */,
 				701E746B10A37967006B6193 /* cBGGenotype.h in Headers */,
 				701E748410A37DB2006B6193 /* cBioGroupManager.h in Headers */,
+				70B547FC10AB22920013E999 /* cBGGenotypeManager.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2234,7 +2234,6 @@
 				7023EC590C0A431B00362B9C /* cGenome.cc in Sources */,
 				7023EC5A0C0A431B00362B9C /* cGenomeUtil.cc in Sources */,
 				7023EC5B0C0A431B00362B9C /* cGenotype.cc in Sources */,
-				7023EC5C0C0A431B00362B9C /* cGenotype_BirthData.cc in Sources */,
 				7023EC5D0C0A431B00362B9C /* cGenotypeControl.cc in Sources */,
 				7023EC5E0C0A431B00362B9C /* cHardwareBase.cc in Sources */,
 				7023EC5F0C0A431B00362B9C /* cHardwareCPU.cc in Sources */,
@@ -2335,6 +2334,7 @@
 				702244C4107D168F0079CD25 /* cBioGroup.cc in Sources */,
 				701E746C10A37967006B6193 /* cBGGenotype.cc in Sources */,
 				701E748510A37DB2006B6193 /* cBioGroupManager.cc in Sources */,
+				70B547FD10AB22920013E999 /* cBGGenotypeManager.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: branches/biounit/source/classification/cBGGenotype.cc
===================================================================
--- branches/biounit/source/classification/cBGGenotype.cc	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cBGGenotype.cc	2009-11-11 19:40:41 UTC (rev 3526)
@@ -24,3 +24,31 @@
 
 #include "cBGGenotype.h"
 
+
+cBGGenotype::cBGGenotype(cBGGenotypeManager* mgr, int in_id, cBioUnit* founder, int update, tArray<cBioGroup*>* parents)
+  : m_mgr(mgr)
+  , m_src(founder->GetUnitSource())
+  , m_genome(founder->GetMetaGenome())
+  , m_name("001-no_name")
+  , m_threshold(false)
+  , m_active(true)
+  , m_id(in_id)
+  , m_update_born(update)
+  , m_update_deactivated(-1)
+  , m_depth(0)
+  , m_active_offspring_genotypes(0)
+{
+  if (parents) {
+    m_parents.Resize(parents->GetSize());
+    for (int i = 0; i < m_parents.GetSize(); i++) {
+      m_parents[i] = (*parents)[i];
+      m_parents[i]->AddReference();
+    }
+  }
+  if (m_parents.GetSize()) m_depth = m_parents[0]->GetDepth() + 1;
+}
+
+cBGGenotype::~cBGGenotype()
+{
+  for (int i = 0; i < m_parents.GetSize(); i++) m_parents[i]->RemoveReference();
+}

Modified: branches/biounit/source/classification/cBGGenotype.h
===================================================================
--- branches/biounit/source/classification/cBGGenotype.h	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cBGGenotype.h	2009-11-11 19:40:41 UTC (rev 3526)
@@ -28,21 +28,84 @@
 #ifndef cBioGroup_h
 #include "cBioGroup.h"
 #endif
+#ifndef cCountTracker_h
+#include "cCountTracker.h"
+#endif
+#ifndef cDoubleSum_h
+#include "cDoubleSum.h"
+#endif
+#ifndef cMetaGenome_h
+#include "cMetaGenome.h"
+#endif
+#ifndef cString_h
+#include "cString.h"
+#endif
 
+
+class cBGGenotypeManager;
+
+
 class cBGGenotype : public cBioGroup
 {
 private:
-  cWorld* m_world;
+  cBGGenotypeManager* m_mgr;
   
+  cBioUnit::eUnitSource m_src;
   cMetaGenome m_genome;
   cString m_name;
+    
+  struct {
+    bool m_threshold:1;
+    bool m_active:1;
+  };
   
+  int m_id;
+  int m_update_born;
+  int m_update_deactivated;
+  int m_depth;
+  int m_active_offspring_genotypes;
   
-  cBGGenotype() { ; }
+  tArray<cBioGroup*> m_parents;
   
+  cCountTracker m_births;
+  cCountTracker m_deaths;
+  cCountTracker m_breed_in;
+  cCountTracker m_breed_true;
+  cCountTracker m_breed_out;
+  cCountTracker m_orgs;
+
+  cDoubleSum m_copied_size;
+  cDoubleSum m_exe_size;
+  cDoubleSum m_gestation_time;
+  cDoubleSum m_repro_rate;
+  cDoubleSum m_merit;
+  cDoubleSum m_fitness;
+    
+  
+  cBGGenotype(cBGGenotypeManager* mgr, int in_id, cBioUnit* founder, int update, tArray<cBioGroup*>* parents);
+  
 public:
-  ~cBGGenotype() { ; }
+  ~cBGGenotype();
   
+  // cBioGroup Interface Methods
+  cBioGroup* ClassifyNewBioUnit(cBioUnit* bu, tArray<cBioGroup*>* parents = NULL);
+  void RemoveBioUnit(cBioUnit* bu);
+  
+  int GetDepth() const { return m_depth; }
+
+  
+  // Genotype Specific Methods
+  inline const cString& GetName() const { return m_name; }
+  
+  inline bool IsThreshold() const { return m_threshold; }
+  inline bool IsActive() const { return m_active; }
+  
+  inline int GetID() const { return m_id; }
+  inline int GetUpdateBorn() const { return m_update_born; }
+  inline int GetUpdateDeactivated() const { return m_update_deactivated; }
+  
+  void SetThreshold() { m_threshold = true; }
+  void ClearThreshold() { m_threshold = false; }
 };
 
 #endif

Added: branches/biounit/source/classification/cBGGenotypeManager.cc
===================================================================
--- branches/biounit/source/classification/cBGGenotypeManager.cc	                        (rev 0)
+++ branches/biounit/source/classification/cBGGenotypeManager.cc	2009-11-11 19:40:41 UTC (rev 3526)
@@ -0,0 +1,26 @@
+/*
+ *  cBGGenotypeManager.cc
+ *  Avida
+ *
+ *  Created by David on 11/11/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 "cBGGenotypeManager.h"
+

Added: branches/biounit/source/classification/cBGGenotypeManager.h
===================================================================
--- branches/biounit/source/classification/cBGGenotypeManager.h	                        (rev 0)
+++ branches/biounit/source/classification/cBGGenotypeManager.h	2009-11-11 19:40:41 UTC (rev 3526)
@@ -0,0 +1,52 @@
+/*
+ *  cBGGenotypeManager.h
+ *  Avida
+ *
+ *  Created by David on 11/11/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 cBGGenotypeManager_h
+#define cBGGenotypeManager_h
+
+#ifndef cBioGroupManager_h
+#include "cBioGroupManager.h"
+#endif
+
+class cWorld;
+
+
+class cBGGenotypeManager : public cBioGroupManager
+{
+private:
+  cWorld* m_world;
+  
+  
+public:
+  cBGGenotypeManager(cWorld* world);
+  ~cBGGenotypeManager();
+  
+  // cBioGroupManager Interface Methods
+  cBioGroup* ClassifyNewBioUnit(cBioUnit* bu);
+  
+  
+  // Genotype Manager Methods
+};
+
+#endif

Modified: branches/biounit/source/classification/cBioGroup.cc
===================================================================
--- branches/biounit/source/classification/cBioGroup.cc	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cBioGroup.cc	2009-11-11 19:40:41 UTC (rev 3526)
@@ -24,4 +24,10 @@
 
 #include "cBioGroup.h"
 
-cBioGroup::~cBioGroup() { ; }
+#include <cassert>
+
+
+cBioGroup::~cBioGroup()
+{
+  assert(m_refs == 0);
+}

Modified: branches/biounit/source/classification/cBioGroup.h
===================================================================
--- branches/biounit/source/classification/cBioGroup.h	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cBioGroup.h	2009-11-11 19:40:41 UTC (rev 3526)
@@ -25,6 +25,9 @@
 #ifndef cBioGroup_h
 #define cBioGroup_h
 
+#ifndef defs_h
+#include "defs.h"
+#endif
 #ifndef cBioUnit_h
 #include "cBioUnit.h"
 #endif
@@ -33,17 +36,21 @@
 
 class cBioGroup
 {
+protected:
+  int m_refs;
+  
 public:
-  cBioGroup() { ; }
+  cBioGroup() : m_refs(0) { ; }
   virtual ~cBioGroup() = 0;
   
-  virtual cBioGroup* ClassifyNewBioUnit(cBioUnit* bu, tArray<cBioGroups>* parents = NULL) = 0;
+  virtual cBioGroup* ClassifyNewBioUnit(cBioUnit* bu, tArray<cBioGroup*>* parents = NULL) = 0;
   virtual void RemoveBioUnit(cBioUnit* bu) = 0;
   
-
-
-protected:
+  virtual int GetDepth() const = 0;
   
+  int GetReferenceCount() const { return m_refs; }
+  void AddReference() { m_refs++; }
+  void RemoveReference() { m_refs--; }
 };
 
 #endif

Modified: branches/biounit/source/classification/cBioGroupManager.cc
===================================================================
--- branches/biounit/source/classification/cBioGroupManager.cc	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cBioGroupManager.cc	2009-11-11 19:40:41 UTC (rev 3526)
@@ -24,3 +24,4 @@
 
 #include "cBioGroupManager.h"
 
+cBioGroupManager::~cBioGroupManager() { ; }

Modified: branches/biounit/source/classification/cBioGroupManager.h
===================================================================
--- branches/biounit/source/classification/cBioGroupManager.h	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cBioGroupManager.h	2009-11-11 19:40:41 UTC (rev 3526)
@@ -25,7 +25,35 @@
 #ifndef cBioGroupManager_h
 #define cBioGroupManager_h
 
+#ifndef cString_h
+#include "cString.h"
+#endif
 
+class cBioGroup;
+class cBioUnit;
 
 
+class cBioGroupManager
+{
+  friend class cClassificationManager;
+private:
+  cString m_role;
+  
+  
+public:
+  cBioGroupManager() { ; }
+  virtual ~cBioGroupManager() = 0;
+  
+  virtual cBioGroup* ClassifyNewBioUnit(cBioUnit* bu) = 0;
+  
+  
+protected:
+  inline const cString& GetRole() const { return m_role; }
+  
+  
+private:
+  void SetRole(const cString& role) { m_role = role; }
+};
+
+
 #endif

Modified: branches/biounit/source/classification/cBioUnit.cc
===================================================================
--- branches/biounit/source/classification/cBioUnit.cc	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cBioUnit.cc	2009-11-11 19:40:41 UTC (rev 3526)
@@ -24,4 +24,4 @@
 
 #include "cBioUnit.h"
 
-cBioUnit::~cBioUnit() { ; }
\ No newline at end of file
+cBioUnit::~cBioUnit() { ; }

Modified: branches/biounit/source/classification/cBioUnit.h
===================================================================
--- branches/biounit/source/classification/cBioUnit.h	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cBioUnit.h	2009-11-11 19:40:41 UTC (rev 3526)
@@ -26,13 +26,25 @@
 #define cBioUnit_h
 
 class cMetaGenome;
+class cString;
 
 class cBioUnit
 {
 public:
+  enum eUnitSource {
+    ORGANISM_FILE_LOAD,
+    ORGANISM_DIVIDE,
+    PARASITE_FILE_LOAD,
+    PARASITE_INJECT
+  };
+  
+
+public:
   cBioUnit() { ; }
   virtual ~cBioUnit() = 0;
   
+  virtual eUnitSource GetUnitSource() = 0;
+  virtual const cString& GetUnitSourceArgs() = 0;
   virtual cMetaGenome& GetMetaGenome() = 0;
 };
 

Modified: branches/biounit/source/classification/cClassificationManager.cc
===================================================================
--- branches/biounit/source/classification/cClassificationManager.cc	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cClassificationManager.cc	2009-11-11 19:40:41 UTC (rev 3526)
@@ -25,6 +25,7 @@
 
 #include "cClassificationManager.h"
 
+#include "cBioGroupManager.h"
 #include "cDataFile.h"
 #include "cGenome.h"
 #include "cGenotype.h"
@@ -71,6 +72,16 @@
   delete m_inject_ctl;
 }
 
+bool cClassificationManager::RegisterBioGroupManager(cBioGroupManager* bgm, const cString& role)
+{
+  // @TODO - verify that this role is not already in use -- maybe hash managers by role
+  m_bgms.Push(bgm);
+  bgm->SetRole(role);
+  
+  return true;
+}
+
+
 void cClassificationManager::UpdateReset()
 {
   cGenotype* best_genotype = GetBestGenotype();

Modified: branches/biounit/source/classification/cClassificationManager.h
===================================================================
--- branches/biounit/source/classification/cClassificationManager.h	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cClassificationManager.h	2009-11-11 19:40:41 UTC (rev 3526)
@@ -47,30 +47,28 @@
 #ifndef cString_h
 #include "cString.h"
 #endif
+#ifndef tArray_h
+#include "tArray.h"
+#endif
 #ifndef tList_h
 #include "tList.h"
 #endif
 
-#if USE_tMemTrack
-# ifndef tMemTrack_h
-#  include "tMemTrack.h"
-# endif
-#endif
-
-
 class cAvidaContext;
+class cBioGroupManager;
 class cLineage;
 class cOrganism;
 class cWorld;
 
+
 class cClassificationManager
 {
-#if USE_tMemTrack
-  tMemTrack<cClassificationManager> mt;
-#endif
 private:
   cWorld* m_world;
   
+  tArray<cBioGroupManager*> m_bgms;
+  
+  
   // Genotype Structures
   unsigned int m_genotype_count[MAX_CREATURE_SIZE];
   tList<cGenotype> m_active_genotypes[nGenotype::HASH_SIZE];
@@ -102,19 +100,6 @@
 	std::set<int>  m_cclade_ids;
   
   
-  // Private Helper Functions
-  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();
-    
   cClassificationManager(); // @not_implemented
   cClassificationManager(const cClassificationManager&); // @not_implemented
   cClassificationManager& operator=(const cClassificationManager&); // @not_implemented
@@ -125,7 +110,9 @@
 
   void UpdateReset();
   
+  bool RegisterBioGroupManager(cBioGroupManager* bgm, const cString& role);
   
+  
   // Genotype Manipulation
   cGenotype* GetGenotype(const cGenome& in_genome, cGenotype* parent1, cGenotype* parent2);
   cGenotype* GetGenotypeInjected(const cGenome& in_genome, int lineage_label);
@@ -219,7 +206,22 @@
   // Utility Functions
   bool SaveClone(std::ofstream& fp);
   bool LoadClone(std::ifstream & fp);
-  bool OK();  
+  bool OK();
+  
+  
+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();
+    
 };
 
 

Modified: branches/biounit/source/classification/cGenotype.cc
===================================================================
--- branches/biounit/source/classification/cGenotype.cc	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cGenotype.cc	2009-11-11 19:40:41 UTC (rev 3526)
@@ -81,6 +81,29 @@
     delete m_phenplast_stats;
 }
 
+cGenotype::cBirthData::cBirthData(int in_update_born)
+  : update_born(in_update_born)
+  , parent_distance(-1)
+  , gene_depth(0)
+  , exec_born(-1)
+  , generation_born(-1)
+  , birth_org_id(-1)
+  , death_org_id(-1)
+  , update_deactivated(-1)
+  , parent_genotype(NULL)
+  , parent_species(NULL)
+  , num_offspring_genotypes(0)
+{
+  // @CAO: we should do a test to see if we have a sexual population.  For now
+  // we will assume we do.
+  ancestor_ids.Resize(6);
+  ancestor_ids.SetAll(-1);
+}
+
+
+
+
+
 bool cGenotype::SaveClone(ofstream& fp)
 {
   fp << id_num         << " ";
@@ -135,11 +158,6 @@
   sum_merit.Add(in.GetDouble());
 }
 
-void cGenotype::RemoveMerit(const cMerit & in)
-{
-  sum_merit.Subtract(in.GetDouble());
-}
-
 void cGenotype::SetParent(cGenotype* parent, cGenotype* parent2)
 {
   birth_data.parent_genotype = parent;

Modified: branches/biounit/source/classification/cGenotype.h
===================================================================
--- branches/biounit/source/classification/cGenotype.h	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cGenotype.h	2009-11-11 19:40:41 UTC (rev 3526)
@@ -28,24 +28,25 @@
 
 #include <cassert>
 #include <fstream>
+
+#ifndef cCountTracker_h
+#include "cCountTracker.h"
+#endif
 #ifndef cDoubleSum_h
 #include "cDoubleSum.h"
 #endif
 #ifndef cGenome_h
 #include "cGenome.h"
 #endif
-#ifndef cGenotype_BirthData_h
-#include "cGenotype_BirthData.h"
-#endif
-#ifndef cGenotype_TestData_h
-#include "cGenotype_TestData.h"
-#endif
 #ifndef cPhenPlastSummary_h
 #include "cPhenPlastSummary.h"
 #endif
 #ifndef cString_h
 #include "cString.h"
 #endif
+#ifndef tArray_h
+#include "tArray.h"
+#endif
 
 
 class cAvidaContext;
@@ -57,6 +58,57 @@
 private:
   friend class cClassificationManager;
 
+  class cBirthData {
+  public:
+    cBirthData(int in_update_born);
+    ~cBirthData() { ; }
+    
+    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_distance;  // Genetic distance from parent genotype
+    int gene_depth;       // depth in the phylogenetic tree from ancestor
+    int lineage_label;    // Unique label for the lineage of this genotype.
+    int exec_born;        // @MRR Number of instruction executions from start
+    int generation_born;  // @MRR Generation genotype created
+    int birth_org_id;     // @MRR Organism ID at birth
+    int death_org_id;     // @MRR Highest organism ID at time of death
+    
+    int update_deactivated;       // If not, when did it get deactivated?
+    cGenotype* parent_genotype;  // Pointer to parent genotype...
+    cGenotype* parent2_genotype; // Pointer to secondary parent genotype...
+    cSpecies* parent_species;
+    int num_offspring_genotypes;  // Num offspring genotypes still in memory.
+    
+    // Ancestral IDs.  This array contains all of the information about the
+    // ids of the ancestors.  It will have one entry if this is an asexual
+    // population, otherwise:
+    // [0]=parent1, [1]=parent2, [2]&[3]=grandparents 1, [4]&[5]=grandparents 2
+    tArray<int> ancestor_ids;
+  };  
+
+  class cTestData {
+  public:
+    cTestData() : fitness(-1) { ; }
+    ~cTestData() { ; }
+    
+    bool is_viable;
+    
+    double fitness;
+    double merit;
+    int gestation_time;
+    int executed_size;
+    int copied_size;
+    double colony_fitness;
+    int generations;
+  };
+    
+  
+private:  
   cWorld* m_world;
   cGenome genome;
   cString name;
@@ -72,8 +124,8 @@
   char symbol;
   int map_color_id;
 
-  mutable cGenotype_TestData test_data;
-  cGenotype_BirthData birth_data;
+  mutable cTestData test_data;
+  cBirthData birth_data;
   mutable cPhenPlastSummary* m_phenplast_stats;
   
   // Statistical info
@@ -183,9 +235,9 @@
   void AddGestationTime(int in) { sum_gestation_time.Add(in);
                                        sum_repro_rate.Add(1/(double)in); }
   void AddMerit(const cMerit& in);
-  void RemoveMerit(const cMerit& in);
   void AddFitness(double in) { assert(in >= 0.0); sum_fitness.Add(in); }
-  void RemoveFitness(double in) { assert(in >= 0.0); sum_fitness.Subtract(in); }
+  
+  
 
   //// Properties Native to Genotype ////
   cGenome& GetGenome() { return genome; }
@@ -266,7 +318,6 @@
   inline int AddOrganism();
   inline int RemoveOrganism();
   int AddParasite()         { return ++total_parasites; }
-  void SwapOrganism()       { total_organisms++; }
   int GetNumOrganisms()     { return num_organisms; }
   int GetTotalOrganisms()   { return total_organisms; }
   int GetTotalParasites()   { return total_parasites; }

Deleted: branches/biounit/source/classification/cGenotype_BirthData.cc
===================================================================
--- branches/biounit/source/classification/cGenotype_BirthData.cc	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cGenotype_BirthData.cc	2009-11-11 19:40:41 UTC (rev 3526)
@@ -1,45 +0,0 @@
-/*
- *  cGenotype_BirthData.cc
- *  Avida
- *
- *  Called "genotype_birth_data.cc" 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.
- *
- */
-
-#include "cGenotype_BirthData.h"
-
-cGenotype_BirthData::cGenotype_BirthData(int in_update_born)
-  : update_born(in_update_born)
-  , parent_distance(-1)
-  , gene_depth(0)
-  , exec_born(-1)
-  , generation_born(-1)
-  , birth_org_id(-1)
-  , death_org_id(-1)
-  , update_deactivated(-1)
-  , parent_genotype(NULL)
-  , parent_species(NULL)
-  , num_offspring_genotypes(0)
-{
-  // @CAO: we should do a test to see if we have a sexual population.  For now
-  // we will assume we do.
-  ancestor_ids.Resize(6);
-  ancestor_ids.SetAll(-1);
-}

Deleted: branches/biounit/source/classification/cGenotype_BirthData.h
===================================================================
--- branches/biounit/source/classification/cGenotype_BirthData.h	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cGenotype_BirthData.h	2009-11-11 19:40:41 UTC (rev 3526)
@@ -1,84 +0,0 @@
-/*
- *  cGenotype_BirthData.h
- *  Avida
- *
- *  Called "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 cGenotype_BirthData_h
-#define cGenotype_BirthData_h
-
-#ifndef cCountTracker_h
-#include "cCountTracker.h"
-#endif
-#ifndef tArray_h
-#include "tArray.h"
-#endif
-
-class cGenotype;
-class cSpecies;
-
-class cGenotype_BirthData {
-public:
-  cGenotype_BirthData(int in_update_born);
-  ~cGenotype_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_distance;  // Genetic distance from parent genotype
-  int gene_depth;       // depth in the phylogenetic tree from ancestor
-  int lineage_label;    // Unique label for the lineage of this genotype.
-  int exec_born;        // @MRR Number of instruction executions from start
-  int generation_born;  // @MRR Generation genotype created
-  int birth_org_id;     // @MRR Organism ID at birth
-  int death_org_id;     // @MRR Highest organism ID at time of death
-  
-  int update_deactivated;       // If not, when did it get deactivated?
-  cGenotype* parent_genotype;  // Pointer to parent genotype...
-  cGenotype* parent2_genotype; // Pointer to secondary parent genotype...
-  cSpecies* parent_species;
-  int num_offspring_genotypes;  // Num offspring genotypes still in memory.
-
-  // Ancestral IDs.  This array contains all of the information about the
-  // ids of the ancestors.  It will have one entry if this is an asexual
-  // population, otherwise:
-  // [0]=parent1, [1]=parent2, [2]&[3]=grandparents 1, [4]&[5]=grandparents 2
-  tArray<int> ancestor_ids;
-};
-
-
-#ifdef ENABLE_UNIT_TESTS
-namespace nGenotype_BirthData {
-  /**
-   * 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/cGenotype_TestData.h
===================================================================
--- branches/biounit/source/classification/cGenotype_TestData.h	2009-11-11 15:54:17 UTC (rev 3525)
+++ branches/biounit/source/classification/cGenotype_TestData.h	2009-11-11 19:40:41 UTC (rev 3526)
@@ -1,57 +0,0 @@
-/*
- *  cGenotype_TestData.h
- *  Avida
- *
- *  Called "genotype_test_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 cGenotype_TestData_h
-#define cGenotype_TestData_h
-
-class cGenotype_TestData {
-public:
-  cGenotype_TestData() : fitness(-1) { ; }
-  ~cGenotype_TestData() { ; }
-
-  bool is_viable;
-
-  double fitness;
-  double merit;
-  int gestation_time;
-  int executed_size;
-  int copied_size;
-  double colony_fitness;
-  int generations;
-};
-
-
-#ifdef ENABLE_UNIT_TESTS
-namespace nGenotype_TestData {
-  /**
-   * Run unit tests
-   *
-   * @param full Run full test suite; if false, just the fast tests.
-   **/
-  void UnitTests(bool full = false);
-}
-#endif  
-
-#endif




More information about the Avida-cvs mailing list