[Avida-SVN] r3107 - in development: . Avida.xcodeproj source/analyze source/main source/tools

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Sun Jan 11 14:26:23 PST 2009


Author: brysonda
Date: 2009-01-11 17:26:23 -0500 (Sun, 11 Jan 2009)
New Revision: 3107

Added:
   development/source/analyze/cModularityAnalysis.cc
   development/source/analyze/cModularityAnalysis.h
Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/CMakeLists.txt
   development/source/analyze/cAnalyzeGenotype.cc
   development/source/analyze/cAnalyzeGenotype.h
   development/source/main/avida.cc
   development/source/tools/tDataEntry.h
Log:
Add stub for cModularityAnalysis.  Implement support for proxy tDataEntry instances that will allow external methods to manipulate the data entry target for data retrieval.  This should facilitate the use of external analysis classes on cAnalyzeGenotype objects, whereby the results are stored within cAnalyzeGenotype.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2009-01-11 20:53:58 UTC (rev 3106)
+++ development/Avida.xcodeproj/project.pbxproj	2009-01-11 22:26:23 UTC (rev 3107)
@@ -32,6 +32,8 @@
 		5629D81C0C3EE26A00C5F152 /* cCoreView_Info.cc in Sources */ = {isa = PBXBuildFile; fileRef = 565121C60C3B055F009CBD3F /* cCoreView_Info.cc */; };
 		56F555E50C3B402A00E2E929 /* cDriver_TextViewer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 56F555DF0C3B402A00E2E929 /* cDriver_TextViewer.cc */; };
 		56F555E70C3B402A00E2E929 /* viewer-text.cc in Sources */ = {isa = PBXBuildFile; fileRef = 56F555E40C3B402A00E2E929 /* viewer-text.cc */; };
+		700D9C460F1A8F34002CC711 /* cModularityAnalysis.h in Headers */ = {isa = PBXBuildFile; fileRef = 700D9C440F1A8F34002CC711 /* cModularityAnalysis.h */; };
+		700D9C470F1A8F34002CC711 /* cModularityAnalysis.cc in Sources */ = {isa = PBXBuildFile; fileRef = 700D9C450F1A8F34002CC711 /* cModularityAnalysis.cc */; };
 		700E2996085A1F6000CF158A /* avida in CopyFiles */ = {isa = PBXBuildFile; fileRef = DCC3164D07626CF3008F7A48 /* avida */; };
 		700E2B87085DE54400CF158A /* avida-viewer in CopyFiles */ = {isa = PBXBuildFile; fileRef = 700E2B83085DE50C00CF158A /* avida-viewer */; };
 		70211A5D0ECBD531004A293A /* cRCObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 70211A5B0ECBD531004A293A /* cRCObject.h */; };
@@ -397,6 +399,8 @@
 		700D9BD90F1A5D33002CC711 /* tAnalyzeJobBatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tAnalyzeJobBatch.h; sourceTree = "<group>"; };
 		700D9C170F1A7436002CC711 /* tArrayMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tArrayMap.h; sourceTree = "<group>"; };
 		700D9C1A0F1A77EC002CC711 /* tKVPair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tKVPair.h; sourceTree = "<group>"; };
+		700D9C440F1A8F34002CC711 /* cModularityAnalysis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cModularityAnalysis.h; sourceTree = "<group>"; };
+		700D9C450F1A8F34002CC711 /* cModularityAnalysis.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cModularityAnalysis.cc; sourceTree = "<group>"; };
 		700E28CF0859FFD700CF158A /* tObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tObjectFactory.h; sourceTree = "<group>"; };
 		700E2B83085DE50C00CF158A /* avida-viewer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "avida-viewer"; sourceTree = BUILT_PRODUCTS_DIR; };
 		7013845F09028B3E0087ED2E /* cAvidaConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cAvidaConfig.h; sourceTree = "<group>"; };
@@ -1051,6 +1055,8 @@
 				70AD4F990F194D2400AA50AC /* cGenotypeData.h */,
 				70AD4F9E0F194DD400AA50AC /* cGenotypeData.cc */,
 				700D9BD90F1A5D33002CC711 /* tAnalyzeJobBatch.h */,
+				700D9C440F1A8F34002CC711 /* cModularityAnalysis.h */,
+				700D9C450F1A8F34002CC711 /* cModularityAnalysis.cc */,
 			);
 			path = analyze;
 			sourceTree = "<group>";
@@ -1735,6 +1741,7 @@
 				709A1EEB0EB6C42D006090AF /* cOrgMovementPredicate.h in Headers */,
 				70211A5D0ECBD531004A293A /* cRCObject.h in Headers */,
 				70310E6B0EDD09260044971B /* cStateGrid.h in Headers */,
+				700D9C460F1A8F34002CC711 /* cModularityAnalysis.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2092,6 +2099,7 @@
 				70211A5E0ECBD531004A293A /* cRCObject.cc in Sources */,
 				D7FB16D60ED62684002E939E /* cOrgMessage.cc in Sources */,
 				70AD4FA00F194F4D00AA50AC /* cGenotypeData.cc in Sources */,
+				700D9C470F1A8F34002CC711 /* cModularityAnalysis.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: development/CMakeLists.txt
===================================================================
--- development/CMakeLists.txt	2009-01-11 20:53:58 UTC (rev 3106)
+++ development/CMakeLists.txt	2009-01-11 22:26:23 UTC (rev 3107)
@@ -134,6 +134,7 @@
   ${ANALYZE_DIR}/cAnalyzeJobWorker.cc
   ${ANALYZE_DIR}/cGenotypeBatch.cc
   ${ANALYZE_DIR}/cGenotypeData.cc
+  ${ANALYZE_DIR}/cModularityAnalysis.cc
   ${ANALYZE_DIR}/cMutationalNeighborhood.cc
 )
 SOURCE_GROUP(analyze FILES ${ANALYZE_SOURCES})

Modified: development/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- development/source/analyze/cAnalyzeGenotype.cc	2009-01-11 20:53:58 UTC (rev 3106)
+++ development/source/analyze/cAnalyzeGenotype.cc	2009-01-11 22:26:23 UTC (rev 3107)
@@ -334,7 +334,7 @@
 #undef ADD_GDATA
 }
 
-const tDataCommandManager<cAnalyzeGenotype>& cAnalyzeGenotype::GetDataCommandManager()
+tDataCommandManager<cAnalyzeGenotype>& cAnalyzeGenotype::GetDataCommandManager()
 {
   return tDMSingleton<tDataCommandManager<cAnalyzeGenotype> >::GetInstance();
 }

Modified: development/source/analyze/cAnalyzeGenotype.h
===================================================================
--- development/source/analyze/cAnalyzeGenotype.h	2009-01-11 20:53:58 UTC (rev 3106)
+++ development/source/analyze/cAnalyzeGenotype.h	2009-01-11 22:26:23 UTC (rev 3107)
@@ -254,7 +254,7 @@
   ~cAnalyzeGenotype();
   
   static void Initialize();
-  static const tDataCommandManager<cAnalyzeGenotype>& GetDataCommandManager();
+  static tDataCommandManager<cAnalyzeGenotype>& GetDataCommandManager();
 
   void Recalculate(cAvidaContext& ctx, cCPUTestInfo* test_info = NULL, cAnalyzeGenotype* parent_genotype = NULL, int num_trials = 1);
   void PrintTasks(std::ofstream& fp, int min_task = 0, int max_task = -1);

Added: development/source/analyze/cModularityAnalysis.cc
===================================================================
--- development/source/analyze/cModularityAnalysis.cc	                        (rev 0)
+++ development/source/analyze/cModularityAnalysis.cc	2009-01-11 22:26:23 UTC (rev 3107)
@@ -0,0 +1,47 @@
+/*
+ *  cModularityAnalysis.cc
+ *  Avida
+ *
+ *  Created by David on 1/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 "cModularityAnalysis.h"
+
+#include "cAnalyzeGenotype.h"
+#include "tDataCommandManager.h"
+#include "tDataEntry.h"
+
+
+void cModularityAnalysis::Initialize()
+{
+//  tDataCommandManager<cAnalyzeGenotype>& dcm = cAnalyzeGenotype::GetDataCommandManager();
+  
+}
+
+void cModularityAnalysis::CalcFunctionalModularity(cAvidaContext& ctx)
+{
+  
+}
+
+
+cModularityAnalysis::cModularityData::cModularityData()
+: tasks_done(0), insts_tasks(0), tasks_prop(0.0), ave_tasks_per_site(0.0), ave_sites_per_task(0.0), ave_prop_nonoverlap(0.0)
+{
+}

Added: development/source/analyze/cModularityAnalysis.h
===================================================================
--- development/source/analyze/cModularityAnalysis.h	                        (rev 0)
+++ development/source/analyze/cModularityAnalysis.h	2009-01-11 22:26:23 UTC (rev 3107)
@@ -0,0 +1,71 @@
+/*
+ *  cModularityAnalysis.h
+ *  Avida
+ *
+ *  Created by David on 1/11/09.
+ *  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 cModularityAnalysis_h
+#define cModularityAnalysis_h
+
+#ifndef cGenotypeData_h
+#include "cGenotypeData.h"
+#endif
+#ifndef tArray_h
+#include "tArray.h"
+#endif
+
+class cAvidaContext;
+class cAnalyzeGenotype;
+
+
+class cModularityAnalysis
+{
+private:
+  cAnalyzeGenotype* m_genotype;
+  
+public:
+  cModularityAnalysis(cAnalyzeGenotype* genotype) : m_genotype(genotype) { ; }
+  
+  static void Initialize();
+  
+  void CalcFunctionalModularity(cAvidaContext& ctx);
+  
+  
+private:
+  class cModularityData : public cGenotypeData
+  {
+  public:
+    int tasks_done;
+    int insts_tasks;
+    double tasks_prop;
+    double ave_tasks_per_site;
+    double ave_sites_per_task;
+    double ave_prop_nonoverlap;
+    tArray<double> ave_sites_per_task_indv;
+    tArray<double> std_sites_per_task_indv;
+    tArray<double> ave_sites_inv_per_task;
+    tArray<double> ave_task_length;
+    
+    cModularityData();
+  };
+};
+
+#endif

Modified: development/source/main/avida.cc
===================================================================
--- development/source/main/avida.cc	2009-01-11 20:53:58 UTC (rev 3106)
+++ development/source/main/avida.cc	2009-01-11 22:26:23 UTC (rev 3107)
@@ -29,6 +29,7 @@
 #include "cAnalyzeGenotype.h"
 #include "cAvidaConfig.h"
 #include "cDriverManager.h"
+#include "cModularityAnalysis.h"
 #include "cString.h"
 #include "cStringIterator.h"
 #include "tDictionary.h"
@@ -52,6 +53,7 @@
 {
   cActionLibrary::Initialize();
   cAnalyzeGenotype::Initialize();
+  cModularityAnalysis::Initialize();
 }
   
   

Modified: development/source/tools/tDataEntry.h
===================================================================
--- development/source/tools/tDataEntry.h	2009-01-11 20:53:58 UTC (rev 3106)
+++ development/source/tools/tDataEntry.h	2009-01-11 22:26:23 UTC (rev 3107)
@@ -156,4 +156,78 @@
 };
 
 
+template <class TargetType, class IdxType> class tDataEntryProxy;
+
+template <class TargetType>
+class tDataEntryProxy<TargetType, cFlexVar ()> : public tDataEntry<TargetType>
+{
+protected:
+  cFlexVar (*DataRetrieval)(TargetType*);
+  
+public:
+  tDataEntryProxy(const cString& name,
+                  cFlexVar (*_funR)(TargetType*),
+                  int compare_type = 0, const cString& null = "0", const cString& html_cell = "align=center")
+  : tDataEntry<TargetType>(name, name, compare_type, null, html_cell), DataRetrieval(_funR) { ; }
+  
+  cFlexVar Get(const TargetType* target, const cFlexVar& idx, const cStringList& args) const
+  {
+    assert(target != NULL);
+    return (*DataRetrieval)(target);
+  }
+};
+
+template <class TargetType, class IdxType>
+class tDataEntryProxy<TargetType, cFlexVar (IdxType)> : public tDataEntry<TargetType>
+{
+protected:
+  cFlexVar (*DataRetrieval)(TargetType*, IdxType);
+  cString (*DescFunction)(TargetType*, IdxType);
+  
+public:
+  tDataEntryProxy(const cString& name,
+                  cString (*_funD)(TargetType*, IdxType),
+                  cFlexVar (*_funR)(TargetType*, IdxType),
+                  int compare_type = 0, const cString& null = "0", const cString& html_cell = "align=center")
+  : tDataEntry<TargetType>(name, name, compare_type, null, html_cell), DataRetrieval(_funR), DescFunction(_funD) { ; }
+  
+  cString GetDesc(const TargetType* target, const cFlexVar& idx) const
+  {
+    return (*DescFunction)(target, idx.As<IdxType>());
+  }
+  
+  cFlexVar Get(const TargetType* target, const cFlexVar& idx, const cStringList& args) const
+  {
+    assert(target != NULL);
+    return (*DataRetrieval)(target, idx.As<IdxType>());
+  }
+};
+
+template <class TargetType, class IdxType>
+class tDataEntryProxy<TargetType, cFlexVar (IdxType, const cStringList&)> : public tDataEntry<TargetType>
+{
+protected:
+  cFlexVar (*DataRetrieval)(TargetType*, IdxType, const cStringList&);
+  cString (*DescFunction)(TargetType*, IdxType);
+  
+public:
+  tDataEntryProxy(const cString& name,
+                  cString (*_funD)(TargetType*, IdxType),
+                  cFlexVar (*_funR)(TargetType*, IdxType, const cStringList&),
+                  int compare_type = 0, const cString& null = "0", const cString& html_cell = "align=center")
+  : tDataEntry<TargetType>(name, name, compare_type, null, html_cell), DataRetrieval(_funR), DescFunction(_funD) { ; }
+  
+  cString GetDesc(const TargetType* target, const cFlexVar& idx) const
+  {
+    return (*DescFunction)(target, idx.As<IdxType>());
+  }
+  
+  cFlexVar Get(const TargetType* target, const cFlexVar& idx, const cStringList& args) const
+  {
+    assert(target != NULL);
+    return (*DataRetrieval)(target, idx.As<IdxType>(), args);
+  }
+};
+
+
 #endif




More information about the Avida-cvs mailing list