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

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Tue Dec 22 13:38:35 PST 2009


Author: brysonda
Date: 2009-12-22 16:38:35 -0500 (Tue, 22 Dec 2009)
New Revision: 3575

Added:
   branches/biounit/source/classification/cBGSpecies.cc
   branches/biounit/source/classification/cBGSpecies.h
   branches/biounit/source/classification/cBGSpeciesManager.cc
   branches/biounit/source/classification/cBGSpeciesManager.h
Modified:
   branches/biounit/Avida.xcodeproj/project.pbxproj
   branches/biounit/source/classification/cBioUnit.cc
   branches/biounit/source/classification/cClassificationManager.cc
   branches/biounit/source/classification/cClassificationManager.h
   branches/biounit/source/tools/tArrayMap.h
Log:
Add stub files for cBGSpecies and cBGSpeciesManager classes.
Add interface slots for detailing bio group dependencies, although at the moment it is simply handled as ordering of role ids (i.e. the managers must be registered in order of dependency).

Modified: branches/biounit/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/biounit/Avida.xcodeproj/project.pbxproj	2009-12-22 16:56:54 UTC (rev 3574)
+++ branches/biounit/Avida.xcodeproj/project.pbxproj	2009-12-22 21:38:35 UTC (rev 3575)
@@ -230,6 +230,10 @@
 		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 */; };
+		7090F71810E16CC400ECFBA1 /* cBGSpecies.h in Headers */ = {isa = PBXBuildFile; fileRef = 7090F71610E16CC400ECFBA1 /* cBGSpecies.h */; };
+		7090F71910E16CC400ECFBA1 /* cBGSpecies.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7090F71710E16CC400ECFBA1 /* cBGSpecies.cc */; };
+		7090F72F10E1731900ECFBA1 /* cBGSpeciesManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 7090F72D10E1731900ECFBA1 /* cBGSpeciesManager.h */; };
+		7090F73010E1731900ECFBA1 /* cBGSpeciesManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7090F72E10E1731900ECFBA1 /* cBGSpeciesManager.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 */; };
@@ -686,6 +690,10 @@
 		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>"; };
+		7090F71610E16CC400ECFBA1 /* cBGSpecies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cBGSpecies.h; sourceTree = "<group>"; };
+		7090F71710E16CC400ECFBA1 /* cBGSpecies.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cBGSpecies.cc; sourceTree = "<group>"; };
+		7090F72D10E1731900ECFBA1 /* cBGSpeciesManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cBGSpeciesManager.h; sourceTree = "<group>"; };
+		7090F72E10E1731900ECFBA1 /* cBGSpeciesManager.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cBGSpeciesManager.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>"; };
@@ -1516,6 +1524,10 @@
 				701E748310A37DB2006B6193 /* cBioGroupManager.cc */,
 				70B547FA10AB22920013E999 /* cBGGenotypeManager.h */,
 				70B547FB10AB22920013E999 /* cBGGenotypeManager.cc */,
+				7090F71610E16CC400ECFBA1 /* cBGSpecies.h */,
+				7090F71710E16CC400ECFBA1 /* cBGSpecies.cc */,
+				7090F72D10E1731900ECFBA1 /* cBGSpeciesManager.h */,
+				7090F72E10E1731900ECFBA1 /* cBGSpeciesManager.cc */,
 			);
 			path = classification;
 			sourceTree = "<group>";
@@ -1929,6 +1941,8 @@
 				B462B5C10FA0F47D00F379D1 /* cPhenPlastSummary.h in Headers */,
 				702082900FB9F2DF00637AD6 /* cBitArray.h in Headers */,
 				7090F57510D956A400ECFBA1 /* cParasite.h in Headers */,
+				7090F71810E16CC400ECFBA1 /* cBGSpecies.h in Headers */,
+				7090F72F10E1731900ECFBA1 /* cBGSpeciesManager.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2313,6 +2327,8 @@
 				70B547FD10AB22920013E999 /* cBGGenotypeManager.cc in Sources */,
 				7090F57610D956A400ECFBA1 /* cParasite.cc in Sources */,
 				700B6D4110DFFDD000A1F8F1 /* cMetaGenome.cc in Sources */,
+				7090F71910E16CC400ECFBA1 /* cBGSpecies.cc in Sources */,
+				7090F73010E1731900ECFBA1 /* cBGSpeciesManager.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: branches/biounit/source/classification/cBGSpecies.cc
===================================================================
--- branches/biounit/source/classification/cBGSpecies.cc	                        (rev 0)
+++ branches/biounit/source/classification/cBGSpecies.cc	2009-12-22 21:38:35 UTC (rev 3575)
@@ -0,0 +1,26 @@
+/*
+ *  cBGSpecies.cc
+ *  Avida
+ *
+ *  Created by David on 12/22/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 "cBGSpecies.h"
+

Added: branches/biounit/source/classification/cBGSpecies.h
===================================================================
--- branches/biounit/source/classification/cBGSpecies.h	                        (rev 0)
+++ branches/biounit/source/classification/cBGSpecies.h	2009-12-22 21:38:35 UTC (rev 3575)
@@ -0,0 +1,78 @@
+/*
+ *  cBGSpecies.h
+ *  Avida
+ *
+ *  Created by David on 12/22/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 cBGSpecies_h
+#define cBGSpecies_h
+
+#ifndef cBioGroup_h
+#include "cBioGroup.h"
+#endif
+#ifndef nSpecies_h
+#include "nSpecies.h"
+#endif
+
+
+class cBGSpeciesManager;
+
+
+class cBGSpecies : public cBioGroup
+{
+  friend class cBGSpeciesManager;
+private:
+  cBGSpeciesManager* m_mgr;
+
+  cBioGroup* m_founder;
+  
+  int m_id;
+  int m_update_born;
+  int m_depth;
+  int m_total_organisms;
+  int m_total_genotypes;
+  int m_num_threshold;
+  int m_num_organisms;
+  int m_genotype_distance[nSpecies::MAX_DISTANCE];
+  
+  
+  cBGSpecies(cBGSpeciesManager* mgr, int in_id, cBioUnit* founder, int update, tArray<cBioGroup*>* parents);
+  
+public:
+  ~cBGSpecies();
+  
+  // cBioGroup Interface Methods
+  int GetRoleID() const;
+  const cString& GetRole() const;  
+  int GetID() const { return m_id; }
+  
+  cBioGroup* ClassifyNewBioUnit(cBioUnit* bu, tArray<cBioGroup*>* parents = NULL);
+  void HandleBioUnitGestation(cBioUnit* bu);
+  void RemoveBioUnit(cBioUnit* bu);
+  
+  int GetDepth() const { return m_depth; }
+  
+  void Save(cDataFile& df);
+  
+  
+};
+
+#endif

Added: branches/biounit/source/classification/cBGSpeciesManager.cc
===================================================================
--- branches/biounit/source/classification/cBGSpeciesManager.cc	                        (rev 0)
+++ branches/biounit/source/classification/cBGSpeciesManager.cc	2009-12-22 21:38:35 UTC (rev 3575)
@@ -0,0 +1,26 @@
+/*
+ *  cBGSpeciesManager.cc
+ *  Avida
+ *
+ *  Created by David on 12/22/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 "cBGSpeciesManager.h"
+

Added: branches/biounit/source/classification/cBGSpeciesManager.h
===================================================================
--- branches/biounit/source/classification/cBGSpeciesManager.h	                        (rev 0)
+++ branches/biounit/source/classification/cBGSpeciesManager.h	2009-12-22 21:38:35 UTC (rev 3575)
@@ -0,0 +1,54 @@
+/*
+ *  cBGSpeciesManager.h
+ *  Avida
+ *
+ *  Created by David on 12/22/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 cBGSpeciesManager_h
+#define cBGSpeciesManager_h
+
+#ifndef defs_h
+#include "defs.h"
+#endif
+#ifndef cBioGroupManager_h
+#include "cBioGroupManager.h"
+#endif
+
+
+class cBGSpeciesManager: public cBioGroupManager
+{
+private:
+
+  
+  
+public:
+  cBGSpeciesManager();
+  ~cBGSpeciesManager();
+  
+  // cBioGroupManager Interface Methods
+  cBioGroup* ClassifyNewBioUnit(cBioUnit* bu);
+  
+  void UpdateReset();
+  
+  void SaveBioGroups(cDataFile& df);
+};
+
+#endif

Modified: branches/biounit/source/classification/cBioUnit.cc
===================================================================
--- branches/biounit/source/classification/cBioUnit.cc	2009-12-22 16:56:54 UTC (rev 3574)
+++ branches/biounit/source/classification/cBioUnit.cc	2009-12-22 21:38:35 UTC (rev 3575)
@@ -27,7 +27,7 @@
 #include "cBioGroup.h"
 #include "cString.h"
 #include "tArrayMap.h"
-#include "tArraySet.h"
+#include "tArrayUtils.h"
 
 
 cBioUnit::~cBioUnit()
@@ -60,7 +60,6 @@
     }
   } else {
     // Handle Sexual Organisms (multi-parent)
-    tArraySet<int> group_roles;
     tArrayMap<int, tArray<cBioGroup*> > parent_groups;
     
     // Sort groups into sets of parental groups by role_id
@@ -68,10 +67,15 @@
       for (int g = 0; g < parents[p]->GetSize(); g++) {
         cBioGroup* group = (*parents[p])[g];
         parent_groups[group->GetRoleID()].Push(group);
-        group_roles.Add(group->GetRoleID());
       }
     }
-     
+    
+    // Get the distinct set of group roles
+    tArray<int> group_roles = parent_groups.GetKeys();
+    
+    // Handle group dependencies - right now this simply means ordered by role id
+    tArrayUtils::QSort(group_roles);
+    
     // Classify this bio unit with all distinct parental group roles
     for (int r = 0; r < group_roles.GetSize(); r++) {
       tArray<cBioGroup*>& pgrps = parent_groups[r];

Modified: branches/biounit/source/classification/cClassificationManager.cc
===================================================================
--- branches/biounit/source/classification/cClassificationManager.cc	2009-12-22 16:56:54 UTC (rev 3574)
+++ branches/biounit/source/classification/cClassificationManager.cc	2009-12-22 21:38:35 UTC (rev 3575)
@@ -68,11 +68,14 @@
   delete m_species_ctl;
 }
 
-bool cClassificationManager::RegisterBioGroupManager(cBioGroupManager* bgm, const cString& role)
+bool cClassificationManager::RegisterBioGroupManager(cBioGroupManager* bgm, const cString& role,
+                                                     const tArray<cString>* dependencies)
 {
   // @TODO - verify that this role is not already in use -- maybe hash managers by role
   bgm->SetRole(m_bgms.Push(bgm), role);
   
+  // @TODO - properly handle bio group dependencies
+  
   return true;
 }
 

Modified: branches/biounit/source/classification/cClassificationManager.h
===================================================================
--- branches/biounit/source/classification/cClassificationManager.h	2009-12-22 16:56:54 UTC (rev 3574)
+++ branches/biounit/source/classification/cClassificationManager.h	2009-12-22 21:38:35 UTC (rev 3575)
@@ -98,7 +98,7 @@
 
   void UpdateReset();
   
-  bool RegisterBioGroupManager(cBioGroupManager* bgm, const cString& role);
+  bool RegisterBioGroupManager(cBioGroupManager* bgm, const cString& role, const tArray<cString>* dependencies = NULL);
   
   void ClassifyNewBioUnit(cBioUnit* bu);
 

Modified: branches/biounit/source/tools/tArrayMap.h
===================================================================
--- branches/biounit/source/tools/tArrayMap.h	2009-12-22 16:56:54 UTC (rev 3574)
+++ branches/biounit/source/tools/tArrayMap.h	2009-12-22 21:38:35 UTC (rev 3575)
@@ -97,6 +97,12 @@
   ValueType& operator[](const KeyType& key) { return ValueFor(key); }
   const ValueType& operator[](const KeyType& key) const { return ValueFor(key); }
   
+  tArray<KeyType> GetKeys() const
+  {
+    tArray<KeyType> keys(m_map.GetSize());
+    for (int i = 0; i < m_map.GetSize(); i++) keys[i] = m_map[i].Key();
+    return keys;
+  }  
   
   void Remove(const KeyType& key)
   {




More information about the Avida-cvs mailing list