[Avida-cvs] [Avida2-svn] r369 - in branches/brysonda: Avida2.xcodeproj source source/analyze source/main

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Thu Nov 3 20:19:25 PST 2005


Author: brysonda
Date: 2005-11-03 22:50:46 -0500 (Thu, 03 Nov 2005)
New Revision: 369

Added:
   branches/brysonda/source/analyze/
   branches/brysonda/source/analyze/cAnalyze.cc
   branches/brysonda/source/analyze/cAnalyze.h
   branches/brysonda/source/analyze/cAnalyzeCommand.h
   branches/brysonda/source/analyze/cAnalyzeCommandDef.h
   branches/brysonda/source/analyze/cAnalyzeCommandDefBase.h
   branches/brysonda/source/analyze/cAnalyzeFlowCommand.h
   branches/brysonda/source/analyze/cAnalyzeFlowCommandDef.h
   branches/brysonda/source/analyze/cAnalyzeFunction.h
   branches/brysonda/source/analyze/cAnalyzeGenotype.cc
   branches/brysonda/source/analyze/cAnalyzeGenotype.h
   branches/brysonda/source/analyze/cAnalyzeUtil.cc
   branches/brysonda/source/analyze/cAnalyzeUtil.h
Removed:
   branches/brysonda/source/main/cAnalyze.cc
   branches/brysonda/source/main/cAnalyze.h
   branches/brysonda/source/main/cAnalyzeCommand.h
   branches/brysonda/source/main/cAnalyzeCommandDef.h
   branches/brysonda/source/main/cAnalyzeCommandDefBase.h
   branches/brysonda/source/main/cAnalyzeFlowCommand.h
   branches/brysonda/source/main/cAnalyzeFlowCommandDef.h
   branches/brysonda/source/main/cAnalyzeFunction.h
   branches/brysonda/source/main/cAnalyzeGenotype.cc
   branches/brysonda/source/main/cAnalyzeGenotype.h
   branches/brysonda/source/main/cAnalyzeUtil.cc
   branches/brysonda/source/main/cAnalyzeUtil.h
Modified:
   branches/brysonda/Avida2.xcodeproj/project.pbxproj
Log:
Move cAnalyze* into source/analyze/

Modified: branches/brysonda/Avida2.xcodeproj/project.pbxproj
===================================================================
--- branches/brysonda/Avida2.xcodeproj/project.pbxproj	2005-11-04 00:39:30 UTC (rev 368)
+++ branches/brysonda/Avida2.xcodeproj/project.pbxproj	2005-11-04 03:50:46 UTC (rev 369)
@@ -42,18 +42,18 @@
 		702D4F0608DA5341007BA469 /* cEnvironment.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4EFC08DA5341007BA469 /* cEnvironment.cc */; };
 		702D4F0708DA5341007BA469 /* cPopulationInterface.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4EFD08DA5341007BA469 /* cPopulationInterface.cc */; };
 		702D4F4508DA61FE007BA469 /* cBirthChamber.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4F3F08DA61FE007BA469 /* cBirthChamber.cc */; };
-		702D4F4808DA61FE007BA469 /* cAnalyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4F3C08DA61FE007BA469 /* cAnalyze.cc */; };
-		702D4F4908DA61FE007BA469 /* cAnalyzeGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4F3D08DA61FE007BA469 /* cAnalyzeGenotype.cc */; };
-		702D4F4A08DA61FE007BA469 /* cAnalyzeUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4F3E08DA61FE007BA469 /* cAnalyzeUtil.cc */; };
 		702D4F4B08DA61FE007BA469 /* cBirthChamber.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4F3F08DA61FE007BA469 /* cBirthChamber.cc */; };
 		7040CF1C0906A52E00AA820F /* cEventManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7040CF1A0906A52E00AA820F /* cEventManager.cc */; };
 		7040CF1E0906A52E00AA820F /* cEventManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7040CF1A0906A52E00AA820F /* cEventManager.cc */; };
 		7040CF1F0906A52E00AA820F /* cEventManager.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7040CF1B0906A52E00AA820F /* cEventManager.h */; };
-		7040D22509071EE000AA820F /* cAnalyzeUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4F3E08DA61FE007BA469 /* cAnalyzeUtil.cc */; };
-		7040D36C09095E4E00AA820F /* cAnalyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4F3C08DA61FE007BA469 /* cAnalyze.cc */; };
-		7040D36D09095E5200AA820F /* cAnalyzeGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4F3D08DA61FE007BA469 /* cAnalyzeGenotype.cc */; };
 		7040D36E09095E5900AA820F /* cAvidaDriver_Analyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702D4EF908DA5341007BA469 /* cAvidaDriver_Analyze.cc */; };
 		7040D3A6090964D100AA820F /* cMxCodeArray.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865808F4974300FC65FE /* cMxCodeArray.cc */; };
+		70422A28091B141000A5E67F /* cAnalyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A1C091B141000A5E67F /* cAnalyze.cc */; };
+		70422A30091B141000A5E67F /* cAnalyzeGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A24091B141000A5E67F /* cAnalyzeGenotype.cc */; };
+		70422A32091B141000A5E67F /* cAnalyzeUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A26091B141000A5E67F /* cAnalyzeUtil.cc */; };
+		70422A34091B141000A5E67F /* cAnalyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A1C091B141000A5E67F /* cAnalyze.cc */; };
+		70422A3C091B141000A5E67F /* cAnalyzeGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A24091B141000A5E67F /* cAnalyzeGenotype.cc */; };
+		70422A3E091B141000A5E67F /* cAnalyzeUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A26091B141000A5E67F /* cAnalyzeUtil.cc */; };
 		704866D3090B51310048600A /* cAvidaDriver_TextPopViewer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 704866B3090B51310048600A /* cAvidaDriver_TextPopViewer.cc */; };
 		704866D5090B51310048600A /* cBarScreen.cc in Sources */ = {isa = PBXBuildFile; fileRef = 704866B5090B51310048600A /* cBarScreen.cc */; };
 		704866D8090B51310048600A /* cEnvironmentScreen.cc in Sources */ = {isa = PBXBuildFile; fileRef = 704866B8090B51310048600A /* cEnvironmentScreen.cc */; };
@@ -390,24 +390,24 @@
 		702D4EFB08DA5341007BA469 /* cAvidaDriver_Population.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAvidaDriver_Population.cc; sourceTree = "<group>"; };
 		702D4EFC08DA5341007BA469 /* cEnvironment.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cEnvironment.cc; sourceTree = "<group>"; };
 		702D4EFD08DA5341007BA469 /* cPopulationInterface.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cPopulationInterface.cc; sourceTree = "<group>"; };
-		702D4F2F08DA61E2007BA469 /* cAnalyze.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyze.h; sourceTree = "<group>"; };
-		702D4F3008DA61E2007BA469 /* cAnalyzeCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeCommand.h; sourceTree = "<group>"; };
-		702D4F3108DA61E2007BA469 /* cAnalyzeCommandDef.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeCommandDef.h; sourceTree = "<group>"; };
-		702D4F3208DA61E2007BA469 /* cAnalyzeCommandDefBase.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeCommandDefBase.h; sourceTree = "<group>"; };
-		702D4F3308DA61E2007BA469 /* cAnalyzeFlowCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeFlowCommand.h; sourceTree = "<group>"; };
-		702D4F3408DA61E2007BA469 /* cAnalyzeFlowCommandDef.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeFlowCommandDef.h; sourceTree = "<group>"; };
-		702D4F3508DA61E2007BA469 /* cAnalyzeFunction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeFunction.h; sourceTree = "<group>"; };
-		702D4F3608DA61E2007BA469 /* cAnalyzeGenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeGenotype.h; sourceTree = "<group>"; };
-		702D4F3708DA61E2007BA469 /* cAnalyzeUtil.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeUtil.h; sourceTree = "<group>"; };
 		702D4F3808DA61E2007BA469 /* cAvidaTriggers.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAvidaTriggers.h; sourceTree = "<group>"; };
 		702D4F3908DA61E2007BA469 /* cBirthChamber.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cBirthChamber.h; sourceTree = "<group>"; };
-		702D4F3C08DA61FE007BA469 /* cAnalyze.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyze.cc; sourceTree = "<group>"; };
-		702D4F3D08DA61FE007BA469 /* cAnalyzeGenotype.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyzeGenotype.cc; sourceTree = "<group>"; };
-		702D4F3E08DA61FE007BA469 /* cAnalyzeUtil.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyzeUtil.cc; sourceTree = "<group>"; };
 		702D4F3F08DA61FE007BA469 /* cBirthChamber.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cBirthChamber.cc; sourceTree = "<group>"; };
 		703F684207B437B800C1CA76 /* status.xml */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = status.xml; sourceTree = "<group>"; };
 		7040CF1A0906A52E00AA820F /* cEventManager.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cEventManager.cc; sourceTree = "<group>"; };
 		7040CF1B0906A52E00AA820F /* cEventManager.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cEventManager.h; sourceTree = "<group>"; };
+		70422A1C091B141000A5E67F /* cAnalyze.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyze.cc; sourceTree = "<group>"; };
+		70422A1D091B141000A5E67F /* cAnalyze.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyze.h; sourceTree = "<group>"; };
+		70422A1E091B141000A5E67F /* cAnalyzeCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeCommand.h; sourceTree = "<group>"; };
+		70422A1F091B141000A5E67F /* cAnalyzeCommandDef.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeCommandDef.h; sourceTree = "<group>"; };
+		70422A20091B141000A5E67F /* cAnalyzeCommandDefBase.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeCommandDefBase.h; sourceTree = "<group>"; };
+		70422A21091B141000A5E67F /* cAnalyzeFlowCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeFlowCommand.h; sourceTree = "<group>"; };
+		70422A22091B141000A5E67F /* cAnalyzeFlowCommandDef.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeFlowCommandDef.h; sourceTree = "<group>"; };
+		70422A23091B141000A5E67F /* cAnalyzeFunction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeFunction.h; sourceTree = "<group>"; };
+		70422A24091B141000A5E67F /* cAnalyzeGenotype.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyzeGenotype.cc; sourceTree = "<group>"; };
+		70422A25091B141000A5E67F /* cAnalyzeGenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeGenotype.h; sourceTree = "<group>"; };
+		70422A26091B141000A5E67F /* cAnalyzeUtil.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyzeUtil.cc; sourceTree = "<group>"; };
+		70422A27091B141000A5E67F /* cAnalyzeUtil.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeUtil.h; sourceTree = "<group>"; };
 		704866B3090B51310048600A /* cAvidaDriver_TextPopViewer.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAvidaDriver_TextPopViewer.cc; sourceTree = "<group>"; };
 		704866B4090B51310048600A /* cAvidaDriver_TextPopViewer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAvidaDriver_TextPopViewer.h; sourceTree = "<group>"; };
 		704866B5090B51310048600A /* cBarScreen.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cBarScreen.cc; sourceTree = "<group>"; };
@@ -1035,6 +1035,25 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		70422A1B091B141000A5E67F /* analyze */ = {
+			isa = PBXGroup;
+			children = (
+				70422A1C091B141000A5E67F /* cAnalyze.cc */,
+				70422A1D091B141000A5E67F /* cAnalyze.h */,
+				70422A1E091B141000A5E67F /* cAnalyzeCommand.h */,
+				70422A1F091B141000A5E67F /* cAnalyzeCommandDef.h */,
+				70422A20091B141000A5E67F /* cAnalyzeCommandDefBase.h */,
+				70422A21091B141000A5E67F /* cAnalyzeFlowCommand.h */,
+				70422A22091B141000A5E67F /* cAnalyzeFlowCommandDef.h */,
+				70422A23091B141000A5E67F /* cAnalyzeFunction.h */,
+				70422A24091B141000A5E67F /* cAnalyzeGenotype.cc */,
+				70422A25091B141000A5E67F /* cAnalyzeGenotype.h */,
+				70422A26091B141000A5E67F /* cAnalyzeUtil.cc */,
+				70422A27091B141000A5E67F /* cAnalyzeUtil.h */,
+			);
+			path = analyze;
+			sourceTree = "<group>";
+		};
 		704866B2090B51310048600A /* viewer */ = {
 			isa = PBXGroup;
 			children = (
@@ -1088,6 +1107,7 @@
 		DCC30C670762539A008F7A48 /* Source */ = {
 			isa = PBXGroup;
 			children = (
+				70422A1B091B141000A5E67F /* analyze */,
 				DCC30F7C0762539D008F7A48 /* cpu */,
 				DCC30FD00762539D008F7A48 /* event */,
 				DCC310040762539D008F7A48 /* main */,
@@ -1184,18 +1204,6 @@
 			children = (
 				DCC3109C0762539E008F7A48 /* avida.cc */,
 				70B086BE08F5D86100FC65FE /* avida.h */,
-				702D4F3C08DA61FE007BA469 /* cAnalyze.cc */,
-				702D4F2F08DA61E2007BA469 /* cAnalyze.h */,
-				702D4F3008DA61E2007BA469 /* cAnalyzeCommand.h */,
-				702D4F3108DA61E2007BA469 /* cAnalyzeCommandDef.h */,
-				702D4F3208DA61E2007BA469 /* cAnalyzeCommandDefBase.h */,
-				702D4F3308DA61E2007BA469 /* cAnalyzeFlowCommand.h */,
-				702D4F3408DA61E2007BA469 /* cAnalyzeFlowCommandDef.h */,
-				702D4F3508DA61E2007BA469 /* cAnalyzeFunction.h */,
-				702D4F3D08DA61FE007BA469 /* cAnalyzeGenotype.cc */,
-				702D4F3608DA61E2007BA469 /* cAnalyzeGenotype.h */,
-				702D4F3E08DA61FE007BA469 /* cAnalyzeUtil.cc */,
-				702D4F3708DA61E2007BA469 /* cAnalyzeUtil.h */,
 				7013846009028B3E0087ED2E /* cAvidaConfig.cc */,
 				7013845F09028B3E0087ED2E /* cAvidaConfig.h */,
 				702D4EF908DA5341007BA469 /* cAvidaDriver_Analyze.cc */,
@@ -2111,9 +2119,6 @@
 				702D4F0508DA5341007BA469 /* cAvidaDriver_Population.cc in Sources */,
 				702D4F0608DA5341007BA469 /* cEnvironment.cc in Sources */,
 				702D4F0708DA5341007BA469 /* cPopulationInterface.cc in Sources */,
-				702D4F4808DA61FE007BA469 /* cAnalyze.cc in Sources */,
-				702D4F4908DA61FE007BA469 /* cAnalyzeGenotype.cc in Sources */,
-				702D4F4A08DA61FE007BA469 /* cAnalyzeUtil.cc in Sources */,
 				702D4F4B08DA61FE007BA469 /* cBirthChamber.cc in Sources */,
 				70CA6ED208DB7F8200068AC2 /* cFitnessMatrix.cc in Sources */,
 				70CA6ED308DB7F8200068AC2 /* cGenebank.cc in Sources */,
@@ -2209,6 +2214,9 @@
 				704866ED090B51310048600A /* cViewInfo.cc in Sources */,
 				704866EF090B51310048600A /* cZoomScreen.cc in Sources */,
 				704866F2090B51310048600A /* viewer.cc in Sources */,
+				70422A28091B141000A5E67F /* cAnalyze.cc in Sources */,
+				70422A30091B141000A5E67F /* cAnalyzeGenotype.cc in Sources */,
+				70422A32091B141000A5E67F /* cAnalyzeUtil.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2322,11 +2330,11 @@
 				70C5BC6509059A970028A785 /* cWorld.cc in Sources */,
 				70C5BD6B0905CE5F0028A785 /* cHardwareManager.cc in Sources */,
 				7040CF1C0906A52E00AA820F /* cEventManager.cc in Sources */,
-				7040D22509071EE000AA820F /* cAnalyzeUtil.cc in Sources */,
-				7040D36C09095E4E00AA820F /* cAnalyze.cc in Sources */,
-				7040D36D09095E5200AA820F /* cAnalyzeGenotype.cc in Sources */,
 				7040D36E09095E5900AA820F /* cAvidaDriver_Analyze.cc in Sources */,
 				7040D3A6090964D100AA820F /* cMxCodeArray.cc in Sources */,
+				70422A34091B141000A5E67F /* cAnalyze.cc in Sources */,
+				70422A3C091B141000A5E67F /* cAnalyzeGenotype.cc in Sources */,
+				70422A3E091B141000A5E67F /* cAnalyzeUtil.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Copied: branches/brysonda/source/analyze/cAnalyze.cc (from rev 368, branches/brysonda/source/main/cAnalyze.cc)

Copied: branches/brysonda/source/analyze/cAnalyze.h (from rev 368, branches/brysonda/source/main/cAnalyze.h)

Copied: branches/brysonda/source/analyze/cAnalyzeCommand.h (from rev 367, branches/brysonda/source/main/cAnalyzeCommand.h)

Copied: branches/brysonda/source/analyze/cAnalyzeCommandDef.h (from rev 367, branches/brysonda/source/main/cAnalyzeCommandDef.h)

Copied: branches/brysonda/source/analyze/cAnalyzeCommandDefBase.h (from rev 367, branches/brysonda/source/main/cAnalyzeCommandDefBase.h)

Copied: branches/brysonda/source/analyze/cAnalyzeFlowCommand.h (from rev 367, branches/brysonda/source/main/cAnalyzeFlowCommand.h)

Copied: branches/brysonda/source/analyze/cAnalyzeFlowCommandDef.h (from rev 367, branches/brysonda/source/main/cAnalyzeFlowCommandDef.h)

Copied: branches/brysonda/source/analyze/cAnalyzeFunction.h (from rev 367, branches/brysonda/source/main/cAnalyzeFunction.h)

Copied: branches/brysonda/source/analyze/cAnalyzeGenotype.cc (from rev 368, branches/brysonda/source/main/cAnalyzeGenotype.cc)

Copied: branches/brysonda/source/analyze/cAnalyzeGenotype.h (from rev 368, branches/brysonda/source/main/cAnalyzeGenotype.h)

Copied: branches/brysonda/source/analyze/cAnalyzeUtil.cc (from rev 367, branches/brysonda/source/main/cAnalyzeUtil.cc)

Copied: branches/brysonda/source/analyze/cAnalyzeUtil.h (from rev 367, branches/brysonda/source/main/cAnalyzeUtil.h)

Deleted: branches/brysonda/source/main/cAnalyze.cc
===================================================================
--- branches/brysonda/source/main/cAnalyze.cc	2005-11-04 00:39:30 UTC (rev 368)
+++ branches/brysonda/source/main/cAnalyze.cc	2005-11-04 03:50:46 UTC (rev 369)
@@ -1,7380 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
-
-#include <fstream>
-#include <sstream>
-#include <string>
-#include <queue>
-#include <stack>
-
-#include "cAnalyze.h"
-
-#include "cAnalyzeCommand.h"
-#include "cAnalyzeCommandDef.h"
-#include "cAnalyzeCommandDefBase.h"
-#include "cAnalyzeFlowCommand.h"
-#include "cAnalyzeFlowCommandDef.h"
-#include "cAnalyzeFunction.h"
-#include "cAnalyzeGenotype.h"
-#include "cDataFile.h"
-#include "cEnvironment.h"
-#include "cFitnessMatrix.h"
-#include "cGenomeUtil.h"
-#include "cHardwareBase.h"
-#include "cHardwareManager.h"
-#include "cHardwareStatusPrinter.h"
-#include "cHelpManager.h"
-#include "cInitFile.h"
-#include "cInstSet.h"
-#include "cInstUtil.h"
-#include "cLandscape.h"
-#include "cPhenotype.h"
-#include "cSpecies.h"
-#include "tArgDataEntry.h"
-#include "cTaskEntry.h"
-#include "tDataEntry.h"
-#include "tDataEntryCommand.h"
-#include "tMatrix.h"
-#include "cTestCPU.h"
-#include "cCPUTestInfo.h"
-#include "cTestUtil.h"
-#include "cResource.h"
-#include "tHashTable.h"
-#include "cWorld.h"
-#ifdef WIN32
-#  include "win32_mkdir_hack.hh"
-#endif
-
-extern "C" {
-#include <errno.h>
-#include <sys/stat.h>
-}
-
-using namespace std;
-
-//////////////
-//  cAnalyze
-//////////////
-
-cAnalyze::cAnalyze(cWorld* world)
-: cur_batch(0)
-, m_world(world)
-, inst_set(world->GetHardwareManager().GetInstSet())
-, verbose(false)
-, interactive_depth(0)
-{
-  
-  random.ResetSeed(m_world->GetConfig().RANDOM_SEED.Get());
-  
-  for (int i = 0; i < MAX_BATCHES; i++) {
-    batch[i].Name().Set("Batch%d", i);
-  }
-  
-  // Initialize the time oriented resource list to be just the initial
-  // concentrations of the resources in the environment.  This will only
-  // be changed if LOAD_RESOURCES analyze command is called.  If there is
-  // no resources in the environment or there is no environment, the list
-  // is empty and will cause an assert to be thrown in FindResource function.
-  const cResourceLib &resource_lib = m_world->GetEnvironment().GetResourceLib();
-  if(resource_lib.GetSize() > 0) {
-    vector<double> r;
-    for(int i=0; i<resource_lib.GetSize(); i++) {
-      cResource *resource = resource_lib.GetResource(i);
-      assert(resource);
-      r.push_back(resource->GetInitial());
-    }
-    resources.push_back(make_pair(0, r));
-  }
-  FillResources(0);
-  
-  cInitFile analyze_file(m_world->GetConfig().ANALYZE_FILE.Get());
-  analyze_file.Load();
-  analyze_file.Compress();
-  analyze_file.Close();
-  
-  LoadCommandList(analyze_file, command_list);
-  ProcessCommands(command_list);
-  
-  return;
-}
-
-cAnalyze::~cAnalyze()
-{
-  data_file_manager.FlushAll();
-  while (genotype_data_list.GetSize()) delete genotype_data_list.Pop();
-  while (command_list.GetSize()) delete command_list.Pop();
-  while (function_list.GetSize()) delete function_list.Pop();
-}
-
-
-//////////////// Loading methods...
-
-void cAnalyze::LoadOrganism(cString cur_string)
-{
-  // LOAD_ORGANISM command...
-  
-  cString filename = cur_string.PopWord();
-  
-  cout << "Loading: " << filename << endl;
-  
-  // Setup the genome...
-  cGenome genome( cInstUtil::LoadGenome(filename, inst_set) );
-  
-  // Construct the new genotype..
-  cAnalyzeGenotype * genotype = new cAnalyzeGenotype(m_world, genome, inst_set);
-  
-  // Determine the organism's original name -- strip off directory...
-  while (filename.Find('/') != -1) filename.Pop('/');
-  while (filename.Find('\\') != -1) filename.Pop('\\');
-  filename.Replace(".gen", "");  // Remove the .gen from the filename.
-  genotype->SetName(filename);
-  
-  // And save it in the current batch.
-  batch[cur_batch].List().PushRear(genotype);
-  
-  // Adjust the flags on this batch
-  batch[cur_batch].SetLineage(false);
-  batch[cur_batch].SetAligned(false);
-}
-
-void cAnalyze::LoadBasicDump(cString cur_string)
-{
-  // LOAD_BASE_DUMP
-  
-  cString filename = cur_string.PopWord();
-  
-  cout << "Loading: " << filename << endl;
-  
-  cInitFile input_file(filename);
-  if (!input_file.IsOpen()) {
-    cerr << "Error: Cannot load file: \"" << filename << "\"." << endl;
-    exit(1);
-  }
-  input_file.Load();
-  input_file.Compress();
-  input_file.Close();
-  
-  // Setup the genome...
-  
-  for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
-    cString cur_line = input_file.GetLine(line_id);
-    
-    // Setup the genotype for this line...
-    cAnalyzeGenotype * genotype = new cAnalyzeGenotype(m_world, cur_line.PopWord(), inst_set);
-    int num_cpus = cur_line.PopWord().AsInt();
-    int id_num = cur_line.PopWord().AsInt();
-    cString name = cStringUtil::Stringf("org-%d", id_num);
-    
-    genotype->SetNumCPUs(num_cpus);
-    genotype->SetID(id_num);
-    genotype->SetName(name);
-    
-    // Add this genotype to the proper batch.
-    batch[cur_batch].List().PushRear(genotype);
-  }
-  
-  // Adjust the flags on this batch
-  batch[cur_batch].SetLineage(false);
-  batch[cur_batch].SetAligned(false);
-}
-
-void cAnalyze::LoadDetailDump(cString cur_string)
-{
-  cout << "Warning: Use of LoadDetailDump() is deprecated.  Use \"LOAD\" instead." << endl;  
-  // LOAD_DETAIL_DUMP
-  
-  cString filename = cur_string.PopWord();
-  
-  cout << "Loading: " << filename << endl;
-  
-  cInitFile input_file(filename);
-  if (!input_file.IsOpen()) {
-    cerr << "Error: Cannot load file: \"" << filename << "\"." << endl;
-    exit(1);
-  }
-  input_file.Load();
-  input_file.Compress();
-  input_file.Close();
-  
-  // Setup the genome...
-  
-  for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
-    cString cur_line = input_file.GetLine(line_id);
-    
-    // Setup the genotype for this line...
-    
-    int id_num      = cur_line.PopWord().AsInt();
-    int parent_id   = cur_line.PopWord().AsInt();
-    int parent_dist = cur_line.PopWord().AsInt();
-    int num_cpus    = cur_line.PopWord().AsInt();
-    int total_cpus  = cur_line.PopWord().AsInt();
-    int length      = cur_line.PopWord().AsInt();
-    double merit    = cur_line.PopWord().AsDouble();
-    int gest_time   = cur_line.PopWord().AsInt();
-    double fitness  = cur_line.PopWord().AsDouble();
-    int update_born = cur_line.PopWord().AsInt();
-    int update_dead = cur_line.PopWord().AsInt();
-    int depth       = cur_line.PopWord().AsInt();
-    cString name = cStringUtil::Stringf("org-%d", id_num);
-    
-    cAnalyzeGenotype * genotype = new cAnalyzeGenotype(m_world, cur_line.PopWord(), inst_set);
-    
-    genotype->SetID(id_num);
-    genotype->SetParentID(parent_id);
-    genotype->SetParentDist(parent_dist);
-    genotype->SetNumCPUs(num_cpus);
-    genotype->SetTotalCPUs(total_cpus);
-    genotype->SetLength(length);
-    genotype->SetMerit(merit);
-    genotype->SetGestTime(gest_time);
-    genotype->SetFitness(fitness);
-    genotype->SetUpdateBorn(update_born);
-    genotype->SetUpdateDead(update_dead);
-    genotype->SetDepth(depth);
-    genotype->SetName(name);
-    
-    // Add this genotype to the proper batch.
-    batch[cur_batch].List().PushRear(genotype);
-  }
-  
-  // Adjust the flags on this batch
-  batch[cur_batch].SetLineage(false);
-  batch[cur_batch].SetAligned(false);
-}
-
-void cAnalyze::LoadMultiDetail(cString cur_string)
-{
-  // LOAD_MULTI_DETAIL
-  
-  int start_UD = cur_string.PopWord().AsInt();
-  int step_UD = cur_string.PopWord().AsInt();
-  int stop_UD = cur_string.PopWord().AsInt();
-  cString data_directory = PopDirectory(cur_string, "./");
-  cur_batch = cur_string.PopWord().AsInt();
-  
-  if (step_UD == 0) {
-    cerr << "Error: LOAD_MULTI_DETAIL must have a non-zero value for step."
-    << endl;
-    return;
-  }
-  
-  int num_steps = (stop_UD - start_UD) / step_UD + 1;
-  if (num_steps > 1000) {
-    cerr << "Warning: Loading over 1000 files in LOAD_MULTI_DETAIL!"
-    << endl;
-  }
-  
-  if (verbose == true) {
-    cout << "Loading in " << num_steps
-    << " detail files from update " << start_UD
-    << " to update " << stop_UD
-    << endl;
-  } else {
-    cout << "Running LOAD_MULTI_DETAIL" << endl;
-  }
-  
-  for (int cur_UD = start_UD; cur_UD <= stop_UD; cur_UD += step_UD) {
-    cString filename = cStringUtil::Stringf("detail_pop.%d", cur_UD);
-    
-    cout << "Loading '" << filename
-      << "' into batch " << cur_batch
-      << endl;
-    
-    cInitFile input_file(filename);
-    if (!input_file.IsOpen()) {
-      cerr << "Error: Cannot load file: \"" << filename << "\"." << endl;
-      exit(1);
-    }
-    input_file.Load();
-    input_file.Compress();
-    input_file.Close();
-    
-    // Setup the genome...
-    
-    for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
-      cString cur_line = input_file.GetLine(line_id);
-      
-      // Setup the genotype for this line...
-      
-      int id_num      = cur_line.PopWord().AsInt();
-      int parent_id   = cur_line.PopWord().AsInt();
-      int parent_dist = cur_line.PopWord().AsInt();
-      int num_cpus    = cur_line.PopWord().AsInt();
-      int total_cpus  = cur_line.PopWord().AsInt();
-      int length      = cur_line.PopWord().AsInt();
-      double merit    = cur_line.PopWord().AsDouble();
-      int gest_time   = cur_line.PopWord().AsInt();
-      double fitness  = cur_line.PopWord().AsDouble();
-      int update_born = cur_line.PopWord().AsInt();
-      int update_dead = cur_line.PopWord().AsInt();
-      int depth       = cur_line.PopWord().AsInt();
-      cString name = cStringUtil::Stringf("org-%d", id_num);
-      
-      cAnalyzeGenotype * genotype = new cAnalyzeGenotype(m_world, cur_line.PopWord(), inst_set);
-      
-      genotype->SetID(id_num);
-      genotype->SetParentID(parent_id);
-      genotype->SetParentDist(parent_dist);
-      genotype->SetNumCPUs(num_cpus);
-      genotype->SetTotalCPUs(total_cpus);
-      genotype->SetLength(length);
-      genotype->SetMerit(merit);
-      genotype->SetGestTime(gest_time);
-      genotype->SetFitness(fitness);
-      genotype->SetUpdateBorn(update_born);
-      genotype->SetUpdateDead(update_dead);
-      genotype->SetDepth(depth);
-      genotype->SetName(name);
-      
-      // Add this genotype to the proper batch.
-      batch[cur_batch].List().PushRear(genotype);
-    }
-    
-    // Adjust the flags on this batch
-    batch[cur_batch].SetLineage(false);
-    batch[cur_batch].SetAligned(false);
-    
-    cur_batch++;
-  }
-}
-
-void cAnalyze::LoadSequence(cString cur_string)
-{
-  // LOAD_SEQUENCE
-  
-  static int sequence_count = 1;
-  cString sequence = cur_string.PopWord();
-  cString seq_name = cur_string.PopWord();
-  
-  cout << "Loading: " << sequence << endl;
-  
-  // Setup the genotype...
-  cAnalyzeGenotype * genotype = new cAnalyzeGenotype(m_world, sequence, inst_set);
-  
-  genotype->SetNumCPUs(1);      // Initialize to a single organism.
-  if (seq_name == "") {
-    seq_name = cStringUtil::Stringf("org-Seq%d", sequence_count);
-  }
-  genotype->SetName(seq_name);
-  sequence_count++;
-  
-  // Add this genotype to the proper batch.
-  batch[cur_batch].List().PushRear(genotype);
-  
-  // Adjust the flags on this batch
-  batch[cur_batch].SetLineage(false);
-  batch[cur_batch].SetAligned(false);
-}
-
-void cAnalyze::LoadDominant(cString cur_string)
-{
-  (void) cur_string;
-  cerr << "Warning: \"LOAD_DOMINANT\" not implmented yet!"<<endl;
-}
-
-// Clears the current time oriented list of resources and loads in a new one
-// from a file specified by the user, or resource.dat by default.
-void cAnalyze::LoadResources(cString cur_string)
-{
-  resources.clear();
-  
-  int words = cur_string.CountNumWords();
-  
-  cString filename = "resource.dat";
-  if(words >= 1) {
-    filename = cur_string.PopWord();
-  }
-  
-  cout << "Loading Resources from: " << filename << endl;
-  
-  // Process the resource.dat, currently assuming this is the only possible
-  // input file
-  ifstream resourceFile(filename, ios::in);
-  assert(resourceFile);
-  
-  // Read in each line of the resource file and process it
-  char line[2048];
-  while(!resourceFile.eof()) {
-    resourceFile.getline(line, 2047);
-    if(line[0] == '\0') { continue; }
-    
-    // Get rid of the whitespace at the beginning of the stream, then 
-    // see if the line begins with a #, if so move on to the next line.
-    stringstream ss;
-    ss << line; ss >> ws; if(ss.peek() == '#') { continue; }
-    
-    // Read the update number from the stream
-    int update;
-    ss >> update; assert(ss.good());
-    
-    // Read in the concentration values for the current update and put them
-    // into a temporary vector.
-    double x;
-    vector<double> tempValues;
-    // Loop until the stream is no longer valid, which means either all the
-    // data has been processed or a non-numeric was encountered.  Currently
-    // assuming a non-numeric is a comment denoting the rest of the line as
-    // not informational.
-    while(true) {
-      ss >> ws; ss >> x;
-      tempValues.push_back(x);
-      if(!ss.good()) { ss.clear(); break; }
-    }
-    // Can't have no resources, so assert
-    if(tempValues.empty()) { assert(0); }
-    // add the update to the list of updates.  Also assuming the values
-    // in the file are already sorted.  If this turns out not to be the
-    // case you will need to sort on resources[i].first
-    resources.push_back(make_pair(update, tempValues));
-  }
-  resourceFile.close();
-  
-  return;
-}
-
-
-// Looks up the resource concentrations that are the closest to the
-// given update and then fill in those concentrations into the environment.
-void cAnalyze::FillResources(int update)
-{
-  // There must be some resources for at least one update
-  //assert(!resources.empty());
-  if(resources.empty()) { return; }
-  
-  int which = -1;
-  // Assuming resource vector is sorted by update, front to back
-  if(update <= resources[0].first) {
-    which = 0;
-  } else if(update >= resources.back().first) {
-    which = resources.size() - 1;
-  } else {
-    // Find the update that is closest to the born update
-    for(unsigned int i=0; i<resources.size()-1; i++) {
-      if(update > resources[i+1].first) { continue; }
-      if(update - resources[i].first <=
-         resources[i+1].first - update) {
-        which = i;
-      } else {
-        which = i + 1;
-      }
-      break;
-    }
-  }
-  if(which < 0) { assert(0); }
-  
-  
-tArray<double> temp(resources[which].second.size());
-for(unsigned int i=0; i<resources[which].second.size(); i++) {
-  temp[i] = resources[which].second[i];
-}
-m_world->GetTestCPU().SetupResourceArray(temp);
-
-return;
-}
-
-double cAnalyze::AnalyzeEntropy(cAnalyzeGenotype * genotype, double mu) 
-{
-  double entropy = 0.0;
-
-  // If the fitness is 0, the entropy is the length of genotype ...
-  genotype->Recalculate();
-  if (genotype->GetFitness() == 0) {
-    return genotype->GetLength();
-  }
-
-  // Calculate the stats for the genotype we're working with ...
-  const int num_insts = inst_set.GetSize();
-  const int num_lines = genotype->GetLength();
-  const cGenome & base_genome = genotype->GetGenome();
-  cGenome mod_genome(base_genome);
-  double base_fitness = genotype->GetFitness();
-  
-  // Loop through all the lines of code, testing all mutations...
-  tArray<double> test_fitness(num_insts);
-  tArray<double> prob(num_insts);
-  for (int line_no = 0; line_no < num_lines; line_no ++) {
-    int cur_inst = base_genome[line_no].GetOp();
-    
-    // Test fitness of each mutant.
-    for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
-      mod_genome[line_no].SetOp(mod_inst);
-      cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
-      test_genotype.Recalculate();
-      // Ajust fitness ...
-      if (test_genotype.GetFitness() <= base_fitness) {
-	test_fitness[mod_inst] = test_genotype.GetFitness();
-      } else {
-	test_fitness[mod_inst] = base_fitness;
-      }
-    }
-    
-    // Calculate probabilities at mut-sel balance
-    double w_bar = 1;
-    
-    // Normalize fitness values
-    double maxFitness = 0.0;
-    for(int i=0; i<num_insts; i++) {
-      if(test_fitness[i] > maxFitness) {
-	maxFitness = test_fitness[i];
-      }
-    }
-    
-   
-    for(int i=0; i<num_insts; i++) {
-      test_fitness[i] /= maxFitness;
-    }
-       
-    while(1) {
-      double sum = 0.0;
-      for (int mod_inst = 0; mod_inst < num_insts; mod_inst ++) {
-	prob[mod_inst] = (mu * w_bar) / 
-	  ((double)num_insts * 
-	   (w_bar + test_fitness[mod_inst] * mu - test_fitness[mod_inst]));
-	sum = sum + prob[mod_inst];
-      }
-      if ((sum-1.0)*(sum-1.0) <= 0.0001) 
-	break;
-      else
-	w_bar = w_bar - 0.000001;
-    }
-    
-    // Calculate entropy ...
-    double this_entropy = 0.0;
-    for (int i = 0; i < num_insts; i ++) {
-      this_entropy += prob[i] * log((double) 1.0/prob[i]) / log ((double) num_insts);
-    }
-    entropy += this_entropy;
-    
-    // Reset the mod_genome back to the original sequence.
-    mod_genome[line_no].SetOp(cur_inst);
-  }
-  return entropy;
-}
-
-double cAnalyze::AnalyzeEntropyGivenParent(cAnalyzeGenotype * genotype,
-					   cAnalyzeGenotype * parent, double mut_rate)
-{
-  double entropy = 0.0;
-
-  // Calculate the stats for the genotype we're working with ...
-  genotype->Recalculate();
-  const int num_insts = inst_set.GetSize();
-  const int num_lines = genotype->GetLength();
-  const cGenome & base_genome = genotype->GetGenome();
-  const cGenome & parent_genome = parent->GetGenome();
-  cGenome mod_genome(base_genome);
-
-  // Loop through all the lines of code, testing all mutations ...
-  tArray<double> test_fitness(num_insts);
-  tArray<double> prob(num_insts);
-  for (int line_no = 0; line_no < num_lines; line_no ++) {
-    int cur_inst = base_genome[line_no].GetOp();
-    int parent_inst = parent_genome[line_no].GetOp();
-
-    // Test fitness of each mutant.
-    for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
-      mod_genome[line_no].SetOp(mod_inst);
-      cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
-      test_genotype.Recalculate();
-      test_fitness[mod_inst] = test_genotype.GetFitness();
-    }
-
-
-    // Calculate probabilities at mut-sel balance
-    double w_bar = 1;
-    
-    // Normalize fitness values, assert if they are all zero
-    double maxFitness = 0.0;
-    for(int i=0; i<num_insts; i++) {
-      if ( i == parent_inst) { continue; }
-      if (test_fitness[i] > maxFitness) {
-	maxFitness = test_fitness[i];
-      }
-    }
-    
-    if(maxFitness > 0) {
-      for(int i = 0; i < num_insts; i ++) {
-	if (i == parent_inst) { continue; }
-	test_fitness[i] /= maxFitness;
-      }
-    } else {
-      // every other inst is equally likely to be mutated to
-      for (int i = 0; i < num_insts; i ++) {
-	if (i == parent_inst) { continue; }
-	test_fitness[i] = 1;
-      }
-    }
-    
-    double double_num_insts = num_insts * 1.0;
-    while(1) {
-      double sum = 0.0;
-      for (int mod_inst = 0; mod_inst < num_insts; mod_inst ++) {
-	if (mod_inst == parent_inst) { continue; }
-	prob[mod_inst] = (mut_rate * w_bar) / 
-	  (double_num_insts-2) / 
-	   (w_bar + test_fitness[mod_inst] * mut_rate * (double_num_insts-1) / (double_num_insts - 2) 
-	    - test_fitness[mod_inst]);
-	sum = sum + prob[mod_inst];
-      }
-      if ((sum-1.0)*(sum-1.0) <= 0.0001) 
-	break;
-      else
-	w_bar = w_bar - 0.000001;
-    }
-    
-    // Calculate entropy ...
-    double this_entropy = 0.0;
-    this_entropy -= (1.0 - mut_rate) * log(1.0 - mut_rate) / log(static_cast<double>(num_insts));
-    for (int i = 0; i < num_insts; i ++) {
-      if (i == parent_inst) { continue; }
-      prob[i] = prob[i] * mut_rate;
-      this_entropy += prob[i] * log(static_cast<double>(1.0/prob[i])) / log (static_cast<double>(num_insts));
-    }
-    entropy += this_entropy;
-
-    // Reset the mod_genome back to the base_genome.
-    mod_genome[line_no].SetOp(cur_inst);
-  }
-  return entropy;
-}
-
-double cAnalyze::IncreasedInfo(cAnalyzeGenotype * genotype1,
-			       cAnalyzeGenotype * genotype2,
-			       double mu) 
-{
-  double increased_info = 0.0;
-
-  // Calculate the stats for the genotypes we're working with ...
-  if ( genotype1->GetLength() != genotype2->GetLength() ) {
-    cerr << "Error: Two genotypes don't have same length.(cAnalyze::IncreasedInfo)" << endl;
-    exit(1);
-  }
-
-  genotype1->Recalculate();
-  if (genotype1->GetFitness() == 0) {
-    return 0.0;
-  }
-
-  const int num_insts = inst_set.GetSize();
-  const int num_lines = genotype1->GetLength();
-  const cGenome & genotype1_base_genome = genotype1->GetGenome();
-  cGenome genotype1_mod_genome(genotype1_base_genome);
-  double genotype1_base_fitness = genotype1->GetFitness();
-  vector<double> genotype1_info(num_lines, 0.0);
-  
-  // Loop through all the lines of code, calculate genotype1 information
-  tArray<double> test_fitness(num_insts);
-  tArray<double> prob(num_insts);
-  for (int line_no = 0; line_no < num_lines; line_no ++) {
-    int cur_inst = genotype1_base_genome[line_no].GetOp();
-    
-    // Test fitness of each mutant.
-    for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
-      genotype1_mod_genome[line_no].SetOp(mod_inst);
-      cAnalyzeGenotype test_genotype(m_world, genotype1_mod_genome, inst_set);
-      test_genotype.Recalculate();
-      // Ajust fitness ...
-      if (test_genotype.GetFitness() <= genotype1_base_fitness) {
-	test_fitness[mod_inst] = test_genotype.GetFitness();
-      } else {
-	test_fitness[mod_inst] = genotype1_base_fitness;
-      }
-    }
-    
-    // Calculate probabilities at mut-sel balance
-    double w_bar = 1;
-    
-    // Normalize fitness values
-    double maxFitness = 0.0;
-    for(int i=0; i<num_insts; i++) {
-      if(test_fitness[i] > maxFitness) {
-	maxFitness = test_fitness[i];
-      }
-    }
-    
-    for(int i=0; i<num_insts; i++) {
-      test_fitness[i] /= maxFitness;
-    }
-    
-    while(1) {
-      double sum = 0.0;
-      for (int mod_inst = 0; mod_inst < num_insts; mod_inst ++) {
-	prob[mod_inst] = (mu * w_bar) / 
-	  ((double)num_insts * 
-	   (w_bar + test_fitness[mod_inst] * mu - test_fitness[mod_inst]));
-	sum = sum + prob[mod_inst];
-      }
-      if ((sum-1.0)*(sum-1.0) <= 0.0001) 
-	break;
-      else
-	w_bar = w_bar - 0.000001;
-    }
-    
-    // Calculate entropy ...
-    double this_entropy = 0.0;
-    for (int i = 0; i < num_insts; i ++) {
-      this_entropy += prob[i] * log((double) 1.0/prob[i]) / log ((double) num_insts);
-    }
-    genotype1_info[line_no] = 1 - this_entropy;
-    
-    // Reset the mod_genome back to the original sequence.
-    genotype1_mod_genome[line_no].SetOp(cur_inst);
-  }
-
-  genotype2->Recalculate();
-  if (genotype2->GetFitness() == 0) {
-    for (int line_no = 0; line_no < num_lines; ++ line_no) {
-      increased_info += genotype1_info[line_no];
-    }
-    return increased_info;
-  }
-    
-  const cGenome & genotype2_base_genome = genotype2->GetGenome();
-  cGenome genotype2_mod_genome(genotype2_base_genome);
-  double genotype2_base_fitness = genotype2->GetFitness();
-
-  // Loop through all the lines of code, calculate increased information
-  for (int line_no = 0; line_no < num_lines; line_no ++) {
-    int cur_inst = genotype2_base_genome[line_no].GetOp();
-    
-    // Test fitness of each mutant.
-    for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
-      genotype2_mod_genome[line_no].SetOp(mod_inst);
-      cAnalyzeGenotype test_genotype(m_world, genotype2_mod_genome, inst_set);
-      test_genotype.Recalculate();
-      // Ajust fitness ...
-      if (test_genotype.GetFitness() <= genotype2_base_fitness) {
-	test_fitness[mod_inst] = test_genotype.GetFitness();
-      } else {
-	test_fitness[mod_inst] = genotype2_base_fitness;
-      }
-    }
-    
-    // Calculate probabilities at mut-sel balance
-    double w_bar = 1;
-    
-    // Normalize fitness values, assert if they are all zero
-    double maxFitness = 0.0;
-    for(int i=0; i<num_insts; i++) {
-      if(test_fitness[i] > maxFitness) {
-	maxFitness = test_fitness[i];
-      }
-    }
-    
-    for(int i=0; i<num_insts; i++) {
-      test_fitness[i] /= maxFitness;
-    }
-    
-    while(1) {
-      double sum = 0.0;
-      for (int mod_inst = 0; mod_inst < num_insts; mod_inst ++) {
-	prob[mod_inst] = (mu * w_bar) / 
-	  ((double)num_insts * 
-	   (w_bar + test_fitness[mod_inst] * mu - test_fitness[mod_inst]));
-	sum = sum + prob[mod_inst];
-      }
-      if ((sum-1.0)*(sum-1.0) <= 0.0001) 
-	break;
-      else
-	w_bar = w_bar - 0.000001;
-    }
-    
-    // Calculate entropy ...
-    double this_entropy = 0.0;
-    for (int i = 0; i < num_insts; i ++) {
-      this_entropy += prob[i] * log((double) 1.0/prob[i]) / log ((double) num_insts);
-    }
-    
-    // Compare information 
-    if (genotype1_info[line_no] > 1 - this_entropy) {
-      increased_info += genotype1_info[line_no] - (1 - this_entropy);
-    } // else increasing is 0, do nothing
-    
-    // Reset the mod_genome back to the original sequence.
-    genotype2_mod_genome[line_no].SetOp(cur_inst);
-  }
-
-
-  return increased_info;
-}
-
-void cAnalyze::LoadFile(cString cur_string)
-{
-  // LOAD
-  
-  cString filename = cur_string.PopWord();
-  
-  cout << "Loading: " << filename << endl;
-  
-  cInitFile input_file(filename);
-  if (!input_file.IsOpen()) {
-    cerr << "Error: Cannot load file: \"" << filename << "\"." << endl;
-    exit(1);
-  }
-  input_file.Load();
-  input_file.ReadHeader();
-  input_file.Compress();
-  input_file.Close();
-  
-  const cString filetype = input_file.GetFiletype();
-  if (filetype != "population_data" &&  // Depricated
-      filetype != "genotype_data") {
-    cerr << "Error: Cannot load files of type \"" << filetype << "\"." << endl;
-    exit(1);
-  }
-  
-  if (verbose == true) {
-    cout << "Loading file of type: " << filetype << endl;
-  }
-  
-  
-  // Construct a linked list of data types that can be loaded...
-  tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
-  tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-  LoadGenotypeDataList(input_file.GetFormat(), output_list);
-  bool id_inc = input_file.GetFormat().HasString("id");
-  
-  // Setup the genome...
-  cGenome default_genome(1);
-  int load_count = 0;
-  
-  for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
-    cString cur_line = input_file.GetLine(line_id);
-    
-    cAnalyzeGenotype * genotype = new cAnalyzeGenotype(m_world, default_genome, inst_set);
-    
-    output_it.Reset();
-    tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
-    while ((data_command = output_it.Next()) != NULL) {
-      data_command->SetTarget(genotype);
-      //        genotype->SetSpecialArgs(data_command->GetArgs());
-      data_command->SetValue(cur_line.PopWord());
-    }
-    
-    // Give this genotype a name.  Base it on the ID if possible.
-    if (id_inc == false) {
-      cString name = cStringUtil::Stringf("org-%d", load_count++);
-      genotype->SetName(name);
-    }
-    else {
-      cString name = cStringUtil::Stringf("org-%d", genotype->GetID());
-      genotype->SetName(name);
-    }
-    
-    // Add this genotype to the proper batch.
-    batch[cur_batch].List().PushRear(genotype);
-  }
-  
-  // Adjust the flags on this batch
-  batch[cur_batch].SetLineage(false);
-  batch[cur_batch].SetAligned(false);
-}
-
-
-//////////////// Reduction....
-
-void cAnalyze::FindGenotype(cString cur_string)
-{
-  // If no arguments are passed in, just find max num_cpus.
-  if (cur_string.GetSize() == 0) cur_string = "num_cpus";
-  
-  if (verbose == true) {
-    cout << "Reducing batch " << cur_batch << " to genotypes: ";
-  }
-  
-  tListPlus<cAnalyzeGenotype> & gen_list = batch[cur_batch].List();
-  tListPlus<cAnalyzeGenotype> found_list;
-  while (cur_string.CountNumWords() > 0) {
-    cString gen_desc(cur_string.PopWord());
-    if (verbose) cout << gen_desc << " ";
-    
-    // Determine by lin_type which genotype were are tracking...
-    cAnalyzeGenotype * found_gen = PopGenotype(gen_desc, cur_batch);
-    
-    if (found_gen == NULL) {
-      cerr << "  Warning: genotype not found!" << endl;
-      continue;
-    }
-    
-    // Save this genotype...
-    found_list.Push(found_gen);
-  }
-  cout << endl;
-  
-  // Delete all genotypes other than the ones found!
-  while (gen_list.GetSize() > 0) delete gen_list.Pop();
-  
-  // And fill it back in with the good stuff.
-  while (found_list.GetSize() > 0) gen_list.Push(found_list.Pop());
-  
-  // Adjust the flags on this batch
-  batch[cur_batch].SetLineage(false);
-  batch[cur_batch].SetAligned(false);
-}
-
-void cAnalyze::FindOrganism(cString cur_string)
-{
-  // At least one argument is rquired.
-  if (cur_string.GetSize() == 0) {
-    cerr << "Error: At least one argument is required in FIND_ORGANISM." << endl;
-    return;
-  }
-  
-  if (verbose == true) {
-    cout << "Reducing batch " << cur_batch << " to organisms: " << endl;
-  }
-  
-  tListPlus<cAnalyzeGenotype> & gen_list = batch[cur_batch].List();
-  tListPlus<cAnalyzeGenotype> found_list;
-  
-  tArray<int> new_counts(gen_list.GetSize());
-  new_counts.SetAll(0);
-  
-  while (cur_string.CountNumWords() > 0) {
-    cString org_desc(cur_string.PopWord());
-    if (verbose) cout << org_desc << " ";
-    
-    // Determine by org_desc which genotype were are tracking...
-    if (org_desc == "random") {
-      bool found = false; 
-      int num_orgs = gen_list.Count(&cAnalyzeGenotype::GetNumCPUs);
-      while (found != true) {
-      	int org_chosen = random.GetUInt(num_orgs);
-      	cAnalyzeGenotype * found_genotype = 
-          gen_list.FindSummedValue(org_chosen, &cAnalyzeGenotype::GetNumCPUs);
-        if ( found_genotype->GetNumCPUs() != 0 && found_genotype->GetViable()) {
-          found_genotype->SetNumCPUs(found_genotype->GetNumCPUs()-1);
-          new_counts[gen_list.FindPosPtr(found_genotype)] +=1;
-          cout << "Found genotype " << gen_list.FindPosPtr(found_genotype) << endl;
-          found = true;
-        }
-      }
-    }
-    
-    // pick a random organisms, with replacement!
-    if (org_desc == "randomWR") {
-      bool found = false;
-      int num_orgs = gen_list.Count(&cAnalyzeGenotype::GetNumCPUs);
-      while (found != true) {
-        int org_chosen = random.GetUInt(num_orgs);
-        cAnalyzeGenotype * found_genotype =
-          gen_list.FindSummedValue(org_chosen, &cAnalyzeGenotype::GetNumCPUs);
-        if ( found_genotype->GetNumCPUs() != 0 && found_genotype->GetViable()) {
-          new_counts[gen_list.FindPosPtr(found_genotype)] +=1;
-          cout << "Found genotype " << gen_list.FindPosPtr(found_genotype) << endl;
-          found = true;
-        }
-      }
-    }
-  }
-  
-  int pos_count = 0;
-  cAnalyzeGenotype * genotype = NULL;
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  
-  while ((genotype = batch_it.Next()) != NULL) {
-    genotype->SetNumCPUs(new_counts[pos_count]);
-    if (genotype->GetNumCPUs() == 0) batch_it.Remove();
-    else cout << "Genotype " << pos_count << " has " << new_counts[pos_count] << " organisms." << endl;
-    pos_count++;
-  }
-  
-  // Adjust the flags on this batch
-  batch[cur_batch].SetLineage(false);
-  batch[cur_batch].SetAligned(false);
-}
-
-void cAnalyze::FindLineage(cString cur_string)
-{
-  cString lin_type = "num_cpus";
-  if (cur_string.CountNumWords() > 0) lin_type = cur_string.PopWord();
-  
-  if (verbose == true) {
-    cout << "Reducing batch " << cur_batch
-    << " to " << lin_type << " lineage " << endl;
-  } else cout << "Performing lineage scan..." << endl;
-  
-  
-  // Determine by lin_type which genotype we are tracking...
-  cAnalyzeGenotype * found_gen = PopGenotype(lin_type, cur_batch);
-  
-  if (found_gen == NULL) {
-    cerr << "  Warning: Genotype " << lin_type
-    << " not found.  Lineage scan aborted." << endl;
-    return;
-  }
-  
-  // Otherwise, trace back through the id numbers to mark all of those
-  // in the ancestral lineage...
-  
-  // Construct a list of genotypes found...
-  
-  tListPlus<cAnalyzeGenotype> found_list;
-  found_list.Push(found_gen);
-  int next_id = found_gen->GetParentID();
-  bool found = true;
-  while (found == true) {
-    found = false;
-    
-    tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-    while ((found_gen = batch_it.Next()) != NULL) {
-      if (found_gen->GetID() == next_id) {
-        batch_it.Remove();
-        found_list.Push(found_gen);
-        next_id = found_gen->GetParentID();
-        found = true;
-        break;
-      }
-    }
-  }
-  
-  // We now have all of the genotypes in this lineage, delete everything
-  // else.
-  
-  const int total_removed = batch[cur_batch].List().GetSize();
-  while (batch[cur_batch].List().GetSize() > 0) {
-    delete batch[cur_batch].List().Pop();
-  }
-  
-  // And fill it back in with the good stuff.
-  int total_kept = found_list.GetSize();
-  while (found_list.GetSize() > 0) {
-    batch[cur_batch].List().PushRear(found_list.Pop());
-  }
-  
-  if (verbose == true) {
-    cout << "  Lineage has " << total_kept << " genotypes; "
-    << total_removed << " were removed." << endl;
-  }
-  
-  // Adjust the flags on this batch
-  batch[cur_batch].SetLineage(true);
-  batch[cur_batch].SetAligned(false);
-}
-
-void cAnalyze::FindSexLineage(cString cur_string)
-{
-  
-  // detemine the method for construicting a lineage 
-  // by defauly, find the lineage of the final dominant
-  cString lin_type = "num_cpus";
-  if (cur_string.CountNumWords() > 0) lin_type = cur_string.PopWord();
-  
-  // parent_method determins which of the two parental lineages to use
-  // "rec_region_size" : 
-  //		"mother" (dominant parent) is the parent contributing
-  // 		more to the offspring genome (default)
-  // "genome_size" : 
-  //		"mother" (dominant parent) is the longer parent 
-  cString parent_method = "rec_region_size";
-  if (cur_string.CountNumWords() > 0) parent_method = cur_string.PopWord();
-  
-  if (verbose == true) {
-    cout << "Reducing batch " << cur_batch
-    << " to " << lin_type << " sexual lineage " 
-    << " using " << parent_method << " criteria." << endl;
-  } else cout << "Performing sexual lineage scan..." << endl;
-  
-  
-  // Determine by lin_type which genotype we are tracking...
-  cAnalyzeGenotype * found_gen = PopGenotype(lin_type, cur_batch);
-  
-  cAnalyzeGenotype * found_dad;
-  cAnalyzeGenotype * found_mom;
-  cAnalyzeGenotype * found_temp;
-  
-  if (found_gen == NULL) {
-    cerr << "  Warning: Genotype " << lin_type
-    << " not found.  Sexual lineage scan aborted." << endl;
-    return;
-  }
-  
-  // Otherwise, trace back through the id numbers to mark all of those
-  // in the ancestral lineage...
-  
-  // Construct a list of genotypes found...
-  
-  tListPlus<cAnalyzeGenotype> found_list;
-  found_list.Push(found_gen);
-  int next_id1 = found_gen->GetParentID();
-  int next_id2 = found_gen->GetParent2ID();
-  
-  bool found_m = true;
-  bool found_d = true;
-  
-  while (found_m == true & found_d == true) {
-    
-    //cout << "Searching for mom=" << next_id1
-    //	 << " and dad=" << next_id2 << endl;
-    found_m = false;
-    found_d = false;
-    
-    // Look for the father first....
-    tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-    batch_it.Reset();
-    while ((found_dad = batch_it.Next()) != NULL) {
-      // Check if the father is found...
-      if (found_dad->GetID() == next_id2) {
-        //cout << "Found dad!" << endl;
-        batch_it.Remove();
-        found_list.Push(found_dad);
-        found_d = true; 
-        break;
-      }
-    }
-    
-    // dad may have already been found, check the find list!
-    if (found_d == false) {
-      tListIterator<cAnalyzeGenotype> found_it(found_list);
-      while ((found_dad = found_it.Next()) != NULL) {
-        if (found_dad->GetID() == next_id2) {
-          //cout << "Found dad in found list!" << endl;
-          found_d = true;
-          break;
-        }
-      }
-    } 
-    
-    // Next, look for the mother...
-    batch_it.Reset();
-    while ((found_mom = batch_it.Next()) != NULL) {
-      if (found_mom->GetID() == next_id1) {
-        //cout << "Found mom!" << endl;
-        batch_it.Remove();
-        found_list.Push(found_mom);
-        // if finding lineages by parental length, may have to swap 
-        if (parent_method == "genome_size" & 
-            found_mom->GetLength() < found_dad->GetLength()) { 
-          //cout << "Swapping parents!" << endl;
-          found_temp = found_mom; 
-          found_mom = found_dad; 
-          found_dad = found_temp; 
-        } 	
-        next_id1 = found_mom->GetParentID();
-        next_id2 = found_mom->GetParent2ID();
-        found_m = true;
-        break;
-      }
-    }
-    
-    // If the mother was not found, it may already have been placed in the
-    // found list as a father... 
-    if (found_m == false) {
-      tListIterator<cAnalyzeGenotype> found_it(found_list);
-      while ((found_mom = found_it.Next()) != NULL) {
-        if (found_mom->GetID() == next_id1) {
-          //cout << "Found mom as dad!" << endl;
-          // Don't move to found list, since its already there, but update
-          // to the next ids.
-          // if finding lineages by parental length, may have to swap 
-          if (parent_method == "genome_size" & 
-              found_mom->GetLength() < found_dad->GetLength()) {
-            //cout << "Swapping parents!" << endl;
-            found_temp = found_mom; 
-            found_mom = found_dad;  
-            found_dad = found_temp;
-          }
-          next_id1 = found_mom->GetParentID();
-          next_id2 = found_mom->GetParent2ID();
-          found_m = true;
-          break;
-        }
-      }
-    }    
-  }
-  
-  // We now have all of the genotypes in this lineage, delete everything
-  // else.
-  
-  const int total_removed = batch[cur_batch].List().GetSize();
-  while (batch[cur_batch].List().GetSize() > 0) {
-    delete batch[cur_batch].List().Pop();
-  }
-  
-  // And fill it back in with the good stuff.
-  int total_kept = found_list.GetSize();
-  while (found_list.GetSize() > 0) {
-    batch[cur_batch].List().PushRear(found_list.Pop());
-  }
-  
-  if (verbose == true) {
-    cout << "  Sexual lineage has " << total_kept << " genotypes; "
-    << total_removed << " were removed." << endl;
-  }
-  
-  // Adjust the flags on this batch
-  batch[cur_batch].SetLineage(false);
-  batch[cur_batch].SetAligned(false);
-}
-
-void cAnalyze::FindClade(cString cur_string)
-{
-  if (cur_string.GetSize() == 0) {
-    cerr << "  Warning: No clade specified for FIND_CLADE.  Aborting." << endl;
-    return;
-  }
-  
-  cString clade_type( cur_string.PopWord() );
-  
-  if (verbose == true) {
-    cout << "Reducing batch " << cur_batch
-    << " to clade " << clade_type << "." << endl;
-  } else cout << "Performing clade scan..." << endl;
-  
-  
-  // Determine by clade_type which genotype we are tracking...
-  cAnalyzeGenotype * found_gen = PopGenotype(clade_type, cur_batch);
-  
-  if (found_gen == NULL) {
-    cerr << "  Warning: Ancestral genotype " << clade_type
-    << " not found.  Clade scan aborted." << endl;
-    return;
-  }
-  
-  // Do this the brute force way... scan for one step at a time.
-  
-  // Construct a list of genotypes found...
-  
-  tListPlus<cAnalyzeGenotype> found_list; // Found and finished.
-  tListPlus<cAnalyzeGenotype> scan_list;  // Found, but need to scan for children.
-  scan_list.Push(found_gen);
-  
-  // Keep going as long as there is something in the scan list...
-  while (scan_list.GetSize() > 0) {
-    // Move the next genotype from the scan list to the found_list.
-    found_gen = scan_list.Pop();
-    int parent_id = found_gen->GetID();
-    found_list.Push(found_gen);
-    
-    // Seach for all of the children of this genotype...
-    tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-    while ((found_gen = batch_it.Next()) != NULL) {
-      // If we found a child, place it into the scan list.
-      if (found_gen->GetParentID() == parent_id) {
-        batch_it.Remove();
-        scan_list.Push(found_gen);
-      }
-    }
-  }
-  
-  // We now have all of the genotypes in this clade, delete everything else.
-  
-  const int total_removed = batch[cur_batch].List().GetSize();
-  while (batch[cur_batch].List().GetSize() > 0) {
-    delete batch[cur_batch].List().Pop();
-  }
-  
-  // And fill it back in with the good stuff.
-  int total_kept = found_list.GetSize();
-  while (found_list.GetSize() > 0) {
-    batch[cur_batch].List().PushRear(found_list.Pop());
-  }
-  
-  if (verbose == true) {
-    cout << "  Clade has " << total_kept << " genotypes; "
-    << total_removed << " were removed." << endl;
-  }
-  
-  // Adjust the flags on this batch
-  batch[cur_batch].SetLineage(false);
-  batch[cur_batch].SetAligned(false);
-}
-
-void cAnalyze::SampleOrganisms(cString cur_string)
-{
-  double fraction = cur_string.PopWord().AsDouble();
-  int init_genotypes = batch[cur_batch].List().GetSize();
-  
-  double test_viable = 0; 
-  if (cur_string.GetSize() > 0) {
-    test_viable = cur_string.PopWord().AsDouble();
-  }
-  
-  if (verbose == true) {
-    cout << "Sampling " << fraction << " organisms from batch "
-    << cur_batch << "." << endl;
-  }
-  else cout << "Sampling Organisms..." << endl;
-  
-  cAnalyzeGenotype * genotype = NULL;
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  
-  // Loop through all genotypes to perform a census
-  int org_count = 0;
-  while ((genotype = batch_it.Next()) != NULL) {
-    // If we require viables, reduce all non-viables to zero organisms.
-    if (test_viable == 1  &&  genotype->GetViable() == 0) { 
-      genotype->SetNumCPUs(0);
-    }
-    
-    // Count the number of organisms in this genotype.
-    org_count += genotype->GetNumCPUs();
-  } 
-  
-  // Create an array to store pointers to the genotypes and fill it in
-  // while temporarily resetting all of the organism counts to zero.
-  tArray<cAnalyzeGenotype *> org_array(org_count);
-  int cur_org = 0;
-  batch_it.Reset();
-  while ((genotype = batch_it.Next()) != NULL) {
-    for (int i = 0; i < genotype->GetNumCPUs(); i++) {
-      org_array[cur_org] = genotype;
-      cur_org++;
-    }
-    genotype->SetNumCPUs(0);
-  }
-  
-  assert(cur_org == org_count);
-  
-  // Determine how many organisms we want to keep.
-  int new_org_count = (int) fraction;
-  if (fraction < 1.0) new_org_count = (int) (fraction * (double) org_count);
-  if (new_org_count > org_count) {
-    cerr << "Warning: Trying to sample " << new_org_count
-    << "organisms from a population of " << org_count
-    << endl;
-    new_org_count = org_count;
-  }
-  
-  // Now pick those that we are keeping.
-  tArray<int> keep_ids(new_org_count);
-  random.Choose(org_count, keep_ids);
-  
-  // And increment the org counts for the associated genotypes.
-  for (int i = 0; i < new_org_count; i++) {
-    genotype = org_array[ keep_ids[i] ];
-    genotype->SetNumCPUs(genotype->GetNumCPUs() + 1);
-  }
-  
-  
-  // Delete all genotypes with no remaining organisms...
-  batch_it.Reset();
-  while ((genotype = batch_it.Next()) != NULL) {
-    if (genotype->GetNumCPUs() == 0) {
-      batch_it.Remove();
-      delete genotype;
-    }
-  }
-  
-  int num_genotypes = batch[cur_batch].List().GetSize();
-  if (verbose) {
-    cout << "  Removed " << org_count - new_org_count
-    << " organisms (" << init_genotypes - num_genotypes
-    << " genotypes); " << new_org_count
-    << " orgs (" << num_genotypes << " gens) remaining."
-    << endl;
-  }
-  
-  // Adjust the flags on this batch
-  batch[cur_batch].SetLineage(false);
-  batch[cur_batch].SetAligned(false);
-}
-
-
-void cAnalyze::SampleGenotypes(cString cur_string)
-{
-  double fraction = cur_string.PopWord().AsDouble();
-  int init_genotypes = batch[cur_batch].List().GetSize();
-  
-  double test_viable = 0;
-  if (cur_string.GetSize() > 0) {
-    test_viable = cur_string.PopWord().AsDouble();
-  }
-  
-  if (verbose == true) {
-    cout << "Sampling " << fraction << " genotypes from batch "
-    << cur_batch << "." << endl;
-  }
-  else cout << "Sampling Genotypes..." << endl;
-  
-  double frac_remove = 1.0 - fraction;
-  
-  cAnalyzeGenotype * genotype = NULL;
-  
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  while ((genotype = batch_it.Next()) != NULL) {
-    if (random.P(frac_remove) || ((genotype->GetViable())==0 && test_viable==1) ) {
-      batch_it.Remove();
-      delete genotype;
-    }
-  }
-  
-  int num_genotypes = batch[cur_batch].List().GetSize();
-  if (verbose == true) {
-    cout << "  Removed " << init_genotypes - num_genotypes
-    << " genotypes; " << num_genotypes << " remaining."
-    << endl;
-  }
-  
-  // Adjust the flags on this batch
-  batch[cur_batch].SetLineage(false);
-  batch[cur_batch].SetAligned(false);
-}
-
-void cAnalyze::KeepTopGenotypes(cString cur_string)
-{
-  const int num_kept = cur_string.PopWord().AsInt();
-  const int num_genotypes = batch[cur_batch].List().GetSize();
-  const int num_removed = num_genotypes - num_kept;
-  
-  for (int i = 0; i < num_removed; i++) {
-    delete batch[cur_batch].List().PopRear();
-  }
-  
-  // Adjust the flags on this batch
-  // batch[cur_batch].SetLineage(false); // Should not destroy a lineage...
-  batch[cur_batch].SetAligned(false);
-}
-
-
-
-//////////////// Output Commands...
-
-void cAnalyze::CommandPrint(cString cur_string)
-{
-  if (verbose == true) cout << "Printing batch " << cur_batch << endl;
-  else cout << "Printing organisms..." << endl;
-  
-  cString directory = PopDirectory(cur_string, "genebank/");
-  
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    cString filename(directory);
-    
-    if (cur_string.GetSize() > 0) {
-      filename += cur_string.PopWord();
-    }
-    else { 
-      filename += genotype->GetName();
-      filename += ".gen";
-    }
-    
-    cTestUtil::PrintGenome(m_world, genotype->GetGenome(), filename);
-    if (verbose) cout << "Printing: " << filename << endl;
-  }
-}
-
-void cAnalyze::CommandTrace(cString cur_string)
-{
-  if (verbose == true) cout << "Tracing batch " << cur_batch << endl;
-  else cout << "Tracing organisms..." << endl;
-  
-  int words = cur_string.CountNumWords();
-  
-  cString dir = cur_string.PopWord();
-  cString defaultDirectory = "genebank/";
-  cString directory = PopDirectory(dir, defaultDirectory);
-  
-  int useResources = 0;
-  if(words >= 2) {
-    useResources = cur_string.PopWord().AsInt();
-    // All non-zero values are considered false
-    if(useResources != 0 && useResources != 1) {
-      useResources = 0;
-    }
-  }
-  
-  bool backupUsage;
-  tArray<double> backupResources;
-  
-  if(useResources) {
-    // Backup test cpu data
-    backupUsage = m_world->GetTestCPU().UseResources();
-    backupResources = m_world->GetTestCPU().GetResources();
-    
-    m_world->GetTestCPU().UseResources() = true;
-  }
-  
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    cString filename(directory);
-    filename += genotype->GetName();
-    filename += ".trace";
-    
-    if (genotype->GetGenome().GetSize() == 0) {
-      break;
-    }
-    
-    // Build the hardware status printer for tracing.
-    ofstream trace_fp;
-    trace_fp.open(filename);
-    assert (trace_fp.good() == true); // Unable to open trace file.
-    cHardwareStatusPrinter trace_printer(trace_fp);
-
-    // Build the test info for printing.
-    cCPUTestInfo test_info;
-    test_info.TestThreads();
-    test_info.SetTraceExecution(&trace_printer);
-    
-    m_world->GetTestCPU().TestGenome(test_info, genotype->GetGenome());
-    
-    if (verbose) cout << "  Tracing: " << filename << endl;
-    trace_fp.close();
-  }
-  
-  if(useResources) {
-    // Set the test cpu back to the state it was in before we messed with it
-    m_world->GetTestCPU().UseResources() = backupUsage;
-    m_world->GetTestCPU().SetupResourceArray(backupResources);
-  }
-  
-  return;
-}
-
-void cAnalyze::CommandPrintTasks(cString cur_string)
-{
-  if (verbose == true) cout << "Printing tasks in batch " << cur_batch << endl;
-  else cout << "Printing tasks..." << endl;
-  
-  // Load in the variables...
-  cString filename("tasks.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  
-  ofstream & fp = data_file_manager.GetOFStream(filename);
-  
-  // Loop through all of the genotypes in this batch...
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    fp << genotype->GetID() << " ";
-    genotype->PrintTasks(fp);
-    fp << endl;
-  }
-}
-
-void cAnalyze::CommandDetail(cString cur_string)
-{
-  if (verbose == true) cout << "Detailing batch " << cur_batch << endl;
-  else cout << "Detailing..." << endl;
-  
-  // Load in the variables...
-  cString filename("detail.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  
-  // Construct a linked list of details needed...
-  tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
-  tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-  LoadGenotypeDataList(cur_string, output_list);
-  
-  // Determine the file type...
-  int file_type = FILE_TYPE_TEXT;
-  cString file_extension(filename);
-  while (file_extension.Find('.') != -1) file_extension.Pop('.');
-  if (file_extension == "html") file_type = FILE_TYPE_HTML;
-  
-  // Setup the file...
-  if (filename == "cout") {
-    CommandDetail_Header(cout, file_type, output_it);
-    CommandDetail_Body(cout, file_type, output_it);
-  } else {
-    ofstream & fp = data_file_manager.GetOFStream(filename);
-    CommandDetail_Header(fp, file_type, output_it);
-    CommandDetail_Body(fp, file_type, output_it);
-  }
-  
-  // And clean up...
-  while (output_list.GetSize() != 0) delete output_list.Pop();
-}
-
-
-void cAnalyze::CommandDetailTimeline(cString cur_string)
-{
-  if (verbose == true) cout << "Detailing batch "
-    << cur_batch << " based on time" << endl;
-  else cout << "Detailing..." << endl;
-  
-  // Load in the variables...
-  cString filename("detail_timeline.dat");
-  int time_step = 100;
-  int max_time = 100000;
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  if (cur_string.GetSize() != 0) time_step = cur_string.PopWord().AsInt();
-  if (cur_string.GetSize() != 0) max_time = cur_string.PopWord().AsInt();
-  
-  if (verbose == true) {
-    cout << "  Time step = " << time_step << endl
-    << "  Max time = " << max_time << endl;
-  }
-  
-  // Construct a linked list of details needed...
-  tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
-  tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-  LoadGenotypeDataList(cur_string, output_list);
-  
-  // Determine the file type...
-  int file_type = FILE_TYPE_TEXT;
-  cString file_extension(filename);
-  while (file_extension.Find('.') != -1) file_extension.Pop('.');
-  if (file_extension == "html") file_type = FILE_TYPE_HTML;
-  
-  // Setup the file...
-  if (filename == "cout") {
-    CommandDetail_Header(cout, file_type, output_it, time_step);
-    CommandDetail_Body(cout, file_type, output_it, time_step, max_time);
-  } else {
-    ofstream & fp = data_file_manager.GetOFStream(filename);
-    CommandDetail_Header(fp, file_type, output_it, time_step);
-    CommandDetail_Body(fp, file_type, output_it, time_step, max_time);
-  }
-  
-  // And clean up...
-  while (output_list.GetSize() != 0) delete output_list.Pop();
-}
-
-
-void cAnalyze::CommandDetail_Header(ostream & fp, int format_type,
-                                    tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it,
-                                    int time_step)
-{
-  // Write out the header on the file
-  if (format_type == FILE_TYPE_TEXT) {
-    fp << "#filetype genotype_data" << endl;
-    fp << "#format ";
-    if (time_step > 0) fp << "update ";
-    while (output_it.Next() != NULL) {
-      const cString & entry_name = output_it.Get()->GetName();
-      fp << entry_name << " ";
-    }
-    fp << endl << endl;
-    
-    // Give the more human-readable legend.
-    fp << "# Legend:" << endl;
-    int count = 0;
-    if (time_step > 0) fp << "# " << ++count << ": Update" << endl;
-    while (output_it.Next() != NULL) {
-      const cString & entry_desc = output_it.Get()->GetDesc();
-      fp << "# " << ++count << ": " << entry_desc << endl;
-    }
-    fp << endl;
-  } else { // if (format_type == FILE_TYPE_HTML) {
-    fp << "<html>" << endl
-    << "<body bgcolor=\"#FFFFFF\"" << endl
-    << " text=\"#000000\"" << endl
-    << " link=\"#0000AA\"" << endl
-    << " alink=\"#0000FF\"" << endl
-    << " vlink=\"#000044\">" << endl
-    << endl
-    << "<h1 align=center>Run " << batch[cur_batch].Name() << endl
-    << endl
-    << "<center>" << endl
-    << "<table border=1 cellpadding=2><tr>" << endl;
-    
-    if (time_step > 0) fp << "<th bgcolor=\"#AAAAFF\">Update ";
-    while (output_it.Next() != NULL) {
-      const cString & entry_desc = output_it.Get()->GetDesc();
-      fp << "<th bgcolor=\"#AAAAFF\">" << entry_desc << " ";
-    }
-    fp << "</tr>" << endl;
-    
-  }
-  
-  }
-
-
-void cAnalyze::CommandDetail_Body(ostream & fp, int format_type,
-                                  tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it,
-                                  int time_step, int max_time)
-{
-  // Loop through all of the genotypes in this batch...
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * cur_genotype = batch_it.Next();
-  cAnalyzeGenotype * next_genotype = batch_it.Next();
-  cAnalyzeGenotype * prev_genotype = NULL;
-  
-  int cur_time = 0;
-  while (cur_genotype != NULL && cur_time <= max_time) {
-    output_it.Reset();
-    tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
-    if (format_type == FILE_TYPE_HTML) {
-      fp << "<tr>";
-      if (time_step > 0) fp << "<td>" << cur_time << " ";
-    }
-    else if (time_step > 0) {  // TEXT file, printing times...
-      fp << cur_time << " ";
-    }
-    
-    while ((data_command = output_it.Next()) != NULL) {
-      data_command->SetTarget(cur_genotype);
-      cur_genotype->SetSpecialArgs(data_command->GetArgs());
-      if (format_type == FILE_TYPE_HTML) {
-        int compare = 0;
-        if (prev_genotype) {
-          prev_genotype->SetSpecialArgs(data_command->GetArgs());
-          compare = data_command->Compare(prev_genotype);
-        }
-        data_command->HTMLPrint(fp, compare);
-      }
-      else {  // if (format_type == FILE_TYPE_TEXT) {
-        fp << data_command->GetEntry() << " ";
-      }
-      }
-    if (format_type == FILE_TYPE_HTML) fp << "</tr>";
-    fp << endl;
-    
-    cur_time += time_step;
-    if (time_step > 0) {
-      while (next_genotype && next_genotype->GetUpdateBorn() < cur_time) {
-        prev_genotype = cur_genotype;
-        cur_genotype = next_genotype;
-        next_genotype = batch_it.Next();
-      }
-    }
-    else {
-      // Always moveon if we're not basing this on time, or if we've run out
-      // of genotypes.
-      prev_genotype = cur_genotype;
-      cur_genotype = next_genotype;
-      next_genotype = batch_it.Next();
-    }
-    
-    }
-  
-  // If in HTML mode, we need to end the file...
-  if (format_type == FILE_TYPE_HTML) {
-    fp << "</table>" << endl
-    << "</center>" << endl;
-  }
-}
-
-void cAnalyze::CommandDetailAverage_Body(ostream & fp, int num_outputs,
-                                         tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it)
-{
-  // Loop through all of the genotypes in this batch...
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * cur_genotype = batch_it.Next();
-  cAnalyzeGenotype * next_genotype = batch_it.Next();
-  cAnalyzeGenotype * prev_genotype = NULL;
-  
-  tArray<cDoubleSum> output_counts(num_outputs);
-  for (int i = 0; i < num_outputs; i++) { output_counts[i].Clear();} 
-  int count; 
-  while (cur_genotype != NULL) { 
-    count = 0; 
-    output_it.Reset();
-    tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
-    while ((data_command = output_it.Next()) != NULL) {
-      data_command->SetTarget(cur_genotype);
-      cur_genotype->SetSpecialArgs(data_command->GetArgs());
-      for (int j = 0; j < cur_genotype->GetNumCPUs(); j++) { 
-        output_counts[count].Add((double) data_command->GetEntry().AsString().AsDouble()); 
-      } 	
-      count++;
-    }
-    
-    prev_genotype = cur_genotype;
-    cur_genotype = next_genotype;
-    next_genotype = batch_it.Next();
-  }
-  fp << batch[cur_batch].Name() << " "; 
-  for (int i = 0; i < num_outputs; i++) {  
-    fp << output_counts[i].Average() << " ";
-  } 
-  fp << endl;   
-}
-
-void cAnalyze::CommandDetailAverage(cString cur_string) 
-{ 
-  if (verbose == true) cout << "Average detailing batch " << cur_batch << endl;
-  else cout << "Detailing..." << endl;
-  
-  // Load in the variables...
-  cString filename("detail.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  
-  // Construct a linked list of details needed...
-  tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
-  tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-  LoadGenotypeDataList(cur_string, output_list);
-  
-  // check if file is already in use.
-  bool file_active = data_file_manager.IsOpen(filename);
-  
-  ofstream & fp = data_file_manager.GetOFStream(filename);
-  
-  // if it's a new file print out the header
-  if (file_active == false) {
-    CommandDetail_Header(fp, FILE_TYPE_TEXT, output_it);
-  } 
-  CommandDetailAverage_Body(fp, cur_string.CountNumWords(), output_it);
-  
-  while (output_list.GetSize() != 0) delete output_list.Pop();
-  
-} 
-
-void cAnalyze::CommandDetailBatches(cString cur_string)
-{
-  // Load in the variables...
-  cString keyword("num_cpus");
-  cString filename("detail_batch.dat");
-  if (cur_string.GetSize() != 0) keyword = cur_string.PopWord();
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  
-  if (verbose == true) cout << "Detailing batches for " << keyword << endl;
-  else cout << "Detailing Batches..." << endl;
-  
-  // Scan the functions list for the keyword we need...
-  SetupGenotypeDataList();
-  tListIterator< tDataEntryBase<cAnalyzeGenotype> >
-    output_it(genotype_data_list);
-  
-  // Divide up the keyword into its acrual entry and its arguments...
-  cString cur_args = keyword;
-  cString cur_entry = cur_args.Pop(':');
-  
-  // Find its associated command...
-  tDataEntryCommand<cAnalyzeGenotype> * cur_command = NULL;
-  bool found = false;
-  while (output_it.Next() != NULL) {
-    if (output_it.Get()->GetName() == cur_entry) {
-      cur_command = new tDataEntryCommand<cAnalyzeGenotype>
-      (output_it.Get(), cur_args);
-      found = true;
-      break;
-    }
-  }
-  if (found == false) {
-    cout << "Error: Unknown data type: " << cur_entry << endl;
-    return;
-  }
-  
-  
-  // Determine the file type...
-  int file_type = FILE_TYPE_TEXT;
-  cString file_extension(filename);
-  while (file_extension.Find('.') != -1) file_extension.Pop('.');
-  if (file_extension == "html") file_type = FILE_TYPE_HTML;
-  
-  ofstream & fp = data_file_manager.GetOFStream(filename);
-  
-  // Write out the header on the file
-  if (file_type == FILE_TYPE_TEXT) {
-    fp << "#filetype batch_data" << endl
-    << "#format batch_id " << keyword << endl
-    << endl;
-    
-    // Give the more human-readable legend.
-    fp << "# Legend:" << endl
-      << "#  Column 1 = Batch ID" << endl
-      << "#  Remaining entries: " << cur_command->GetDesc() << endl
-      << endl;
-    
-  } else { // if (file_type == FILE_TYPE_HTML) {
-    fp << "<html>" << endl
-    << "<body bgcolor=\"#FFFFFF\"" << endl
-    << " text=\"#000000\"" << endl
-    << " link=\"#0000AA\"" << endl
-    << " alink=\"#0000FF\"" << endl
-    << " vlink=\"#000044\">" << endl
-    << endl
-    << "<h1 align=center> Distribution of " << cur_command->GetDesc()
-    << endl << endl
-    << "<center>" << endl
-    << "<table border=1 cellpadding=2>" << endl
-    << "<tr><th bgcolor=\"#AAAAFF\">" << cur_command->GetDesc() << "</tr>"
-    << endl;
-  }
-  
-  
-  // Loop through all of the batches...
-  for (int i = 0; i < MAX_BATCHES; i++) {
-    if (batch[i].List().GetSize() == 0) continue;
-    
-    if (file_type == FILE_TYPE_HTML) fp << "<tr><td>";
-    fp << i << " ";
-    
-    tListIterator<cAnalyzeGenotype> batch_it(batch[i].List());
-    cAnalyzeGenotype * genotype = NULL;
-    while ((genotype = batch_it.Next()) != NULL) {
-      output_it.Reset();
-      if (file_type == FILE_TYPE_HTML) fp << "<td>";
-      
-      cur_command->SetTarget(genotype);
-      genotype->SetSpecialArgs(cur_command->GetArgs());
-      if (file_type == FILE_TYPE_HTML) {
-        cur_command->HTMLPrint(fp, 0);
-      }
-      else {  // if (file_type == FILE_TYPE_TEXT) {
-        fp << cur_command->GetEntry() << " ";
-      }
-      }
-    if (file_type == FILE_TYPE_HTML) fp << "</tr>";
-    fp << endl;
-    }
-  
-  // If in HTML mode, we need to end the file...
-  if (file_type == FILE_TYPE_HTML) {
-    fp << "</table>" << endl
-    << "</center>" << endl;
-  }
-  
-  delete cur_command;
-  }
-
-
-
-void cAnalyze::CommandDetailIndex(cString cur_string)
-{
-  cout << "Creating a Detail Index..." << endl;
-  
-  // A filename and min and max batches must be included.
-  if (cur_string.CountNumWords() < 3) {
-    cerr << "Error: must include filename, and min and max batch numbers."
-    << endl;
-    exit(1);
-  }
-  
-  // Load in the variables...
-  cString filename(cur_string.PopWord());
-  int min_batch = cur_string.PopWord().AsInt();
-  int max_batch = cur_string.PopWord().AsInt();
-  
-  if (max_batch < min_batch) {
-    cerr << "Error: min_batch=" << min_batch
-    << ", max_batch=" << max_batch << "  (incorrect order?)" << endl;
-    exit(1);
-  }
-  
-  // Construct a linked list of details needed...
-  tList< tDataEntryBase<cAnalyzeGenotype> > output_list;
-  tListIterator< tDataEntryBase<cAnalyzeGenotype> > output_it(output_list);
-  
-  // For the moment, just put everything into the output list.
-  SetupGenotypeDataList();
-  
-  // If no args were given, load all of the stats.
-  if (cur_string.CountNumWords() == 0) {
-    tListIterator< tDataEntryBase<cAnalyzeGenotype> >
-    genotype_data_it(genotype_data_list);
-    while (genotype_data_it.Next() != NULL) {
-      output_list.PushRear(genotype_data_it.Get());
-    }
-  }
-  // Otherwise, load only those listed.
-  else {
-    while (cur_string.GetSize() != 0) {
-      // Setup the next entry
-      cString cur_entry = cur_string.PopWord();
-      bool found_entry = false;
-      
-      // Scan the genotype data list for the current entry
-      tListIterator< tDataEntryBase<cAnalyzeGenotype> >
-        genotype_data_it(genotype_data_list);
-      
-      while (genotype_data_it.Next() != NULL) {
-        if (genotype_data_it.Get()->GetName() == cur_entry) {
-          output_list.PushRear(genotype_data_it.Get());
-          found_entry = true;
-          break;
-        }
-      }
-      
-      // If the entry was not found, give a warning.
-      if (found_entry == false) {
-        int best_match = 1000;
-        cString best_entry;
-        
-        genotype_data_it.Reset();
-        while (genotype_data_it.Next() != NULL) {
-          const cString & test_str = genotype_data_it.Get()->GetName();
-          const int test_dist = cStringUtil::EditDistance(test_str, cur_entry);
-          if (test_dist < best_match) {
-            best_match = test_dist;
-            best_entry = test_str;
-          }
-        }	
-        
-        cerr << "Warning: Format entry \"" << cur_entry
-          << "\" not found.  Best match is \""
-          << best_entry << "\"." << endl;
-      }
-      
-    }
-  }
-  
-  // Setup the file...
-  ofstream fp;
-  fp.open(filename);
-  
-  // Determine the file type...
-  int file_type = FILE_TYPE_TEXT;
-  while (filename.Find('.') != -1) filename.Pop('.'); // Grab only extension
-  if (filename == "html") file_type = FILE_TYPE_HTML;
-  
-  // Write out the header on the file
-  if (file_type == FILE_TYPE_TEXT) {
-    fp << "#filetype genotype_data" << endl;
-    fp << "#format ";
-    while (output_it.Next() != NULL) {
-      const cString & entry_name = output_it.Get()->GetName();
-      fp << entry_name << " ";
-    }
-    fp << endl << endl;
-    
-    // Give the more human-readable legend.
-    fp << "# Legend:" << endl;
-    fp << "# 1: Batch Name" << endl;
-    int count = 1;
-    while (output_it.Next() != NULL) {
-      const cString & entry_desc = output_it.Get()->GetDesc();
-      fp << "# " << ++count << ": " << entry_desc << endl;
-    }
-    fp << endl;
-  } else { // if (file_type == FILE_TYPE_HTML) {
-    fp << "<html>" << endl
-    << "<body bgcolor=\"#FFFFFF\"" << endl
-    << " text=\"#000000\"" << endl
-    << " link=\"#0000AA\"" << endl
-    << " alink=\"#0000FF\"" << endl
-    << " vlink=\"#000044\">" << endl
-    << endl
-    << "<h1 align=center>Batch Index" << endl
-    << endl
-    << "<center>" << endl
-    << "<table border=1 cellpadding=2><tr>" << endl;
-    
-    fp << "<th bgcolor=\"#AAAAFF\">Batch ";
-    while (output_it.Next() != NULL) {
-      const cString & entry_desc = output_it.Get()->GetDesc();
-      fp << "<th bgcolor=\"#AAAAFF\">" << entry_desc << " ";
-    }
-    fp << "</tr>" << endl;
-    
-  }
-  
-  // Loop through all of the batchs...
-  for (int batch_id = min_batch; batch_id <= max_batch; batch_id++) {
-    cAnalyzeGenotype * genotype = batch[batch_id].List().GetFirst();
-    if (genotype == NULL) continue;
-    output_it.Reset();
-    tDataEntryBase<cAnalyzeGenotype> * data_entry = NULL;
-    const cString & batch_name = batch[batch_id].Name();
-    if (file_type == FILE_TYPE_HTML) {
-      fp << "<tr><th><a href=lineage." << batch_name << ".html>"
-      << batch_name << "</a> ";
-    }
-    else {
-      fp << batch_name << " ";
-    }
-    
-    while ((data_entry = output_it.Next()) != NULL) {
-      data_entry->SetTarget(genotype);
-      if (file_type == FILE_TYPE_HTML) {
-        fp << "<td align=center><a href=\""
-        << data_entry->GetName() << "." << batch_name << ".png\">"
-        << *data_entry << "</a> ";
-      }
-      else {  // if (file_type == FILE_TYPE_TEXT) {
-        fp << *data_entry << " ";
-      }
-      }
-    if (file_type == FILE_TYPE_HTML) fp << "</tr>";
-    fp << endl;
-    }
-  
-  // If in HTML mode, we need to end the file...
-  if (file_type == FILE_TYPE_HTML) {
-    fp << "</table>" << endl
-    << "</center>" << endl;
-  }
-}
-
-void cAnalyze::CommandHistogram(cString cur_string)
-{
-  if (verbose == true) cout << "Histogram batch " << cur_batch << endl;
-  else cout << "Histograming..." << endl;
-  
-  // Load in the variables...
-  cString filename("histogram.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  
-  // Construct a linked list of details needed...
-  tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
-  tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-  LoadGenotypeDataList(cur_string, output_list);
-  
-  // Determine the file type...
-  int file_type = FILE_TYPE_TEXT;
-  cString file_extension(filename);
-  while (file_extension.Find('.') != -1) file_extension.Pop('.');
-  if (file_extension == "html") file_type = FILE_TYPE_HTML;
-  
-  // Setup the file...
-  if (filename == "cout") {
-    CommandHistogram_Header(cout, file_type, output_it);
-    CommandHistogram_Body(cout, file_type, output_it);
-  } else {
-    ofstream & fp = data_file_manager.GetOFStream(filename);
-    CommandHistogram_Header(fp, file_type, output_it);
-    CommandHistogram_Body(fp, file_type, output_it);
-  }
-  
-  // And clean up...
-  while (output_list.GetSize() != 0) delete output_list.Pop();
-}
-
-void cAnalyze::CommandHistogram_Header(ostream & fp, int format_type,
-       tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it)
-{
-  // Write out the header on the file
-  if (format_type == FILE_TYPE_TEXT) {
-    fp << "#filetype histogram_data" << endl;
-    fp << "#format ";
-    while (output_it.Next() != NULL) {
-      const cString & entry_name = output_it.Get()->GetName();
-      fp << entry_name << " ";
-    }
-    fp << endl << endl;
-    
-    // Give the more human-readable legend.
-    fp << "# Histograms:" << endl;
-    int count = 0;
-    while (output_it.Next() != NULL) {
-      const cString & entry_desc = output_it.Get()->GetDesc();
-      fp << "# " << ++count << ": " << entry_desc << endl;
-    }
-    fp << endl;
-  } else { // if (format_type == FILE_TYPE_HTML) {
-    fp << "<html>" << endl
-       << "<body bgcolor=\"#FFFFFF\"" << endl
-       << " text=\"#000000\"" << endl
-       << " link=\"#0000AA\"" << endl
-       << " alink=\"#0000FF\"" << endl
-       << " vlink=\"#000044\">" << endl
-       << endl
-       << "<h1 align=center>Histograms for " << batch[cur_batch].Name()
-       << "</h1>" << endl
-       << endl
-       << "<center>" << endl
-       << "<table border=1 cellpadding=2><tr>" << endl;
-    
-    while (output_it.Next() != NULL) {
-      const cString & entry_desc = output_it.Get()->GetDesc();
-      const cString & entry_name = output_it.Get()->GetName();
-      fp << "<tr><th bgcolor=\"#AAAAFF\"><a href=\"#"
-	 << entry_name << "\">"
-	 << entry_desc << "</a></tr>";
-    }
-    fp << "</tr></table>" << endl;    
-  }
-}
-
-
-void cAnalyze::CommandHistogram_Body(ostream & fp, int format_type,
-	     tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it)
-{
-  output_it.Reset();
-  tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
-    
-  while ((data_command = output_it.Next()) != NULL) {
-    if (format_type == FILE_TYPE_TEXT) {
-      fp << "# --- " << data_command->GetDesc() << " ---" << endl;
-    } else {
-      fp << "<table cellpadding=3>" << endl
-	 << "<tr><th colspan=3><a name=\"" << data_command->GetName() << "\">"
-	 << data_command->GetDesc() << "</th></tr>" << endl;
-    }
-
-    tDictionary<int> count_dict;
-
-    // Loop through all genotypes in this batch to collect the info we need.
-    tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-    cAnalyzeGenotype * cur_genotype;
-    while ((cur_genotype = batch_it.Next()) != NULL) {
-      data_command->SetTarget(cur_genotype);
-      const cString cur_name(data_command->GetEntry().AsString());
-      int count = 0;
-      count_dict.Find(cur_name, count);
-      count += cur_genotype->GetNumCPUs();
-      count_dict.SetValue(cur_name, count);
-    }
-
-    tList<cString> name_list;
-    tList<int> count_list;
-    count_dict.AsLists(name_list, count_list);
-
-    // Figure out the maximum count and the maximum widths...
-    int max_count = 0;
-    int max_name_width = 0;
-    int max_count_width = 0;
-    tListIterator<int> count_it(count_list);
-    tListIterator<cString> name_it(name_list);
-    while (count_it.Next() != NULL) {
-      const cString cur_name( *(name_it.Next()) );
-      const int cur_count = *(count_it.Get());
-      const int name_width = cur_name.GetSize();
-      const int count_width = cStringUtil::Stringf("%d", cur_count).GetSize();
-      if (cur_count > max_count) max_count = cur_count;
-      if (name_width > max_name_width) max_name_width = name_width;
-      if (count_width > max_count_width) max_count_width = count_width;
-    }
-
-    // Do some final calculations now that we know the maximums...
-    const int max_stars = 75 - max_name_width - max_count_width;
-
-    // Now print everything out...
-    count_it.Reset();
-    name_it.Reset();
-    while (count_it.Next() != NULL) {
-      const cString cur_name( *(name_it.Next()) );
-      const int cur_count = *(count_it.Get());
-      if (cur_count == 0) continue;
-      int num_stars = (cur_count * max_stars) / max_count;
-
-      if (format_type == FILE_TYPE_TEXT) {
-	fp << setw(max_name_width) << cur_name << "  " 
-	   << setw(max_count_width) << cur_count << "  ";
-	for (int i = 0; i < num_stars; i++) { fp << '#'; }
-	fp << endl;
-      } else { // FILE_TYPE_HTML
-	fp << "<tr><td>" << cur_name
-	   << "<td>" << cur_count
-	   << "<td>";
-	for (int i = 0; i < num_stars; i++) { fp << '#'; }
-	fp << "</tr>" << endl;
-      }
-    }
-
-    if (format_type == FILE_TYPE_TEXT) {
-      // Skip a line between histograms...
-      fp << endl;
-    } else {
-      fp << "</table><br><br>" << endl << endl;;
-    }
-  }
-  
-  // If in HTML mode, we need to end the file...
-  if (format_type == FILE_TYPE_HTML) {
-    fp << "</table>" << endl
-    << "</center>" << endl;
-  }
-}
-
-
-///// Population Analysis Commands ////
-
-void cAnalyze::CommandPrintPhenotypes(cString cur_string)
-{
-  if (verbose == true) cout << "Printing phenotypes in batch "
-    << cur_batch << endl;
-  else cout << "Printing phenotypes..." << endl;
-  
-  // Load in the variables...
-  cString filename("phenotype.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  
-  // Make sure we have at least one genotype...
-  if (batch[cur_batch].List().GetSize() == 0) return;
-  
-  // Setup the phenotype categories...
-  const int num_tasks = batch[cur_batch].List().GetFirst()->GetNumTasks();
-  const int num_phenotypes = 1 << (num_tasks + 1);
-  tArray<int> phenotype_counts(num_phenotypes);
-  tArray<int> genotype_counts(num_phenotypes);
-  tArray<double> total_length(num_phenotypes);
-  tArray<double> total_gest(num_phenotypes);
-  
-  phenotype_counts.SetAll(0);
-  genotype_counts.SetAll(0);
-  total_length.SetAll(0.0);
-  total_gest.SetAll(0.0);
-  
-  // Loop through all of the genotypes in this batch...
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    int phen_id = 0;
-    if (genotype->GetViable() == true) phen_id++;
-    for (int i = 0; i < num_tasks; i++) {
-      if (genotype->GetTaskCount(i) > 0)  phen_id += 1 << (i+1);
-    }
-    phenotype_counts[phen_id] += genotype->GetNumCPUs();
-    genotype_counts[phen_id]++;
-    total_length[phen_id] += genotype->GetNumCPUs() * genotype->GetLength();
-    total_gest[phen_id] += genotype->GetNumCPUs() * genotype->GetGestTime();
-  }
-  
-  // Print out the results...
-  
-  ofstream & fp = data_file_manager.GetOFStream(filename);
-  
-  fp << "# 1: Number of organisms of this phenotype" << endl
-    << "# 2: Number of genotypes of this phenotye" << endl
-    << "# 3: Average Genome Length" << endl
-    << "# 4: Average Gestation Time" << endl
-    << "# 5: Viability of Phenotype" << endl
-    << "# 6+: Tasks performed in this phenotype" << endl
-    << endl;
-  
-  // @CAO Lets do this inefficiently for the moment, but print out the
-  // phenotypes in order.
-  
-  while (true) {
-    // Find the next phenotype to print...
-    int max_count = phenotype_counts[0];
-    int max_position = 0;
-    for (int i = 0; i < num_phenotypes; i++) {
-      if (phenotype_counts[i] > max_count) {
-        max_count = phenotype_counts[i];
-        max_position = i;
-      }
-    }
-    
-    if (max_count == 0) break; // we're done!
-    
-    fp << phenotype_counts[max_position] << " "
-      << genotype_counts[max_position] << " "
-      << total_length[max_position] / phenotype_counts[max_position] << " "
-      << total_gest[max_position] / phenotype_counts[max_position] << " "
-      << (max_position & 1) << "  ";
-    for (int i = 1; i <= num_tasks; i++) {
-      if ((max_position >> i) & 1 > 0) fp << "1 ";
-      else fp << "0 ";
-    }
-    fp << endl;
-    phenotype_counts[max_position] = 0;
-  }
-  
-  fp.close();
-}
-
-
-// Print various diversity metrics from the current batch of genotypes...
-void cAnalyze::CommandPrintDiversity(cString cur_string)
-{
-  if (verbose == true) cout << "Printing diversity data for batch "
-    << cur_batch << endl;
-  else cout << "Printing diversity data..." << endl;
-  
-  // Load in the variables...
-  cString filename("diversity.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  
-  // Make sure we have at least one genotype...
-  if (batch[cur_batch].List().GetSize() == 0) return;
-  
-  // Setup the task categories...
-  const int num_tasks = batch[cur_batch].List().GetFirst()->GetNumTasks();
-  tArray<int> task_count(num_tasks);
-  tArray<int> task_gen_count(num_tasks);
-  tArray<double> task_gen_dist(num_tasks);
-  tArray<double> task_site_entropy(num_tasks);
-  task_count.SetAll(0);
-  task_gen_count.SetAll(0);
-  
-  // We must determine the average hamming distance between genotypes in
-  // this batch that perform each task.  Levenstein distance would be ideal,
-  // but takes a while, so we'll do it this way first.  For the calculations,
-  // we need to know home many times each instruction appears at each
-  // position for each genotype collection that performs a particular task.
-  const int num_insts = inst_set.GetSize();
-  const int max_length = BatchUtil_GetMaxLength();
-  tMatrix<int> inst_freq(max_length, num_insts+1);
-  
-  for (int task_id = 0; task_id < num_tasks; task_id++) {
-    inst_freq.SetAll(0);
-    
-    // Loop through all genotypes, singling out those that do current task...
-    tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-    cAnalyzeGenotype * genotype = NULL;
-    while ((genotype = batch_it.Next()) != NULL) {
-      if (genotype->GetTaskCount(task_id) == 0) continue;
-      
-      const cGenome & genome = genotype->GetGenome();
-      const int num_cpus = genotype->GetNumCPUs();
-      task_count[task_id] += num_cpus;
-      task_gen_count[task_id]++;
-      for (int i = 0; i < genotype->GetLength(); i++) {
-        inst_freq( i, genome[i].GetOp() ) += num_cpus;
-      }
-      for (int i = genotype->GetLength(); i < max_length; i++) {
-        inst_freq(i, num_insts) += num_cpus; // Entry for "past genome end"
-      }
-    }
-    
-    // Analyze the data for this entry...
-    const int cur_count = task_count[task_id];
-    const int total_pairs = cur_count * (cur_count - 1) / 2;
-    int total_dist = 0;
-    double total_ent = 0;
-    for (int pos = 0; pos < max_length; pos++) {
-      // Calculate distance component...
-      for (int inst1 = 0; inst1 < num_insts; inst1++) {
-        if (inst_freq(pos, inst1) == 0) continue;
-        for (int inst2 = inst1+1; inst2 <= num_insts; inst2++) {
-          total_dist += inst_freq(pos, inst1) * inst_freq(pos, inst2);
-        }
-      }
-      
-      // Calculate entropy component...
-      for (int i = 0; i <= num_insts; i++) {
-        const int cur_freq = inst_freq(pos, i);
-        if (cur_freq == 0) continue;
-        const double p = ((double) cur_freq) / (double) cur_count;
-        total_ent -= p * log(p);
-      }
-    }
-    
-    task_gen_dist[task_id] = ((double) total_dist) / (double) total_pairs;
-    task_site_entropy[task_id] = total_ent;
-  }
-  
-  // Print out the results...
-  cDataFile & df = data_file_manager.Get(filename);
-  
-  for (int i = 0; i < num_tasks; i++) {
-    df.Write(i,                    "# 1: Task ID");
-    df.Write(task_count[i],        "# 2: Number of organisms performing task");
-    df.Write(task_gen_count[i],    "# 3: Number of genotypes performing task");
-    df.Write(task_gen_dist[i],     "# 4: Average distance between genotypes performing task");
-    df.Write(task_site_entropy[i], "# 5: Total per-site entropy of genotypes performing task");
-    df.Endl();
-  }
-}
-
-
-void cAnalyze::PhyloCommunityComplexity(cString cur_string)
-{
-
-  /////////////////////////////////////////////////////////////////////////
-  // Calculate the mutual information between all genotypes and environment
-  /////////////////////////////////////////////////////////////////////////
-
-  cout << "Analyze biocomplexity of current population about environment ...\n";
-
-  // Get the number of genotypes that are gonna be analyzed.
-  int max_genotypes = cur_string.PopWord().AsInt();
-
-  // Get update
-  int update = cur_string.PopWord().AsInt();
-
-  // Get the directory  
-  cString dir = cur_string.PopWord();
-  cString defaultDir = "community_cpx/";
-  cString directory = PopDirectory(dir, defaultDir);
-
-  // Get the file name that saves the result 
-  cString filename = cur_string.PopWord();
-  if (filename.IsEmpty()) {
-    filename = "community.complexity.dat";
-  }
-
-  filename.Set("%s%s", directory(), filename.GetData());
-  ofstream cpx_fp(filename());
-
-  cpx_fp << "# Legend:" << endl;
-  cpx_fp << "# 1: Genotype ID" << endl;
-  cpx_fp << "# 2: Entropy given Known Genotypes" << endl;
-  cpx_fp << "# 3: Entropy given Both Known Genotypes and Env" << endl;
-  cpx_fp << "# 4: New Information about Environment" << endl;
-  cpx_fp << "# 5: Total Complexity" << endl;
-  cpx_fp << endl;
-
-  /////////////////////////////////////////////////////////////////////////////////
-  // Loop through all of the genotypes in all batches and build id vs. genotype map
-
-  map<int, cAnalyzeGenotype *> genotype_database;
-  for (int i = 0; i < MAX_BATCHES; ++ i) {
-    tListIterator<cAnalyzeGenotype> batch_it(batch[i].List());
-    cAnalyzeGenotype * genotype = NULL;
-    while ((genotype = batch_it.Next()) != NULL) {
-      genotype_database.insert(make_pair(genotype->GetID(), genotype));
-    }
-  }
-
-  ////////////////////////////////////////////////
-  // Check if all the genotypes having same length
-
-  int length_genome;
-  if (genotype_database.size() > 0) {
-    length_genome = genotype_database.begin()->second->GetLength();
-  }
-  map<int, cAnalyzeGenotype *>::iterator gen_iterator = genotype_database.begin();
-  for (; gen_iterator != genotype_database.end(); ++ gen_iterator) {
-    if (gen_iterator->second->GetLength() != length_genome) {
-      cerr << "Genotype " << gen_iterator->first << " has different genome length." << endl;
-      exit(1);
-    }
-  }
-
-  ///////////////////////
-  // Backup test CPU data
-  bool backupUsage = m_world->GetTestCPU().UseResources();
-  tArray<double> backupResources(m_world->GetTestCPU().GetResources());
-  m_world->GetTestCPU().UseResources() = true;
-  FillResources(update);
-
-  ///////////////////////////////////////////////////////////////////////
-  // Choose the first n most abundant genotypes and put them in community
-
-  vector<cAnalyzeGenotype *> community;
-  cAnalyzeGenotype * genotype = NULL;
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-
-  while (((genotype = batch_it.Next()) != NULL) && (community.size() < max_genotypes)) {
-    community.push_back(genotype);
-  }
-    
-  ///////////////////////////
-  // Measure hamming distance
-
-  int size_community = community.size();
-  if (size_community == 0) {
-    cerr << "There is no genotype in this community." << endl;
-    cpx_fp.close();
-    exit(1);
-  }
-  typedef pair<int,int> gen_pair;
-  map<gen_pair, int> hamming_dist;
-  
-  for (int i = 0; i< size_community; ++ i) {
-    for (int j = i+1; j < size_community; ++ j) {
-      int dist = cGenomeUtil::FindHammingDistance(community[i]->GetGenome(),
-						  community[j]->GetGenome());
-      int id1 = community[i]->GetID();
-      int id2 = community[j]->GetID();
-
-      hamming_dist.insert(make_pair(gen_pair(id1, id2), dist));
-      hamming_dist.insert(make_pair(gen_pair(id2, id1), dist));
-    }
-  }
-
-  //////////////////////////////////
-  // Get Most Recent Common Ancestor
-
-  map<gen_pair, cAnalyzeGenotype *> mrca;
-  map<gen_pair, int> raw_dist;
-  for (int i = 0; i< size_community; ++ i) {
-    for (int j = i+1; j < size_community; ++ j) {
-				    
-      cAnalyzeGenotype * lineage1_genotype = community[i];
-      cAnalyzeGenotype * lineage2_genotype = community[j];
-      int total_dist = 0;
-
-      while (lineage1_genotype->GetID() != lineage2_genotype->GetID()) {
-	if (lineage1_genotype->GetID() > lineage2_genotype->GetID()) {
-	  int parent_id = lineage1_genotype->GetParentID();
-	  cAnalyzeGenotype * parent = genotype_database.find(parent_id)->second;
-
-	  total_dist += cGenomeUtil::FindHammingDistance(lineage1_genotype->GetGenome(),
-							 parent->GetGenome());
-	  lineage1_genotype = parent;
-	} else {
-	  int parent_id = lineage2_genotype->GetParentID();
-	  cAnalyzeGenotype * parent = genotype_database.find(parent_id)->second;
-	  total_dist += cGenomeUtil::FindHammingDistance(lineage2_genotype->GetGenome(),
-							 parent->GetGenome());
-      
-	  lineage2_genotype = parent;
-	}
-      }
-
-      int id1 = community[i]->GetID();
-      int id2 = community[j]->GetID();
-      mrca.insert(make_pair(gen_pair(id1, id2), lineage1_genotype));
-      mrca.insert(make_pair(gen_pair(id2, id1), lineage1_genotype));
-      raw_dist.insert(make_pair(gen_pair(id1, id2), total_dist));
-      raw_dist.insert(make_pair(gen_pair(id2, id1), total_dist));
-    }
-  }
-
-  /*
-  ////////////////////////////////////////////////////////////////////////////////////////////
-  // Sort the genotype that is next genotype is the most closest one to all previous genotypes
-
-  vector<cAnalyzeGenotype *> sorted_community;
-  vector<cAnalyzeGenotype *> left_genotypes = community;
-
-  // Put the first genotype in left to sorted.
-  sorted_community.push_back(*left_genotypes.begin());
-  left_genotypes.erase(left_genotypes.begin());
-
-  while (left_genotypes.size() > 0) {
-    int min_total_hamming = size_community * length_genome;
-    int index_next;
-
-    for (int next = 0; next < left_genotypes.size(); ++ next) {
-      int total_hamming = 0;
-      int id1 = left_genotypes[next]->GetID();
-      
-      for (int given = 0; given < sorted_community.size(); ++ given) {
-	int id2 = sorted_community[given]->GetID();
-	total_hamming += hamming_dist.find(gen_pair(id1, id2))->second;
-      }
-
-      if (total_hamming < min_total_hamming) {
-	min_total_hamming = total_hamming;
-	index_next = next;
-      }
-    }
-
-    sorted_community.push_back(left_genotypes[index_next]);
-    left_genotypes.erase(left_genotypes.begin() + index_next);
-  }
-
-  */
-
-  vector<cAnalyzeGenotype *> sorted_community = community;
-  /////////////////////////////////////////////
-  // Loop through genotypes in sorted community
-
-  double complexity = 0.0;
-  vector<cAnalyzeGenotype *> given_genotypes;
-  int num_insts = inst_set.GetSize();
-
-  for (int i = 0; i < size_community; ++ i) {
-    genotype = sorted_community[i];
-
-    // Skip the dead organisms
-    genotype->Recalculate();
-    if (genotype->GetFitness() == 0) {
-      continue;
-    }
-
-    vector<double> one_line_prob(num_insts, 0.0);
-    vector< vector<double> > prob(length_genome, one_line_prob);
-
-    cout << endl << genotype->GetID() << endl;
-
-    /*if (given_genotypes.size() >= 2) {
-
-      ///////////////////////////////////////////////////////////////////
-      // Look for two given genotypes that has minimun depth dist with it
-
-      cAnalyzeGenotype * min_depth_gen = given_genotypes[0];
-      cAnalyzeGenotype * tmrca = mrca.find(gen_pair(genotype->GetID(), 
-						    given_genotypes[0]->GetID()))->second;
-      int min_depth_dist = genotype->GetDepth() + given_genotypes[0]->GetDepth() - 2 * tmrca->GetDepth();
-      
-      cAnalyzeGenotype * second_min_gen = given_genotypes[1];
-      tmrca = mrca.find(gen_pair(genotype->GetID(), given_genotypes[1]->GetID()))->second;
-      int second_min_depth = genotype->GetDepth() + given_genotypes[1]->GetDepth() - 2 * tmrca->GetDepth();
-
-      for (int i = 2; i < given_genotypes.size(); ++ i) {
-	cAnalyzeGenotype * given_genotype = given_genotypes[i];
-	cAnalyzeGenotype * tmrca = mrca.find(gen_pair(genotype->GetID(),
-						      given_genotype->GetID()))->second;
-	int dist = genotype->GetDepth() + given_genotype->GetDepth() - 2 * tmrca->GetDepth();
-
-	if (dist < min_depth_dist) {
-	  second_min_depth = min_depth_dist;
-	  second_min_gen = min_depth_gen;
-	  min_depth_dist = dist;
-	  min_depth_gen = given_genotype;
-	} else if (dist >= min_depth_dist && dist < second_min_depth) {
-	  second_min_depth = dist;
-	  second_min_gen = given_genotype;
-	}
-      }
-
-      const cGenome & given_genome1 = min_depth_gen->GetGenome();
-      const cGenome & given_genome2 = second_min_gen->GetGenome();
-      for (int line = 0; line < length_genome; ++ line) {
-	int given_inst = given_genome1[line].GetOp();
-	prob[line][given_inst] += pow(1 - 1.0/length_genome, min_depth_dist);
-	given_inst = given_genome2[line].GetOp();
-	prob[line][given_inst] += pow(1 - 1.0/length_genome, min_depth_dist);
-      }
-
-      cpx_fp << genotype->GetID() << " " << min_depth_dist << " " << second_min_depth 
-	     << " " << raw_dist.find(gen_pair(genotype->GetID(), min_depth_gen->GetID()))->second
-	     << " " << raw_dist.find(gen_pair(genotype->GetID(), second_min_gen->GetID()))->second
-	     << " ";
-      
-	
-    } else  if (given_genotypes.size() == 1) {
-      //////////////////////////////////////////////////////
-      // Calculate the probability of each inst at each line
-      cAnalyzeGenotype * tmrca = mrca.find(gen_pair(genotype->GetID(), 
-						    given_genotypes[0]->GetID()))->second;
-      int dist = genotype->GetDepth() + given_genotypes[0]->GetDepth() - 2 * tmrca->GetDepth();
-      const cGenome & given_genome = given_genotypes[0]->GetGenome();
-
-      for (int line = 0; line < length_genome; ++ line) {
-	int given_inst = given_genome[line].GetOp();
-	prob[line][given_inst] += pow(1 - 1.0/length_genome, dist);
-      }
-      
-      cpx_fp << genotype->GetID() << " " << dist << " " 
-	     << raw_dist.find(gen_pair(genotype->GetID(), given_genotypes[0]->GetID()))->second << " ";
-    } else {
-      cpx_fp << genotype->GetID() << " ";
-      }*/
-
-    if (given_genotypes.size() >= 1) {
-      //////////////////////////////////////////////////
-      // Look for a genotype that is closest to this one
-      
-      cAnalyzeGenotype * min_depth_gen = given_genotypes[0];
-      cAnalyzeGenotype * tmrca = mrca.find(gen_pair(genotype->GetID(), 
-						    given_genotypes[0]->GetID()))->second;
-      int min_depth_dist = genotype->GetDepth() + given_genotypes[0]->GetDepth() - 2 * tmrca->GetDepth();
-
-      for (int i = 1; i < given_genotypes.size() ; ++ i) {
-	cAnalyzeGenotype * given_genotype = given_genotypes[i];
-	cAnalyzeGenotype * tmrca = mrca.find(gen_pair(genotype->GetID(),
-						      given_genotype->GetID()))->second;
-	int dist = genotype->GetDepth() + given_genotype->GetDepth() - 2 * tmrca->GetDepth();
-	
-	if (dist < min_depth_dist) {
-	  min_depth_dist = dist;
-	  min_depth_gen = given_genotype;
-	}
-      }
-
-      const cGenome & given_genome = min_depth_gen->GetGenome();
-      const cGenome & base_genome = genotype->GetGenome();
-      cGenome mod_genome(base_genome);
-      for (int line = 0; line < length_genome; ++ line) {
-	int given_inst = given_genome[line].GetOp();
-	mod_genome = base_genome;
-	mod_genome[line].SetOp(given_inst);
-	cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
-	test_genotype.Recalculate();
-
-	// Only when given inst make the genotype alive
-	if (test_genotype.GetFitness() > 0) {
-	  prob[line][given_inst] += pow(1 - 1.0/length_genome, min_depth_dist);
-	}
-      }
-      
-      cpx_fp << genotype->GetID() << " " << min_depth_dist << " " 
-	     << raw_dist.find(gen_pair(genotype->GetID(), min_depth_gen->GetID()))->second << " "
-	     << hamming_dist.find(gen_pair(genotype->GetID(), min_depth_gen->GetID()))->second << "   ";
-    } else {
-      cpx_fp << genotype->GetID() << " ";
-    }
-
-    ///////////////////////////////////////////////////////////////////
-    // Point mutation at all lines of code to look for neutral mutation
-    // and the mutations that can make organism alive
-    cout << "Test point mutation." << endl;
-    vector<bool> one_line_neutral(num_insts, false);
-    vector< vector<bool> > neutral_mut(length_genome, one_line_neutral);
-    vector< vector<bool> > alive_mut(length_genome, one_line_neutral);
-//     if (verbose == true) {
-//       PrintTestCPUResources("");
-//     }
-
-    genotype->Recalculate();
-    double base_fitness = genotype->GetFitness();
-    cout << base_fitness << endl;
-    const cGenome & base_genome = genotype->GetGenome();
-    cGenome mod_genome(base_genome);
-      
-    for (int line = 0; line < length_genome; ++ line) {
-      int cur_inst = base_genome[line].GetOp();
-      
-      for (int mod_inst = 0; mod_inst < num_insts; ++ mod_inst) {
-	mod_genome[line].SetOp(mod_inst);
-	cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
-	test_genotype.Recalculate();
-	if (test_genotype.GetFitness() >= base_fitness) {
-	  neutral_mut[line][mod_inst] = true;
-	} 
-	if (test_genotype.GetFitness() > 0) {
-	  alive_mut[line][mod_inst] = true;
-	}
-      }
-      
-      mod_genome[line].SetOp(cur_inst);
-    }
-
-    /////////////////////////////////////////
-    // Normalize the probability at each line
-    vector< vector<double> > prob_before_env(length_genome, one_line_prob);
-
-    for (int line = 0; line < length_genome; ++ line) {
-      double cur_total_prob = 0.0;
-      int num_alive = 0;
-      for (int inst = 0; inst < num_insts; ++ inst) {
-	if (alive_mut[line][inst] == true) {
-	  cur_total_prob += prob[line][inst];
-	  num_alive ++;
-	}
-      }
-      if (cur_total_prob > 1) {
-	cout << "Total probability at " << line << " is greater than 0." << endl;
-	exit(1);
-      }
-      double left_prob = 1 - cur_total_prob;
-
-      for (int inst = 0; inst < num_insts; ++ inst) {
-	if (alive_mut[line][inst] == true) {
-	  prob_before_env[line][inst] = prob[line][inst] + left_prob / num_alive;
-	} else {
-	  prob_before_env[line][inst] = 0;
-	}	
-      }
-      
-    }
-
-    /////////////////////////////////
-    // Calculate entropy of each line  
-    vector<double> entropy(length_genome, 0.0);
-    for (int line = 0; line < length_genome; ++ line) {
-      double sum = 0;
-      for (int inst = 0; inst < num_insts; ++ inst) {
-	sum += prob_before_env[line][inst];
-	if (prob_before_env[line][inst] > 0) {
-	  entropy[line] -= prob_before_env[line][inst] * log(prob_before_env[line][inst]) / log(num_insts*1.0);
-	}
-      }
-      if (sum > 1.001 || sum < 0.999) {
-	cout << "Sum of probability is not 1 at line " << line << endl;
-	exit(1);
-      }
-    }
-
-
-    /////////////////////////////////////////////////////
-    // Redistribute the probability of insts at each line
-    vector< vector<double> > prob_given_env(length_genome, one_line_prob);
-    
-    for (int line = 0; line < length_genome; ++ line) {
-      double total_prob = 0.0;
-      int num_neutral = 0;
-      for (int inst = 0; inst < num_insts; ++ inst) {
-	if (neutral_mut[line][inst] == true) {
-	  num_neutral ++;
-	  total_prob += prob[line][inst];
-	}
-      }
-
-      double left = 1 - total_prob;
-
-      for (int inst = 0; inst < num_insts; ++ inst) {
-	if (neutral_mut[line][inst] == true) {
-	  prob_given_env[line][inst] = prob[line][inst] + left / num_neutral;
-	} else {
-	  prob_given_env[line][inst] = 0.0;
-	}
-      }
-      
-    }
-
-    ////////////////////////////////////////////////
-    // Calculate the entropy given environment
-
-    vector<double> entropy_given_env(length_genome, 0.0);
-    for (int line = 0; line < length_genome; ++ line) {
-      double sum = 0;
-      for (int inst = 0; inst < num_insts; ++ inst) {
-	sum += prob_given_env[line][inst];
-	if (prob_given_env[line][inst] > 0) {
-	  entropy_given_env[line] -= prob_given_env[line][inst] * log(prob_given_env[line][inst]) / 
-	                             log(num_insts*1.0);
-	}
-      }
-      if (sum > 1.001 || sum < 0.999) {
-	cout << "Sum of probability is not 1 at line " << line << " " << sum << endl;
-	exit(1);
-      }
-    }
-
-
-    ///////////////////////////////////////////////////////////////////////////
-    // Calculate the information between genotype and env given other genotypes
-    double information = 0.0;
-    double entropy_before = 0.0;
-    double entropy_after = 0.0;
-    for (int line = 0; line < length_genome; ++ line) {
-      entropy_before += entropy[line];
-      entropy_after += entropy_given_env[line];
-
-      if (entropy[line] >= entropy_given_env[line]) {
-	information += entropy[line] - entropy_given_env[line];	
-      } else {    // Negative information is because given condition is not related with this genotype  ...
-	
-	// Count the number of insts that can make genotype alive
-	int num_inst_alive = 0;
-	for (int inst = 0; inst < num_insts; ++ inst) {
-	  if (alive_mut[line][inst] == true) {
-	    num_inst_alive ++;
-	  }
-	}
-	
-	double entropy_before = - log(1.0/num_inst_alive) / log(num_insts*1.0);
-	information += entropy_before - entropy_given_env[line];
-	if (information < 0) {
-	  cout << "Negative information at site " << line << endl;
-	  exit(1);
-	}
-      }
-      
-    }
-    complexity += information;
-
-    cpx_fp << entropy_before << " " << entropy_after << " "
-	   << information << " " << complexity << "   ";
-
-    genotype->PrintTasks(cpx_fp, 0, -1);
-    cpx_fp << endl; 
-
-    /////////////////////////////////////////////////////////////
-    // This genotype becomes the given condition of next genotype
-
-    given_genotypes.push_back(genotype);
-    
-  }
-
-  // Set the test CPU back to the state it was 
-  m_world->GetTestCPU().UseResources() = backupUsage;
-  m_world->GetTestCPU().SetupResourceArray(backupResources);
-    
-  cpx_fp.close();
-  return;
-	 
-}
-
-void cAnalyze::AnalyzeCommunityComplexity(cString cur_string)
-{
-  /////////////////////////////////////////////////////////////////////
-  // Calculate the mutual information between community and environment
-  /////////////////////////////////////////////////////////////////////
-
-  cout << "Analyze community complexity of current population about environment with Charles method ...\n";
-
-  // Get the number of genotypes that are gonna be analyzed.
-  int max_genotypes = cur_string.PopWord().AsInt(); // If it is 0, we sample 
-                                                    //two genotypes for each task.
-
-  // Get update
-  int update = cur_string.PopWord().AsInt();
-
-  // Get the directory  
-  cString dir = cur_string.PopWord();
-  cString defaultDir = "community_cpx/";
-  cString directory = PopDirectory(dir, defaultDir);
-
-  // Get the file name that saves the result 
-  cString filename = cur_string.PopWord();
-  if (filename.IsEmpty()) {
-    filename = "community.complexity.dat";
-  }
-
-  filename.Set("%s%s", directory(), filename.GetData());
-  ofstream cpx_fp(filename());
-
-  cpx_fp << "# Legend:" << endl;
-  cpx_fp << "# 1: Genotype ID" << endl;
-  cpx_fp << "# 2: Entropy given Known Genotypes" << endl;
-  cpx_fp << "# 3: Entropy given Both Known Genotypes and Env" << endl;
-  cpx_fp << "# 4: New Information about Environment" << endl;
-  cpx_fp << "# 5: Total Complexity" << endl;
-  cpx_fp << "# 6: Hamming Distance to Closest Given Genotype" << endl;
-  cpx_fp << "# 7: Total Hamming Distance to Closest Neighbor" << endl;
-  cpx_fp << "# 8: Number of Organisms" << endl;
-  cpx_fp << "# 9: Total Number of Organisms" << endl;
-  cpx_fp << "# 10 - : Tasks Implemented" << endl;
-  cpx_fp << endl;
-
-  ///////////////////////
-  // Backup test CPU data
-  bool backupUsage = m_world->GetTestCPU().UseResources();
-  tArray<double> backupResources(m_world->GetTestCPU().GetResources());
-  m_world->GetTestCPU().UseResources() = true;
-  FillResources(update);
-
-  
-  vector<cAnalyzeGenotype *> community;
-  cAnalyzeGenotype * genotype = NULL;
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  
-  
-  if (max_genotypes > 0) {
-    
-    ///////////////////////////////////////////////////////////////////////
-    // Choose the first n most abundant genotypes and put them in community
-    
-    while (((genotype = batch_it.Next()) != NULL) && (community.size() < max_genotypes)) {
-      community.push_back(genotype);
-    }
-  } else if (max_genotypes == 0) {
-    
-    /////////////////////////////////////
-    // Choose two genotypes for each task
-    
-    genotype = batch_it.Next();
-    if (genotype == NULL) {
-      cpx_fp.close();
-      return;
-    }
-    genotype->Recalculate();
-    int num_tasks = genotype->GetNumTasks();
-    vector< vector<cAnalyzeGenotype *> > genotype_class(num_tasks);
-    do {
-      for (int task_id = 0; task_id < num_tasks; ++ task_id) {
-        int count = genotype->GetTaskCount(task_id);
-        if (count > 0) {
-          genotype_class[task_id].push_back(genotype);
-        }
-      }
-    } while ((genotype = batch_it.Next()) != NULL);
-    
-    cRandom random;
-    for (int task_id = 0; task_id < num_tasks; ++ task_id) {
-      int num_genotype = genotype_class[task_id].size();
-      if (num_genotype > 0) {
-        int index = random.GetUInt(num_genotype);
-        community.push_back(genotype_class[task_id][index]);
-        index = random.GetUInt(num_genotype);
-        community.push_back(genotype_class[task_id][index]);
-      } else {
-        // Pick up a class that is not empty
-        int class_id = random.GetUInt(num_tasks);
-        while (genotype_class[class_id].size() == 0) {
-          class_id ++;
-          if (class_id >= num_tasks) {
-            class_id = 0;
-          }
-        }
-        int num_genotype = genotype_class[class_id].size();
-        int index = random.GetUInt(num_genotype);
-        community.push_back(genotype_class[task_id][index]);
-        index = random.GetUInt(num_genotype);
-        community.push_back(genotype_class[task_id][index]);
-      }
-    }
-    
-  }
-  
-  ////////////////////////////////////////////////////
-  // Test point mutation of each genotype in community
-
-  int num_insts = inst_set.GetSize();
-  map<int, tMatrix<double> > point_mut; 
-  int size_community = community.size();
-  int length_genome;
-  if (size_community > 1) {
-    length_genome = community[0]->GetLength();
-  }
-
-  for (int i = 0; i < size_community; ++ i) {
-    genotype = community[i];
-    
-    ///////////////////////////////////////////////////////////////////
-    // Point mutation at all lines of code to look for neutral mutation
-    cout << "Test point mutation for genotype " << genotype->GetID() << endl;
-    tMatrix<double> prob(length_genome, num_insts);
-//     if (verbose == true) {
-//       PrintTestCPUResources("");
-//     }
-
-    genotype->Recalculate();
-    double base_fitness = genotype->GetFitness();
-    const cGenome & base_genome = genotype->GetGenome();
-    cGenome mod_genome(base_genome);
-      
-    for (int line = 0; line < length_genome; ++ line) {
-      int cur_inst = base_genome[line].GetOp();
-      int num_neutral = 0;
-
-      for (int mod_inst = 0; mod_inst < num_insts; ++ mod_inst) {
-	mod_genome[line].SetOp(mod_inst);
-	cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
-	test_genotype.Recalculate();
-	if (test_genotype.GetFitness() >= base_fitness) {
-	  prob[line][mod_inst] = 1.0;
-	  num_neutral ++;
-	} else {
-	  prob[line][mod_inst] = 0.0;
-	}
-      }
-
-      for (int mod_inst = 0; mod_inst < num_insts; ++ mod_inst) {
-	prob[line][mod_inst] /= num_neutral;
-      }
-   
-      
-      mod_genome[line].SetOp(cur_inst);
-    }
-
-    point_mut.insert(make_pair(genotype->GetID(), prob));
-  }
-
-  //////////////////////////////////////
-  // Loop through genotypes in community
-
-  double complexity = 0.0;
-  int total_dist = 0;
-  int total_cpus = 0;
-  vector<cAnalyzeGenotype *> given_genotypes;
-
-  ////////////////////////////////////////
-  // New information in the first gentoype
-  genotype = community[0];
-  double oo_initial_entropy = length_genome;
-  double oo_conditional_entropy = 0.0;
-  tMatrix<double> this_prob = point_mut.find(genotype->GetID())->second;
-
-  for (int line = 0; line < length_genome; ++ line) {
-    double oneline_entropy = 0.0;
-    for (int inst = 0; inst < num_insts; ++ inst) {
-      if (this_prob[line][inst] > 0) {
-	oneline_entropy -= this_prob[line][inst] * (log(this_prob[line][inst]) /
-						    log(1.0*num_insts));
-      }
-    }
-    oo_conditional_entropy += oneline_entropy;
-  }
-
-  double new_info = oo_initial_entropy - oo_conditional_entropy;
-  complexity += new_info;
-  given_genotypes.push_back(genotype);
-
-  cpx_fp << genotype->GetID() << " " 
-	 << oo_initial_entropy << " " 
-	 << oo_conditional_entropy << " "
-	 << new_info << " " 
-	 << complexity << "   "
-	 << "0 0" << "   ";
-  int num_cpus = genotype->GetNumCPUs();
-  total_cpus += num_cpus;
-  cpx_fp << num_cpus << " " << total_cpus << "   ";
-  genotype->Recalculate();
-  genotype->PrintTasks(cpx_fp, 0, -1);
-  cpx_fp << endl;
-
-
-  //////////////////////////////////////////////////////
-  // New information in other genotypes in community ...
-  for (int i = 1; i < size_community; ++ i) {
-    genotype = community[i];
-    if (genotype->GetLength() != length_genome) {
-      cerr << "Genotypes in the community do not same genome length.\n";
-      cpx_fp.close();
-      exit(1);
-    }
-
-    // Skip the dead organisms
-    genotype->Recalculate();
-    cout << genotype->GetID() << " " << genotype->GetFitness() << endl;
-    if (genotype->GetFitness() == 0) {
-      continue;
-    }
-
-    double min_new_info = length_genome; 
-    double oo_initial_entropy, oo_conditional_entropy;
-    cAnalyzeGenotype * used_genotype;
-    tMatrix<double> this_prob = point_mut.find(genotype->GetID())->second;
-
-    // For any given genotype, calculate the new information in genotype
-    for (int j = 0; j < given_genotypes.size(); ++ j) {
-
-      tMatrix<double> given_prob = point_mut.find(given_genotypes[j]->GetID())->second;
-      double new_info = 0.0;
-      double total_initial_entropy = 0.0;
-      double total_conditional_entropy = 0.0;
-
-      for (int line = 0; line < length_genome; ++ line) {
-
-	// H(genotype|known_genotype)    
-	double prob_overlap = 0;
-	for (int inst = 0; inst < num_insts; ++ inst) {
-	  if (this_prob[line][inst] < given_prob[line][inst]) {
-	    prob_overlap += this_prob[line][inst];
-	  } else {
-	    prob_overlap += given_prob[line][inst];
-	  }
-	}
-
-	double given_site_entropy = 0.0;
-	for (int inst = 0; inst < num_insts; ++ inst) {
-	  if (given_prob[line][inst] > 0) {
-	    given_site_entropy -= given_prob[line][inst] * (log(given_prob[line][inst]) /
-							 log(1.0*num_insts));
-	  }
-	}
-	
-
-	double entropy_overlap = 0.0;
-	if (prob_overlap > 0 &&  (1 - prob_overlap > 0)) {
-	  entropy_overlap = (- prob_overlap * log(prob_overlap) 
-			     - (1-prob_overlap) * log(1 - prob_overlap)) / log(1.0*num_insts);
-	} else {
-	  entropy_overlap = 0; 
-	}
-
-	double initial_entropy = prob_overlap * given_site_entropy 
-                             + (1 - prob_overlap) * 1 + entropy_overlap;
-	total_initial_entropy += initial_entropy;
-
-	// H(genotype|E, known_genotype) = H(genotype|Env)
-	double conditional_entropy = 0.0;
-	for (int inst = 0; inst < num_insts; ++ inst) {
-	  if (this_prob[line][inst] > 0) {
-	    conditional_entropy -= this_prob[line][inst] * (log(this_prob[line][inst]) / 
-							    log(1.0*num_insts));
-	  }
-	}
-	total_conditional_entropy += conditional_entropy;
-
-	if (conditional_entropy > initial_entropy + 0.00001) {
-	  cerr << "Negative Information.\n";
-	  cout << line << endl;
-	  for (int inst = 0; inst < num_insts; ++ inst) {
-	    cout << this_prob[line][inst] << " ";
-	  }
-	  cout << endl;
-	  for (int inst = 0; inst < num_insts; ++ inst) {
-	    cout << given_prob[line][inst] << " ";
-	  }
-	  cout << endl;
-
-	  exit(1);
-	}
-
-	new_info += initial_entropy - conditional_entropy;
-      }
-     
-      if (new_info < min_new_info) {
-	min_new_info = new_info;
-	oo_initial_entropy = total_initial_entropy;
-	oo_conditional_entropy = total_conditional_entropy;
-	used_genotype = given_genotypes[j];
-	cout << "        " << "New closest genotype " << used_genotype->GetID() 
-	     << " " << new_info << endl;;
-      }
-
-    }
-    complexity += min_new_info;
-    cpx_fp << genotype->GetID() << " " 
-	   << oo_initial_entropy << " "
-	   << oo_conditional_entropy << " "
-	   << min_new_info << " " << complexity << "   ";
-
-    int hamm_dist = cGenomeUtil::FindHammingDistance(genotype->GetGenome(),
-						     used_genotype->GetGenome());
-    total_dist += hamm_dist;
-    cpx_fp << hamm_dist << " " << total_dist << "   ";
-    
-     int num_cpus = genotype->GetNumCPUs();
-     total_cpus += num_cpus;
-     cpx_fp << num_cpus << " " << total_cpus << "   ";
- 
-    
-    genotype->PrintTasks(cpx_fp, 0, -1);
-    cpx_fp << endl;
-    given_genotypes.push_back(genotype);
-  }
-  
-  
-  // Set the test CPU back to the state it was 
-  m_world->GetTestCPU().UseResources() = backupUsage;
-  m_world->GetTestCPU().SetupResourceArray(backupResources);
-    
-  cpx_fp.close();
-  return;
-
-    
-  
-}
-
-void cAnalyze::CommandLandscape(cString cur_string)
-{
-  if (verbose == true) cout << "Landscaping batch " << cur_batch << endl;
-  else cout << "Landscapping..." << endl;
-  
-  // Load in the variables...
-  cString filename;
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  int dist = 1;
-  if (cur_string.GetSize() != 0) dist = cur_string.PopWord().AsInt();
-  int num_test = 0;
-  if (cur_string.GetSize() != 0) num_test=cur_string.PopWord().AsInt();
-  
-  // If we're given a file, write to it.
-  ofstream & fp = data_file_manager.GetOFStream(filename);
-  
-  // Loop through all of the genotypes in this batch...
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    cLandscape landscape(m_world, genotype->GetGenome(), inst_set);
-    if (num_test == 0) landscape.Process(dist);
-    else landscape.RandomProcess(num_test,dist,num_test,num_test*2);
-    landscape.PrintStats(fp);
-  }
-}
-
-void cAnalyze::AnalyzeEpistasis(cString cur_string)
-{
-  if (verbose == true) cout << "Epistasis on " << cur_batch << endl;
-  else cout << "Calculating epistasis values..." << endl;
-  
-  // Load in the variables...
-  cString filename;
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  int test_num = 1;
-  if (cur_string.GetSize() != 0) test_num = cur_string.PopWord().AsInt();
-  
-  // If we're given a file, write to it.
-  ofstream & fp = data_file_manager.GetOFStream(filename);
-  
-  // Loop through all of the genotypes in this batch...
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    cLandscape landscape(m_world, genotype->GetGenome(), inst_set);
-    if (test_num == 1)  landscape.TestAllPairs(fp);
-    else 		landscape.TestPairs(test_num,fp); 
-    landscape.PrintStats(fp);
-  }
-}
-
-
-// This command will take the current batch and analyze how well organisms
-// cross-over with each other, both across the population and between mates.
-
-void cAnalyze::AnalyzeMateSelection(cString cur_string)
-{
-  int sample_size = 10000;
-  if (cur_string.GetSize() != 0) sample_size = cur_string.PopWord().AsInt();
-  cString filename("none");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  double min_swap_frac = 0.0;
-  if (cur_string.GetSize() != 0) min_swap_frac=cur_string.PopWord().AsDouble();
-  double max_swap_frac = 1.0 - min_swap_frac;
-
-  cout << "Analyzing Mate Selection... " << endl;
-
-  // Do some quick tests before moving on...
-  if (min_swap_frac < 0.0 || min_swap_frac >= 0.5) {
-    cerr << "ERROR: Minimum swap fraction out of range [0.0, 0.5)." << endl;
-  }
-  
-  // Next, we create an array that contains pointers to all of the organisms
-  // in this batch.  Note that we want to select genotypes based on their
-  // abundance, so they will have one entry in the array per organism.  Note
-  // that we only consider viable genotypes.
-
-  // Start by counting the total number of organisms (and do other such
-  // data collection...
-  tHashTable<int, int> mate_id_counts;
-
-  int org_count = 0;
-  int gen_count = 0;
-  cAnalyzeGenotype * genotype = NULL;
-  tListIterator<cAnalyzeGenotype> list_it(batch[cur_batch].List());
-  while ((genotype = list_it.Next()) != NULL) {
-    if (genotype->GetViable() == false || genotype->GetNumCPUs() == 0) {
-      continue;
-    }
-    gen_count++;
-    org_count += genotype->GetNumCPUs();
-
-    // Keep track of how many organisms have each mate id...
-    int mate_id = genotype->GetMateID();
-    int count = 0;
-    mate_id_counts.Find(mate_id, count);
-    count += genotype->GetNumCPUs();
-    mate_id_counts.SetValue(mate_id, count);
-  }
-
-  // Create an array of the correct size.
-  tArray<cAnalyzeGenotype *> genotype_array(org_count);
-
-  // And insert all of the organisms into the array.
-  int cur_pos = 0;
-  while ((genotype = list_it.Next()) != NULL) {
-    if (genotype->GetViable() == false) continue;
-    int cur_count = genotype->GetNumCPUs();
-    for (int i = 0; i < cur_count; i++) {
-      genotype_array[cur_pos++] = genotype;
-    }
-  }
-  
-
-  // Setup some variables to collect statistics.
-  int total_matches_tested = 0;
-  int fail_count = 0;
-  int match_fail_count = 0;
-
-  // Loop through all of the tests, picking random organisms each time and
-  // performing a random cross test.
-  cAnalyzeGenotype * genotype2 = NULL;
-  for (int test_id = 0; test_id < sample_size; test_id++) {
-    genotype = genotype_array[ m_world->GetRandom().GetUInt(org_count) ];
-    genotype2 = genotype_array[ m_world->GetRandom().GetUInt(org_count) ];
-
-    // Stop immediately if we're comparing a genotype to itself.
-    if (genotype == genotype2) {
-      total_matches_tested++;
-      continue;
-    }
-
-    // Setup the random parameters for this test.
-    cCPUMemory test_genome0 = genotype->GetGenome(); 
-    cCPUMemory test_genome1 = genotype2->GetGenome(); 
-
-    double start_frac = -1.0;
-    double end_frac = -1.0;
-    double swap_frac = -1.0;
-    while (swap_frac < min_swap_frac || swap_frac > max_swap_frac) {
-      start_frac = m_world->GetRandom().GetDouble();
-      end_frac = m_world->GetRandom().GetDouble();
-      if (start_frac > end_frac) nFunctions::Swap(start_frac, end_frac);
-      swap_frac = end_frac - start_frac;
-    }
-          
-    int start0 = (int) (start_frac * (double) test_genome0.GetSize());
-    int end0   = (int) (end_frac * (double) test_genome0.GetSize());
-    int size0 = end0 - start0;
-
-    int start1 = (int) (start_frac * (double) test_genome1.GetSize());
-    int end1   = (int) (end_frac * (double) test_genome1.GetSize());
-    int size1 = end1 - start1;
-
-    int new_size0 = test_genome0.GetSize() - size0 + size1;   
-    int new_size1 = test_genome1.GetSize() - size1 + size0;
-
-    // Setup some statistics for this particular test.
-    bool same_mate_id = ( genotype->GetMateID() == genotype2->GetMateID() );
-    if (same_mate_id == true) total_matches_tested++;
-
-    // Don't Crossover if offspring will be illegal!!!
-    if (new_size0 < MIN_CREATURE_SIZE || new_size0 > MAX_CREATURE_SIZE || 
-	new_size1 < MIN_CREATURE_SIZE || new_size1 > MAX_CREATURE_SIZE) { 
-      fail_count++; 
-      if (same_mate_id == true) match_fail_count++;
-      continue; 
-    } 
-
-    // Do the replacement...  We're only going to test genome0, so we only
-    // need to modify that one.
-    cGenome cross1 = cGenomeUtil::Crop(test_genome1, start1, end1);
-    test_genome0.Replace(start0, size0, cross1);
-
-    // Do the test.
-    cCPUTestInfo test_info;
-          
-    // Run each side, and determine viability...
-    m_world->GetTestCPU().TestGenome(test_info, test_genome0);
-    if( test_info.IsViable() == false ) {
-      fail_count++;
-      if (same_mate_id == true) match_fail_count++;
-    }
-  }
-
-  // Do some calculations on the sizes of the mate groups...
-  const int num_mate_groups = mate_id_counts.GetSize();
-
-  // Collect lists on all of the mate groups for the calculations...
-  tList<int> key_list;
-  tList<int> count_list;
-  mate_id_counts.AsLists(key_list, count_list);
-  tListIterator<int> count_it(count_list);
-
-  int max_group_size = 0;
-  double mate_id_entropy = 0.0;
-  while (count_it.Next() != NULL) {
-    int cur_count = *(count_it.Get());
-    double cur_frac = ((double) cur_count) / ((double) org_count);
-    if (cur_count > max_group_size) max_group_size = cur_count;
-    mate_id_entropy -= cur_frac * log(cur_frac);
-  }
-  
-  // Calculate the final answer
-  double fail_frac = (double) fail_count / (double) sample_size;
-  double match_fail_frac =
-    (double) match_fail_count / (double) total_matches_tested;
-  cout << "  ave fraction failed = " << fail_frac << endl
-       << "  ave matches failed = " << match_fail_frac << endl
-       << "  total mate matches = " <<  total_matches_tested
-       << " / " << sample_size<< endl;
-
-  if (filename == "none") return;
-  
-  cDataFile & df = data_file_manager.Get(filename);
-  df.WriteComment( "Mate selection information" );
-  df.WriteTimeStamp();  
-  
-  df.Write(fail_frac,       "Average fraction failed");
-  df.Write(match_fail_frac, "Average fraction of mate matches failed");
-  df.Write(sample_size, "Total number of crossovers tested");
-  df.Write(total_matches_tested, "Number of crossovers with matching mate IDs");
-  df.Write(gen_count, "Number of genotypes in test batch");
-  df.Write(org_count, "Number of organisms in test batch");
-  df.Write(num_mate_groups, "Number of distinct mate IDs");
-  df.Write(max_group_size, "Size of the largest distinct mate ID group");
-  df.Write(mate_id_entropy, "Diversity of mate IDs (entropy)");
-  df.Endl();
-}
-
-  
-void cAnalyze::AnalyzeComplexityDelta(cString cur_string)
-{
-  // This command will examine the current population, and sample mutations
-  // to see what the distribution of complexity changes is.  Only genotypes
-  // with a certain abundance (default=3) will be tested to make sure that
-  // the organism didn't already have hidden complexity due to a downward
-  // step.
-  cout << "Testing complexity delta." << endl;
-  
-  cString filename = "complexity_delta.dat";
-  int num_tests = 10;
-  double copy_mut_prob = m_world->GetConfig().COPY_MUT_PROB.Get();
-  double ins_mut_prob = m_world->GetConfig().DIVIDE_INS_PROB.Get();
-  double del_mut_prob = m_world->GetConfig().DIVIDE_DEL_PROB.Get();
-  int count_threshold = 3;
-  
-  if (cur_string.GetSize() > 0) filename = cur_string.PopWord();
-  if (cur_string.GetSize() > 0) num_tests = cur_string.PopWord().AsInt();
-  if (cur_string.GetSize() > 0) copy_mut_prob = cur_string.PopWord().AsDouble();
-  if (cur_string.GetSize() > 0) ins_mut_prob = cur_string.PopWord().AsDouble();
-  if (cur_string.GetSize() > 0) del_mut_prob = cur_string.PopWord().AsDouble();
-  if (cur_string.GetSize() > 0) count_threshold = cur_string.PopWord().AsInt();
-  
-  if (verbose == true) {
-    cout << "...using:"
-    << " filename='" << filename << "'"
-    << " num_tests=" << num_tests
-    << " copy_mut_prob=" << copy_mut_prob
-    << " ins_mut_prob=" << ins_mut_prob
-    << " del_mut_prob=" << del_mut_prob
-    << " count_threshold=" << count_threshold
-    << endl;
-  }
-  
-  // Create an array of all of the genotypes above threshold.
-  cAnalyzeGenotype * genotype = NULL;
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  
-  // Loop through all genotypes to perform a census
-  int org_count = 0;
-  while ((genotype = batch_it.Next()) != NULL) {
-    // Only count genotypes above threshold
-    if (genotype->GetNumCPUs() >= count_threshold) { 
-      org_count += genotype->GetNumCPUs();
-    }
-  } 
-  
-  // Create an array to store pointers to the genotypes and fill it in.
-  tArray<cAnalyzeGenotype *> org_array(org_count);
-  int cur_org = 0;
-  batch_it.Reset();
-  while ((genotype = batch_it.Next()) != NULL) {
-    // Ignore genotypes below threshold.
-    if (genotype->GetNumCPUs() < count_threshold) continue;
-    
-    // Insert the remaining genotypes into the array.
-    for (int i = 0; i < genotype->GetNumCPUs(); i++) {
-      org_array[cur_org] = genotype;
-      cur_org++;
-    }
-  }
-  
-  // Open up the file and prepare it for output.
-  cDataFile & df = data_file_manager.Get(filename);
-  df.WriteComment( "An analyze of expected complexity changes between parent and offspring" );
-  df.WriteTimeStamp();  
-  
-  // Next check the appropriate number of organisms, perform mutations, and
-  // store the results.
-  for (int cur_test = 0; cur_test < num_tests; cur_test++) {
-    // Pick the genotype to test.
-    int test_org_id = m_world->GetRandom().GetInt(org_count);
-    genotype = org_array[test_org_id];
-    
-    // Create a copy of the genome.
-    cCPUMemory mod_genome = genotype->GetGenome();
-    
-    if (copy_mut_prob == 0.0 &&
-        ins_mut_prob == 0.0 &&
-        del_mut_prob == 0.0) {
-      cerr << "ERROR: All mutation rates are zero!  No complexity delta analysis possible." << endl;
-      return;
-    }
-    
-    // Perform the per-site mutations -- we are going to keep looping until
-    // we trigger at least one mutation.
-    int num_mutations = 0;
-    while (num_mutations == 0) {
-      if (copy_mut_prob > 0.0) {
-        for (int i = 0; i < mod_genome.GetSize(); i++) {
-          if (m_world->GetRandom().P(copy_mut_prob)) {
-            mod_genome[i] = inst_set.GetRandomInst();
-            num_mutations++;
-          }
-        }
-      }
-      
-      // Perform an Insertion if it has one.
-      if (m_world->GetRandom().P(ins_mut_prob)) {
-        int ins_line = m_world->GetRandom().GetInt(mod_genome.GetSize() + 1);
-        mod_genome.Insert(ins_line, inst_set.GetRandomInst());
-        num_mutations++;
-      }
-      
-      // Perform a Deletion if it has one.
-      if (m_world->GetRandom().P(del_mut_prob)) {
-        int del_line = m_world->GetRandom().GetInt(mod_genome.GetSize());
-        mod_genome.Remove(del_line);
-        num_mutations++;
-      }
-    }
-    
-    // Calculate the complexities....
-    genotype->Recalculate();
-    double start_complexity = genotype->GetComplexity();
-    double start_fitness = genotype->GetFitness();
-    int start_length = genotype->GetLength();
-    int start_gest = genotype->GetGestTime();
-    
-    cAnalyzeGenotype new_genotype(m_world, mod_genome, inst_set);
-    new_genotype.Recalculate();
-    double end_complexity = new_genotype.GetComplexity();
-    double complexity_change = end_complexity - start_complexity;
-    double end_fitness = new_genotype.GetFitness();
-    int end_length = new_genotype.GetLength();
-    int end_gest = new_genotype.GetGestTime();
-    
-    df.Write(num_mutations, "Number of mutational differences between original organism and mutant.");
-    df.Write(complexity_change, "Complexity difference between original organism and mutant.");
-    df.Write(start_complexity, "Complexity of initial organism.");
-    df.Write(end_complexity, "Complexity of mutant.");
-    df.Write(start_fitness, "Fitness of initial organism.");
-    df.Write(end_fitness, "Fitness of mutant.");
-    df.Write(start_length, "Length of initial organism.");
-    df.Write(end_length, "Length of mutant.");
-    df.Write(start_gest, "Gestation Time of initial organism.");
-    df.Write(end_gest, "Gestation Time of mutant.");
-    df.Write(genotype->GetID(), "ID of initial genotype.");
-    df.Endl();
-  }
-}
-
-void cAnalyze::AnalyzeKnockouts(cString cur_string)
-{
-  cout << "Analyzing the effects of knockouts..." << endl;
-  
-  cString filename = "knockouts.dat";
-  if (cur_string.GetSize() > 0) filename = cur_string.PopWord();
-  
-  int max_knockouts = 1;
-  if (cur_string.GetSize() > 0) max_knockouts = cur_string.PopWord().AsInt();
-  
-  // Open up the data file...
-  cDataFile & df = data_file_manager.Get(filename);
-  df.WriteComment( "Analysis of knockouts in genomes" );
-  df.WriteTimeStamp();  
-  
-  
-  // Setup a NULL instruction in a special inst set.
-  cInstSet ko_inst_set(inst_set);
-  // Locate the instruction corresponding to "NULL" in the instruction library.
-  {
-    cInstruction lib_null_inst = ko_inst_set.GetInstLib()->GetInst("NULL");
-    if (lib_null_inst == ko_inst_set.GetInstLib()->GetInstError()) {
-      cout << "<cAnalyze::AnalyzeKnockouts> got error:" << endl
-      << "  instruction 'NULL' not in current hardware type" << endl;
-      exit(1);
-    }
-    // Add mapping to located instruction. 
-    ko_inst_set.Add2(lib_null_inst.GetOp());
-  }
-  const cInstruction null_inst = ko_inst_set.GetInst("NULL");
-  
-  // Loop through all of the genotypes in this batch...
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    if (verbose == true) cout << "  Knockout: " << genotype->GetName() << endl;
-    
-    // Calculate the stats for the genotype we're working with...
-    genotype->Recalculate();
-    const double base_fitness = genotype->GetFitness();
-    
-    const int max_line = genotype->GetLength();
-    const cGenome & base_genome = genotype->GetGenome();
-    cGenome mod_genome(base_genome);
-    
-    // Loop through all the lines of code, testing the removal of each.
-    int dead_count = 0;
-    int neg_count = 0;
-    int neut_count = 0;
-    int pos_count = 0;
-    for (int line_num = 0; line_num < max_line; line_num++) {
-      // Save a copy of the current instruction and replace it with "NULL"
-      int cur_inst = base_genome[line_num].GetOp();
-      mod_genome[line_num] = null_inst;
-      cAnalyzeGenotype ko_genotype(m_world, mod_genome, ko_inst_set);
-      ko_genotype.Recalculate();
-      
-      double ko_fitness = ko_genotype.GetFitness();
-      if (ko_fitness == 0.0) dead_count++;
-      else if (ko_fitness < base_fitness) neg_count++;
-      else if (ko_fitness == base_fitness) neut_count++;
-      else if (ko_fitness > base_fitness) pos_count++;
-      else cerr << "ERROR: illegal state in AnalyzeKnockouts()" << endl;
-      
-      // Reset the mod_genome back to the original sequence.
-      mod_genome[line_num].SetOp(cur_inst);
-    }
-    
-    df.Write(genotype->GetID(), "Genotype ID");
-    df.Write(dead_count, "Count of lethal knockouts");
-    df.Write(neg_count,  "Count of detrimental knockouts");
-    df.Write(neut_count, "Count of neutral knockouts");
-    df.Write(pos_count,  "Count of beneficial knockouts");
-    df.Endl();
-  }
-}
-
-
-void cAnalyze::CommandFitnessMatrix(cString cur_string)
-{
-  if (verbose == true) cout << "Calculating fitness matrix for batch " << cur_batch << endl;
-  else cout << "Calculating fitness matrix..." << endl;
-  
-  cout << "Warning: considering only first genotype of the batch!" << endl;
-  
-  // Load in the variables...
-  int depth_limit = 4;
-  if (cur_string.GetSize() != 0) depth_limit = cur_string.PopWord().AsInt();
-  
-  double fitness_threshold_ratio = .9;
-  if (cur_string.GetSize() != 0) fitness_threshold_ratio = cur_string.PopWord().AsDouble();
-  
-  int ham_thresh  = 1;
-  if (cur_string.GetSize() != 0) ham_thresh = cur_string.PopWord().AsInt();
-  
-  double error_rate_min = 0.005;
-  if (cur_string.GetSize() != 0) error_rate_min = cur_string.PopWord().AsDouble();
-  
-  double error_rate_max = 0.05;
-  if (cur_string.GetSize() != 0) error_rate_max = cur_string.PopWord().AsDouble();
-  
-  double error_rate_step = 0.005;
-  if (cur_string.GetSize() != 0) error_rate_step = cur_string.PopWord().AsDouble();
-  
-  double vect_fmax = 1.1;
-  if (cur_string.GetSize() != 0) vect_fmax = cur_string.PopWord().AsDouble();
-  
-  double vect_fstep = .1;
-  if (cur_string.GetSize() != 0) vect_fstep = cur_string.PopWord().AsDouble();
-  
-  int diag_iters = 200;
-  if (cur_string.GetSize() != 0) diag_iters = cur_string.PopWord().AsInt();
-  
-  int write_ham_vector = 0;
-  if (cur_string.GetSize() != 0) write_ham_vector = cur_string.PopWord().AsInt();
-  
-  int write_full_vector = 0;
-  if (cur_string.GetSize() != 0) write_full_vector = cur_string.PopWord().AsInt();
-  
-  // Consider only the first genotypes in this batch...
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = batch_it.Next();
-  
-  cFitnessMatrix matrix(m_world, genotype->GetGenome(), &inst_set);
-  
-  matrix.CalcFitnessMatrix( depth_limit, fitness_threshold_ratio, ham_thresh, error_rate_min, error_rate_max, error_rate_step, vect_fmax, vect_fstep, diag_iters, write_ham_vector, write_full_vector );
-}
-
-
-void cAnalyze::CommandMapTasks(cString cur_string)
-{
-  cout << "Constructing genotype-phenotype maps..." << endl;
-  
-  // Load in the variables...
-  cString directory = PopDirectory(cur_string, "phenotype/");
-  int print_mode = 0;   // 0=Normal, 1=Boolean results
-  int file_type = FILE_TYPE_TEXT;
-  
-  // HTML special flags...
-  bool link_maps = false;  // Should muliple maps be linked together?
-  bool link_insts = false; // Should links be made to instruction descs?
-  
-  // Collect any other format information needed...
-  tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
-  tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-  
-  cStringList arg_list(cur_string);
-  
-  cout << "Found " << arg_list.GetSize() << " args." << endl;
-  
-  // Check for some command specific variables.
-  if (arg_list.PopString("0") != "") print_mode = 0;
-  if (arg_list.PopString("1") != "") print_mode = 1;
-  if (arg_list.PopString("text") != "") file_type = FILE_TYPE_TEXT;
-  if (arg_list.PopString("html") != "") file_type = FILE_TYPE_HTML;
-  if (arg_list.PopString("link_maps") != "") link_maps = true;
-  if (arg_list.PopString("link_insts") != "") link_insts = true;
-  
-  cout << "There are " << arg_list.GetSize() << " column args." << endl;
-  
-  LoadGenotypeDataList(arg_list, output_list);
-  
-  cout << "Args are loaded." << endl;
-  
-  const int num_cols = output_list.GetSize();
-  
-  // Give some information in verbose mode.
-  if (verbose == true) {
-    cout << "  outputing as ";
-    if (print_mode == 1) cout << "boolean ";
-    if (file_type == FILE_TYPE_TEXT) {
-      cout << "text files." << endl;
-    } else { // if (file_type == FILE_TYPE_HTML) {
-      cout << "HTML files";
-      if (link_maps == true) cout << "; linking files together";
-      if (link_maps == true) cout << "; linking inst names to descs";
-      cout << "." << endl;
-    }
-    cout << "  Format: ";
-    
-    output_it.Reset();
-    while (output_it.Next() != NULL) {
-      cout << output_it.Get()->GetName() << " ";
-    }
-    cout << endl;
-  }
-  
-  
-  ///////////////////////////////////////////////////////
-  // Loop through all of the genotypes in this batch...
-  
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    if (verbose == true) cout << "  Mapping " << genotype->GetName() << endl;
-    
-    // Construct this filename...
-    cString filename;
-    if (file_type == FILE_TYPE_TEXT) {
-      filename.Set("%stasksites.%s.dat", directory(), genotype->GetName()());
-    } else {   //  if (file_type == FILE_TYPE_HTML) {
-      filename.Set("%stasksites.%s.html", directory(), genotype->GetName()());
-    }
-    ofstream fp(filename());
-    
-    // Construct linked filenames...
-    cString next_file("");
-    cString prev_file("");
-    if (link_maps == true) {
-      // Check the next genotype on the list...
-      if (batch_it.Next() != NULL) {
-        next_file.Set("tasksites.%s.html", batch_it.Get()->GetName()());
-      }
-      batch_it.Prev();  // Put the list back where it was...
-      
-      // Check the previous genotype on the list...
-      if (batch_it.Prev() != NULL) {
-        prev_file.Set("tasksites.%s.html", batch_it.Get()->GetName()());
-      }
-      batch_it.Next();  // Put the list back where it was...
-    }
-    
-    // Calculate the stats for the genotype we're working with...
-    genotype->Recalculate();
-    
-    // Headers...
-    if (file_type == FILE_TYPE_TEXT) {
-      fp << "-1 "  << batch[cur_batch].Name() << " "
-      << genotype->GetID() << " ";
-      
-      tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
-      while ((data_command = output_it.Next()) != NULL) {
-        data_command->SetTarget(genotype);
-        fp << data_command->GetEntry() << " ";
-      }
-      fp << endl;
-      
-    } else { // if (file_type == FILE_TYPE_HTML) {
-             // Mark file as html
-      fp << "<html>" << endl;
-      
-      // Setup any javascript macros needed...
-      fp << "<head>" << endl;
-      if (link_insts == true) {
-        fp << "<script language=\"javascript\">" << endl
-        << "function Inst(inst_name)" << endl
-        << "{" << endl
-        << "var filename = \"help.\" + inst_name + \".html\";" << endl
-        << "newwin = window.open(filename, 'Instruction', "
-        << "'toolbar=0,status=0,location=0,directories=0,menubar=0,"
-        << "scrollbars=1,height=150,width=300');" << endl
-        << "newwin.focus();" << endl
-        << "}" << endl
-        << "</script>" << endl;
-      }
-      fp << "</head>" << endl;
-      
-      // Setup the body...
-      fp << "<body bgcolor=\"#FFFFFF\"" << endl
-        << " text=\"#000000\"" << endl
-        << " link=\"#0000AA\"" << endl
-        << " alink=\"#0000FF\"" << endl
-        << " vlink=\"#000044\">" << endl
-        << endl
-        << "<h1 align=center>Run " << batch[cur_batch].Name()
-        << ", ID " << genotype->GetID() << "</h1>" << endl
-        << "<center>" << endl
-        << endl;
-      
-      // Links?
-      fp << "<table width=90%><tr><td align=left>";
-      if (prev_file != "") fp << "<a href=\"" << prev_file << "\">Prev</a>";
-      else fp << "&nbsp;";
-      fp << "<td align=right>";
-      if (next_file != "") fp << "<a href=\"" << next_file << "\">Next</a>";
-      else fp << "&nbsp;";
-      fp << "</tr></table>" << endl;
-      
-      // The table
-      fp << "<table border=1 cellpadding=2>" << endl;
-      
-      // The headings...///
-      fp << "<tr><td colspan=3> ";
-      output_it.Reset();
-      while (output_it.Next() != NULL) {
-        fp << "<th>" << output_it.Get()->GetDesc() << " ";
-      }
-      fp << "</tr>" << endl;
-      
-      // The base creature...
-      fp << "<tr><th colspan=3>Base Creature";
-      tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
-      cAnalyzeGenotype null_genotype(m_world, "a", inst_set);
-      while ((data_command = output_it.Next()) != NULL) {
-        data_command->SetTarget(genotype);
-        genotype->SetSpecialArgs(data_command->GetArgs());
-        if (data_command->Compare(&null_genotype) > 0) {
-          fp << "<th bgcolor=\"#00FF00\">";
-        }
-        else  fp << "<th bgcolor=\"#FF0000\">";
-        
-        if (data_command->HasArg("blank") == true) fp << "&nbsp;" << " ";
-        else fp << data_command->GetEntry() << " ";
-      }
-      fp << "</tr>" << endl;
-    }
-    
-    
-    const int max_line = genotype->GetLength();
-    const cGenome & base_genome = genotype->GetGenome();
-    cGenome mod_genome(base_genome);
-    
-    // Keep track of the number of failues/successes for attributes...
-    int * col_pass_count = new int[num_cols];
-    int * col_fail_count = new int[num_cols];
-    for (int i = 0; i < num_cols; i++) {
-      col_pass_count[i] = 0;
-      col_fail_count[i] = 0;
-    }
-    
-    cInstSet map_inst_set(inst_set);
-    // Locate instruction corresponding to "NULL" in the instruction library.
-    {
-      const cInstruction inst_lib_null_inst = map_inst_set.GetInstLib()->GetInst("NULL");
-      if(inst_lib_null_inst == map_inst_set.GetInstLib()->GetInstError()){
-        cout << "<cAnalyze::CommandMapTasks> got error:" << endl;
-        cout << " --- instruction \"NULL\" isn't in the instruction library for the" << endl;
-        cout << " --- current hardware type." << endl;
-        exit(1);
-      }
-      // Add mapping to located instruction. 
-      map_inst_set.Add2(inst_lib_null_inst.GetOp());
-    }
-    const cInstruction null_inst = map_inst_set.GetInst("NULL");
-    
-    // Loop through all the lines of code, testing the removal of each.
-    for (int line_num = 0; line_num < max_line; line_num++) {
-      int cur_inst = base_genome[line_num].GetOp();
-      char cur_symbol = base_genome[line_num].GetSymbol();
-      
-      mod_genome[line_num] = null_inst;
-      cAnalyzeGenotype test_genotype(m_world, mod_genome, map_inst_set);
-      test_genotype.Recalculate();
-      
-      if (file_type == FILE_TYPE_HTML) fp << "<tr><td align=right>";
-      fp << (line_num + 1) << " ";
-      if (file_type == FILE_TYPE_HTML) fp << "<td align=center>";
-      fp << cur_symbol << " ";
-      if (file_type == FILE_TYPE_HTML) fp << "<td align=center>";
-      if (link_insts == true) {
-        fp << "<a href=\"javascript:Inst('"
-        << map_inst_set.GetName(cur_inst)
-        << "')\">";
-      }
-      fp << map_inst_set.GetName(cur_inst) << " ";
-      if (link_insts == true) fp << "</a>";
-      
-      
-      // Print the individual columns...
-      output_it.Reset();
-      tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
-      int cur_col = 0;
-      while ((data_command = output_it.Next()) != NULL) {
-        data_command->SetTarget(&test_genotype);
-        test_genotype.SetSpecialArgs(data_command->GetArgs());
-        int compare = data_command->Compare(genotype);
-        if (file_type == FILE_TYPE_HTML) {
-          data_command->HTMLPrint(fp, compare,
-                                  !(data_command->HasArg("blank")));
-        } 
-        else fp << data_command->GetEntry() << " ";
-        
-        if (compare == -2) col_fail_count[cur_col]++;
-        else if (compare == 2) col_pass_count[cur_col]++;
-        cur_col++;
-      }
-      if (file_type == FILE_TYPE_HTML) fp << "</tr>";
-      fp << endl;
-      
-      // Reset the mod_genome back to the original sequence.
-      mod_genome[line_num].SetOp(cur_inst);
-    }
-    
-    
-    // Construct the final line of the table with all totals...
-    if (file_type == FILE_TYPE_HTML) {
-      fp << "<tr><th colspan=3>Totals";
-      
-      for (int i = 0; i < num_cols; i++) {
-        if (col_pass_count[i] > 0) {
-          fp << "<th bgcolor=\"#00FF00\">" << col_pass_count[i];
-        }
-        else if (col_fail_count[i] > 0) {
-          fp << "<th bgcolor=\"#FF0000\">" << col_fail_count[i];
-        }
-        else fp << "<th>0";
-      }
-      fp << "</tr>" << endl;
-      
-      // And close everything up...
-      fp << "</table>" << endl
-        << "</center>" << endl;
-    }
-    
-    delete [] col_pass_count;
-    delete [] col_fail_count;
-  }
-}
-
-void cAnalyze::CommandAverageModularity(cString cur_string)
-{
-  cout << "Average Modularity calculations" << endl;
-  
-  // Load in the variables...
-  cString filename = cur_string.PopWord();
-  //    cString filename = "average.dat";
-  
-  int print_mode = 0;   // 0=Normal, 1=Boolean results
-  
-  // Collect any other format information needed...
-  tList< tDataEntryCommand<cAnalyzeGenotype> > output_list;
-  tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list);
-  
-  cStringList arg_list(cur_string);
-  
-  cout << "Found " << arg_list.GetSize() << " args." << endl;
-  
-  // Check for some command specific variables.
-  if (arg_list.PopString("0") != "") print_mode = 0;
-  if (arg_list.PopString("1") != "") print_mode = 1;
-  
-  cout << "There are " << arg_list.GetSize() << " column args." << endl;
-  
-  LoadGenotypeDataList(arg_list, output_list);
-  
-  cout << "Args are loaded." << endl;
-  
-  const int num_cols = output_list.GetSize();
-  
-  // Give some information in verbose mode.
-  if (verbose == true) {
-    cout << "  outputing as ";
-    if (print_mode == 1) cout << "boolean ";
-    cout << "text files." << endl;
-    cout << "  Format: ";
-    
-    output_it.Reset();
-    while (output_it.Next() != NULL) {
-      cout << output_it.Get()->GetName() << " ";
-    }
-    cout << endl;
-  }
-  
-  ofstream & fp = data_file_manager.GetOFStream(filename);
-  
-  // printing the headers
-  // not done by default since many dumps may be analyzed at the same time
-  // and results would be put in the same file
-  if (arg_list.GetSize()==0) {
-    // Headers
-    fp << "# Avida analyze modularity data" << endl;
-    fp << "# 1: organism length" << endl;
-    fp << "# 2: number of tasks done" << endl;
-    fp << "# 3: number of sites used in tasks" << endl;
-    fp << "# 4: proportion of sites used in tasks" << endl;
-    fp << "# 5: average number of tasks done per site" << endl;
-    fp << "# 6: average number sites per task done" << endl;
-    fp << "# 7: average number tasks per site per task" << endl;
-    fp << "# 8: average proportion of the non-overlaping region of a task" << endl;
-    fp << "# 9-17: average StDev in positions used for task 1-9" << endl;
-    fp << "# 18-26: average number of sites necessary for each of the tasks" << endl;
-    fp << "# 27-36: number of sites involved in 0-9 tasks" << endl;
-    fp << "# 37-45: average task length (distance from first to last inst used)" << endl;
-    fp << endl;
-    return;
-  }        
-  
-  // initialize various variables used in calculations
-  
-  int num_orgs = 0;		// number of organisms in the dump
-  
-  double  av_length = 0; 	// average organism length
-  double  av_task = 0; 	// average # of tasks done
-  double  av_inst = 0; 	// average # instructions used in tasks
-  double  av_inst_len = 0; 	// proportion of sites used for tasks
-  double  av_site_task = 0; 	// average number of sites per task
-  double  av_task_site = 0;   // average number of tasks per site
-  double  av_t_s_norm = 0;	// average number of tasks per site per task
-  double  av_task_overlap = 0; // average overlap between tasks
-  
-  // average StDev in positions used for a task
-  tArray<double> std_task_position(num_cols);
-  std_task_position.SetAll(0.0);
-  
-  // # of organisms actually doing a task
-  tArray<double> org_task(num_cols);
-  org_task.SetAll(0.0);
-  
-  // av. # of sites necessary for each of the tasks
-  tArray<double> av_num_inst(num_cols);
-  av_num_inst.SetAll(0.0);
-  
-  // number of sites involved in 0-9 tasks 
-  tArray<double> av_inst_task(num_cols+1);
-  av_inst_task.SetAll(0.0);
-  
-  // av. # task length (distance from first to last site used)
-  tArray<double> av_task_length(num_cols);
-  av_task_length.SetAll(0.0);
-  
-  
-  ///////////////////////////////////////////////////////
-  // Loop through all of the genotypes in this batch...
-  ///////////////////////////////////////////////////////
-  
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  
-  // would like to test oly the viable ones, but they can be non-viable
-  // and still reproduce and do tasks
-  // while ((genotype = batch_it.Next()) != NULL && genotype->GetViable()) {
-  while ((genotype = batch_it.Next()) != NULL) {
-    
-    int num_cpus = genotype->GetNumCPUs();
-    
-    if (verbose == true) cout << "  Mapping " << genotype->GetName() << endl;
-    
-    // Calculate the stats for the genotype we're working with...
-    genotype->Recalculate();
-    
-    // Check if the organism does any tasks. 
-    int does_tasks = 0;
-    for (int i = 0; i < num_cols; i++) {
-      if (genotype->GetTaskCount(i) > 0)  does_tasks = 1;
-    }
-    
-    // Don't calculate the modularity if the organism doesn't reproduce
-    // i.e. if the fitness is 0 
-    if (genotype->GetFitness() != 0 && does_tasks != 0) {
-      num_orgs = num_orgs + num_cpus;
-      
-      const int max_line = genotype->GetLength();
-      const cGenome & base_genome = genotype->GetGenome();
-      cGenome mod_genome(base_genome);
-      
-      // Create and initialize the modularity matrix
-      tMatrix<int> mod_matrix(num_cols, max_line);
-      mod_matrix.SetAll(0);
-      
-      // Create and initialize the task overalp matrix
-      tMatrix<int> task_overlap(num_cols, num_cols);
-      task_overlap.SetAll(0);
-      
-      // Create an initialize the counters for modularity
-      tArray<int> num_task(max_line); // number of tasks instruction is used in
-      tArray<int> num_inst(num_cols); // number of instructions involved in a task
-      tArray<int> sum(num_cols); 	    // helps with StDev calculations
-      tArray<int> sumsq(num_cols);    // helps with StDev calculations
-      tArray<int> inst_task(num_cols+1); // # of inst's involved in 0,1,2,3... tasks
-      tArray<int> task_length(num_cols);    // ditance between first and last inst involved in a task
-      
-      num_task.SetAll(0);
-      num_inst.SetAll(0);
-      sum.SetAll(0);
-      sumsq.SetAll(0);
-      inst_task.SetAll(0);
-      task_length.SetAll(0);
-      
-      int total_task = 0;        // total number of tasks done
-      int total_inst = 0;        // total number of instructions involved in tasks
-      int total_all = 0;         // sum of mod_matrix
-      double sum_task_overlap = 0;// task overlap for for this geneome
-        
-        cInstSet map_inst_set(inst_set);
-        
-        // Locate instruction corresponding to "NULL" in the instruction library.
-        {
-          const cInstruction inst_lib_null_inst = map_inst_set.GetInstLib()->GetInst("NULL");
-          if(inst_lib_null_inst == map_inst_set.GetInstLib()->GetInstError()){
-            cout << "<cAnalyze::CommandMapTasks> got error:" << endl;
-            cout << " --- instruction \"NULL\" isn't in the instruction library;" << endl;
-            cout << " --- get somebody to map a function to \"NULL\" in the library." << endl;
-            cout << " --- (probably to class method \"cHardware-of-some-type::initInstLib\"" << endl;
-            cout << " --- in file named \"cpu/hardware-of-some-type.cc\".)" << endl;
-            cout << " --- bailing-out." << endl;
-            exit(1);
-          }
-          // Add mapping to located instruction. 
-          map_inst_set.Add2(inst_lib_null_inst.GetOp());
-        }
-        const cInstruction null_inst = map_inst_set.GetInst("NULL");
-        
-        // Loop through all the lines of code, testing the removal of each.
-        for (int line_num = 0; line_num < max_line; line_num++) {
-          int cur_inst = base_genome[line_num].GetOp();
-          
-          mod_genome[line_num] = null_inst;
-          cAnalyzeGenotype test_genotype(m_world, mod_genome, map_inst_set);
-          cAnalyzeGenotype old_genotype(m_world, base_genome, map_inst_set);
-          test_genotype.Recalculate();
-          
-          // Print the individual columns...
-          output_it.Reset();
-          tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
-          int cur_col = 0;
-          while ((data_command = output_it.Next()) != NULL) {
-            data_command->SetTarget(&test_genotype);
-            test_genotype.SetSpecialArgs(data_command->GetArgs());
-            // This is done so that under 'binary' option it marks
-            // the task as being influenced by the mutation iff
-            // it is completely knocked out, not just decreased
-            genotype->SetSpecialArgs(data_command->GetArgs());
-            
-            int compare = data_command->Compare(genotype);
-            
-            // If knocking out an instruction stops the expression of a
-            // particular task, mark that in the modularity matrix
-            // and add it to two counts
-            // Only do the checking if the test_genotype replicate, i.e.
-            // if it's fitness is not zeros
-            
-            if (compare < 0  && test_genotype.GetFitness() != 0) {
-              mod_matrix(cur_col,line_num) = 1;
-              num_inst[cur_col]++;
-              num_task[line_num]++;
-            }
-            cur_col++;
-          }
-          
-          // Reset the mod_genome back to the original sequence.
-          mod_genome[line_num].SetOp(cur_inst);
-        } // end of genotype-phenotype mapping for a single organism
-        
-        for (int i = 0; i < num_cols; i++) {if (num_inst[i] != 0) total_task++;}
-        for (int i = 0; i < max_line; i++) {if (num_task[i] != 0) total_inst++;}
-        for (int i = 0; i < num_cols; i++) {total_all = total_all + num_inst[i];}
-        
-        // Add the values to the av_ variables, used for calculating the average
-        // in order to weigh them by abundance, multiply everything by num_cpus
-        
-        av_length = av_length + max_line*num_cpus;
-        av_task = av_task + total_task*num_cpus;
-        av_inst = av_inst + total_inst*num_cpus;
-        av_inst_len = av_inst_len + (double) total_inst*num_cpus/max_line;
-        
-        if (total_task !=0)  av_site_task = av_site_task + num_cpus * (double) total_all/total_task; 
-        if (total_inst !=0)  av_task_site = av_task_site + num_cpus * (double) total_all/total_inst; 
-        if (total_inst !=0 && total_task !=0) {
-          av_t_s_norm = av_t_s_norm + num_cpus * (double) total_all/(total_inst*total_task); 
-        }
-        
-        for (int i = 0; i < num_cols; i++) { 
-          if (num_inst[i] > 0) {
-            av_num_inst[i] = av_num_inst[i] + num_inst[i] * num_cpus;
-            org_task[i] = org_task[i] + num_cpus;   // count how many are actually doing the task
-          }
-        }	
-        
-        // calculate average task overlap
-        // first construct num_task x num_task matrix with number of sites overlapping
-        for (int i = 0; i < max_line; i++) {
-          for (int j = 0; j < num_cols; j++) {
-            for (int k = j; k < num_cols; k++) {
-              if (mod_matrix(j,i)>0 && mod_matrix(k,i)>0) {
-                task_overlap(j,k)++;
-                if (j!=k) task_overlap(k,j)++;
-              }               
-            }
-          }
-        }
-        
-        // go though the task_overlap matrix, add and average everything up. 
-        if (total_task > 1) {
-          for (int i = 0; i < num_cols; i++) {
-            double overlap_per_task = 0;                 
-            for (int j = 0; j < num_cols; j++) {
-              if (i!=j) {overlap_per_task = overlap_per_task + task_overlap(i,j);}
-            }
-            if (task_overlap(i,i) !=0){
-              sum_task_overlap = sum_task_overlap + overlap_per_task / (task_overlap(i,i) * (total_task-1));   
-            }
-          }
-        }
-        
-        // now, divide that by number of tasks done and add to the grand sum, weigthed by num_cpus 
-        if (total_task!=0) {
-          av_task_overlap = av_task_overlap + num_cpus * (double) sum_task_overlap/total_task ;
-        }
-        // calculate the first/last postion of a task, the task "spread"
-        // starting from the top look for the fist command that matters for a task
-        
-        for (int i = 0; i < num_cols; i++) { 
-          int j = 0; 
-          while (j < max_line) {
-            if (mod_matrix(i,j) > 0 && task_length[i] == 0 ) {
-              task_length[i] = j;
-              break;
-            }
-            j++;
-          }
-        }
-        
-        // starting frm the bottom look for the last command that matters for a task
-        // and substract it from the first to get the task length
-        // add one in order to account for both the beginning and the end instruction
-        for (int i = 0; i < num_cols; i++) { 
-          int j = max_line - 1; 
-          while (j > -1) {
-            if (mod_matrix(i,j) > 0) {
-              task_length[i] = j - task_length[i] + 1;
-              break;
-            }
-            j--;
-          }
-        }
-        // add the task lengths to the average for the batch
-        // weigthed by the number of cpus for that genotype 
-        for (int i = 0; i < num_cols; i++) { 
-          av_task_length[i] = av_task_length[i] +  num_cpus * task_length[i];
-        }
-        
-        // calculate the Standard Deviation in the mean position of the task
-        for (int i = 0; i < num_cols; i++) { 
-          for (int j = 0; j < max_line; j++) { 
-            if (mod_matrix(i,j)>0) sum[i] = sum[i] + j;
-          }		
-        }
-        
-        double temp = 0;
-        for (int i = 0; i < num_cols; i++) {
-          if (num_inst[i]>1) { 
-            double av_sum = sum[i]/num_inst[i];
-            for (int j = 0; j < max_line; j++) {
-              if (mod_matrix(i,j)>0) temp = (av_sum - j)*(av_sum - j);
-            }
-            std_task_position[i] = std_task_position[i] + sqrt(temp/(num_inst[i]-1))*num_cpus;
-          } 
-        } 
-        
-        for (int i = 0; i < max_line; i++) { inst_task[num_task[i]]++ ;}
-        for (int i = 0; i < num_cols+1; i++) { av_inst_task[i] = av_inst_task[i] + inst_task[i] * num_cpus;}
-        
-    }
-  }  // this is the end of the loop going though all the organisms
-  
-  // make sure there are some organisms doing task in this batch
-  // if not, return all zeros
-  
-  if (num_orgs != 0) { 
-    fp << (double) av_length/num_orgs  << " ";  	// 1: average length
-    fp << (double) av_task/num_orgs << " ";		// 2: av. number of tasks done
-    fp << (double) av_inst/num_orgs << " ";		// 3: av. number of sites used for tasks
-    fp << (double) av_inst_len/num_orgs << " ";		// 4: proportion of sites used for tasks
-    fp << (double) av_task_site/num_orgs << " ";	// 5: av. number of tasks per site
-    fp << (double) av_site_task/num_orgs << " ";	// 6: av. number of sites per task
-    fp << (double) av_t_s_norm/num_orgs << " ";		// 7: av. number of tasks per site per task
-    fp << (double) 1 - av_task_overlap/num_orgs << " ";        // 8: av. proportion of a task that DOESN'T overlap
-    for (int i = 0; i < num_cols; i++) {
-      if (org_task[i] > 0) fp << std_task_position[i]/org_task[i]  << " ";
-      else fp << 0 << " ";
-    }
-    for (int i = 0; i < num_cols; i++) {
-      if (org_task[i] > 0) fp << (double) av_num_inst[i]/org_task[i]  << " ";
-      else fp << 0 << " ";
-    }
-    for (int i = 0; i < num_cols+1; i++) { fp << (double) av_inst_task[i]/num_orgs  << " ";}
-    for (int i = 0; i < num_cols; i++) { fp << (double) av_task_length[i]/num_orgs  << " ";}
-    fp << endl;
-  }
-  
-  else {
-    for (int i = 0; i < 8+4*num_cols+1; i++) {fp << "0 ";}
-    fp << endl;
-  }
-  }
-
-
-void cAnalyze::CommandMapMutations(cString cur_string)
-{
-  cout << "Constructing genome mutations maps..." << endl;
-  
-  // Load in the variables...
-  cString directory = PopDirectory(cur_string, "mutations/");
-  int file_type = FILE_TYPE_TEXT;
-  
-  cStringList arg_list(cur_string);
-  
-  // Check for some command specific variables.
-  if (arg_list.PopString("text") != "") file_type = FILE_TYPE_TEXT;
-  if (arg_list.PopString("html") != "") file_type = FILE_TYPE_HTML;
-  
-  // Give some information in verbose mode.
-  if (verbose == true) {
-    cout << "  outputing as ";
-    if (file_type == FILE_TYPE_TEXT) cout << "text files." << endl;
-    else cout << "HTML files." << endl;
-  }
-  
-  
-  ///////////////////////////////////////////////////////
-  // Loop through all of the genotypes in this batch...
-  
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    if (verbose == true) {
-      cout << "  Creating mutation map for " << genotype->GetName() << endl;
-    }
-    
-    // Construct this filename...
-    cString filename;
-    if (file_type == FILE_TYPE_TEXT) {
-      filename.Set("%smut_map.%s.dat", directory(), genotype->GetName()());
-    } else {   //  if (file_type == FILE_TYPE_HTML) {
-      filename.Set("%smut_map.%s.html", directory(), genotype->GetName()());
-    }
-    ofstream fp(filename());
-    
-    // Calculate the stats for the genotype we're working with...
-    genotype->Recalculate();
-    const double base_fitness = genotype->GetFitness();
-    const int num_insts = inst_set.GetSize();
-    
-    // Headers...
-    if (file_type == FILE_TYPE_TEXT) {
-      fp << "# 1: Genome instruction ID (pre-mutation)" << endl;
-      for (int i = 0; i < num_insts; i++) {
-        fp << "# " << i+1 <<": Fit if mutated to '"
-        << inst_set.GetName(i) << "'" << endl;
-      }
-      fp << "# " << num_insts + 2 << ": Knockout" << endl;
-      fp << "# " << num_insts + 3 << ": Fraction Lethal" << endl;
-      fp << "# " << num_insts + 4 << ": Fraction Detremental" << endl;
-      fp << "# " << num_insts + 5 << ": Fraction Neutral" << endl;
-      fp << "# " << num_insts + 6 << ": Fraction Beneficial" << endl;
-      fp << "# " << num_insts + 7 << ": Average Fitness" << endl;
-      fp << "# " << num_insts + 8 << ": Expected Entropy" << endl;
-      fp << "# " << num_insts + 9 << ": Original Instruction Name" << endl;
-      fp << endl;
-      
-    } else { // if (file_type == FILE_TYPE_HTML) {
-             // Mark file as html
-      fp << "<html>" << endl;
-      
-      // Setup the body...
-      fp << "<body bgcolor=\"#FFFFFF\"" << endl
-        << " text=\"#000000\"" << endl
-        << " link=\"#0000AA\"" << endl
-        << " alink=\"#0000FF\"" << endl
-        << " vlink=\"#000044\">" << endl
-        << endl
-        << "<h1 align=center>Mutation Map for Run " << batch[cur_batch].Name()
-        << ", ID " << genotype->GetID() << "</h1>" << endl
-        << "<center>" << endl
-        << endl;
-      
-      // The main chart...
-      fp << "<table border=1 cellpadding=2>" << endl;
-      
-      // The headings...///
-      fp << "<tr><th>Genome ";
-      for (int i = 0; i < num_insts; i++) {
-        fp << "<th>" << inst_set.GetName(i) << " ";
-      }
-      fp << "<th>Knockout ";
-      fp << "<th>Frac. Lethal ";
-      fp << "<th>Frac. Detremental ";
-      fp << "<th>Frac. Neutral ";
-      fp << "<th>Frac. Beneficial ";
-      fp << "<th>Ave. Fitness ";
-      fp << "<th>Expected Entropy ";
-      fp << "</tr>" << endl << endl;
-    }
-    
-    const int max_line = genotype->GetLength();
-    const cGenome & base_genome = genotype->GetGenome();
-    cGenome mod_genome(base_genome);
-    
-    // Keep track of the number of mutations in each category...
-    int total_dead = 0, total_neg = 0, total_neut = 0, total_pos = 0;
-    double total_fitness = 0.0;
-    tArray<double> col_fitness(num_insts + 1);
-    col_fitness.SetAll(0.0);
-    
-    // Build an empty instruction into the an instruction library.
-    cInstSet map_inst_set(inst_set);
-    // Locate instruction corresponding to "NULL" in the instruction library.
-    {
-      const cInstruction inst_lib_null_inst = map_inst_set.GetInstLib()->GetInst("NULL");
-      if (inst_lib_null_inst == map_inst_set.GetInstLib()->GetInstError()){
-        cout << "<cAnalyze::CommandMapMutations> got error:" << endl;
-        cout << " --- instruction \"NULL\" isn't in the instruction library;" << endl;
-        cout << " --- get somebody to map a function to \"NULL\" in the library." << endl;
-        cout << " --- (probably to class method \"cHardware-of-some-type::initInstLib\"" << endl;
-        cout << " --- in file named \"cpu/hardware-of-some-type.cc\".)" << endl;
-        cout << " --- bailing-out." << endl;
-        exit(1);
-      }
-      // Add mapping to located instruction. 
-      map_inst_set.Add2(inst_lib_null_inst.GetOp());
-    }
-    const cInstruction null_inst = map_inst_set.GetInst("NULL");
-    
-    cString color_string;  // For coloring cells...
-    
-    // Loop through all the lines of code, testing all mutations...
-    for (int line_num = 0; line_num < max_line; line_num++) {
-      int cur_inst = base_genome[line_num].GetOp();
-      char cur_symbol = base_genome[line_num].GetSymbol();
-      int row_dead = 0, row_neg = 0, row_neut = 0, row_pos = 0;
-      double row_fitness = 0.0;
-      
-      // Column 1... the original instruction in the geneome.
-      if (file_type == FILE_TYPE_HTML) {
-        fp << "<tr><td align=right>" << inst_set.GetName(cur_inst)
-        << " (" << cur_symbol << ") ";
-      } else {
-        fp << cur_inst << " ";
-      }
-      
-      // Columns 2 to D+1 (the possible mutations)
-      for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) 
-      {
-        if (mod_inst == cur_inst) {
-          if (file_type == FILE_TYPE_HTML) {
-            color_string = "#FFFFFF";
-            fp << "<th bgcolor=\"" << color_string << "\">";
-          }
-        }
-        else {
-          mod_genome[line_num].SetOp(mod_inst);
-          cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
-          test_genotype.Recalculate();
-          const double test_fitness = test_genotype.GetFitness() / base_fitness;
-          row_fitness += test_fitness;
-          total_fitness += test_fitness;
-          col_fitness[mod_inst] += test_fitness;
-
-          // Categorize this mutation...
-          if (test_fitness == 1.0) {           // Neutral Mutation...
-            row_neut++;
-            total_neut++;
-            if (file_type == FILE_TYPE_HTML) color_string = "#FFFFFF";
-          } else if (test_fitness == 0.0) {    // Lethal Mutation...
-            row_dead++;
-            total_dead++;
-            if (file_type == FILE_TYPE_HTML) color_string = "#FF0000";
-          } else if (test_fitness < 1.0) {     // Detrimental Mutation...
-            row_neg++;
-            total_neg++;
-            if (file_type == FILE_TYPE_HTML) color_string = "#FFFF00";
-          } else {                             // Beneficial Mutation...
-            row_pos++;
-            total_pos++;
-            if (file_type == FILE_TYPE_HTML) color_string = "#00FF00";
-          }
-          
-          // Write out this cell...
-          if (file_type == FILE_TYPE_HTML) {
-            fp << "<th bgcolor=\"" << color_string << "\">";
-          }
-          fp << test_fitness << " ";
-        }
-      }
-      
-      // Column: Knockout
-      mod_genome[line_num] = null_inst;
-      cAnalyzeGenotype test_genotype(m_world, mod_genome, map_inst_set);
-      test_genotype.Recalculate();
-      const double test_fitness = test_genotype.GetFitness() / base_fitness;
-      col_fitness[num_insts] += test_fitness;
-      
-      // Categorize this mutation if its in HTML mode (color only)...
-      if (file_type == FILE_TYPE_HTML) {
-        if (test_fitness == 1.0) color_string = "#FFFFFF";
-        else if (test_fitness == 0.0) color_string = "#FF0000";
-        else if (test_fitness < 1.0) color_string = "#FFFF00";
-        else color_string = "#00FF00";
-        
-        fp << "<th bgcolor=\"" << color_string << "\">";
-      }
-      
-      fp << test_fitness << " ";
-      
-      // Fraction Columns...
-      if (file_type == FILE_TYPE_HTML) fp << "<th bgcolor=\"#FF0000\">";
-      fp << (double) row_dead / (double) (num_insts-1) << " ";
-      
-      if (file_type == FILE_TYPE_HTML) fp << "<th bgcolor=\"#FFFF00\">";
-      fp << (double) row_neg / (double) (num_insts-1) << " ";
-      
-      if (file_type == FILE_TYPE_HTML) fp << "<th bgcolor=\"#FFFFFF\">";
-      fp << (double) row_neut / (double) (num_insts-1) << " ";
-      
-      if (file_type == FILE_TYPE_HTML) fp << "<th bgcolor=\"#00FF00\">";
-      fp << (double) row_pos / (double) (num_insts-1) << " ";
-      
-      
-      // Column: Average Fitness
-      if (file_type == FILE_TYPE_HTML) fp << "<th>";
-      fp << row_fitness / (double) (num_insts-1) << " ";
-      
-      // Column: Expected Entropy  @CAO Implement!
-      if (file_type == FILE_TYPE_HTML) fp << "<th>";
-      fp << 0.0 << " ";
-      
-      // End this row...
-      if (file_type == FILE_TYPE_HTML) fp << "</tr>";
-      fp << endl;
-      
-      // Reset the mod_genome back to the original sequence.
-      mod_genome[line_num].SetOp(cur_inst);
-    }
-    
-    
-    // Construct the final line of the table with all totals...
-    if (file_type == FILE_TYPE_HTML) {
-      fp << "<tr><th>Totals";
-      
-      // Instructions + Knockout
-      for (int i = 0; i <= num_insts; i++) {
-        fp << "<th>" << col_fitness[i] / max_line << " ";
-      }
-      
-      int total_tests = max_line * (num_insts-1);
-      fp << "<th>" << (double) total_dead / (double) total_tests << " ";
-      fp << "<th>" << (double) total_neg / (double) total_tests << " ";
-      fp << "<th>" << (double) total_neut / (double) total_tests << " ";
-      fp << "<th>" << (double) total_pos / (double) total_tests << " ";
-      fp << "<th>" << total_fitness / (double) total_tests << " ";
-      fp << "<th>" << 0.0 << " ";
-      
-      
-      // And close everything up...
-      fp << "</table>" << endl
-        << "</center>" << endl;
-    }
-    
-    }
-    }
-
-
-void cAnalyze::CommandMapDepth(cString cur_string)
-{
-  cout << "Constructing depth map..." << endl;
-  
-  cString filename("depth_map.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();  
-  
-  int min_batch = 0;
-  int max_batch = cur_batch - 1;
-  
-  if (cur_string.GetSize() != 0) min_batch = cur_string.PopWord().AsInt();
-  if (cur_string.GetSize() != 0) max_batch = cur_string.PopWord().AsInt();
-  
-  // First, scan all of the batches to find the maximum depth.
-  int max_depth = -1;
-  cAnalyzeGenotype * genotype;
-  for (int i = min_batch; i <= max_batch; i++) {
-    tListIterator<cAnalyzeGenotype> list_it(batch[i].List());
-    while ((genotype = list_it.Next()) != NULL) {
-      if (genotype->GetDepth() > max_depth) max_depth = genotype->GetDepth();
-    }
-  }
-  
-  cout << "max_depth = " << max_depth << endl;
-  
-  ofstream & fp = data_file_manager.GetOFStream(filename);
-  
-  cout << "Output to " << filename << endl;
-  tArray<int> depth_array(max_depth+1);
-  for (cur_batch = min_batch; cur_batch <= max_batch; cur_batch++) {
-    depth_array.SetAll(0);
-    tListIterator<cAnalyzeGenotype> list_it(batch[cur_batch].List());
-    while ((genotype = list_it.Next()) != NULL) {
-      const int cur_depth = genotype->GetDepth();
-      const int cur_count = genotype->GetNumCPUs();
-      depth_array[cur_depth] += cur_count;
-    }
-    
-    for (int i = 0; i <= max_depth; i++) {
-      fp << depth_array[i] << " ";
-    }
-    fp << endl;
-  }
-}
-
-void cAnalyze::CommandHamming(cString cur_string)
-{
-  cString filename("hamming.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  
-  int batch1 = PopBatch(cur_string.PopWord());
-  int batch2 = PopBatch(cur_string.PopWord());
-  
-  // We want batch2 to be the larger one for efficiency...
-  if (batch[batch1].List().GetSize() > batch[batch2].List().GetSize()) {
-    int tmp = batch1;  batch1 = batch2;  batch2 = tmp;
-  }
-  
-  if (verbose == false) {
-    cout << "Calculating Hamming Distance... ";
-    cout.flush();
-  } else {
-    cout << "Calculating Hamming Distance between batches "
-    << batch1 << " and " << batch2 << endl;
-    cout.flush();
-  }
-  
-  // Setup some variables;
-  cAnalyzeGenotype * genotype1 = NULL;
-  cAnalyzeGenotype * genotype2 = NULL;
-  int total_dist = 0;
-  int total_count = 0;
-  
-  tListIterator<cAnalyzeGenotype> list1_it(batch[batch1].List());
-  tListIterator<cAnalyzeGenotype> list2_it(batch[batch2].List());
-  
-  while ((genotype1 = list1_it.Next()) != NULL) {
-    list2_it.Reset();
-    while ((genotype2 = list2_it.Next()) != NULL) {
-      // Determine the counts...
-      const int count1 = genotype1->GetNumCPUs();
-      const int count2 = genotype2->GetNumCPUs();
-      const int num_pairs = (genotype1 == genotype2) ?
-        ((count1 - 1) * (count2 - 1)) : (count1 * count2);
-      if (num_pairs == 0) continue;
-      
-      // And do the tests...
-      const int dist =
-        cGenomeUtil::FindHammingDistance(genotype1->GetGenome(),
-                                         genotype2->GetGenome());
-      total_dist += dist * num_pairs;
-      total_count += num_pairs;
-    }
-  }
-  
-  
-  // Calculate the final answer
-  double ave_dist = (double) total_dist / (double) total_count;
-  cout << " ave distance = " << ave_dist << endl;
-  
-  cDataFile & df = data_file_manager.Get(filename);
-  
-  df.WriteComment( "Hamming distance information" );
-  df.WriteTimeStamp();  
-  
-  df.Write(batch[batch1].Name(), "Name of First Batch");
-  df.Write(batch[batch2].Name(), "Name of Second Batch");
-  df.Write(ave_dist,             "Average Hamming Distance");
-  df.Write(total_count,          "Total Pairs Test");
-  df.Endl();
-}
-
-void cAnalyze::CommandLevenstein(cString cur_string)
-{
-  cString filename("lev.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  
-  int batch1 = PopBatch(cur_string.PopWord());
-  int batch2 = PopBatch(cur_string.PopWord());
-  
-  // We want batch2 to be the larger one for efficiency...
-  if (batch[batch1].List().GetSize() > batch[batch2].List().GetSize()) {
-    int tmp = batch1;  batch1 = batch2;  batch2 = tmp;
-  }
-  
-  if (verbose == false) {
-    cout << "Calculating Levenstein Distance... ";
-    cout.flush();
-  } else {
-    cout << "Calculating Levenstein Distance between batch "
-    << batch1 << " and " << batch2 << endl;
-    cout.flush();
-  }
-  
-  // Setup some variables;
-  cAnalyzeGenotype * genotype1 = NULL;
-  cAnalyzeGenotype * genotype2 = NULL;
-  int total_dist = 0;
-  int total_count = 0;
-  
-  tListIterator<cAnalyzeGenotype> list1_it(batch[batch1].List());
-  tListIterator<cAnalyzeGenotype> list2_it(batch[batch2].List());
-  
-  // Loop through all of the genotypes in each batch...
-  while ((genotype1 = list1_it.Next()) != NULL) {
-    list2_it.Reset();
-    while ((genotype2 = list2_it.Next()) != NULL) {
-      // Determine the counts...
-      const int count1 = genotype1->GetNumCPUs();
-      const int count2 = genotype2->GetNumCPUs();
-      const int num_pairs = (genotype1 == genotype2) ?
-        ((count1 - 1) * (count2 - 1)) : (count1 * count2);
-      if (num_pairs == 0) continue;
-      
-      // And do the tests...
-      const int dist = cGenomeUtil::FindEditDistance(genotype1->GetGenome(),
-                                                     genotype2->GetGenome());
-      total_dist += dist * num_pairs;
-      total_count += num_pairs;
-    }
-  }
-  
-  // Calculate the final answer
-  double ave_dist = (double) total_dist / (double) total_count;
-  cout << " ave distance = " << ave_dist << endl;
-  
-  cDataFile & df = data_file_manager.Get(filename);
-  
-  df.WriteComment( "Levenstein distance information" );
-  df.WriteTimeStamp();  
-  
-  df.Write(batch[batch1].Name(), "Name of First Batch");
-  df.Write(batch[batch2].Name(), "Name of Second Batch");
-  df.Write(ave_dist,             "Average Levenstein Distance");
-  df.Write(total_count,          "Total Pairs Test");
-  df.Endl();
-}
-
-void cAnalyze::CommandSpecies(cString cur_string)
-{
-  cString filename("species.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  
-  int batch1 = PopBatch(cur_string.PopWord());
-  int batch2 = PopBatch(cur_string.PopWord());
-  int num_compare = PopBatch(cur_string.PopWord());
-  
-  // We want batch2 to be the larger one for efficiency...
-  if (batch[batch1].List().GetSize() > batch[batch2].List().GetSize()) {
-    int tmp = batch1;  batch1 = batch2;  batch2 = tmp;
-  }
-  
-  if (verbose == false) cout << "Calculating Species Distance... " << endl;
-  else cout << "Calculating Species Distance between batch "
-    << batch1 << " and " << batch2 << endl;
-  
-  // Setup some variables;
-  cAnalyzeGenotype * genotype1 = NULL;
-  cAnalyzeGenotype * genotype2 = NULL;
-  int total_fail = 0;
-  int total_count = 0;
-  
-  tListIterator<cAnalyzeGenotype> list1_it(batch[batch1].List());
-  tListIterator<cAnalyzeGenotype> list2_it(batch[batch2].List());
-  
-  // Loop through all of the genotypes in each batch...
-  while ((genotype1 = list1_it.Next()) != NULL) {
-    list2_it.Reset();
-    while ((genotype2 = list2_it.Next()) != NULL) {
-      // Determine the counts...
-      const int count1 = genotype1->GetNumCPUs();
-      const int count2 = genotype2->GetNumCPUs();
-      int num_pairs = count1 * count2; 
-      int fail_count = 0;
-      bool cross1_viable = true;
-      bool cross2_viable = true;
-      
-      
-      if (genotype1 == genotype2) {
-        total_count += num_pairs * 2 * num_compare;
-      }
-      else {	
-        assert(num_compare!=0);
-        // And do the tests...
-        for (int iter=1; iter < num_compare; iter++) {
-          cCPUMemory test_genome0 = genotype1->GetGenome(); 
-          cCPUMemory test_genome1 = genotype2->GetGenome(); 
-          
-          double start_frac = m_world->GetRandom().GetDouble();
-          double end_frac = m_world->GetRandom().GetDouble();
-          if (start_frac > end_frac) nFunctions::Swap(start_frac, end_frac);
-          
-          int start0 = (int) (start_frac * (double) test_genome0.GetSize());
-          int end0   = (int) (end_frac * (double) test_genome0.GetSize());
-          int start1 = (int) (start_frac * (double) test_genome1.GetSize());
-          int end1   = (int) (end_frac * (double) test_genome1.GetSize());
-          assert( start0 >= 0  &&  start0 < test_genome0.GetSize() );
-          assert( end0   >= 0  &&  end0   < test_genome0.GetSize() );
-          assert( start1 >= 0  &&  start1 < test_genome1.GetSize() );
-          assert( end1   >= 0  &&  end1   < test_genome1.GetSize() );
-          
-          // Calculate size of sections crossing over...    
-          int size0 = end0 - start0;
-          int size1 = end1 - start1;
-          
-          int new_size0 = test_genome0.GetSize() - size0 + size1;   
-          int new_size1 = test_genome1.GetSize() - size1 + size0;
-          
-          // Don't Crossover if offspring will be illegal!!!
-          if (new_size0 < MIN_CREATURE_SIZE || new_size0 > MAX_CREATURE_SIZE || 
-              new_size1 < MIN_CREATURE_SIZE || new_size1 > MAX_CREATURE_SIZE) { 
-            fail_count +=2; 
-            break; 
-          } 
-          
-	  // Swap the components
-	  cGenome cross0 = cGenomeUtil::Crop(test_genome0, start0, end0);
-	  cGenome cross1 = cGenomeUtil::Crop(test_genome1, start1, end1);
-	  test_genome0.Replace(start0, size0, cross1);
-	  test_genome1.Replace(start1, size1, cross0);
-          
-	  // Run each side, and determine viability...
-          cCPUTestInfo test_info;
-          m_world->GetTestCPU().TestGenome(test_info, test_genome0);
-          cross1_viable = test_info.IsViable();
-          
-          m_world->GetTestCPU().TestGenome(test_info, test_genome1);
-          cross2_viable = test_info.IsViable();
-          
-          if (cross1_viable == false) fail_count++;   
-          if (cross2_viable == false) fail_count++;
-        }
-        
-        total_fail += fail_count * num_pairs;
-        total_count += num_pairs * 2 * num_compare;
-      }
-    }
-  }
-  // Calculate the final answer
-  double ave_dist = (double) total_fail / (double) total_count;
-  cout << "  ave distance = " << ave_dist
-    << " in " << total_count
-    << " tests." << endl; 
-  
-  cDataFile & df = data_file_manager.Get(filename);
-  
-  df.WriteComment( "Species information" );
-  df.WriteTimeStamp();  
-  
-  df.Write(batch[batch1].Name(), "Name of First Batch");
-  df.Write(batch[batch2].Name(), "Name of Second Batch");
-  df.Write(ave_dist,             "Average Species Distance");
-  df.Write(total_count,          "Total Recombinants tested");
-  df.Endl();
-}
-
-void cAnalyze::CommandRecombine(cString cur_string)
-{
-  int batch1 = PopBatch(cur_string.PopWord());
-  int batch2 = PopBatch(cur_string.PopWord());
-  int batch3 = PopBatch(cur_string.PopWord());
-  int num_compare = PopBatch(cur_string.PopWord());
-  
-  // We want batch2 to be the larger one for efficiency...
-  if (batch[batch1].List().GetSize() > batch[batch2].List().GetSize()) {
-    int tmp = batch1;  batch1 = batch2;  batch2 = tmp;
-  }
-  
-  if (verbose == false) cout << "Creating recombinants...  " << endl;
-  else cout << "Creating recombinants between batch "
-    << batch1 << " and " << batch2 << endl;
-  
-  // Setup some variables;
-  cAnalyzeGenotype * genotype1 = NULL;
-  cAnalyzeGenotype * genotype2 = NULL;
-  
-  tListIterator<cAnalyzeGenotype> list1_it(batch[batch1].List());
-  tListIterator<cAnalyzeGenotype> list2_it(batch[batch2].List());
-  
-  // Loop through all of the genotypes in each batch...
-  while ((genotype1 = list1_it.Next()) != NULL) {
-    list2_it.Reset();
-    while ((genotype2 = list2_it.Next()) != NULL) {
-      // Determine the counts...
-      int fail_count = 0;
-      
-      
-      assert(num_compare!=0);
-      // And do the tests...
-      for (int iter=1; iter < num_compare; iter++) {
-        cCPUMemory test_genome0 = genotype1->GetGenome(); 
-        cCPUMemory test_genome1 = genotype2->GetGenome(); 
-        
-        double start_frac = m_world->GetRandom().GetDouble();
-        double end_frac = m_world->GetRandom().GetDouble();
-        if (start_frac > end_frac) nFunctions::Swap(start_frac, end_frac);
-        
-        int start0 = (int) (start_frac * (double) test_genome0.GetSize());
-        int end0   = (int) (end_frac * (double) test_genome0.GetSize());
-        int start1 = (int) (start_frac * (double) test_genome1.GetSize());
-        int end1   = (int) (end_frac * (double) test_genome1.GetSize());
-        assert( start0 >= 0  &&  start0 < test_genome0.GetSize() );
-        assert( end0   >= 0  &&  end0   < test_genome0.GetSize() );
-        assert( start1 >= 0  &&  start1 < test_genome1.GetSize() );
-        assert( end1   >= 0  &&  end1   < test_genome1.GetSize() );
-        
-        // Calculate size of sections crossing over...    
-        int size0 = end0 - start0;
-        int size1 = end1 - start1;
-        
-        int new_size0 = test_genome0.GetSize() - size0 + size1;   
-        int new_size1 = test_genome1.GetSize() - size1 + size0;
-        
-        // Don't Crossover if offspring will be illegal!!!
-        if (new_size0 < MIN_CREATURE_SIZE || new_size0 > MAX_CREATURE_SIZE || 
-            new_size1 < MIN_CREATURE_SIZE || new_size1 > MAX_CREATURE_SIZE) { 
-          fail_count +=2; 
-          break; 
-        } 
-        
-        if (size0 > 0 && size1 > 0) {
-          cGenome cross0 = cGenomeUtil::Crop(test_genome0, start0, end0);
-          cGenome cross1 = cGenomeUtil::Crop(test_genome1, start1, end1);
-          test_genome0.Replace(start0, size0, cross1);
-          test_genome1.Replace(start1, size1, cross0);
-        }
-        else if (size0 > 0) {
-          cGenome cross0 = cGenomeUtil::Crop(test_genome0, start0, end0);
-          test_genome1.Replace(start1, size1, cross0);
-        }
-        else if (size1 > 0) {
-          cGenome cross1 = cGenomeUtil::Crop(test_genome1, start1, end1);
-          test_genome0.Replace(start0, size0, cross1);
-        }
-        
-        cAnalyzeGenotype * new_genotype0 = new cAnalyzeGenotype(m_world, test_genome0, inst_set); 
-        cAnalyzeGenotype * new_genotype1 = new cAnalyzeGenotype(m_world, test_genome1, inst_set); 
-        new_genotype0->SetNumCPUs(1); 
-        new_genotype1->SetNumCPUs(1); 
-        new_genotype0->SetID(0);
-        new_genotype1->SetID(0);
-        new_genotype0->SetName("noname");
-        new_genotype1->SetName("noname");
-        
-        batch[batch3].List().PushRear(new_genotype0);
-        batch[batch3].List().PushRear(new_genotype1); 
-        
-        //batch[batch3].List().PushRear(new cAnalyzeGenotype(test_genome0, inst_set));
-        //batch[batch3].List().PushRear(new cAnalyzeGenotype(test_genome1, inst_set));
-        
-      }
-    }
-  }
-}
-
-void cAnalyze::CommandAlign(cString cur_string)
-{
-  // Align does not need any args yet.
-  (void) cur_string;
-  
-  cout << "Aligning sequences..." << endl;
-  
-  if (batch[cur_batch].IsLineage() == false && verbose == true) {
-    cerr << "  Warning: sequences may not be a consecutive lineage."
-    << endl;
-  }
-  
-  // Create an array of all the sequences we need to align.
-  tListPlus<cAnalyzeGenotype> & glist = batch[cur_batch].List();
-  tListIterator<cAnalyzeGenotype> batch_it(glist);
-  const int num_sequences = glist.GetSize();
-  cString * sequences = new cString[num_sequences];
-  
-  // Move through each sequence an update it.
-  batch_it.Reset();
-  cString diff_info;
-  for (int i = 0; i < num_sequences; i++) {
-    sequences[i] = batch_it.Next()->GetGenome().AsString();
-    if (i == 0) continue;
-    // Track of the number of insertions and deletions to shift properly.
-    int num_ins = 0;
-    int num_del = 0;
-    
-    // Compare each string to the previous.
-    cStringUtil::EditDistance(sequences[i], sequences[i-1], diff_info, '_');
-    while (diff_info.GetSize() != 0) {
-      cString cur_mut = diff_info.Pop(',');
-      const char mut_type = cur_mut[0];
-      cur_mut.ClipFront(1); cur_mut.ClipEnd(1);
-      int position = cur_mut.AsInt();
-      
-      // Nothing to do with Mutations
-      if (mut_type == 'M') continue;
-      
-      // Handle insertions...
-      if (mut_type == 'I') {
-        // Loop back and insert an '_' into all previous sequences.
-        for (int j = 0; j < i; j++) {
-          sequences[j].Insert('_', position + num_del);
-        }
-        num_ins++;
-      }
-      
-      // Handle Deletions...
-      else if (mut_type == 'D') {
-        // Insert '_' into the current sequence at the point of deletions.
-        sequences[i].Insert("_", position + num_ins);
-        num_del++;
-      }
-      
-    }
-  }
-  
-  batch_it.Reset();
-  for (int i = 0; i < num_sequences; i++) {
-    batch_it.Next()->SetAlignedSequence(sequences[i]);
-  }
-  
-  // Cleanup
-  delete [] sequences;
-  
-  // Adjust the flags on this batch
-  // batch[cur_batch].SetLineage(false);
-  batch[cur_batch].SetAligned(true);
-}
-
-// Now this command do not consider changing environment 
-// and only work for lineage and fixed-length runs.
-void cAnalyze::AnalyzeNewInfo(cString cur_string)
-{
-  cout << "Analyze new information in child about environment ..." << endl;
-  
-  // Load in the variables
-  int words = cur_string.CountNumWords();
-  if (words < 1) {
-    cout << "This command requires mutation rate, skipping." << endl;
-    return;
-  }
-  
-  // Get the mutation rate ...
-  double mu = cur_string.PopWord().AsDouble();
-  
-  // Create the directory using the string given as the second argument
-  cString dir = cur_string.PopWord();
-  cString defaultDir = "newinfo/";
-  cString directory = PopDirectory(dir, defaultDir);
-  
-  ///////////////////////////////////////////////////////
-  // Loop through all of the genotypes in this batch...
-  
-  cString newinfo_fn;
-  ofstream newinfo_fp;
-  if (batch[cur_batch].IsLineage() == true) {
-    newinfo_fn.Set("%s%s.newinfo.dat", directory(), "lineage");
-    newinfo_fp.open(newinfo_fn);
-  } else {
-    cout << "This command requires the lineage in the batch, skipping.\n";
-    return;
-  }
-  newinfo_fp << "# Legend:" << endl;
-  newinfo_fp << "# 1:Child Genotype ID" << endl;
-  newinfo_fp << "# 2:Parent Genotype ID" << endl;
-  newinfo_fp << "# 3:Information of Child about Environment I(C:E)" << endl;
-  newinfo_fp << "# 4:Information of Parent about Environment I(P:E)" << endl;
-  newinfo_fp << "# 5:I(C:E)-I(P:E)" << endl;
-  newinfo_fp << "# 6:Information Gained in Child" << endl;
-  newinfo_fp << "# 7:Information Decreased in Child" << endl;
-  newinfo_fp << "# 8:Net Increasing of Information in Child" << endl;
-  newinfo_fp << endl; 
-  
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * parent_genotype = batch_it.Next();
-  if (parent_genotype == NULL) {
-    newinfo_fp.close();
-    return;
-  }
-  cAnalyzeGenotype * child_genotype = NULL;
-  double I_P_E; // Information of parent about environment
-  double H_P_E = AnalyzeEntropy(parent_genotype, mu);
-  I_P_E = parent_genotype->GetLength() - H_P_E;
-
-  while ((child_genotype = batch_it.Next()) != NULL) {
-    
-    if (verbose == true) {
-      cout << "Analyze new information for " << child_genotype->GetName() << endl;
-    }
-    
-    // Information of parent about its environment should not be zero.
-    if (I_P_E == 0) {
-      cerr << "Error: Information between parent and its enviroment is zero."
-	   << "(cAnalyze::AnalyzeNewInfo)" << endl;
-      exit(1);
-    }
-
-    double H_C_E = AnalyzeEntropy(child_genotype, mu);
-    double I_C_E = child_genotype->GetLength() - H_C_E;
-    double net_gain = I_C_E - I_P_E;
-    
-    // Increased information in child compared to parent
-    double child_increased_info = IncreasedInfo(child_genotype, parent_genotype, mu);
-    
-    // Lost information in child compared to parent
-    double child_lost_info = IncreasedInfo(parent_genotype, child_genotype, mu);
-
-    // Write information to file ...
-    newinfo_fp << child_genotype->GetID() << " ";
-    newinfo_fp << parent_genotype->GetID() << " ";
-    newinfo_fp << I_C_E << " ";
-    newinfo_fp << I_P_E << " ";
-    newinfo_fp << net_gain << " ";
-    newinfo_fp << child_increased_info << " ";
-    newinfo_fp << child_lost_info << " ";
-    newinfo_fp << child_increased_info - child_lost_info << endl;
-    
-    parent_genotype = child_genotype;
-    I_P_E = I_C_E;
-  }
-  
-  newinfo_fp.close();
-  return;
-}
-
-
-
-void cAnalyze::WriteClone(cString cur_string)
-{
-  // Load in the variables...
-  cString filename("clone.dat");
-  int num_cells = -1;
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  if (cur_string.GetSize() != 0) num_cells = cur_string.PopWord().AsInt();
-  
-  
-  ofstream & fp = data_file_manager.GetOFStream(filename);
-  
-  // Start up again at update zero...
-  fp << "0 ";
-  
-  // Setup the genebank sizes of lists to all be zero.
-  fp << MAX_CREATURE_SIZE << " ";
-  for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
-    fp << "0 ";
-  }
-  
-  // Save the individual genotypes
-  fp << batch[cur_batch].List().GetSize() << " ";
-  
-  int org_count = 0;
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    org_count += genotype->GetNumCPUs();
-    const int length = genotype->GetLength();
-    const cGenome & genome = genotype->GetGenome();
-    
-    fp << genotype->GetID() << " "
-      << length << " ";
-    
-    for (int i = 0; i < length; i++) {
-      fp << genome[i].GetOp() << " ";
-    }
-  }
-  
-  // Write out the current state of the grid.
-  
-  if (num_cells == 0) num_cells = org_count;
-  fp << num_cells << " ";
-  
-  batch_it.Reset();
-  while ((genotype = batch_it.Next()) != NULL) {
-    for (int i = 0; i < genotype->GetNumCPUs(); i++) {
-      fp << genotype->GetID() << " ";
-    }
-  }
-  
-  // Fill out the remainder of the grid with -1
-  for (int i = org_count; i < num_cells; i++) {
-    fp << "-1 ";
-  }
-}
-
-
-void cAnalyze::WriteInjectEvents(cString cur_string)
-{
-  // Load in the variables...
-  cString filename("events_inj.cfg");
-  int start_cell = 0;
-  int lineage = 0;
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  if (cur_string.GetSize() != 0) start_cell = cur_string.PopWord().AsInt();
-  if (cur_string.GetSize() != 0) lineage = cur_string.PopWord().AsInt();
-  
-  ofstream & fp = data_file_manager.GetOFStream(filename);
-  
-  int org_count = 0;
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    const int cur_count = genotype->GetNumCPUs();
-    org_count += cur_count;
-    const cGenome & genome = genotype->GetGenome();
-    
-    fp << "u 0 inject_sequence "
-      << genome.AsString() << " "
-      << start_cell << " "
-      << start_cell + cur_count << " "
-      << genotype->GetMerit() << " "
-      << lineage << " "
-      << endl;
-    start_cell += cur_count;
-  }
-}
-
-
-void cAnalyze::WriteCompetition(cString cur_string)
-{
-  cout << "Writing Competition events..." << endl;
-  
-  // Load in the variables...
-  int join_UD = 0;
-  double start_merit = 50000;
-  cString filename("events_comp.cfg");
-  int batch_A = cur_batch - 1;
-  int batch_B = cur_batch;
-  int grid_side = -1;
-  int lineage = 0;
-  
-  // Make sure we have reasonable default batches.
-  if (cur_batch == 0) { batch_A = 0; batch_B = 1; }
-  
-  if (cur_string.GetSize() != 0) join_UD = cur_string.PopWord().AsInt();
-  if (cur_string.GetSize() != 0) start_merit = cur_string.PopWord().AsDouble();
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  if (cur_string.GetSize() != 0) batch_A = cur_string.PopWord().AsInt();
-  if (cur_string.GetSize() != 0) batch_B = cur_string.PopWord().AsInt();
-  if (cur_string.GetSize() != 0) grid_side = cur_string.PopWord().AsInt();
-  if (cur_string.GetSize() != 0) lineage = cur_string.PopWord().AsInt();
-  
-  // Check inputs...
-  if (join_UD < 0) join_UD = 0;
-  if (batch_A < 0 || batch_B < 0) {
-    cerr << "Error: Batch IDs must be positive!" << endl;
-    return;
-  }
-  
-  ofstream & fp = data_file_manager.GetOFStream(filename);
-  
-  // Count the number of organisms in each batch...
-  cAnalyzeGenotype * genotype = NULL;
-  
-  int org_count_A = 0;
-  tListIterator<cAnalyzeGenotype> batchA_it(batch[batch_A].List());
-  while ((genotype = batchA_it.Next()) != NULL) {
-    org_count_A += genotype->GetNumCPUs();
-  }
-  
-  int org_count_B = 0;
-  tListIterator<cAnalyzeGenotype> batchB_it(batch[batch_B].List());
-  while ((genotype = batchB_it.Next()) != NULL) {
-    org_count_B += genotype->GetNumCPUs();
-  }
-  
-  int max_count = Max(org_count_A, org_count_B);
-  if (max_count > 10000) {
-    cout << "Warning: more than 10,000 organisms in sub-population!" << endl;
-  }
-  
-  if (grid_side <= 0) {
-    for (grid_side = 5; grid_side < 100; grid_side += 5) {
-      if (grid_side * grid_side >= max_count) break;
-    }
-    if (verbose == true) {
-      cout << "...assuming population size "
-      << grid_side << "x" << grid_side << "." << endl;
-    }
-  }
-  
-  
-  int pop_size = grid_side * grid_side;
-  
-  int inject_pos = 0;
-  while ((genotype = batchA_it.Next()) != NULL) {
-    const int cur_count = genotype->GetNumCPUs();
-    const cGenome & genome = genotype->GetGenome();
-    double cur_merit = start_merit;
-    if (cur_merit < 0) cur_merit = genotype->GetMerit();
-    fp << "u 0 inject_sequence "
-      << genome.AsString() << " "
-      << inject_pos << " "
-      << inject_pos + cur_count << " "
-      << cur_merit << " "
-      << lineage << " "
-      << endl;
-    inject_pos += cur_count;
-  }
-  
-  inject_pos = pop_size;
-  while ((genotype = batchB_it.Next()) != NULL) {
-    const int cur_count = genotype->GetNumCPUs();
-    const cGenome & genome = genotype->GetGenome();
-    double cur_merit = start_merit;
-    if (cur_merit < 0) cur_merit = genotype->GetMerit();
-    fp << "u 0 inject_sequence "
-      << genome.AsString() << " "
-      << inject_pos << " "
-      << inject_pos + cur_count << " "
-      << cur_merit << " "
-      << lineage+1 << " "
-      << endl;
-    inject_pos += cur_count;
-  }
-  
-  fp << "u 0 sever_grid_row" << grid_side << endl;
-  fp << "u " << join_UD << " join_grid_row " << grid_side << endl;
-}
-
-
-void cAnalyze::AnalyzeMuts(cString cur_string)
-{
-  cout << "Analyzing Mutations" << endl;
-  
-  // Make sure we have everything we need.
-  if (batch[cur_batch].IsAligned() == false) {
-    cout << "  Error: sequences not aligned." << endl;
-    return;
-  }
-  
-  // Setup variables...
-  cString filename("analyze_muts.dat");
-  bool all_combos = false;
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  if (cur_string.GetSize() != 0) all_combos = cur_string.PopWord().AsInt();
-  
-  tListPlus<cAnalyzeGenotype> & gen_list = batch[cur_batch].List();
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  
-  const int num_sequences = gen_list.GetSize();
-  const int sequence_length =
-    gen_list.GetFirst()->GetAlignedSequence().GetSize();
-  cString * sequences = new cString[num_sequences];
-  int * mut_count = new int[sequence_length];
-  for (int i = 0; i < sequence_length; i++) mut_count[i] = 0;
-  
-  // Load in the sequences
-  batch_it.Reset();
-  int count = 0;
-  while (batch_it.Next() != NULL) {
-    sequences[count] = batch_it.Get()->GetAlignedSequence();
-    count++;
-  }
-  
-  // Count the number of changes at each site...
-  for (int i = 1; i < num_sequences; i++) {       // For each pair...
-    cString & seq1 = sequences[i-1];
-    cString & seq2 = sequences[i];
-    for (int j = 0; j < sequence_length; j++) {   // For each site...
-      if (seq1[j] != seq2[j]) mut_count[j]++;
-    }
-  }
-  
-  // Grab the two strings we're actively going to be working with.
-  cString & first_seq = sequences[0];
-  cString & last_seq = sequences[num_sequences - 1];
-  
-  // Print out the header...
-  ofstream & fp = data_file_manager.GetOFStream(filename);
-  fp << "# " << sequences[0] << endl;
-  fp << "# " << sequences[num_sequences - 1] << endl;
-  fp << "# ";
-  for (int i = 0; i < sequence_length; i++) {
-    if (mut_count[i] == 0) fp << " ";
-    else if (mut_count[i] > 9) fp << "+";
-    else fp << mut_count[i];
-  }
-  fp << endl;
-  fp << "# ";
-  for (int i = 0; i < sequence_length; i++) {
-    if (first_seq[i] == last_seq[i]) fp << " ";
-    else fp << "^";
-  }
-  fp << endl << endl;
-  
-  // Count the number of diffs between the two strings we're interested in.
-  const int total_diffs = cStringUtil::Distance(first_seq, last_seq);
-  if (verbose) cout << "  " << total_diffs << " mutations being tested."
-    << endl;
-  
-  // Locate each difference.
-  int * mut_positions = new int[total_diffs];
-  int cur_mut = 0;
-  for (int i = 0; i < first_seq.GetSize(); i++) {
-    if (first_seq[i] != last_seq[i]) {
-      mut_positions[cur_mut] = i;
-      cur_mut++;
-    }
-  }
-  
-  // The number of mutations we need to deal with will tell us how much
-  // we can attempt to do. (@CAO should be able to overide defaults)
-  bool scan_combos = true;  // Scan all possible combos of mutations?
-  bool detail_muts = true;  // Collect detailed info on all mutations?
-  bool print_all = true;    // Print everything we collect without digestion?
-  if (total_diffs > 30) scan_combos = false;
-  if (total_diffs > 20) detail_muts = false;
-  if (total_diffs > 10) print_all = false;
-  
-  // Start moving through the difference combinations...
-  if (scan_combos) {
-    const int total_combos = 1 << total_diffs;
-    cout << "  Scanning through " << total_combos << " combos." << endl;
-    
-    double * total_fitness = new double[total_diffs + 1];
-    double * total_sqr_fitness = new double[total_diffs + 1];
-    double * max_fitness = new double[total_diffs + 1];
-    cString * max_sequence = new cString[total_diffs + 1];
-    int * test_count = new int[total_diffs + 1];
-    for (int i = 0; i <= total_diffs; i++) {
-      total_fitness[i] = 0.0;
-      total_sqr_fitness[i] = 0.0;
-      max_fitness[i] = 0.0;
-      test_count[i] = 0;
-    }
-    
-    // Loop through all of the combos...
-    const int combo_step = total_combos / 79;
-    for (int combo_id = 0; combo_id < total_combos; combo_id++) {
-      if (combo_id % combo_step == 0) {
-        cout << '.';
-        cout.flush();
-      }
-      // Start at the first sequence and add needed changes...
-      cString test_sequence = first_seq;
-      int diff_count = 0;
-      for (int mut_id = 0; mut_id < total_diffs; mut_id++) {
-        if ((combo_id >> mut_id) & 1) {
-          const int cur_pos = mut_positions[mut_id];
-          test_sequence[cur_pos] = last_seq.GetData()[cur_pos];
-          diff_count++;
-        }
-      }
-      
-      // Determine the fitness of the current sequence...
-      cGenome test_genome(test_sequence);
-      cCPUTestInfo test_info;
-      test_info.TestThreads();
-      m_world->GetTestCPU().TestGenome(test_info, test_genome);
-      const double fitness = test_info.GetGenotypeFitness();
-      
-      //cAnalyzeGenotype test_genotype(test_sequence);
-      //test_genotype.Recalculate();
-      //const double fitness = test_genotype.GetFitness();
-      
-      total_fitness[diff_count] += fitness;
-      total_sqr_fitness[diff_count] += fitness * fitness;
-      if (fitness > max_fitness[diff_count]) {
-        max_fitness[diff_count] = fitness;
-        max_sequence[diff_count] = test_sequence;
-        //  	cout << endl
-        //  	     << max_sequence[diff_count] << " "
-        //  	     << test_info.GetGenotypeMerit() << " "
-        //  	     << fitness << " "
-        //  	     << combo_id << endl;
-      }
-      test_count[diff_count]++;
-    }
-    
-    // Output the results...
-    
-    for (int i = 0; i <= total_diffs; i++) {
-      cAnalyzeGenotype max_genotype(m_world, max_sequence[i], inst_set);
-      max_genotype.Recalculate();
-      fp << i                                         << " "  //  1
-        << test_count[i]                             << " "  //  2
-        << total_fitness[i] / (double) test_count[i] << " "  //  3
-        << max_fitness[i]                            << " "  //  4
-        << max_genotype.GetMerit()                   << " "  //  5
-        << max_genotype.GetGestTime()                << " "  //  6
-        << max_genotype.GetLength()                  << " "  //  7
-        << max_genotype.GetCopyLength()              << " "  //  8
-        << max_genotype.GetExeLength()               << " "; //  9
-      max_genotype.PrintTasks(fp, 3,12);
-      fp << max_sequence[i] << endl;
-    }
-    
-    // Cleanup
-    delete [] total_fitness;
-    delete [] total_sqr_fitness;
-    delete [] max_fitness;
-    delete [] max_sequence;
-    delete [] test_count;
-  }
-  // If we can't scan through all combos, give wanring.
-  else {
-    cerr << "  Warning: too many mutations (" << total_diffs
-    << ") to scan through combos." << endl;
-  }
-  
-  
-  // Cleanup...
-  delete [] sequences;
-  delete [] mut_count;
-  delete [] mut_positions;
-}
-
-void cAnalyze::AnalyzeInstructions(cString cur_string)
-{
-  if (verbose == true) {
-    cout << "Analyzing Instructions in batch " << cur_batch << endl;
-  }
-  else cout << "Analyzeing Instructions..." << endl;
-  
-  // Load in the variables...
-  cString filename("inst_analyze.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  const int num_insts = inst_set.GetSize();
-  
-  // Setup the file...
-  ofstream fp(filename);
-  
-  // Determine the file type...
-  int file_type = FILE_TYPE_TEXT;
-  while (filename.Find('.') != -1) filename.Pop('.');
-  if (filename == "html") file_type = FILE_TYPE_HTML;
-  
-  // If we're in HTML mode, setup the header...
-  if (file_type == FILE_TYPE_HTML) {
-    // Document header...
-    fp << "<html>" << endl
-    << "<body bgcolor=\"#FFFFFF\"" << endl
-    << " text=\"#000000\"" << endl
-    << " link=\"#0000AA\"" << endl
-    << " alink=\"#0000FF\"" << endl
-    << " vlink=\"#000044\">" << endl
-    << endl
-    << "<h1 align=center>Instruction Chart: "
-    << batch[cur_batch].Name() << endl
-    << "<br><br>" << endl
-    << endl;
-    
-    // Instruction key...
-    const int num_cols = 6;
-    const int num_rows = ((num_insts - 1) / num_cols) + 1;
-    fp << "<table border=2 cellpadding=3>" << endl
-      << "<tr bgcolor=\"#AAAAFF\"><th colspan=6>Instruction Set Legend</tr>"
-      << endl;
-    for (int i = 0; i < num_rows; i++) {
-      fp << "<tr>";
-      for (int j = 0; j < num_cols; j++) {
-        const int inst_id = i + j * num_rows;
-        if (inst_id < num_insts) {
-          cInstruction cur_inst(inst_id);
-          fp << "<td><b>" << cur_inst.GetSymbol() << "</b> : "
-            << inst_set.GetName(inst_id) << " ";
-        }
-        else {
-          fp << "<td>&nbsp; ";
-        }
-      }
-      fp << "</tr>" << endl;
-    }
-    fp << "</table>" << endl
-      << "<br><br><br>" << endl;
-    
-    // Main table header...
-    fp << "<center>" << endl
-      << "<table border=1 cellpadding=2>" << endl
-      << "<tr><th bgcolor=\"#AAAAFF\">Run # <th bgcolor=\"#AAAAFF\">Length"
-      << endl;
-    for (int i = 0; i < num_insts; i++) {
-      cInstruction cur_inst(i);
-      fp << "<th bgcolor=\"#AAAAFF\">" << cur_inst.GetSymbol() << " ";
-    }
-    fp << "</tr>" << endl;
-  }
-  else { // if (file_type == FILE_TYPE_TEXT) {
-    fp << "#RUN_NAME  LENGTH  ";
-    for (int i = 0; i < num_insts; i++) {
-      cInstruction cur_inst(i);
-      fp << cur_inst.GetSymbol() << ":" << inst_set.GetName(i) << " ";
-    }
-    fp << endl;
-  }
-  
-  // Figure out how often we expect each instruction to appear...
-  const double exp_freq = 1.0 / (double) num_insts;
-  const double min_freq = exp_freq * 0.5;
-  const double max_freq = exp_freq * 2.0;
-  
-  double total_length = 0.0;
-  tArray<double> total_freq(num_insts);
-  for (int i = 0; i < num_insts; i++) total_freq[i] = 0.0;
-  
-  // Loop through all of the genotypes in this batch...
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    // Setup for counting...
-    tArray<int> inst_bin(num_insts);
-    for (int i = 0; i < num_insts; i++) inst_bin[i] = 0;
-    
-    // Count it up!
-    const int genome_size = genotype->GetLength();
-    for (int i = 0; i < genome_size; i++) {
-      const int inst_id = genotype->GetGenome()[i].GetOp();
-      inst_bin[inst_id]++;
-    }
-    
-    // Print it out...
-    if (file_type == FILE_TYPE_HTML) fp << "<tr><th>";
-    fp << genotype->GetName() << " ";
-    if (file_type == FILE_TYPE_HTML) fp << "<td align=center>";
-    total_length += genome_size;
-    fp << genome_size << " ";
-    for (int i = 0; i < num_insts; i++) {
-      const double inst_freq = ((double) inst_bin[i]) / (double) genome_size;
-      total_freq[i] += inst_freq;
-      if (file_type == FILE_TYPE_HTML) {
-        if (inst_freq == 0.0) fp << "<td bgcolor=\"FFAAAA\">";
-        else if (inst_freq < min_freq) fp << "<td bgcolor=\"FFFFAA\">";
-        else if (inst_freq < max_freq) fp << "<td bgcolor=\"AAAAFF\">";
-        else fp << "<td bgcolor=\"AAFFAA\">";
-      }
-      fp << cStringUtil::Stringf("%04.3f", inst_freq) << " ";
-    }
-    if (file_type == FILE_TYPE_HTML) fp << "</tr>";
-    fp << endl;
-  }
-  
-  if (file_type == FILE_TYPE_HTML) {
-    int num_genomes = batch[cur_batch].List().GetSize();
-    fp << "<tr><th>Average <th>" << total_length / num_genomes << " ";
-    for (int i = 0; i < num_insts; i++) {
-      double inst_freq = total_freq[i] / num_genomes;
-      if (inst_freq == 0.0) fp << "<td bgcolor=\"FF0000\">";
-      else if (inst_freq < min_freq) fp << "<td bgcolor=\"FFFF00\">";
-      else if (inst_freq < max_freq) fp << "<td bgcolor=\"0000FF\">";
-      else fp << "<td bgcolor=\"00FF00\">";
-      fp << cStringUtil::Stringf("%04.3f", inst_freq) << " ";
-    }
-    fp << "</tr>" << endl
-      << "</table></center>" << endl;
-  }
-  }
-
-void cAnalyze::AnalyzeInstPop(cString cur_string)
-{
-  if (verbose == true) {
-    cout << "Analyzing Instructions in batch " << cur_batch << endl;
-  }
-  else cout << "Analyzeing Instructions..." << endl;
-  
-  // Load in the variables...
-  cString filename("inst_analyze.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  const int num_insts = inst_set.GetSize();
-  
-  // Setup the file...
-  ofstream fp(filename);
-  
-  for (int i = 0; i < num_insts; i++) {
-    cInstruction cur_inst(i);
-    fp << cur_inst.GetSymbol() << ":" << inst_set.GetName(i) << " ";
-  }
-  fp << endl;
-  
-  double total_length = 0.0;
-  tArray<double> total_freq(num_insts);
-  for (int i = 0; i < num_insts; i++) total_freq[i] = 0.0;
-  int num_orgs = 0; 
-  
-  // Loop through all of the genotypes in this batch...
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    
-    num_orgs++; 
-    
-    // Setup for counting...
-    tArray<int> inst_bin(num_insts);
-    for (int i = 0; i < num_insts; i++) inst_bin[i] = 0;
-    
-    // Count it up!
-    const int genome_size = genotype->GetLength();
-    for (int i = 0; i < genome_size; i++) {
-      const int inst_id = genotype->GetGenome()[i].GetOp();
-      inst_bin[inst_id]++;
-    }
-    total_length += genome_size;
-    for (int i = 0; i < num_insts; i++) {
-      const double inst_freq = ((double) inst_bin[i]) / (double) genome_size;
-      total_freq[i] += inst_freq;
-    }
-  }
-  // Print it out...
-  //    fp << total_length/num_orgs  << " ";
-  for (int i = 0; i < num_insts; i++) {
-    fp << cStringUtil::Stringf("%04.3f", total_freq[i]/num_orgs) << " ";
-  }
-  fp << endl;
-  
-}
-
-void cAnalyze::AnalyzeBranching(cString cur_string)
-{
-  if (verbose == true) {
-    cout << "Analyzing branching patterns in batch " << cur_batch << endl;
-  }
-  else cout << "Analyzeing Branches..." << endl;
-  
-  // Load in the variables...
-  cString filename("branch_analyze.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  
-  // Setup the file...
-  ofstream fp(filename);
-  
-  // UNFINISHED!
-  // const int num_insts = inst_set.GetSize();
-}
-
-void cAnalyze::AnalyzeMutationTraceback(cString cur_string)
-{
-  if (verbose == true) {
-    cout << "Analyzing mutation traceback in batch " << cur_batch << endl;
-  }
-  else cout << "Analyzing mutation traceback..." << endl;
-  
-  // This works best on lineages, so warn if we don't have one.
-  if (batch[cur_batch].IsLineage() == false && verbose == true) {
-    cerr << "  Warning: trying to traceback mutations outside of lineage."
-    << endl;
-  }
-  
-  if (batch[cur_batch].List().GetSize() == 0) {
-    cerr << "Error: Trying to traceback mutations with no genotypes in batch."
-    << endl;
-    return;
-  }
-  
-  // Make sure all genotypes are the same length.
-  int size = -1;
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    if (size == -1) size = genotype->GetLength();
-    if (size != genotype->GetLength()) {
-      cerr << "  Error: Trying to traceback mutations in genotypes of differing lengths." << endl;
-      cerr << "  Aborting." << endl;
-      return;
-    }
-  }
-  
-  // Setup variables...
-  cString filename("analyze_traceback.dat");
-  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  
-  // Setup a genome to store the previous values before mutations.
-  tArray<int> prev_inst(size);
-  prev_inst.SetAll(-1);  // -1 indicates never changed.
-  
-  // Open the output file...
-  ofstream fp(filename);
-  
-  // Loop through all of the genotypes again, testing mutation reversions.
-  cAnalyzeGenotype * prev_genotype = batch_it.Next();
-  while ((genotype = batch_it.Next()) != NULL) {
-    continue;
-    // Check to see if any sites have changed...
-    for (int i = 0; i < size; i++) {
-      if (genotype->GetGenome()[i] != prev_genotype->GetGenome()[i]) {
-        prev_inst[i] = prev_genotype->GetGenome()[i].GetOp();
-      }
-    }
-    
-    // Next, determine the fraction of mutations that are currently adaptive.
-    int num_beneficial = 0;
-    int num_neutral = 0;
-    int num_detrimental = 0;
-    int num_static = 0;      // Sites that were never mutated.
-    
-    cGenome test_genome = genotype->GetGenome();
-    cCPUTestInfo test_info;
-    m_world->GetTestCPU().TestGenome(test_info, test_genome);
-    const double base_fitness = test_info.GetGenotypeFitness();
-    
-    for (int i = 0; i < size; i++) {
-      if (prev_inst[i] == -1) num_static++;
-      else {
-        test_genome[i].SetOp(prev_inst[i]);
-        m_world->GetTestCPU().TestGenome(test_info, test_genome);
-        const double cur_fitness = test_info.GetGenotypeFitness();
-        if (cur_fitness > base_fitness) num_detrimental++;
-        else if (cur_fitness < base_fitness) num_beneficial++;
-        else num_neutral++;
-        test_genome[i] = genotype->GetGenome()[i];
-      }      
-    }
-    
-    fp << genotype->GetDepth() << " "
-      << num_beneficial << " "
-      << num_neutral << " "
-      << num_detrimental << " "
-      << num_static << " "
-      << endl;
-    
-    prev_genotype = genotype;
-  }
-}
-
-void cAnalyze::AnalyzeComplexity(cString cur_string)
-{
-  cout << "Analyzing genome complexity..." << endl;
-  
-  // Load in the variables...
-  // This command requires at least on arguement
-  int words = cur_string.CountNumWords();
-  if(words < 1) {
-    cout << "Error: AnalyzeComplexity has no parameters, skipping." << endl;
-    return;
-  }
-  
-  // Get the mutation rate arguement
-  double mut_rate = cur_string.PopWord().AsDouble();
-  
-  // Create the directory using the string given as the second arguement
-  cString dir = cur_string.PopWord();
-  cString defaultDirectory = "complexity/";
-  cString directory = PopDirectory(dir, defaultDirectory);
-  
-  // Default for usage of resources is false
-  int useResources = 0;
-  // resource usage flag is an optional arguement, but is always the 3rd arg
-  if(words >= 3) {
-    useResources = cur_string.PopWord().AsInt();
-    // All non-zero values are considered false
-    if(useResources != 0 && useResources != 1) {
-      useResources = 0;
-    }
-  }
-  
-  // Batch frequency begins with the first organism, but then skips that 
-  // amount ahead in the batch.  It defaults to 1, so that default analyzes
-  // all the organisms in the batch.  It is always the 4th arg.
-  int batchFrequency = 1;
-  if(words == 4) {
-    batchFrequency = cur_string.PopWord().AsInt();
-    if(batchFrequency <= 0) {
-      batchFrequency = 1;
-    }
-  }
-  
-  // These are used to backup the state of the environment and resource_count
-  // for the test cpu, and will be reset to their original values at the end
-  bool backupUsage;
-  tArray<double> backupResources;
-  
-  if(useResources) {
-    // Backup test cpu data
-    backupUsage = m_world->GetTestCPU().UseResources();
-    backupResources = m_world->GetTestCPU().GetResources();
-    
-    m_world->GetTestCPU().UseResources() = true;
-  }
-  
-  ///////////////////////////////////////////////////////
-  // Loop through all of the genotypes in this batch...
-  
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  
-  
-  bool islineage = false;
-  cString lineage_filename;
-  ofstream lineage_fp;
-  ofstream non_lineage_fp;
-  if (batch[cur_batch].IsLineage() == true) {
-    lineage_filename.Set("%s%s.complexity.dat", directory(), "lineage");
-    lineage_fp.open(lineage_filename);
-    islineage = true;
-  } else {
-    cString non_lineage_file;
-    non_lineage_file.Set("%s%s.complexity.dat", directory(), "nonlineage");
-    non_lineage_fp.open(non_lineage_file);
-    islineage = false;
-  }
-  
-  while ((genotype = batch_it.Next()) != NULL) {
-    if (verbose == true) {
-      cout << "  Analyzing complexity for " << genotype->GetName() << endl;
-    }
-    
-    // Construct this filename...
-    cString filename;
-    filename.Set("%s%s.complexity.dat", directory(), genotype->GetName()());
-    ofstream fp(filename());
-    if (islineage) {
-      lineage_fp << genotype->GetID() << " ";
-    } else {
-      non_lineage_fp << genotype->GetID() << " ";
-    }
-    
-    int updateBorn = -1;
-    if(useResources) {
-      updateBorn = genotype->GetUpdateBorn();
-      FillResources(updateBorn);
-    }
-    
-    // Calculate the stats for the genotype we're working with ...
-    genotype->Recalculate();
-    cout << genotype->GetFitness() << endl;
-    const int num_insts = inst_set.GetSize();
-    const int max_line = genotype->GetLength();
-    const cGenome & base_genome = genotype->GetGenome();
-    cGenome mod_genome(base_genome);
-    
-    // Loop through all the lines of code, testing all mutations...
-    tArray<double> test_fitness(num_insts);
-    tArray<double> prob(num_insts);
-    for (int line_num = 0; line_num < max_line; line_num++) {
-      int cur_inst = base_genome[line_num].GetOp();
-      //char cur_symbol = base_genome[line_num].GetSymbol();
-      
-      // Column 1 ... the original instruction in the genome.
-      fp << cur_inst << " ";
-      
-      // Test fitness of each mutant.
-      for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
-        mod_genome[line_num].SetOp(mod_inst);
-        cAnalyzeGenotype test_genotype(m_world, mod_genome, inst_set);
-        test_genotype.Recalculate();
-        test_fitness[mod_inst] = test_genotype.GetFitness();
-      }
-      
-      // Ajust fitness
-      double cur_inst_fitness = test_fitness[cur_inst];
-      for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
-        if (test_fitness[mod_inst] > cur_inst_fitness)
-          test_fitness[mod_inst] = cur_inst_fitness;
-        test_fitness[mod_inst] = test_fitness[mod_inst] / cur_inst_fitness;
-      }
-      
-      // Calculate probabilities at mut-sel balance
-      double w_bar = 1;
-      
-      // Normalize fitness values, assert if they are all zero
-      double maxFitness = 0.0;
-      for(int i=0; i<num_insts; i++) {
-        if(test_fitness[i] > maxFitness) {
-          maxFitness = test_fitness[i];
-        }
-      }
-      
-      if(maxFitness > 0) {
-        for(int i=0; i<num_insts; i++) {
-          test_fitness[i] /= maxFitness;
-        }
-      } else {
-        fp << "All zero fitness, ERROR." << endl;
-        continue;
-      }
-      
-      while(1) {
-        double sum = 0.0;
-        for (int mod_inst = 0; mod_inst < num_insts; mod_inst ++) {
-          prob[mod_inst] = (mut_rate * w_bar) /
-          ((double)num_insts * (w_bar + test_fitness[mod_inst] * mut_rate - test_fitness[mod_inst]));
-          sum = sum + prob[mod_inst];
-        }
-        if ((sum-1.0)*(sum-1.0) <= 0.0001) 
-          break;
-        else
-          w_bar = w_bar - 0.000001;
-      }
-      // Write probability
-      for (int mod_inst = 0; mod_inst < num_insts; mod_inst ++) {
-        fp << prob[mod_inst] << " ";
-      }
-      
-      // Calculate complexity
-      double entropy = 0;
-      for (int i = 0; i < num_insts; i ++) {
-        entropy += prob[i] * log((double) 1.0/prob[i]) / log ((double) num_insts);
-      }
-      double complexity = 1 - entropy;
-      fp << complexity << endl;
-      
-      if (islineage) {
-        lineage_fp << complexity << " ";
-      } else {
-        non_lineage_fp << complexity << " ";
-      }
-      
-      // Reset the mod_genome back to the original sequence.
-      mod_genome[line_num].SetOp(cur_inst);
-    }
-    fp.close();
-    if (islineage) {
-      lineage_fp << endl;
-    } else {
-      non_lineage_fp << endl;
-    }
-    
-    // Always grabs the first one
-    // Skip i-1 times, so that the beginning of the loop will grab the ith one
-    // where i is the batchFrequency
-    for(int count=0; genotype != NULL && count < batchFrequency - 1; count++) {
-      genotype = batch_it.Next();
-      if(genotype != NULL && verbose == true) {
-        cout << "Skipping: " << genotype->GetName() << endl;
-      }
-    }
-    if(genotype == NULL) { break; }
-  }
-  if (islineage) {
-    lineage_fp.close();
-  } else {
-    non_lineage_fp.close();
-  }
-  
-  if(useResources) {
-    // Set the test cpu back to the state it was in before we messed with it
-    m_world->GetTestCPU().UseResources() = backupUsage;
-    m_world->GetTestCPU().SetupResourceArray(backupResources);
-  }
-  
-  return;
-}
-
-void cAnalyze::AnalyzePopComplexity(cString cur_string)
-{
-  cout << "Analyzing population complexity ..." << endl;
-  
-  // Load in the variables...
-  //int batch_size = cur_string.PopWord().AsInt();
-  //int sample_size = cur_string.PopWord().AsInt();
-  cString directory = PopDirectory(cur_string, "pop_complexity/");
-  cString file = cur_string;
-  
-  // Get sample index...
-  /*if (sample_size > batch_size) {
-    cout << " Sample size is greater than batch size." << endl;
-  return;
-  }
-int *index_array;
-int *flag_array;
-index_array = (int*) malloc (batch_size*sizeof(int));
-flag_array = (int*) malloc (batch_size*sizeof(int));
-for (int i=0; i<batch_size; i++) {
-  index_array[i] = i;
-  flag_array[i] = 0;
-}
-int max_num = batch_size;
-cRandom random;
-for (int i=0; i<sample_size; i++) {
-  int index = random.GetUInt(max_num);
-  flag_array[index_array[index]] = 1;
-  index_array[index] = index_array[max_num-1];
-  max_num--;
-}*/
-  
-  // Construct filename...
-  cString filename;
-  filename.Set("%spop%s.complexity.dat", directory(), file());
-  ofstream fp(filename());
-  
-  //////////////////////////////////////////////////////////
-  // Loop through all of the genotypes in this batch ...
-  
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  
-  
-  genotype = batch_it.Next();
-  
-  
-  if (genotype == NULL) return;
-  int seq_length = genotype->GetLength();
-  const int num_insts = inst_set.GetSize();
-  tMatrix<int> inst_stat(seq_length, num_insts);
-  
-  // Initializing inst_stat ...
-  for (int line_num = 0; line_num < seq_length; line_num ++) 
-    for (int inst_num = 0; inst_num < num_insts; inst_num ++) 
-      inst_stat(line_num, inst_num) = 0;
-
-  int num_cpus = 0;
-  int actural_samples = 0;
-  while (genotype != NULL) {
-    num_cpus = genotype->GetNumCPUs();
-    const cGenome & base_genome = genotype->GetGenome();
-    for (int i=0; i<num_cpus; i++) {   // Stat on every organism with same genotype.
-                                       //if (flag_array[organism_index] == 0) {
-                                       //organism_index++;
-                                       //continue;
-                                       //}
-      for (int line_num = 0; line_num < seq_length; line_num ++) {
-        int cur_inst = base_genome[line_num].GetOp();
-        inst_stat(line_num, cur_inst) ++;
-      }
-      //organism_index++;
-      actural_samples++;
-    }
-    genotype = batch_it.Next();
-  }
-
-
-
-// Calculate complexity
-for (int line_num = 0; line_num < seq_length; line_num ++) {
-  double entropy = 0.0;
-  for (int inst_num = 0; inst_num < num_insts; inst_num ++) {
-    if (inst_stat(line_num, inst_num) == 0) continue;
-    float prob = (float) (inst_stat(line_num, inst_num)) / (float) (actural_samples);
-    entropy += prob * log((double) 1.0/prob) / log((double) num_insts);
-  }
-  double complexity = 1 - entropy;
-  fp << complexity << " ";
-};
-fp << endl;
-fp.close();
-//free(index_array);
-//free(flag_array);
-return;
-}
-
-
-void cAnalyze::EnvironmentSetup(cString cur_string)
-{
-  cout << "Running environment command: " << endl
-  << "  " << cur_string << endl;
-  
-  m_world->GetEnvironment().LoadLine(cur_string);
-}
-
-
-void cAnalyze::CommandHelpfile(cString cur_string)
-{
-  cout << "Printing helpfiles in: " << cur_string << endl;
-  
-  cHelpManager help_control;
-  if (verbose == true) help_control.SetVerbose();
-  while (cur_string.GetSize() > 0) {
-    help_control.LoadFile(cur_string.PopWord());
-  }
-  
-  help_control.PrintHTML();
-}
-
-void cAnalyze::CommandDocfile(cString cur_string)
-{
-  cout << "Printing documentation files in: " << cur_string << endl;
-  
-  cHelpManager help_control;
-  if (verbose == true) help_control.SetVerbose();
-  while (cur_string.GetSize() > 0) {
-    help_control.LoadFile(cur_string.PopWord());
-  }
-  
-  help_control.PrintHTML();
-}
-
-
-
-//////////////// Control...
-
-void cAnalyze::VarSet(cString cur_string)
-{
-  cString var = cur_string.PopWord();
-  
-  if (cur_string.GetSize() == 0) {
-    cerr << "Error: No variable provided in SET command" << endl;
-    return;
-  }
-  
-  cString & cur_variable = GetVariable(var);
-  cur_variable = cur_string.PopWord();
-  
-  if (verbose == true) {
-    cout << "Setting " << var << " to " << cur_variable << endl;
-  }
-}
-
-void cAnalyze::BatchSet(cString cur_string)
-{
-  int next_batch = 0;
-  if (cur_string.CountNumWords() > 0) {
-    next_batch = cur_string.PopWord().AsInt();
-  }
-  if (verbose) cout << "Setting current batch to " << next_batch << endl;
-  if (next_batch >= MAX_BATCHES) {
-    cerr << "  Error: max batches is " << MAX_BATCHES << endl;
-    exit(1);
-  } else {
-    cur_batch = next_batch;
-  }
-}
-
-void cAnalyze::BatchName(cString cur_string)
-{
-  if (cur_string.CountNumWords() == 0) {
-    if (verbose) cout << "  Warning: No name given in NAME_BATCH!" << endl;
-    return;
-  }
-  
-  batch[cur_batch].Name() = cur_string.PopWord();
-}
-
-void cAnalyze::BatchTag(cString cur_string)
-{
-  if (cur_string.CountNumWords() == 0) {
-    if (verbose) cout << "  Warning: No tag given in TAG_BATCH!" << endl;
-    return;
-  }
-  
-  if (verbose == true) {
-    cout << "Tagging batch " << cur_batch
-    << " with tag '" << cur_string << "'" << endl;
-  }
-  
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    genotype->SetTag(cur_string);
-  }
-  
-}
-
-void cAnalyze::BatchPurge(cString cur_string)
-{
-  int batch_id = cur_batch;
-  if (cur_string.CountNumWords() > 0) batch_id = cur_string.PopWord().AsInt();
-  
-  if (verbose) cout << "Purging batch " << batch_id << endl;
-  
-  while (batch[batch_id].List().GetSize() > 0) {
-    delete batch[batch_id].List().Pop();
-  }
-  
-  batch[batch_id].SetLineage(false);
-  batch[batch_id].SetAligned(false);
-}
-
-void cAnalyze::BatchDuplicate(cString cur_string)
-{
-  if (cur_string.GetSize() == 0) {
-    cerr << "Duplicate Error: Must include from ID!" << endl;
-    exit(1);
-  }
-  int batch_from = cur_string.PopWord().AsInt();
-  
-  int batch_to = cur_batch;
-  if (cur_string.GetSize() > 0) batch_to = cur_string.PopWord().AsInt();
-  
-  if (verbose == true) {
-    cout << "Duplicating from batch " << batch_from
-    << " to batch " << batch_to << "." << endl;
-  }
-  
-  tListIterator<cAnalyzeGenotype> batch_from_it(batch[batch_from].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_from_it.Next()) != NULL) {
-    cAnalyzeGenotype * new_genotype = new cAnalyzeGenotype(*genotype);
-    batch[batch_to].List().PushRear(new_genotype);
-  }
-  
-  batch[batch_to].SetLineage(false);
-  batch[batch_to].SetAligned(false);
-}
-
-void cAnalyze::BatchRecalculate(cString cur_string)
-{
-  int words = cur_string.CountNumWords();
-  int useResources = 0;
-  int update = -1;
-  if(words >= 1) {
-    useResources = cur_string.PopWord().AsInt();
-    // All non-zero values are considered false
-    if(useResources != 0 && useResources != 1) {
-      useResources = 0;
-    }
-  }
-  if (words >= 2) {
-    update = cur_string.PopWord().AsInt();
-  }
-  
-  bool backupUsage;
-  tArray<double> backupResources;
-  
-  if(useResources) {
-    // Backup test cpu data
-    backupUsage = m_world->GetTestCPU().UseResources();
-    backupResources = m_world->GetTestCPU().GetResources();
-    
-    m_world->GetTestCPU().UseResources() = true;
-  }
-  
-  if (verbose == true) {
-    cout << "Running batch " << cur_batch << " through test CPUs..." << endl;
-  } else cout << "Running through test CPUs..." << endl;
-  
-  if (verbose == true && batch[cur_batch].IsLineage() == false) {
-    cerr << "  Warning: batch may not be a linege; "
-    << "parent and ancestor distances may not be correct" << endl;
-  }
-  
-  if (useResources && update > -1) {
-    FillResources(update);
-  }
-
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  cAnalyzeGenotype * last_genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    
-    // If use resources, load proper resource according to update_born
-    if(useResources && update == -1) {
-      int updateBorn = -1;
-      updateBorn = genotype->GetUpdateBorn();
-      FillResources(updateBorn);
-    }
-    
-    // If the previous genotype was the parent of this one, pass in a pointer
-    // to it for improved recalculate (such as distance to parent, etc.)
-//     if (verbose == true) {
-//       PrintTestCPUResources("");
-//     }
-    if (last_genotype != NULL &&
-        genotype->GetParentID() == last_genotype->GetID()) {
-      genotype->Recalculate(last_genotype);
-    }
-    else genotype->Recalculate();
-    last_genotype = genotype;
-  }
-  
-  if(useResources) {
-    // Set the test cpu back to the state it was in before we messed with it
-    m_world->GetTestCPU().UseResources() = backupUsage;
-    m_world->GetTestCPU().SetupResourceArray(backupResources);
-  }
-  
-  return;
-}
-
-void cAnalyze::BatchRename(cString cur_string)
-{
-  if (verbose == false) cout << "Renaming organisms..." << endl;
-  else cout << "Renaming organisms in batch " << cur_batch << endl;
-  
-  // If a number is given with rename, start at that number...
-  
-  int id_num = cur_string.PopWord().AsInt();
-  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    cString name = cStringUtil::Stringf("org-%d", id_num);
-    genotype->SetID(id_num);
-    genotype->SetName(name);
-    id_num++;
-  }
-}
-
-void cAnalyze::PrintStatus(cString cur_string)
-{
-  // No Args needed...
-  (void) cur_string;
-  
-  cout << "Status Report:" << endl;
-  for (int i = 0; i < MAX_BATCHES; i++) {
-    if (i == cur_batch || batch[i].List().GetSize() > 0) {
-      cout << "  Batch " << i << " -- "
-      << batch[i].List().GetSize() << " genotypes.";
-      if (i == cur_batch) cout << "  <current>";
-      if (batch[i].IsLineage() == true) cout << "  <lineage>";
-      if (batch[i].IsAligned() == true) cout << "  <aligned>";
-      
-      cout << endl;
-    }
-  }
-}
-
-void cAnalyze::PrintDebug(cString cur_string)
-{
-  cerr << "Debug Args: " << cur_string << endl;
-}
-
-void cAnalyze::ToggleVerbose(cString cur_string)
-{
-  // No Args needed...
-  (void) cur_string;
-  
-  if (verbose == false) {
-    cout << "Using verbose log messages..." << endl;
-    verbose = true;
-  } else {
-    cout << "Using non-verbose log messages..." << endl;
-    verbose = false;
-  }
-}
-
-void cAnalyze::IncludeFile(cString cur_string)
-{
-  while (cur_string.GetSize() > 0) {
-    cString filename = cur_string.PopWord();
-    
-    cInitFile include_file(filename);
-    include_file.Load();
-    include_file.Compress();
-    include_file.Close();
-    
-    tList<cAnalyzeCommand> include_list;
-    LoadCommandList(include_file, include_list);
-    ProcessCommands(include_list);
-  }
-}
-
-void cAnalyze::CommandSystem(cString cur_string)
-{
-  cout << "Running System Command: " << cur_string << endl;
-  
-  system(cur_string());
-}
-
-void cAnalyze::CommandInteractive(cString cur_string)
-{
-  // No Args needed...
-  (void) cur_string;
-  
-  RunInteractive();
-}
-
-void cAnalyze::PrintTestCPUResources(cString cur_string)
-{
-  cout << "TestCPU is using resources: ";
-  cout << m_world->GetTestCPU().UseResources() << endl;
-  cout << "Resources currently in TestCPU: ";
-  const tArray<double> &quantity = m_world->GetTestCPU().GetResources();
-  for(int i=0; i<quantity.GetSize(); i++) {
-    cout << quantity.ElementAt(i) << " ";
-  }
-  cout << endl;
-  
-  return;
-}
-
-void cAnalyze::FunctionCreate(cString cur_string,
-                              tList<cAnalyzeCommand> & clist)
-{
-  int num_args = cur_string.CountNumWords();
-  if (num_args < 1) {
-    cerr << "Error: Must provide function name when creating function.";
-    exit(1);
-  }
-  
-  cString fun_name = cur_string.PopWord();
-  fun_name.ToUpper();
-  
-  if (FindAnalyzeCommandDef(fun_name) != NULL) {
-    cerr << "Error: Cannot create function '" << fun_name
-    << "'; already exists." << endl;
-    exit(1);
-  }
-  
-  if (verbose) cout << "Creating function: " << fun_name << endl;
-  
-  // Create the new function...
-  cAnalyzeFunction * new_function = new cAnalyzeFunction(fun_name);
-  while (clist.GetSize() > 0) {
-    new_function->GetCommandList()->PushRear(clist.Pop());
-  }
-  
-  // Save the function on the new list...
-  function_list.PushRear(new_function);
-}
-
-bool cAnalyze::FunctionRun(const cString & fun_name, cString args)
-{
-  if (verbose) {
-    cout << "Running function: " << fun_name << endl;
-    // << " with args: " << args << endl;
-  }
-  
-  // Find the function we're about to run...
-  cAnalyzeFunction * found_function = NULL;
-  tListIterator<cAnalyzeFunction> function_it(function_list);
-  while (function_it.Next() != NULL) {
-    if (function_it.Get()->GetName() == fun_name) {
-      found_function = function_it.Get();
-      break;
-    }
-  }
-  
-  // If we were unable to find the command we're looking for, return false.
-  if (found_function == NULL) return false;
-  
-  // Back up the local variables
-  cString backup_arg_vars[10];
-  cString backup_local_vars[26];
-  for (int i = 0; i < 10; i++) backup_arg_vars[i] = arg_variables[i];
-  for (int i = 0; i < 26; i++) backup_local_vars[i] = local_variables[i];
-  
-  // Set the arg variables to the passed-in args...
-  arg_variables[0] = fun_name;
-  for (int i = 1; i < 10; i++) arg_variables[i] = args.PopWord();
-  for (int i = 0; i < 26; i++) local_variables[i] = "";
-  
-  ProcessCommands(*(found_function->GetCommandList()));
-  
-  // Restore the local variables
-  for (int i = 0; i < 10; i++) arg_variables[i] = backup_arg_vars[i];
-  for (int i = 0; i < 26; i++) local_variables[i] = backup_local_vars[i];
-  
-  return true;
-}
-
-
-int cAnalyze::BatchUtil_GetMaxLength(int batch_id)
-{
-  if (batch_id < 0) batch_id = cur_batch;
-  
-  int max_length = 0;
-  
-  tListIterator<cAnalyzeGenotype> batch_it(batch[batch_id].List());
-  cAnalyzeGenotype * genotype = NULL;
-  while ((genotype = batch_it.Next()) != NULL) {
-    if (genotype->GetLength() > max_length) max_length = genotype->GetLength();
-  }
-  
-  return max_length;
-}
-
-
-void cAnalyze::CommandForeach(cString cur_string,
-                              tList<cAnalyzeCommand> & clist)
-{
-  if (verbose) cout << "Initiating Foreach loop..." << endl;
-  
-  cString var = cur_string.PopWord();
-  int num_args = cur_string.CountNumWords();
-  
-  cString & cur_variable = GetVariable(var);
-  
-  for (int i = 0; i < num_args; i++) {
-    cur_variable = cur_string.PopWord();
-    
-    if (verbose == true) {
-      cout << "Foreach: setting " << var << " to " << cur_variable << endl;
-    }
-    ProcessCommands(clist);
-  }
-  
-  if (verbose == true) {
-    cout << "Ending Foreach on " << var << endl;
-  }
-}
-
-
-void cAnalyze::CommandForRange(cString cur_string,
-                               tList<cAnalyzeCommand> & clist)
-{
-  if (verbose) cout << "Initiating FORRANGE loop..." << endl;
-  
-  int num_args = cur_string.CountNumWords();
-  if (num_args < 3) {
-    cerr << "  Error: Must give variable, min and max with FORRANGE!"
-    << endl;
-    exit(1);
-  }
-  
-  cString var = cur_string.PopWord();
-  double min_val = cur_string.PopWord().AsDouble();
-  double max_val = cur_string.PopWord().AsDouble();
-  double step_val = 1.0;
-  if (num_args >=4 ) step_val = cur_string.PopWord().AsDouble();
-  
-  cString & cur_variable = GetVariable(var);
-  
-  // Seperate out all ints from not all ints...
-  if (min_val == (double) ((int) min_val) &&
-      max_val == (double) ((int) max_val) &&
-      step_val == (double) ((int) step_val)) {
-    for (int i = (int) min_val; i <= (int) max_val; i += (int) step_val) {
-      cur_variable.Set("%d", i);
-      
-      if (verbose == true) {
-        cout << "FORRANGE: setting " << var << " to " << cur_variable << endl;
-      }
-      ProcessCommands(clist);
-    }
-  } else {
-    for (double i = min_val; i <= max_val; i += step_val) {
-      cur_variable.Set("%f", i);
-      
-      if (verbose == true) {
-        cout << "FORRANGE: setting " << var << " to " << cur_variable << endl;
-      }
-      ProcessCommands(clist);
-    }
-  }
-  
-  if (verbose == true) {
-    cout << "Ending FORRANGE on " << var << endl;
-  }
-}
-
-
-///////////////////  Private Methods ///////////////////////////
-
-cString cAnalyze::PopDirectory(cString & in_string,
-                               const cString & default_dir)
-{
-  // Determing the directory name
-  cString directory(default_dir);
-  if (in_string.GetSize() != 0) directory = in_string.PopWord();
-  
-  // Make sure the directory ends in a slash.  If not, add one.
-  int last_pos = directory.GetSize() - 1;
-  if (directory[last_pos] != '/' && directory[last_pos] != '\\') {
-    directory += '/';
-  }
-  
-  // Make sure the directory exists.
-  FILE *fp = fopen ( directory(), "r" );
-  if ( fp == 0 ){
-    if ( errno == ENOENT ){
-      cerr << "Directory '" << directory
-      << "' does not exist.  Creating..." << endl;
-      if ( mkdir( directory(), (S_IRWXU|S_IRWXG|S_IRWXO) ) )
-        cerr << " Error creating '" << directory << "'" << endl;
-    }
-    else cerr << " Error opening '" << directory << "'" << endl;
-  }
-  
-  return directory;
-}
-
-int cAnalyze::PopBatch(const cString & in_string)
-{
-  int batch = cur_batch;
-  if (in_string.GetSize() != 0 && in_string != "current") {
-    batch = in_string.AsInt();
-  }
-  
-  return batch;
-}
-
-cAnalyzeGenotype * cAnalyze::PopGenotype(cString gen_desc, int batch_id)
-{
-  if (batch_id == -1) batch_id = cur_batch;
-  tListPlus<cAnalyzeGenotype> & gen_list = batch[batch_id].List();
-  gen_desc.ToLower();
-  
-  cAnalyzeGenotype * found_gen = NULL;
-  if (gen_desc == "num_cpus")
-    found_gen = gen_list.PopIntMax(&cAnalyzeGenotype::GetNumCPUs);
-  else if (gen_desc == "total_cpus")
-    found_gen = gen_list.PopIntMax(&cAnalyzeGenotype::GetTotalCPUs);
-  else if (gen_desc == "merit")
-    found_gen = gen_list.PopDoubleMax(&cAnalyzeGenotype::GetMerit);
-  else if (gen_desc == "fitness")
-    found_gen = gen_list.PopDoubleMax(&cAnalyzeGenotype::GetFitness);
-  else if (gen_desc.IsNumeric(0))
-    found_gen = gen_list.PopIntValue(&cAnalyzeGenotype::GetID,
-                                     gen_desc.AsInt());
-  else if (gen_desc == "random") {
-    int gen_pos = random.GetUInt(gen_list.GetSize());
-    found_gen = gen_list.PopPos(gen_pos);
-  }
-  else {
-    cout << "  Error: unknown type " << gen_desc << endl;
-    exit(1);
-  }
-  
-  return found_gen;
-}
-
-
-cString & cAnalyze::GetVariable(const cString & var)
-{
-  if (var.GetSize() != 1 ||
-      (var.IsLetter(0) == false && var.IsNumeric(0) == false)) {
-    cerr << "Error: Illegal variable " << var << " being used." << endl;
-    exit(1);
-  }
-  
-  if (var.IsLowerLetter(0) == true) {
-    int var_id = (int) (var[0] - 'a');
-    return variables[var_id];
-  }
-  else if (var.IsUpperLetter(0) == true) {
-    int var_id = (int) (var[0] - 'A');
-    return local_variables[var_id];
-  }
-  // Otherwise it must be a number...
-  int var_id = (int) (var[0] - '0');
-  return arg_variables[var_id];
-}
-
-
-void cAnalyze::LoadCommandList(cInitFile & init_file,
-                               tList<cAnalyzeCommand> & clist)
-{
-  while (init_file.GetLineNum() < init_file.GetNumLines()) {
-    cString cur_string = init_file.GetNextLine();
-    cString command = cur_string.PopWord();
-    command.ToUpper();
-    
-    cAnalyzeCommand * cur_command;
-    cAnalyzeCommandDefBase * command_def = FindAnalyzeCommandDef(command);
-    if (command == "END") {
-      // We are done with this section of code; break out...
-      break;
-    }
-    else if (command_def != NULL && command_def->IsFlowCommand() == true) {
-      // This code has a body to it... fill it out!
-      cur_command = new cAnalyzeFlowCommand(command, cur_string);
-      LoadCommandList( init_file, *(cur_command->GetCommandList()) );
-    }
-    else {
-      // This is a normal command...
-      cur_command = new cAnalyzeCommand(command, cur_string);
-    }
-    
-    clist.PushRear(cur_command);
-  }
-}
-
-void cAnalyze::InteractiveLoadCommandList(tList<cAnalyzeCommand> & clist)
-{
-  interactive_depth++;
-  char text_input[2048];
-  while (true) {
-    for (int i = 0; i <= interactive_depth; i++) {
-      cout << ">>";
-    }
-    cout << " ";
-    cout.flush();
-    cin.getline(text_input, 2048);
-    cString cur_input(text_input);
-    cString command = cur_input.PopWord();
-    command.ToUpper();
-    
-    cAnalyzeCommand * cur_command;
-    cAnalyzeCommandDefBase * command_def = FindAnalyzeCommandDef(command);
-    if (command == "END") {
-      // We are done with this section of code; break out...
-      break;
-    }
-    else if (command_def != NULL && command_def->IsFlowCommand() == true) {
-      // This code has a body to it... fill it out!
-      cur_command = new cAnalyzeFlowCommand(command, cur_input);
-      InteractiveLoadCommandList(*(cur_command->GetCommandList()));
-    }
-    else {
-      // This is a normal command...
-      cur_command = new cAnalyzeCommand(command, cur_input);
-    }
-    
-    clist.PushRear(cur_command);
-  }
-  interactive_depth--;
-}
-
-void cAnalyze::PreProcessArgs(cString & args)
-{
-  int pos = 0;
-  int search_start = 0;
-  while ((pos = args.Find('$', search_start)) != -1) {
-    // Setup the variable name that was found...
-    char varlet = args[pos+1];
-    cString varname("$");
-    varname += varlet;
-    
-    // Determine the variable and act on it.
-    int varsize = 0;
-    if (varlet == '$') {
-      args.Clip(pos+1, 1);
-      varsize = 1;
-    }
-    else if (varlet >= 'a' && varlet <= 'z') {
-      int var_id = (int) (varlet - 'a');
-      args.Replace(varname, variables[var_id], pos);
-      varsize = variables[var_id].GetSize();
-    }
-    else if (varlet >= 'A' && varlet <= 'Z') {
-      int var_id = (int) (varlet - 'A');
-      args.Replace(varname, local_variables[var_id], pos);
-      varsize = local_variables[var_id].GetSize();
-    }
-    else if (varlet >= '0' && varlet <= '9') {
-      int var_id = (int) (varlet - '0');
-      args.Replace(varname, arg_variables[var_id], pos);
-      varsize = arg_variables[var_id].GetSize();
-    }
-    search_start = pos + varsize;
-  }
-}
-
-void cAnalyze::ProcessCommands(tList<cAnalyzeCommand> & clist)
-{
-  // Process the command list...
-  tListIterator<cAnalyzeCommand> command_it(clist);
-  command_it.Reset();
-  cAnalyzeCommand * cur_command = NULL;
-  while ((cur_command = command_it.Next()) != NULL) {
-    cString command = cur_command->GetCommand();
-    cString args = cur_command->GetArgs();
-    PreProcessArgs(args);
-    
-    cAnalyzeCommandDefBase * command_fun = FindAnalyzeCommandDef(command);
-    
-    if (command_fun != NULL) command_fun->Run(this, args, *cur_command);
-    else if (FunctionRun(command, args) == true) {
-      // Found a defined function by this name.
-    }
-    else {
-      cerr << "Error: Unknown analysis keyword '" << command << "'." << endl;
-      exit(1);
-    }
-    
-  }
-}
-
-void cAnalyze::SetupGenotypeDataList()
-{
-  if (genotype_data_list.GetSize() != 0) return; // List already setup.
-  
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, bool>
-                              ("viable",      "Is Viable (0/1)", &cAnalyzeGenotype::GetViable,
-                               &cAnalyzeGenotype::SetViable));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("id",          "Genotype ID",       &cAnalyzeGenotype::GetID,
-                               &cAnalyzeGenotype::SetID));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, const cString &>
-                              ("tag",         "Genotype Tag",    &cAnalyzeGenotype::GetTag,
-                               &cAnalyzeGenotype::SetTag,
-                               &cAnalyzeGenotype::CompareNULL, "(none)", ""));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("parent_id",   "Parent ID",       &cAnalyzeGenotype::GetParentID,
-                               &cAnalyzeGenotype::SetParentID));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("parent2_id",  "Second Parent ID (for sexual genotypes)",
-                               &cAnalyzeGenotype::GetParent2ID, &cAnalyzeGenotype::SetParent2ID));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("parent_dist", "Parent Distance", &cAnalyzeGenotype::GetParentDist,
-                               &cAnalyzeGenotype::SetParentDist));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("ancestor_dist","Ancestor Distance",&cAnalyzeGenotype::GetAncestorDist,
-                               &cAnalyzeGenotype::SetAncestorDist));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("lineage", "Unique Lineage Label",&cAnalyzeGenotype::GetLineageLabel,
-                               &cAnalyzeGenotype::SetLineageLabel));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("num_cpus",    "Number of CPUs",  &cAnalyzeGenotype::GetNumCPUs,
-                               &cAnalyzeGenotype::SetNumCPUs));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("total_cpus",  "Total CPUs Ever", &cAnalyzeGenotype::GetTotalCPUs,
-                               &cAnalyzeGenotype::SetTotalCPUs));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("length",      "Genome Length",   &cAnalyzeGenotype::GetLength,
-                               &cAnalyzeGenotype::SetLength, &cAnalyzeGenotype::CompareLength));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("copy_length", "Copied Length",   &cAnalyzeGenotype::GetCopyLength,
-                               &cAnalyzeGenotype::SetCopyLength));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("exe_length",  "Executed Length", &cAnalyzeGenotype::GetExeLength,
-                               &cAnalyzeGenotype::SetExeLength));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-                              ("merit",       "Merit",           &cAnalyzeGenotype::GetMerit,
-                               &cAnalyzeGenotype::SetMerit, &cAnalyzeGenotype::CompareMerit));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-                              ("comp_merit",  "Computational Merit", &cAnalyzeGenotype::GetCompMerit,
-                               (void (cAnalyzeGenotype::*)(double)) NULL, &cAnalyzeGenotype::CompareCompMerit));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-                              ("comp_merit_ratio", "Computational Merit Ratio",
-                               &cAnalyzeGenotype::GetCompMeritRatio,
-                               (void (cAnalyzeGenotype::*)(double)) NULL,
-                               &cAnalyzeGenotype::CompareCompMerit));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("gest_time",   "Gestation Time",  &cAnalyzeGenotype::GetGestTime,
-                               &cAnalyzeGenotype::SetGestTime,
-                               &cAnalyzeGenotype::CompareGestTime, "Inf."));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-                              ("efficiency",  "Rep. Efficiency", &cAnalyzeGenotype::GetEfficiency,
-                               (void (cAnalyzeGenotype::*)(double)) NULL,
-                               &cAnalyzeGenotype::CompareEfficiency));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-                              ("efficiency_ratio", "Rep. Efficiency Ratio",
-                               &cAnalyzeGenotype::GetEfficiencyRatio,
-                               (void (cAnalyzeGenotype::*)(double)) NULL,
-                               &cAnalyzeGenotype::CompareEfficiency));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-                              ("fitness",     "Fitness",         &cAnalyzeGenotype::GetFitness,
-                               &cAnalyzeGenotype::SetFitness, &cAnalyzeGenotype::CompareFitness));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-                              ("div_type",     "Divide Type",    &cAnalyzeGenotype::GetDivType,
-                               &cAnalyzeGenotype::SetDivType));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("mate_id",     "Mate Selection ID Number",  &cAnalyzeGenotype::GetMateID,
-                               &cAnalyzeGenotype::SetMateID));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-                              ("fitness_ratio", "Fitness Ratio", &cAnalyzeGenotype::GetFitnessRatio,
-                               (void (cAnalyzeGenotype::*)(double)) NULL,
-                               &cAnalyzeGenotype::CompareFitness));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("update_born", "Update Born",     &cAnalyzeGenotype::GetUpdateBorn,
-                               &cAnalyzeGenotype::SetUpdateBorn));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("update_dead", "Update Dead",     &cAnalyzeGenotype::GetUpdateDead,
-                               &cAnalyzeGenotype::SetUpdateDead));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("depth",       "Tree Depth",      &cAnalyzeGenotype::GetDepth,
-                               &cAnalyzeGenotype::SetDepth));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-                              ("frac_dead",   "Fraction Mutations Lethal",
-                               &cAnalyzeGenotype::GetFracDead,
-                               (void (cAnalyzeGenotype::*)(double)) NULL));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-                              ("frac_neg",   "Fraction Mutations Detrimental",
-                               &cAnalyzeGenotype::GetFracNeg,
-                               (void (cAnalyzeGenotype::*)(double)) NULL));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-                              ("frac_neut",   "Fraction Mutations Neutral",
-                               &cAnalyzeGenotype::GetFracNeut,
-                               (void (cAnalyzeGenotype::*)(double)) NULL));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-                              ("frac_pos",   "Fraction Mutations Beneficial",
-                               &cAnalyzeGenotype::GetFracPos,
-                               (void (cAnalyzeGenotype::*)(double)) NULL));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, double>
-                              ("complexity",   "Basic Complexity (all neutral/beneficial muts are equal)",
-                               &cAnalyzeGenotype::GetComplexity,
-                               (void (cAnalyzeGenotype::*)(double)) NULL));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, const cString &>
-                              ("parent_muts", "Mutations from Parent",
-                               &cAnalyzeGenotype::GetParentMuts, &cAnalyzeGenotype::SetParentMuts,
-                               &cAnalyzeGenotype::CompareNULL, "(none)", ""));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, const cString &>
-                              ("task_order", "Task Performance Order",
-                               &cAnalyzeGenotype::GetTaskOrder, &cAnalyzeGenotype::SetTaskOrder,
-                               &cAnalyzeGenotype::CompareNULL, "(none)", ""));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
-                              ("sequence",    "Genome Sequence",
-                               &cAnalyzeGenotype::GetSequence, &cAnalyzeGenotype::SetSequence, 
-                               &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, const cString &>
-                              ("alignment",   "Aligned Sequence",
-                               &cAnalyzeGenotype::GetAlignedSequence,
-                               &cAnalyzeGenotype::SetAlignedSequence,
-                               &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
-  
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
-                              ("task_list",    "List of all tasks performed",
-                               &cAnalyzeGenotype::GetTaskList,
-                               (void (cAnalyzeGenotype::*)(cString)) NULL,
-                               &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
-  
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
-                              ("link.tasksites", "Phenotype Map", &cAnalyzeGenotype::GetMapLink,
-                               (void (cAnalyzeGenotype::*)(cString)) NULL));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
-                              ("html.sequence",  "Genome Sequence",
-                               &cAnalyzeGenotype::GetHTMLSequence,
-                               (void (cAnalyzeGenotype::*)(cString)) NULL,
-                               &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
-  
-  const cTaskLib & task_lib = m_world->GetEnvironment().GetTaskLib();
-  for (int i = 0; i < task_lib.GetSize(); i++) {
-    cString t_name, t_desc;
-    t_name.Set("task.%d", i);
-    t_desc = task_lib.GetTask(i).GetDesc();
-    genotype_data_list.PushRear(new tArgDataEntry<cAnalyzeGenotype, int, int>
-                                (t_name, t_desc, &cAnalyzeGenotype::GetTaskCount, i,
-                                 &cAnalyzeGenotype::CompareTaskCount));
-  }
-  
-  // The remaining values should actually go in a seperate list called
-  // "population_data_list", but for the moment we're going to put them
-  // here so that we only need to worry about a single system to load and
-  // save genotype information.
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("update",       "Update Output",
-                               &cAnalyzeGenotype::GetUpdateDead, &cAnalyzeGenotype::SetUpdateDead));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("dom_num_cpus", "Number of Dominant Organisms",
-                               &cAnalyzeGenotype::GetNumCPUs, &cAnalyzeGenotype::SetNumCPUs));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("dom_depth",    "Tree Depth of Dominant Genotype",
-                               &cAnalyzeGenotype::GetDepth, &cAnalyzeGenotype::SetDepth));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, int>
-                              ("dom_id",       "Dominant Genotype ID",
-                               &cAnalyzeGenotype::GetID, &cAnalyzeGenotype::SetID));
-  genotype_data_list.PushRear(new tDataEntry<cAnalyzeGenotype, cString>
-                              ("dom_sequence", "Dominant Genotype Sequence",
-                               &cAnalyzeGenotype::GetSequence, &cAnalyzeGenotype::SetSequence, 
-                               &cAnalyzeGenotype::CompareNULL, "(N/A)", ""));
-}
-
-
-// Pass in the arguments for a command and fill out the entries in list
-// format....
-
-void cAnalyze::LoadGenotypeDataList(cStringList arg_list,
-                                    tList< tDataEntryCommand<cAnalyzeGenotype> > & output_list)
-{
-  // For the moment, just put everything into the output list.
-  SetupGenotypeDataList();
-  
-  // If no args were given, load all of the stats.
-  if (arg_list.GetSize() == 0) {
-    tListIterator< tDataEntryBase<cAnalyzeGenotype> >
-    genotype_data_it(genotype_data_list);
-    while (genotype_data_it.Next() != (void *) NULL) {
-      tDataEntryCommand<cAnalyzeGenotype> * entry_command =
-      new tDataEntryCommand<cAnalyzeGenotype>(genotype_data_it.Get());
-      output_list.PushRear(entry_command);
-    }
-  }
-  // Otherwise, load only those listed.
-  else {
-    while (arg_list.GetSize() != 0) {
-      // Setup the next entry
-      cString cur_args = arg_list.Pop();
-      cString cur_entry = cur_args.Pop(':');
-      bool found_entry = false;
-      
-      // Scan the genotype data list for the current entry
-      tListIterator< tDataEntryBase<cAnalyzeGenotype> >
-        genotype_data_it(genotype_data_list);
-      
-      while (genotype_data_it.Next() != (void *) NULL) {
-        if (genotype_data_it.Get()->GetName() == cur_entry) {
-          tDataEntryCommand<cAnalyzeGenotype> * entry_command =
-          new tDataEntryCommand<cAnalyzeGenotype>
-          (genotype_data_it.Get(), cur_args);
-          output_list.PushRear(entry_command);
-          found_entry = true;
-          break;
-        }
-      }
-      
-      // If the entry was not found, give a warning.
-      if (found_entry == false) {
-        int best_match = 1000;
-        cString best_entry;
-        
-        genotype_data_it.Reset();
-        while (genotype_data_it.Next() != (void *) NULL) {
-          const cString & test_str = genotype_data_it.Get()->GetName();
-          const int test_dist = cStringUtil::EditDistance(test_str, cur_entry);
-          if (test_dist < best_match) {
-            best_match = test_dist;
-            best_entry = test_str;
-          }
-        }	
-        
-        cerr << "Warning: Format entry \"" << cur_entry
-          << "\" not found.  Best match is \""
-          << best_entry << "\"." << endl;
-      }
-      
-    }
-  }
-}
-
-
-void cAnalyze::AddLibraryDef(const cString & name,
-                             void (cAnalyze::*_fun)(cString))
-{
-  command_lib.PushRear(new cAnalyzeCommandDef(name, _fun));
-}
-
-void cAnalyze::AddLibraryDef(const cString & name,
-                             void (cAnalyze::*_fun)(cString, tList<cAnalyzeCommand> &))
-{
-  command_lib.PushRear(new cAnalyzeFlowCommandDef(name, _fun));
-}
-
-void cAnalyze::SetupCommandDefLibrary()
-{
-  if (command_lib.GetSize() != 0) return; // Library already setup.
-  
-  AddLibraryDef("LOAD_ORGANISM", &cAnalyze::LoadOrganism);
-  AddLibraryDef("LOAD_BASE_DUMP", &cAnalyze::LoadBasicDump);
-  AddLibraryDef("LOAD_DETAIL_DUMP", &cAnalyze::LoadDetailDump);
-  AddLibraryDef("LOAD_MULTI_DETAIL", &cAnalyze::LoadMultiDetail);
-  AddLibraryDef("LOAD_SEQUENCE", &cAnalyze::LoadSequence);
-  AddLibraryDef("LOAD_DOMINANT", &cAnalyze::LoadDominant);
-  AddLibraryDef("LOAD_RESOURCES", &cAnalyze::LoadResources);
-  AddLibraryDef("LOAD", &cAnalyze::LoadFile);
-  
-  // Reduction commands...
-  AddLibraryDef("FIND_GENOTYPE", &cAnalyze::FindGenotype);
-  AddLibraryDef("FIND_ORGANISM", &cAnalyze::FindOrganism);
-  AddLibraryDef("FIND_LINEAGE", &cAnalyze::FindLineage);
-  AddLibraryDef("FIND_SEX_LINEAGE", &cAnalyze::FindSexLineage);
-  AddLibraryDef("FIND_CLADE", &cAnalyze::FindClade);
-  AddLibraryDef("SAMPLE_ORGANISMS", &cAnalyze::SampleOrganisms);
-  AddLibraryDef("SAMPLE_GENOTYPES", &cAnalyze::SampleGenotypes);
-  AddLibraryDef("KEEP_TOP", &cAnalyze::KeepTopGenotypes);
-  
-  // Direct output commands...
-  AddLibraryDef("PRINT", &cAnalyze::CommandPrint);
-  AddLibraryDef("TRACE", &cAnalyze::CommandTrace);
-  AddLibraryDef("PRINT_TASKS", &cAnalyze::CommandPrintTasks);
-  AddLibraryDef("DETAIL", &cAnalyze::CommandDetail);
-  AddLibraryDef("DETAIL_TIMELINE", &cAnalyze::CommandDetailTimeline);
-  AddLibraryDef("DETAIL_BATCHES", &cAnalyze::CommandDetailBatches);
-  AddLibraryDef("DETAIL_AVERAGE", &cAnalyze::CommandDetailAverage);
-  AddLibraryDef("DETAIL_INDEX", &cAnalyze::CommandDetailIndex);
-  AddLibraryDef("HISTOGRAM", &cAnalyze::CommandHistogram);
-  
-  // Population analysis commands...
-  AddLibraryDef("PRINT_PHENOTYPES", &cAnalyze::CommandPrintPhenotypes);
-  AddLibraryDef("PRINT_DIVERSITY", &cAnalyze::CommandPrintDiversity);
-  AddLibraryDef("COMMUNITY_COMPLEXITY", &cAnalyze::AnalyzeCommunityComplexity);
-
-  // Individual organism analysis...
-  AddLibraryDef("LANDSCAPE", &cAnalyze::CommandLandscape);
-  AddLibraryDef("FITNESS_MATRIX", &cAnalyze::CommandFitnessMatrix);
-  AddLibraryDef("MAP", &cAnalyze::CommandMapTasks);  // Deprecated...
-  AddLibraryDef("MAP_TASKS", &cAnalyze::CommandMapTasks);
-  AddLibraryDef("AVERAGE_MODULARITY", &cAnalyze::CommandAverageModularity);
-  AddLibraryDef("MAP_MUTATIONS", &cAnalyze::CommandMapMutations);
-  AddLibraryDef("ANALYZE_COMPLEXITY", &cAnalyze::AnalyzeComplexity);
-  AddLibraryDef("ANALYZE_KNOCKOUTS", &cAnalyze::AnalyzeKnockouts);
-  AddLibraryDef("ANALYZE_POP_COMPLEXITY", &cAnalyze::AnalyzePopComplexity);
-  AddLibraryDef("MAP_DEPTH", &cAnalyze::CommandMapDepth);
-  
-  // Population comparison commands...
-  AddLibraryDef("HAMMING", &cAnalyze::CommandHamming);
-  AddLibraryDef("LEVENSTEIN", &cAnalyze::CommandLevenstein);
-  AddLibraryDef("SPECIES", &cAnalyze::CommandSpecies);
-  AddLibraryDef("RECOMBINE", &cAnalyze::CommandRecombine);
-  
-  // Lineage analysis commands...
-  AddLibraryDef("ALIGN", &cAnalyze::CommandAlign);
-  AddLibraryDef("ANALYZE_NEWINFO", &cAnalyze::AnalyzeNewInfo);
-  
-  // Build input files for avida...
-  AddLibraryDef("WRITE_CLONE", &cAnalyze::WriteClone);
-  AddLibraryDef("WRITE_INJECT_EVENTS", &cAnalyze::WriteInjectEvents);
-  AddLibraryDef("WRITE_COMPETITION", &cAnalyze::WriteCompetition);
-  
-  // Automated analysis
-  AddLibraryDef("ANALYZE_MUTS", &cAnalyze::AnalyzeMuts);
-  AddLibraryDef("ANALYZE_INSTRUCTIONS", &cAnalyze::AnalyzeInstructions);
-  AddLibraryDef("ANALYZE_INST_POP", &cAnalyze::AnalyzeInstPop);
-  AddLibraryDef("ANALYZE_BRANCHING", &cAnalyze::AnalyzeBranching);
-  AddLibraryDef("ANALYZE_MUTATION_TRACEBACK",
-                &cAnalyze::AnalyzeMutationTraceback);
-  AddLibraryDef("ANALYZE_EPISTASIS", &cAnalyze::AnalyzeEpistasis);
-  AddLibraryDef("ANALYZE_MATE_SELECTION", &cAnalyze::AnalyzeMateSelection);
-  AddLibraryDef("ANALYZE_COMPLEXITY_DELTA", &cAnalyze::AnalyzeComplexityDelta);
-  
-  // Environment manipulation
-  AddLibraryDef("ENVIRONMENT", &cAnalyze::EnvironmentSetup);
-  
-  // Documantation...
-  AddLibraryDef("HELPFILE", &cAnalyze::CommandHelpfile);
-  
-  // Control commands...
-  AddLibraryDef("SET", &cAnalyze::VarSet);
-  AddLibraryDef("SET_BATCH", &cAnalyze::BatchSet);
-  AddLibraryDef("NAME_BATCH", &cAnalyze::BatchName);
-  AddLibraryDef("TAG_BATCH", &cAnalyze::BatchTag);
-  AddLibraryDef("PURGE_BATCH", &cAnalyze::BatchPurge);
-  AddLibraryDef("DUPLICATE", &cAnalyze::BatchDuplicate);
-  AddLibraryDef("RECALCULATE", &cAnalyze::BatchRecalculate);
-  AddLibraryDef("RENAME", &cAnalyze::BatchRename);
-  AddLibraryDef("STATUS", &cAnalyze::PrintStatus);
-  AddLibraryDef("DEBUG", &cAnalyze::PrintDebug);
-  AddLibraryDef("ECHO", &cAnalyze::PrintDebug);
-  AddLibraryDef("VERBOSE", &cAnalyze::ToggleVerbose);
-  AddLibraryDef("INCLUDE", &cAnalyze::IncludeFile);
-  AddLibraryDef("SYSTEM", &cAnalyze::CommandSystem);
-  AddLibraryDef("INTERACTIVE", &cAnalyze::CommandInteractive);
-  AddLibraryDef("PRINT_TEST_CPU_RESOURCES", &cAnalyze::PrintTestCPUResources);
-  
-  // Functions...
-  AddLibraryDef("FUNCTION", &cAnalyze::FunctionCreate);
-  
-  // Flow commands...
-  AddLibraryDef("FOREACH", &cAnalyze::CommandForeach);
-  AddLibraryDef("FORRANGE", &cAnalyze::CommandForRange);
-}
-
-cAnalyzeCommandDefBase * cAnalyze::FindAnalyzeCommandDef(const cString & name)
-{
-  SetupCommandDefLibrary();
-  
-  tListIterator<cAnalyzeCommandDefBase> lib_it(command_lib);
-  while (lib_it.Next() != (void *) NULL) {
-    if (lib_it.Get()->GetName() == name) break;
-  }
-  
-  return lib_it.Get();
-}
-
-void cAnalyze::RunInteractive()
-{
-  cout << "Entering interactive mode..." << endl;
-  
-  char text_input[2048];
-  while (true) {
-    cout << ">> ";
-    cout.flush();
-    cin.getline(text_input, 2048);
-    cString cur_input(text_input);
-    cString command = cur_input.PopWord();
-    command.ToUpper();
-    
-    cAnalyzeCommand * cur_command;
-    cAnalyzeCommandDefBase * command_def = FindAnalyzeCommandDef(command);
-    if (command == "") {
-      // Don't worry about blank lines...
-      continue;
-    }
-    else if (command == "END" || command == "QUIT" || command == "EXIT") {
-      // We are done with interactive mode...
-      break;
-    }
-    else if (command_def != NULL && command_def->IsFlowCommand() == true) {
-      // This code has a body to it... fill it out!
-      cur_command = new cAnalyzeFlowCommand(command, cur_input);
-      InteractiveLoadCommandList(*(cur_command->GetCommandList()));
-    }
-    else {
-      // This is a normal command...
-      cur_command = new cAnalyzeCommand(command, cur_input);
-    }
-    
-    cString args = cur_command->GetArgs();
-    PreProcessArgs(args);
-    
-    cAnalyzeCommandDefBase * command_fun = FindAnalyzeCommandDef(command);
-    
-    // First check for built-in functions...
-    if (command_fun != NULL) command_fun->Run(this, args, *cur_command);
-    
-    // Then for user defined functions
-    else if (FunctionRun(command, args) == true) { }
-    
-    // Otherwise, give an error.
-    else cerr << "Error: Unknown command '" << command << "'." << endl;
-  }
-}

Deleted: branches/brysonda/source/main/cAnalyze.h
===================================================================
--- branches/brysonda/source/main/cAnalyze.h	2005-11-04 00:39:30 UTC (rev 368)
+++ branches/brysonda/source/main/cAnalyze.h	2005-11-04 03:50:46 UTC (rev 369)
@@ -1,255 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef ANALYZE_HH
-#define ANALYZE_HH
-
-#include <vector>
-
-#ifndef DATA_FILE_MANAGER_HH
-#include "cDataFileManager.h"
-#endif
-#ifndef GENOTYPE_BATCH_HH
-#include "cGenotypeBatch.h"
-#endif
-#ifndef cRandom_h
-#include "cRandom.h"
-#endif
-#ifndef STRING_HH
-#include "cString.h"
-#endif
-#ifndef STRING_LIST_HH
-#include "cStringList.h"
-#endif
-#ifndef TLIST_HH
-#include "tList.h"
-#endif
-
-#define MAX_BATCHES 2000
-
-// cAnalyze            : The master analyze object.
-
-class cGenotypeBatch; // array
-template <class T> class tList; // aggregate
-class cAnalyzeCommand;
-class cAnalyzeFunction;
-class cAnalyzeCommandDefBase;
-class cString; // aggregate
-class cDataFileManager; // aggregate
-template <class T> class tDataEntryBase;
-class cInstSet;
-class cRandom; // aggregate
-class cString; // aggregate
-class cAnalyzeGenotype;
-class cInitFile;
-class cStringList; // aggregate
-template <class T> class tDataEntryCommand;
-template <class T> class tListIterator;
-class cEnvironment;
-class cWorld;
-
-class cAnalyze {
-private:
-  int cur_batch;
-  cGenotypeBatch batch[MAX_BATCHES];
-  tList<cAnalyzeCommand> command_list;
-  tList<cAnalyzeFunction> function_list;
-  tList<cAnalyzeCommandDefBase> command_lib;
-  cString variables[26];
-  cString local_variables[26];
-  cString arg_variables[10];
-
-  cWorld* m_world;
-  cInstSet& inst_set;
-
-  // This is the storage for the resource information from resource.dat.  It 
-  // is a pair of the update and a vector of the resource concentrations
-  std::vector<std::pair<int, std::vector<double> > > resources;
-
-  bool verbose;            // Should details be output to command line?
-  int interactive_depth;   // How nested are we if in interactive mode?
-
-  cDataFileManager data_file_manager;
-  tList< tDataEntryBase<cAnalyzeGenotype> > genotype_data_list;
-
-  cRandom random;
-
-private:
-  // Pop specific types of arguments from an arg list.
-  cString PopDirectory(cString & in_string, const cString & default_dir);
-  int PopBatch(const cString & in_string);
-  cAnalyzeGenotype * PopGenotype(cString gen_desc, int batch_id=-1);
-  cString & GetVariable(const cString & varname);
-
-  // Other arg-list methods
-  void LoadCommandList(cInitFile & init_file, tList<cAnalyzeCommand> & clist);
-  void InteractiveLoadCommandList(tList<cAnalyzeCommand> & clist);
-  void PreProcessArgs(cString & args);
-  void ProcessCommands(tList<cAnalyzeCommand> & clist);
-
-  void SetupGenotypeDataList();	
-  void LoadGenotypeDataList(cStringList arg_list,
-	    tList< tDataEntryCommand<cAnalyzeGenotype> > & output_list);
-		      
-  void AddLibraryDef(const cString & name, void (cAnalyze::*_fun)(cString));
-  void AddLibraryDef(const cString & name,
-	     void (cAnalyze::*_fun)(cString, tList<cAnalyzeCommand> &));
-  cAnalyzeCommandDefBase * FindAnalyzeCommandDef(const cString & name);
-  void SetupCommandDefLibrary();
-  bool FunctionRun(const cString & fun_name, cString args);
-
-  // Batch management...
-  int BatchUtil_GetMaxLength(int batch_id=-1);
-
-  // Comamnd helpers...
-  void CommandDetail_Header(std::ostream & fp, int format_type,
-            tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it,
-            int time_step=-1);
-  void CommandDetail_Body(std::ostream & fp, int format_type,
-            tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it,
-            int time_step=-1, int max_time=1);
-  void CommandDetailAverage_Body(std::ostream & fp, int num_arguments,
-            tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it);
-  void CommandHistogram_Header(std::ostream & fp, int format_type,
-            tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it);
-  void CommandHistogram_Body(std::ostream & fp, int format_type,
-            tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it);
-
-private:
-  // Loading methods...
-  void LoadOrganism(cString cur_string);
-  void LoadBasicDump(cString cur_string);
-  void LoadDetailDump(cString cur_string);
-  void LoadMultiDetail(cString cur_string);
-  void LoadSequence(cString cur_string);
-  void LoadDominant(cString cur_string);
-  // Clears the current time oriented list of resources and loads in a new one
-  // from a file specified by the user, or resource.dat by default.
-  void LoadResources(cString cur_string);
-  void LoadFile(cString cur_string);
-
-  // Reduction
-  void FindGenotype(cString cur_string);
-  void FindOrganism(cString cur_string);
-  void FindLineage(cString cur_string);
-  void FindSexLineage(cString cur_string);
-  void FindClade(cString cur_string);
-  void SampleOrganisms(cString cur_string);
-  void SampleGenotypes(cString cur_string);
-  void KeepTopGenotypes(cString cur_string);
-
-  // Direct Output Commands...
-  void CommandPrint(cString cur_string);
-  void CommandTrace(cString cur_string);
-  void CommandTraceWithResources(cString cur_string);
-  void CommandPrintTasks(cString cur_string);
-  void CommandDetail(cString cur_string);
-  void CommandDetailTimeline(cString cur_string);
-  void CommandDetailBatches(cString cur_string);
-  void CommandDetailAverage(cString cur_string);
-  void CommandDetailIndex(cString cur_string);
-  void CommandHistogram(cString cur_string);
-
-  // Population Analysis Commands...
-  void CommandPrintPhenotypes(cString cur_string);
-  void CommandPrintDiversity(cString cur_string);
-  void PhyloCommunityComplexity(cString cur_string);
-  void AnalyzeCommunityComplexity(cString cur_string);
-
-  // Individual Organism Analysis...
-  void CommandLandscape(cString cur_string);
-  void CommandFitnessMatrix(cString cur_string);
-  void CommandMapTasks(cString cur_string);
-  void CommandAverageModularity(cString cur_string);
-  void CommandMapMutations(cString cur_string);
-  void CommandMapDepth(cString cur_string);
-
-  // Population Comparison Commands...
-  void CommandHamming(cString cur_string);
-  void CommandLevenstein(cString cur_string);
-  void CommandSpecies(cString cur_string);
-  void CommandRecombine(cString cur_string);
-
-  // Lineage Analysis Commands...
-  void CommandAlign(cString cur_string);
-  void AnalyzeNewInfo(cString cur_string);   
-
-  // Build Input Files for Avida
-  void WriteClone(cString cur_string);
-  void WriteInjectEvents(cString cur_string);
-  void WriteCompetition(cString cur_string);
-
-  // Automated analysis...
-  void AnalyzeMuts(cString cur_string);
-  void AnalyzeInstructions(cString cur_string);
-  void AnalyzeInstPop(cString cur_string);
-  void AnalyzeBranching(cString cur_string);
-  void AnalyzeMutationTraceback(cString cur_string);
-  void AnalyzeComplexity(cString cur_string);
-  void AnalyzeKnockouts(cString cur_string);
-  void AnalyzePopComplexity(cString cur_string);
-  void AnalyzeEpistasis(cString cur_string);
-  void AnalyzeMateSelection(cString cur_string);
-  void AnalyzeComplexityDelta(cString cur_string);
-
-  // Environment Manipulation
-  void EnvironmentSetup(cString cur_string);
-
-  // Documentation...
-  void CommandHelpfile(cString cur_string);
-  void CommandDocfile(cString cur_string);
-
-  // Control...
-  void VarSet(cString cur_string);
-  void BatchSet(cString cur_string);
-  void BatchName(cString cur_string);
-  void BatchTag(cString cur_string);
-  void BatchPurge(cString cur_string);
-  void BatchDuplicate(cString cur_string);
-  void BatchRecalculate(cString cur_string);
-  void BatchRename(cString cur_string);
-  void PrintStatus(cString cur_string);
-  void PrintDebug(cString cur_string);
-  void ToggleVerbose(cString cur_string);
-  void IncludeFile(cString cur_string);
-  void CommandSystem(cString cur_string);
-  void CommandInteractive(cString cur_string);
-  void PrintTestCPUResources(cString cur_string);
-
-  // Functions...
-  void FunctionCreate(cString cur_string, tList<cAnalyzeCommand> & clist);
-  // Looks up the resource concentrations that are the closest to the
-  // given update and then fill in those concentrations into the environment.
-  void FillResources(int update);
-  // Analyze the entropy of genotype under default environment
-  double AnalyzeEntropy(cAnalyzeGenotype * genotype, double mut_rate);
-  // Analyze the entropy of child given parent and default environment
-  double AnalyzeEntropyGivenParent(cAnalyzeGenotype * genotype, 
-				   cAnalyzeGenotype * parent, 
-				   double mut_rate);
-  // Calculate the increased information in genotype1 comparing to genotype2 
-  // line by line. If information in genotype1 is less than that in genotype2 
-  // in a line, increasing is 0. Usually this is used for child-parent comparison.
-  double IncreasedInfo(cAnalyzeGenotype * genotype1, 
-		       cAnalyzeGenotype * genotype2, 
-		       double mut_rate);
-  
-  // Flow Control...
-  void CommandForeach(cString cur_string, tList<cAnalyzeCommand> & clist);
-  void CommandForRange(cString cur_string, tList<cAnalyzeCommand> & clist);
-
-private:
-  // disabled copy constructor.
-  cAnalyze(const cAnalyze &);
-public:
-  cAnalyze(cWorld* world);
-  ~cAnalyze();
-
-  void RunInteractive();
-};
-
-#endif

Deleted: branches/brysonda/source/main/cAnalyzeCommand.h
===================================================================
--- branches/brysonda/source/main/cAnalyzeCommand.h	2005-11-04 00:39:30 UTC (rev 368)
+++ branches/brysonda/source/main/cAnalyzeCommand.h	2005-11-04 03:50:46 UTC (rev 369)
@@ -1,44 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef ANALYZE_COMMAND_HH
-#define ANALYZE_COMMAND_HH
-
-#ifndef STRING_HH
-#include "cString.h"
-#endif
-
-// cAnalyzeCommand     : A command in a loaded program
-
-class cString; // aggregate
-template <class T> class tList;
-
-class cAnalyzeCommand {
-protected:
-  cString command;
-  cString args;
-private:
-  // disabled copy constructor.
-  cAnalyzeCommand(const cAnalyzeCommand &);
-public:
-  cAnalyzeCommand(const cString & _command, const cString & _args)
-    : command(_command), args(_args) { command.ToUpper(); }
-  virtual ~cAnalyzeCommand() { ; }
-
-  const cString & GetCommand() { return command; }
-  const cString & GetArgs() const { return args; }
-  cString GetArgs() { return args; }
-  virtual tList<cAnalyzeCommand> * GetCommandList() { return NULL; }
-
-  /*
-  added to satisfy Boost.Python; the semantics are fairly useless --
-  equality of two references means that they refer to the same object.
-  */
-  bool operator==(const cAnalyzeCommand &in) const { return &in == this; }
-};
-
-#endif

Deleted: branches/brysonda/source/main/cAnalyzeCommandDef.h
===================================================================
--- branches/brysonda/source/main/cAnalyzeCommandDef.h	2005-11-04 00:39:30 UTC (rev 368)
+++ branches/brysonda/source/main/cAnalyzeCommandDef.h	2005-11-04 03:50:46 UTC (rev 369)
@@ -1,37 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef ANALYZE_COMMAND_DEF_HH
-#define ANALYZE_COMMAND_DEF_HH
-
-#ifndef ANALYZE_COMMAND_DEF_BASE_HH
-#include "cAnalyzeCommandDefBase.h"
-#endif
-#ifndef STRING_HH
-#include "cString.h"
-#endif
-
-class cAnalyze;
-class cString; // aggregate
-class cAnalyzeCommand;
-
-class cAnalyzeCommandDef : public cAnalyzeCommandDefBase {
-private:
-  void (cAnalyze::*CommandFunction)(cString);
-public:
-  cAnalyzeCommandDef(const cString & _name, void (cAnalyze::*_cf)(cString))
-    : cAnalyzeCommandDefBase(_name), CommandFunction(_cf) { ; }
-  virtual ~cAnalyzeCommandDef() { ; }
-
-  virtual void Run(cAnalyze * analyze, const cString & args,
-		   cAnalyzeCommand & command) const {
-    (void) command; // used in other types of command defininitions.
-    (analyze->*CommandFunction)(args);
-  }
-};
-
-#endif

Deleted: branches/brysonda/source/main/cAnalyzeCommandDefBase.h
===================================================================
--- branches/brysonda/source/main/cAnalyzeCommandDefBase.h	2005-11-04 00:39:30 UTC (rev 368)
+++ branches/brysonda/source/main/cAnalyzeCommandDefBase.h	2005-11-04 03:50:46 UTC (rev 369)
@@ -1,33 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef ANALYZE_COMMAND_DEF_BASE_HH
-#define ANALYZE_COMMAND_DEF_BASE_HH
-
-#ifndef STRING_HH
-#include "cString.h"
-#endif
-
-class cString; // aggregate
-class cAnalyze;
-class cAnalyzeCommand;
-
-class cAnalyzeCommandDefBase {
-protected:
-  cString name;
-public:
-  cAnalyzeCommandDefBase(const cString & _name) : name(_name) { ; }
-  virtual ~cAnalyzeCommandDefBase() { ; }
-
-  virtual void Run(cAnalyze * analyze, const cString & args,
-		   cAnalyzeCommand & command) const = 0;
-  virtual bool IsFlowCommand() { return false; }
-
-  const cString & GetName() const { return name; }
-};
-
-#endif

Deleted: branches/brysonda/source/main/cAnalyzeFlowCommand.h
===================================================================
--- branches/brysonda/source/main/cAnalyzeFlowCommand.h	2005-11-04 00:39:30 UTC (rev 368)
+++ branches/brysonda/source/main/cAnalyzeFlowCommand.h	2005-11-04 03:50:46 UTC (rev 369)
@@ -1,36 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef ANALYZE_FLOW_COMMAND_HH
-#define ANALYZE_FLOW_COMMAND_HH
-
-#ifndef ANALYZE_COMMAND_HH
-#include "cAnalyzeCommand.h"
-#endif
-#ifndef TLIST_HH
-#include "tList.h"
-#endif
-
-// cAnalyzeFlowCommand : A cAnalyzeCommand containing other commands
-
-template <class T> class tList; // aggregate
-class cString;
-
-class cAnalyzeFlowCommand : public cAnalyzeCommand {
-protected:
-  tList<cAnalyzeCommand> command_list;
-public:
-  cAnalyzeFlowCommand(const cString & _command, const cString & _args)
-    : cAnalyzeCommand(_command, _args) { ; }
-  virtual ~cAnalyzeFlowCommand() {
-    while ( command_list.GetSize() > 0 ) delete command_list.Pop();
-  }
-
-  tList<cAnalyzeCommand> * GetCommandList() { return &command_list; }
-};
-
-#endif

Deleted: branches/brysonda/source/main/cAnalyzeFlowCommandDef.h
===================================================================
--- branches/brysonda/source/main/cAnalyzeFlowCommandDef.h	2005-11-04 00:39:30 UTC (rev 368)
+++ branches/brysonda/source/main/cAnalyzeFlowCommandDef.h	2005-11-04 03:50:46 UTC (rev 369)
@@ -1,46 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef ANALYZE_FLOW_COMMAND_DEF_HH
-#define ANALYZE_FLOW_COMMAND_DEF_HH
-
-#ifndef ANALYZE_COMMAND_HH
-#include "cAnalyzeCommand.h"
-#endif
-#ifndef ANALYZE_COMMAND_DEF_BASE_HH
-#include "cAnalyzeCommandDefBase.h"
-#endif
-#ifndef STRING_HH
-#include "cString.h"
-#endif
-#ifndef TLIST_HH
-#include "tList.h"
-#endif
-
-class cAnalyze;
-template <class T> class tList;
-class cAnalyzeCommand; // access
-class cString; // aggregate
-
-class cAnalyzeFlowCommandDef : public cAnalyzeCommandDefBase {
-private:
-  void (cAnalyze::*CommandFunction)(cString, tList<cAnalyzeCommand> &);
-public:
-  cAnalyzeFlowCommandDef(const cString &_name,
-	 void (cAnalyze::*_cf)(cString, tList<cAnalyzeCommand> &))
-    : cAnalyzeCommandDefBase(_name), CommandFunction(_cf) { ; }
-  virtual ~cAnalyzeFlowCommandDef() { ; }
-			 
-  virtual void Run(cAnalyze * analyze, const cString & args,
-		   cAnalyzeCommand & command) const {
-    (analyze->*CommandFunction)(args, *(command.GetCommandList()) );
-  }
-
-  virtual bool IsFlowCommand() { return true; }
-};
-
-#endif

Deleted: branches/brysonda/source/main/cAnalyzeFunction.h
===================================================================
--- branches/brysonda/source/main/cAnalyzeFunction.h	2005-11-04 00:39:30 UTC (rev 368)
+++ branches/brysonda/source/main/cAnalyzeFunction.h	2005-11-04 03:50:46 UTC (rev 369)
@@ -1,44 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef ANALYZE_FUNCTION_HH
-#define ANALYZE_FUNCTION_HH
-
-#ifndef ANALYZE_COMMAND_HH
-#include "cAnalyzeCommand.h"
-#endif
-#ifndef STRING_HH
-#include "cString.h"
-#endif
-#ifndef TLIST_HH
-#include "tList.h"
-#endif
-
-// cAnalyzeFunction    : User-defined function
-
-class cString; // aggregate
-template <class T> class tList; // aggregate
-class cAnalyzeCommand;
-
-class cAnalyzeFunction {
-private:
-  cString name;
-  tList<cAnalyzeCommand> command_list;
-private:
-  // disabled copy constructor.
-  cAnalyzeFunction(const cAnalyzeFunction &);
-public:
-  cAnalyzeFunction(const cString & _name) : name(_name) { ; }
-  ~cAnalyzeFunction() { 
-    while ( command_list.GetSize() > 0 ) delete command_list.Pop();
-  }
-
-  const cString & GetName() { return name; }
-  tList<cAnalyzeCommand> * GetCommandList() { return &command_list; }
-};
-
-#endif

Deleted: branches/brysonda/source/main/cAnalyzeGenotype.cc
===================================================================
--- branches/brysonda/source/main/cAnalyzeGenotype.cc	2005-11-04 00:39:30 UTC (rev 368)
+++ branches/brysonda/source/main/cAnalyzeGenotype.cc	2005-11-04 03:50:46 UTC (rev 369)
@@ -1,347 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
-
-#include "cAnalyzeGenotype.h"
-
-#include "cCPUTestInfo.h"
-#include "cInstSet.h"
-#include "cLandscape.h"
-#include "cOrganism.h"
-#include "cPhenotype.h"
-#include "cTestCPU.h"
-#include "cEnvironment.h"
-#include "cHardwareManager.h"
-#include "cWorld.h"
-
-using namespace std;
-
-//////////////////////
-//  cAnalyzeGenotype
-//////////////////////
-
-cAnalyzeGenotype::cAnalyzeGenotype(cWorld* world, cString symbol_string, cInstSet& in_inst_set)
-  : m_world(world)
-  , genome(symbol_string)
-  , inst_set(in_inst_set)
-  , name("")
-  , aligned_sequence("")
-  , tag("")
-  , viable(false)
-  , id_num(-1)
-  , parent_id(-1)
-  , parent2_id(-1)
-  , num_cpus(0)
-  , total_cpus(0)
-  , update_born(0)
-  , update_dead(0)
-  , depth(0)
-  , length(0)
-  , copy_length(0)
-  , exe_length(0)
-  , merit(0.0)
-  , gest_time(INT_MAX)
-  , fitness(0.0)
-  , errors(0)
-  , task_counts(0)
-  , fitness_ratio(0.0)
-  , efficiency_ratio(0.0)
-  , comp_merit_ratio(0.0)
-  , parent_dist(0)
-  , ancestor_dist(0)
-  , parent_muts("")
-  , landscape_stats(NULL)
-{
-  // Make sure that the sequences jive with the inst_set
-  for (int i = 0; i < genome.GetSize(); i++) {
-    if (genome[i].GetOp() >= inst_set.GetSize()) {
-      cerr << "Error: Trying to load instruction " << genome[i].GetOp()
-	   << ".  Max in set is" << inst_set.GetSize() - 1
-	   << endl;
-    }
-  }
-}
-
-cAnalyzeGenotype::cAnalyzeGenotype(cWorld* world, const cGenome& _genome, cInstSet& in_inst_set)
-  : m_world(world)
-  , genome(_genome)
-  , inst_set(in_inst_set)
-  , name("")
-  , aligned_sequence("")
-  , tag("")
-  , viable(false)
-  , id_num(-1)
-  , parent_id(-1)
-  , parent2_id(-1)
-  , num_cpus(0)
-  , total_cpus(0)
-  , update_born(0)
-  , update_dead(0)
-  , depth(0)
-  , length(0)
-  , copy_length(0)
-  , exe_length(0)
-  , merit(0.0)
-  , gest_time(INT_MAX)
-  , fitness(0.0)
-  , errors(0)
-  , task_counts(0)
-  , fitness_ratio(0.0)
-  , efficiency_ratio(0.0)
-  , comp_merit_ratio(0.0)
-  , parent_dist(0)
-  , ancestor_dist(0)
-  , parent_muts("")
-  , landscape_stats(NULL)
-{
-}
-
-cAnalyzeGenotype::cAnalyzeGenotype(const cAnalyzeGenotype & _gen)
-  : m_world(_gen.m_world)
-  , genome(_gen.genome)
-  , inst_set(_gen.inst_set)
-  , name(_gen.name)
-  , aligned_sequence(_gen.aligned_sequence)
-  , tag(_gen.tag)
-  , viable(_gen.viable)
-  , id_num(_gen.id_num)
-  , parent_id(_gen.parent_id)
-  , parent2_id(_gen.parent2_id)
-  , num_cpus(_gen.num_cpus)
-  , total_cpus(_gen.total_cpus)
-  , update_born(_gen.update_born)
-  , update_dead(_gen.update_dead)
-  , depth(_gen.depth)
-  , length(_gen.length)
-  , copy_length(_gen.copy_length)
-  , exe_length(_gen.exe_length)
-  , merit(_gen.merit)
-  , gest_time(_gen.gest_time)
-  , fitness(_gen.fitness)
-  , errors(_gen.errors)
-  , task_counts(_gen.task_counts)
-  , fitness_ratio(_gen.fitness_ratio)
-  , efficiency_ratio(_gen.efficiency_ratio)
-  , comp_merit_ratio(_gen.comp_merit_ratio)
-  , parent_dist(_gen.parent_dist)
-  , ancestor_dist(_gen.ancestor_dist)
-  , parent_muts(_gen.parent_muts)
-  , landscape_stats(NULL)
-{
-  if (_gen.landscape_stats != NULL) {
-    landscape_stats = new cAnalyzeLandscape;
-    *landscape_stats = *(_gen.landscape_stats);
-  }
-}
-
-cAnalyzeGenotype::~cAnalyzeGenotype()
-{
-  if (landscape_stats != NULL) delete landscape_stats;
-}
-
-
-int cAnalyzeGenotype::CalcMaxGestation() const
-{
-  return m_world->GetConfig().TEST_CPU_TIME_MOD.Get() * genome.GetSize();
-}
-
-void cAnalyzeGenotype::CalcLandscape() const
-{
-  if (landscape_stats != NULL) return;
-
-  landscape_stats = new cAnalyzeLandscape;
-  cLandscape landscape(m_world, genome, inst_set);
-  landscape.Process(1);
-  landscape_stats->frac_dead = landscape.GetProbDead();
-  landscape_stats->frac_neg  = landscape.GetProbNeg();
-  landscape_stats->frac_neut = landscape.GetProbNeut();
-  landscape_stats->frac_pos  = landscape.GetProbPos();
-  landscape_stats->complexity = landscape.GetComplexity();
-}
-
-void cAnalyzeGenotype::Recalculate(cAnalyzeGenotype * parent_genotype)
-{
-    // Build the test info for printing.
-  cCPUTestInfo test_info;
-  test_info.TestThreads();
-  // test_info.TraceTaskOrder();
-
-  // DDD - This does some 'interesting' things with the instruction set
-  
-  // Use the inst lib for this genotype... and syncrhonize environment
-  
-  // Backup old instruction set, update with new
-  cInstSet env_inst_set_backup = m_world->GetHardwareManager().GetInstSet();
-  m_world->GetHardwareManager().GetInstSet() = inst_set;
-
-  m_world->GetTestCPU().TestGenome(test_info, genome);
-  
-  // Restore the instruction set
-  m_world->GetHardwareManager().GetInstSet() = env_inst_set_backup;
-
-  viable = test_info.IsViable();
-
-  cOrganism * test_organism = test_info.GetTestOrganism();
-  cPhenotype & test_phenotype = test_organism->GetPhenotype();
-
-  length = test_organism->GetGenome().GetSize();
-  copy_length = test_phenotype.GetCopiedSize();
-  exe_length = test_phenotype.GetExecutedSize();
-  merit = test_phenotype.GetMerit().GetDouble();
-  gest_time = test_phenotype.GetGestationTime();
-  fitness = test_phenotype.GetFitness();
-  errors = test_phenotype.GetLastNumErrors();
-  div_type = test_phenotype.GetDivType();
-  mate_id = test_phenotype.MateSelectID();
-  task_counts = test_phenotype.GetLastTaskCount();
-
-  // Setup a new parent stats if we have a parent to work with.
-  if (parent_genotype != NULL) {
-    fitness_ratio = GetFitness() / parent_genotype->GetFitness();
-    efficiency_ratio = GetEfficiency() / parent_genotype->GetEfficiency();
-    comp_merit_ratio = GetCompMerit() / parent_genotype->GetCompMerit();
-    parent_dist = cStringUtil::EditDistance(genome.AsString(),
-		    parent_genotype->GetGenome().AsString(), parent_muts);
-    ancestor_dist = parent_genotype->GetAncestorDist() + parent_dist;
-  }
-}
-
-
-void cAnalyzeGenotype::PrintTasks(ofstream & fp, int min_task, int max_task)
-{
-  if (max_task == -1) max_task = task_counts.GetSize();
-
-  for (int i = min_task; i < max_task; i++) {
-    fp << task_counts[i] << " ";
-  }
-}
-
-void cAnalyzeGenotype::SetSequence(cString _sequence)
-{
-  cGenome new_genome(_sequence);
-  genome = new_genome;
-}
-
-
-double cAnalyzeGenotype::GetFracDead() const
-{
-  CalcLandscape();  // Make sure the landscape is calculated...
-  return landscape_stats->frac_dead;
-}
-
-double cAnalyzeGenotype::GetFracNeg() const
-{
-  CalcLandscape();  // Make sure the landscape is calculated...
-  return landscape_stats->frac_neg;
-}
-
-double cAnalyzeGenotype::GetFracNeut() const
-{
-  CalcLandscape();  // Make sure the landscape is calculated...
-  return landscape_stats->frac_neut;
-}
-
-double cAnalyzeGenotype::GetFracPos() const
-{
-  CalcLandscape();  // Make sure the landscape is calculated...
-  return landscape_stats->frac_pos;
-}
-
-double cAnalyzeGenotype::GetComplexity() const
-{
-  CalcLandscape();  // Make sure the landscape is calculated...
-  return landscape_stats->complexity;
-}
-
-cString cAnalyzeGenotype::GetTaskList() const
-{
-  const int num_tasks = task_counts.GetSize();
-  cString out_string(num_tasks);
-  
-  for (int i = 0; i < num_tasks; i++) {
-    const int cur_count = task_counts[i];
-    if (cur_count < 10) {
-      out_string[i] = '0' + cur_count;
-    }
-    else if (cur_count < 30) {
-      out_string[i] = 'X';
-    }
-    else if (cur_count < 80) {
-      out_string[i] = 'L';
-    }
-    else if (cur_count < 300) {
-      out_string[i] = 'C';
-    }
-    else if (cur_count < 800) {
-      out_string[i] = 'D';
-    }
-    else if (cur_count < 3000) {
-      out_string[i] = 'M';
-    }
-    else {
-      out_string[i] = '+';
-    }
-  }
-
-  return out_string;
-}
-
-
-cString cAnalyzeGenotype::GetHTMLSequence() const
-{
-  cString text_genome = genome.AsString();
-  cString html_code("<tt>");
-
-  cString diff_info = parent_muts;
-  char mut_type = 'N';
-  int mut_pos = -1;
-
-  cString cur_mut = diff_info.Pop(',');
-  if (cur_mut != "") {
-    mut_type = cur_mut[0];
-    cur_mut.ClipFront(1); cur_mut.ClipEnd(1);
-    mut_pos = cur_mut.AsInt();
-  }
-
-  int ins_count = 0;
-  for (int i = 0; i < genome.GetSize(); i++) {
-    char symbol = text_genome[i];
-    if (i != mut_pos) html_code += symbol;
-    else {
-      // Figure out the information for the type of mutation we had...
-      cString color;
-      if (mut_type == 'M') {
-	color = "#FF0000";	
-      } else if (mut_type == 'I') {
-	color = "#00FF00";
-	ins_count++;
-      } else { // if (mut_type == 'D') {
-	color = "#0000FF";
-	symbol = '*';
-	i--;  // Rewind - we didn't read the handle character yet!
-      }
-
-      // Move on to the next mutation...
-      cur_mut = diff_info.Pop(',');
-      if (cur_mut != "") {
-	mut_type = cur_mut[0];
-	cur_mut.ClipFront(1); cur_mut.ClipEnd(1);
-	mut_pos = cur_mut.AsInt();
-	if (mut_type == 'D') mut_pos += ins_count;
-      } else mut_pos = -1;
-
-      // Tack on the current symbol...
-      cString symbol_string;
-      symbol_string.Set("<b><font color=\"%s\">%c</font></b>",
-			color(), symbol);
-      html_code += symbol_string;
-    }
-  }
-
-  html_code += "</tt>";
-
-  return html_code;
-}

Deleted: branches/brysonda/source/main/cAnalyzeGenotype.h
===================================================================
--- branches/brysonda/source/main/cAnalyzeGenotype.h	2005-11-04 00:39:30 UTC (rev 368)
+++ branches/brysonda/source/main/cAnalyzeGenotype.h	2005-11-04 03:50:46 UTC (rev 369)
@@ -1,268 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef ANALYZE_GENOTYPE_HH
-#define ANALYZE_GENOTYPE_HH
-
-#include <fstream>
-
-#ifndef FUNCTIONS_HH
-#include "functions.h"
-#endif
-#ifndef GENOME_HH
-#include "cGenome.h"
-#endif
-#ifndef STRING_HH
-#include "cString.h"
-#endif
-#ifndef STRING_LIST_HH
-#include "cStringList.h"
-#endif
-#ifndef STRING_UTIL_HH
-#include "cStringUtil.h"
-#endif
-#ifndef TARRAY_HH
-#include "tArray.h"
-#endif
-
-// cAnalyzeGenotype    : Collection of information about loaded genotypes
-
-class cGenome; // aggregate
-class cInstSet;
-class cString; // aggregate
-template <class T> class tArray; // aggregate
-class cStringList; // aggregate
-class cStringUtil; // access
-class cWorld;
-
-class cAnalyzeGenotype {
-private:
-  cWorld* m_world;
-  cGenome genome;            // Full Genome
-  cInstSet& inst_set;       // Instruction set used in this genome
-  cString name;              // Name, if one was provided in loading
-  cString aligned_sequence;  // Sequence (in ASCII) after alignment
-  cString tag;               // All genotypes in a batch can be tagged
-
-  bool viable;
-
-  // Group 1 : Load-in Stats (Only obtained if available for input file)
-  int id_num;
-  int parent_id;
-  int parent2_id;
-  int num_cpus;
-  int total_cpus;
-  int update_born;
-  int update_dead;
-  int depth;
-
-  // Group 2 : Basic Execution Stats (Obtained from test CPUs)
-  int length;
-  int copy_length;
-  int exe_length;
-  double merit;
-  int gest_time;
-  double fitness;
-  int errors;
-  double div_type;
-  int mate_id;
-
-  tArray<int> task_counts;
-
-  // Group 3 : Stats requiring parental genotype (Also from test CPUs)
-  double fitness_ratio;
-  double efficiency_ratio;
-  double comp_merit_ratio;
-  int parent_dist;
-  int ancestor_dist;
-  int lineage_label;
-  cString parent_muts;
-
-  // Group 4 : Landscape stats (obtained from testing all possible mutations)
-  class cAnalyzeLandscape {
-  public:
-    double frac_dead;
-    double frac_neg;
-    double frac_neut;
-    double frac_pos;
-    double complexity;
-    cAnalyzeLandscape() : frac_dead(0.0), frac_neg(0.0),
-			  frac_neut(0.0), frac_pos(0.0), complexity(0.0) { ; }
-  };
-  mutable cAnalyzeLandscape * landscape_stats;
-
-  // Group 5 : More complex stats (obtained indvidually, through tests)
-  cString task_order;
-
-  cStringList special_args; // These are args placed after a ':' in details...
-
-  int NumCompare(double new_val, double old_val) const {
-    if (new_val == old_val) return  0;
-    else if (new_val == 0)       return -2;
-    else if (old_val == 0)       return +2;
-    else if (new_val < old_val)  return -1;
-    // else if (new_val > old_val)
-    return +1;
-  }
-
-  int CalcMaxGestation() const;
-  void CalcLandscape() const;
-public:
-  cAnalyzeGenotype(cWorld* world, cString symbol_string, cInstSet & in_inst_set);
-  cAnalyzeGenotype(cWorld* world, const cGenome & _genome, cInstSet & in_inst_set);
-  cAnalyzeGenotype(const cAnalyzeGenotype & _gen);
-  ~cAnalyzeGenotype();
-
-  const cStringList & GetSpecialArgs() { return special_args; }
-  void SetSpecialArgs(const cStringList & _args) { special_args = _args; }
-
-  void Recalculate(cAnalyzeGenotype * parent_genotype=NULL);
-  void PrintTasks(std::ofstream & fp, int min_task=0, int max_task=-1);
-
-  // Set...
-  void SetSequence(cString _sequence);
-  
-  void SetName(const cString & _name) { name = _name; }
-  void SetAlignedSequence(const cString & _seq) { aligned_sequence = _seq; }
-  void SetTag(const cString & _tag) { tag = _tag; }
-
-  void SetViable(bool _viable) { viable = _viable; }
-
-  void SetID(int _id) { id_num = _id; }
-  void SetParentID(int _id) { parent_id = _id; }
-  void SetParent2ID(int _id) { parent2_id = _id; }
-  void SetNumCPUs(int _cpus) { num_cpus = _cpus; }
-  void SetTotalCPUs(int _cpus) { total_cpus = _cpus; }
-  void SetUpdateBorn(int _born) { update_born = _born; }
-  void SetUpdateDead(int _dead) { update_dead = _dead; }
-  void SetDepth(int _depth) { depth = _depth; }
-
-  void SetLength(int _length) { length = _length; }
-  void SetCopyLength(int _length) { copy_length = _length; }
-  void SetExeLength(int _length) { exe_length = _length; }
-  void SetMerit(double _merit) { merit = _merit; }
-  void SetGestTime(int _gest) { gest_time = _gest; }
-  void SetFitness(double _fitness) { fitness = _fitness; }
-  void SetDivType(double _div_type) { div_type = _div_type; }
-  void SetMateID(int _mate_id) { mate_id = _mate_id; }
-  void SetParentDist(int _dist) { parent_dist = _dist; }
-  void SetAncestorDist(int _dist) { ancestor_dist = _dist; }
-  void SetLineageLabel(int _label) { lineage_label = _label; }
-
-  void SetParentMuts(const cString & in_muts) { parent_muts = in_muts; }
-  void SetTaskOrder(const cString & in_order) { task_order = in_order; }
-
-//    void SetFracDead(double in_frac);
-//    void SetFracNeg(double in_frac);
-//    void SetFracNeut(double in_frac);
-//    void SetFracPos(double in_frac);
-
-  // Accessors...
-  const cGenome & GetGenome() const { return genome; }
-  const cString & GetName() const { return name; }
-  const cString & GetAlignedSequence() const { return aligned_sequence; }
-  const cString & GetTag() const { return tag; }
-
-  bool GetViable() const { return viable; }
-
-  int GetID() const { return id_num; }
-  int GetParentID() const { return parent_id; }
-  int GetParent2ID() const { return parent2_id; }
-  int GetParentDist() const { return parent_dist; }
-  int GetAncestorDist() const { return ancestor_dist; }
-  int GetLineageLabel() const { return lineage_label; }
-  int GetNumCPUs() const { return num_cpus; }
-  int GetTotalCPUs() const { return total_cpus; }
-  int GetLength() const { return length; }
-  int GetCopyLength() const { return copy_length; }
-  int GetExeLength() const { return exe_length; }
-  int GetMinLength() const { return Min(exe_length, copy_length); }
-  double GetMerit() const { return merit; }
-  double GetCompMerit() const { return merit / (double) GetMinLength(); }
-  int GetGestTime() const { return gest_time; }
-  double GetEfficiency() const
-    { return ((double) GetMinLength()) / (double) gest_time; }
-  double GetFitness() const { return fitness; }
-  double GetDivType() const { return div_type; }
-  int GetMateID() const { return mate_id; }
-  int GetUpdateBorn() const { return update_born; }
-  int GetUpdateDead() const { return update_dead; }
-  int GetDepth() const { return depth; }
-
-  const cString & GetParentMuts() const { return parent_muts; }
-
-  // Landscape accessors
-  double GetFracDead() const;
-  double GetFracNeg() const;
-  double GetFracNeut() const;
-  double GetFracPos() const;
-  double GetComplexity() const;
-
-  double GetFitnessRatio() const { return fitness_ratio; }
-  double GetEfficiencyRatio() const { return efficiency_ratio; }
-  double GetCompMeritRatio() const { return comp_merit_ratio; }
-
-  const cString & GetTaskOrder() const { return task_order; }
-  cString GetTaskList() const;
-
-  cString GetSequence() const { return genome.AsString(); }
-  cString GetHTMLSequence() const;
-
-  cString GetMapLink() const {
-    return cStringUtil::Stringf("<a href=\"tasksites.%s.html\">Phenotype Map</a>", GetName()());
-  }
-
-  int GetNumTasks() const { return task_counts.GetSize(); }
-  int GetTaskCount(int task_id) const {
-    if (task_id >= task_counts.GetSize()) return 0;
-    if (special_args.HasString("binary")) return (task_counts[task_id] > 0);
-    return task_counts[task_id];
-  }
-
-  // Comparisons...  Compares a genotype to the "previous" one, which is
-  // passed in, in one specified phenotype.
-  // Return values are:
-  //   -2 : Toggle; no longer has phenotype it used to...
-  //   -1 : Reduction in strength of phenotype
-  //    0 : Identical in phenotype
-  //   +1 : Improvement in phenotype
-  //   +2 : Toggle; phenotype now present that wasn't.
-  int CompareNULL(cAnalyzeGenotype * prev) const { (void) prev; return 0; }
-  int CompareArgNULL(cAnalyzeGenotype * prev, int i) const
-    { (void) prev; (void) i;  return 0; }
-  int CompareLength(cAnalyzeGenotype * prev) const {
-    if (GetLength() < MIN_CREATURE_SIZE &&
-	prev->GetLength() > MIN_CREATURE_SIZE) return -2;
-    if (GetLength() > MIN_CREATURE_SIZE &&
-	prev->GetLength() < MIN_CREATURE_SIZE) return 2;
-    return 0;
-  }
-  int CompareMerit(cAnalyzeGenotype * prev) const
-    { return NumCompare(GetMerit(), prev->GetMerit()); }
-  int CompareCompMerit(cAnalyzeGenotype * prev) const
-    { return NumCompare(GetCompMerit(), prev->GetCompMerit()); }
-  int CompareGestTime(cAnalyzeGenotype * prev) const {
-    const int max_time = CalcMaxGestation();
-    const int cur_time = max_time - GetGestTime();
-    const int prev_time = max_time - prev->GetGestTime();
-    return NumCompare(cur_time, prev_time);
-  }
-  int CompareEfficiency(cAnalyzeGenotype * prev) const
-    { return NumCompare(GetEfficiency(), prev->GetEfficiency()); }
-  int CompareFitness(cAnalyzeGenotype * prev) const
-    { return NumCompare(GetFitness(), prev->GetFitness()); }
-  int CompareTaskCount(cAnalyzeGenotype * prev, int task_id) const
-    { return NumCompare(GetTaskCount(task_id), prev->GetTaskCount(task_id)); }
-
-  /*
-  added to satisfy Boost.Python; the semantics are fairly useless --
-  equality of two references means that they refer to the same object.
-  */
-  bool operator==(const cAnalyzeGenotype &in) const { return &in == this; }
-};
-
-#endif

Deleted: branches/brysonda/source/main/cAnalyzeUtil.cc
===================================================================
--- branches/brysonda/source/main/cAnalyzeUtil.cc	2005-11-04 00:39:30 UTC (rev 368)
+++ branches/brysonda/source/main/cAnalyzeUtil.cc	2005-11-04 03:50:46 UTC (rev 369)
@@ -1,961 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2001 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
-
-#include "cAnalyzeUtil.h"
-
-#include "defs.h"
-#include "cEnvironment.h"
-#include "cGenebank.h"
-#include "cGenome.h"
-#include "cGenomeUtil.h"
-#include "cGenotype.h"
-#include "cHardwareBase.h"
-#include "cHardwareManager.h"
-#include "cHistogram.h"
-#include "cInstSet.h"
-#include "cInstUtil.h"
-#include "cLandscape.h"
-#include "cOrganism.h"
-#include "cPhenotype.h"
-#include "cPopulation.h"
-#include "cPopulationCell.h"
-#include "cSpecies.h"
-#include "cStats.h"
-#include "cTestCPU.h"
-#include "cTestUtil.h"
-#include "cTools.h"
-#include "cWorld.h"
-
-#include <vector>
-
-using namespace std;
-
-void cAnalyzeUtil::TestGenome(cWorld* world, const cGenome & genome, cInstSet & inst_set,
-			      ofstream & fp, int update)
-{
-  cCPUTestInfo test_info;
-  world->GetTestCPU().TestGenome(test_info, genome);
-
-  cPhenotype &colony_phenotype = test_info.GetColonyOrganism()->GetPhenotype();
-  fp << update << " "                                //  1
-     << colony_phenotype.GetMerit().GetDouble() << " "            //  2
-     << colony_phenotype.GetGestationTime() << " "             //  3
-     << colony_phenotype.GetFitness() << " "                      //  4
-     << 1.0 / (0.1  + colony_phenotype.GetGestationTime()) << " " //  5
-     << genome.GetSize() << " "                                   //  6
-     << colony_phenotype.GetCopiedSize() << " "                   //  7
-     << colony_phenotype.GetExecutedSize() << endl;               //  8
-}
-
-
-
-void cAnalyzeUtil::TestInsSizeChangeRobustness(cWorld* world, ofstream & fp,
-		    const cInstSet & inst_set, const cGenome & in_genome,
-		    int num_trials, int update)
-{
-  cCPUTestInfo test_info;
-  const cInstruction inst_none = inst_set.GetInst("instruction_none");
-
-  // Stats
-  int num_viable = 0;
-  int num_new_size = 0;
-  int num_parent_size = 0;
-
-  for (int i = 0; i < num_trials; i++) {
-    cCPUMemory genome(in_genome);
-    // Should check to only insert infront of an instruction (not a Nop)
-    int ins_pos = -1;
-    while (ins_pos < 0) {
-      ins_pos = world->GetRandom().GetUInt(genome.GetSize());
-      if( inst_set.IsNop(genome[ins_pos]) )  ins_pos = -1;
-    }
-
-    // Insert some "instruction_none" into the genome
-    const int num_nops = world->GetRandom().GetUInt(5) + 5;
-    for (int j = 0; j < num_nops; j++)  genome.Insert(ins_pos, inst_none);
-
-    // Test the genome and output stats
-    if (world->GetTestCPU().TestGenome(test_info, genome)){ // Daughter viable...
-      num_viable++;
-      const double child_size =
-	test_info.GetColonyOrganism()->GetGenome().GetSize();
-
-      if (child_size == (double) in_genome.GetSize()) num_parent_size++;
-      else if (child_size == (double) genome.GetSize()) num_new_size++;
-    }
-  } // for num_trials
-
-  fp << update << " "
-     << (double) num_viable / num_trials << " "
-     << (double) num_new_size / num_trials << " "
-     << (double) num_parent_size / num_trials << " "
-     << endl;
-}
-
-
-
-// Returns the genome of maximal fitness.
-cGenome cAnalyzeUtil::CalcLandscape(cWorld* world, int dist, const cGenome & genome,
-				    cInstSet & inst_set)
-{
-  cLandscape landscape(world, genome, inst_set);
-  landscape.Process(dist);
-  double peak_fitness = landscape.GetPeakFitness();
-  cGenome peak_genome = landscape.GetPeakGenome();
-
-  // Print the results.
-
-  static ofstream fp("landscape.dat");
-  static ofstream fp_entropy("land-entropy.dat");
-  static ofstream fp_count("land-sitecount.dat");
-
-  landscape.PrintStats(fp);
-  landscape.PrintEntropy(fp_entropy);
-  landscape.PrintSiteCount(fp_count);
-
-  // Repeat for Insertions...
-  landscape.Reset(genome);
-  landscape.ProcessInsert();
-  static ofstream fp_ins("landscape-ins.dat");
-  static ofstream fp_ins_count("land-ins-sitecount.dat");
-  landscape.PrintStats(fp_ins);
-  landscape.PrintSiteCount(fp_ins_count);
-  if (landscape.GetPeakFitness() > peak_fitness) {
-    peak_fitness = landscape.GetPeakFitness();
-    peak_genome = landscape.GetPeakGenome();
-  }
-
-  // And Deletions...
-  landscape.Reset(genome);
-  landscape.ProcessDelete();
-  static ofstream fp_del("landscape-del.dat");
-  static ofstream fp_del_count("land-del-sitecount.dat");
-  landscape.PrintStats(fp_del);
-  landscape.PrintSiteCount(fp_del_count);
-  if (landscape.GetPeakFitness() > peak_fitness) {
-    peak_fitness = landscape.GetPeakFitness();
-    peak_genome = landscape.GetPeakGenome();
-  }
-
-  return peak_genome;
-}
-
-
-void cAnalyzeUtil::AnalyzeLandscape(cWorld* world, const cGenome & genome, cInstSet &inst_set,
-	       int sample_size, int min_found, int max_sample_size, int update)
-{
-  cLandscape landscape(world, genome, inst_set);
-
-  static ofstream fp("land_analyze.dat");
-
-  int num_found = 0;
-  for (int dist = 1; dist <= 10; dist++) {
-    landscape.Reset(genome);
-    if (dist == 1) {
-      landscape.Process(dist);
-      num_found = genome.GetSize() * (inst_set.GetSize() - 1);
-    } else {
-      num_found =
-	landscape.RandomProcess(sample_size, dist, min_found, max_sample_size);
-    }
-
-    fp << update                       << " "  // 1
-       << dist                         << " "  // 2
-       << landscape.GetProbDead()      << " "  // 3
-       << landscape.GetProbNeg()       << " "  // 4
-       << landscape.GetProbNeut()      << " "  // 5
-       << landscape.GetProbPos()       << " "  // 6
-       << landscape.GetNumTrials()     << " "  // 7
-       << num_found                    << " "  // 8
-       << landscape.GetAveFitness()    << " "  // 9
-       << landscape.GetAveSqrFitness() << " "  // 10
-       << endl;
-
-    if ((dist > 1) && (num_found < min_found)) break;
-  }
-}
-
-
-void cAnalyzeUtil::PairTestLandscape(cWorld* world, const cGenome &genome, cInstSet &inst_set,
-				     int sample_size, int update)
-{
-  cLandscape landscape(world, genome, inst_set);
-
-  cString filename;
-  filename.Set("pairtest.%d.dat", update);
-  ofstream fp(filename());
-
-  if (sample_size != 0) landscape.TestPairs(sample_size, fp);
-  else landscape.TestAllPairs(fp);
-}
-
-
-void cAnalyzeUtil::CalcConsensus(cWorld* world, int lines_saved)
-{
-  cPopulation* population = &world->GetPopulation();
-  const int num_inst = world->GetHardwareManager().GetInstSet().GetSize();
-  const int update = population->GetStats().GetUpdate();
-  cGenebank & genebank = population->GetGenebank();
-
-  // Setup the histogtams...
-  cHistogram * inst_hist = new cHistogram[MAX_CREATURE_SIZE];
-  for (int i = 0; i < MAX_CREATURE_SIZE; i++) inst_hist[i].Resize(num_inst,-1);
-
-  // Loop through all of the genotypes adding them to the histograms.
-  cGenotype * cur_genotype = genebank.GetBestGenotype();
-  for (int i = 0; i < genebank.GetSize(); i++) {
-    const int num_organisms = cur_genotype->GetNumOrganisms();
-    const int length = cur_genotype->GetLength();
-    const cGenome & genome = cur_genotype->GetGenome();
-
-    // Place this genotype into the histograms.
-    for (int j = 0; j < length; j++) {
-      assert(genome[j].GetOp() < num_inst);
-      inst_hist[j].Insert(genome[j].GetOp(), num_organisms);
-    }
-
-    // Mark all instructions beyond the length as -1 in histogram...
-    for (int j = length; j < MAX_CREATURE_SIZE; j++) {
-      inst_hist[j].Insert(-1, num_organisms);
-    }
-
-    // ...and advance to the next genotype...
-    cur_genotype = cur_genotype->GetNext();
-  }
-
-  // Now, lets print something!
-  static ofstream fp("consensus.dat");
-  static ofstream fp_abundance("con-abundance.dat");
-  static ofstream fp_var("con-var.dat");
-  static ofstream fp_entropy("con-entropy.dat");
-
-  // Determine the length of the concensus genome
-  int con_length;
-  for (con_length = 0; con_length < MAX_CREATURE_SIZE; con_length++) {
-    if (inst_hist[con_length].GetMode() == -1) break;
-  }
-
-  // Build the concensus genotype...
-  cGenome con_genome(con_length);
-  double total_entropy = 0.0;
-  for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
-    const int mode = inst_hist[i].GetMode();
-    const int count = inst_hist[i].GetCount(mode);
-    const int total = inst_hist[i].GetCount();
-    const double entropy = inst_hist[i].GetNormEntropy();
-    if (i < con_length) total_entropy += entropy;
-
-    // Break out if ALL creatures have a -1 in this area, and we've
-    // finished printing all of the files.
-    if (mode == -1 && count == total) break;
-
-    if ( i < con_length )
-      con_genome[i].SetOp(mode);
-
-    // Print all needed files.
-    if (i < lines_saved) {
-      fp_abundance << count << " ";
-      fp_var << inst_hist[i].GetCountVariance() << " ";
-      fp_entropy << entropy << " ";
-    }
-  }
-
-  // Put end-of-lines on the files.
-  if (lines_saved > 0) {
-    fp_abundance << endl;
-    fp_var       << endl;
-    fp_entropy   << endl;
-  }
-
-  // --- Study the consensus genome ---
-
-  // Loop through genotypes again, and determine the average genetic distance.
-  cur_genotype = genebank.GetBestGenotype();
-  cDoubleSum distance_sum;
-  for (int i = 0; i < genebank.GetSize(); i++) {
-    const int num_organisms = cur_genotype->GetNumOrganisms();
-    const int cur_dist =
-      cGenomeUtil::FindEditDistance(con_genome, cur_genotype->GetGenome());
-    distance_sum.Add(cur_dist, num_organisms);
-
-    // ...and advance to the next genotype...
-    cur_genotype = cur_genotype->GetNext();
-  }
-
-  // Finally, gather last bits of data and print the results.
-  cGenotype * con_genotype = genebank.FindGenotype(con_genome, -1);
-  const int best_dist = cGenomeUtil::FindEditDistance(con_genome,
-			     genebank.GetBestGenotype()->GetGenome());
-
-  const double ave_dist = distance_sum.Average();
-  const double var_dist = distance_sum.Variance();
-  const double complexity_base = (double) con_genome.GetSize() - total_entropy;
-
-  cString con_name;
-  con_name.Set("genebank/%03d-consensus-u%i.gen", con_genome.GetSize(),update);
-  cTestUtil::PrintGenome(world, con_genome, con_name());
-
-
-  if (con_genotype) {
-    fp << update                                 << " " //  1
-       << con_genotype->GetMerit()               << " " //  2
-       << con_genotype->GetGestationTime()       << " " //  3
-       << con_genotype->GetFitness()             << " " //  4
-       << con_genotype->GetReproRate()           << " " //  5
-       << con_genotype->GetLength()              << " " //  6
-       << con_genotype->GetCopiedSize()          << " " //  7
-       << con_genotype->GetExecutedSize()        << " " //  8
-       << con_genotype->GetBirths()              << " " //  9
-       << con_genotype->GetBreedTrue()           << " " // 10
-       << con_genotype->GetBreedIn()             << " " // 11
-       << con_genotype->GetNumOrganisms()        << " " // 12
-       << con_genotype->GetDepth()               << " " // 13
-       << con_genotype->GetID()                  << " " // 14
-       << update - con_genotype->GetUpdateBorn() << " " // 15
-       << best_dist                              << " " // 16
-       << ave_dist                               << " " // 17
-       << var_dist                               << " " // 18
-       << total_entropy                          << " " // 19
-       << complexity_base                        << " " // 20
-       << endl;
-  }
-  else {
-    cCPUTestInfo test_info;
-    world->GetTestCPU().TestGenome(test_info, con_genome);
-    cPhenotype & colony_phenotype =
-      test_info.GetColonyOrganism()->GetPhenotype();
-    fp << update                                             << " "   //  1
-       << colony_phenotype.GetMerit()                        << " "  //  2
-       << colony_phenotype.GetGestationTime()                << " "  //  3
-       << colony_phenotype.GetFitness()                      << " "  //  4
-       << 1.0 / (0.1  + colony_phenotype.GetGestationTime()) << " "  //  5
-       << con_genome.GetSize()                               << " "  //  6
-       << colony_phenotype.GetCopiedSize()                   << " "  //  7
-       << colony_phenotype.GetExecutedSize()                 << " "  //  8
-       << 0                                  << " "  // Births       //  9
-       << 0                                  << " "  // Breed True   // 10
-       << 0                                  << " "  // Breed In     // 11
-       << 0                                  << " "  // Num CPUs     // 12
-       << -1                                 << " "  // Depth        // 13
-       << -1                                 << " "  // ID           // 14
-       << 0                                  << " "  // Age          // 15
-       << best_dist                                          << " "  // 16
-       << ave_dist                                           << " "  // 17
-       << var_dist                                           << " "  // 18
-       << total_entropy                                      << " "  // 19
-       << complexity_base                                    << " "  // 20
-       << endl;
-  }
-
-  // Flush the file...
-  fp.flush();
-  
-  delete [] inst_hist;
-}
-
-
-
-/**
- * This function goes through all creatures in the soup, and saves the
- * basic landscape data (neutrality, fitness, and so on) into a stream.
- *
- * @param fp The stream into which the data should be saved.
- *
- * @param sample_prob The probability with which a particular creature should
- * be analyzed (a value of 1 analyzes all creatures, a value of 0.1 analyzes
- * 10%, and so on).
- *
- * @param landscape A bool that indicates whether the creatures should be
- * landscaped (calc. neutrality and so on) or not.
- *
- * @param save_genotype A bool that indicates whether the creatures should
- * be saved or not.
- **/
-
-void cAnalyzeUtil::AnalyzePopulation(cWorld* world, ofstream & fp,
-	    double sample_prob, bool landscape, bool save_genotype)
-{
-  cPopulation* pop = &world->GetPopulation();
-  fp << "# (1) cell number (2) genotype name (3) length (4) fitness [test-cpu] (5) fitness (actual) (6) merit (7) no of breed trues occurred (8) lineage label (9) neutral metric (10) -... landscape data" << endl;
-
-  const double skip_prob = 1.0 - sample_prob;
-  for (int i = 0; i < pop->GetSize(); i++) {
-    if (pop->GetCell(i).IsOccupied() == false) continue;  // No organism...
-    if (world->GetRandom().P(skip_prob)) continue;               // Not sampled...
-
-    cOrganism * organism = pop->GetCell(i).GetOrganism();
-    cGenotype * genotype = organism->GetGenotype();
-    const cGenome & genome = organism->GetGenome();
-
-    cString creature_name;
-    if ( genotype->GetThreshold() ) creature_name = genotype->GetName();
-    else creature_name.Set("%03d-no_name-u%i-c%i", genotype->GetLength(),
-			   pop->GetStats().GetUpdate(), i );
-
-    fp << i                                     << " "  // 1 cell ID
-       << creature_name()                       << " "  // 2 name
-       << genotype->GetLength()                 << " "  // 3 length
-       << genotype->GetTestFitness()            << " "  // 4 fitness (test-cpu)
-       << organism->GetPhenotype().GetFitness() << " "  // 5 fitness (actual)
-       << organism->GetPhenotype().GetMerit()   << " "  // 6 merit
-       << genotype->GetBreedTrue()              << " "  // 7 breed true?
-       << organism->GetLineageLabel()           << " "  // 8 lineage label
-       << organism->GetPhenotype().GetNeutralMetric() << " "; // 9 neut metric
-
-    // create landscape object for this creature
-    if (landscape &&  genotype->GetTestFitness() > 0) {
-      cLandscape landscape(world, genome, world->GetHardwareManager().GetInstSet());
-      landscape.Process(1);
-      landscape.PrintStats(fp);
-    }
-    else fp << endl;
-    if ( save_genotype ){
-      char filename[40];
-      sprintf( filename, "genebank/%s", creature_name() );
-      cTestUtil::PrintGenome(world, genome, filename);
-    }
-  }
-}
-
-
-/**
- * This function prints out fitness data. The main point is that it
- * calculates the average fitness from info from the testCPU + the actual
- * merit of the organisms, and assigns zero fitness to those organisms
- * that will never reproduce.
- *
- * The function also determines the maximum fitness genotype, and can
- * produce fitness histograms.
- *
- * @param datafp A stream into which the fitness data should be written.
- * @param histofp A stream into which the fitness histogram should be
- * written.
- * @param histo_testCPU_fp A stream into which the fitness histogram as
- * determined exclusively from the test-CPU should be written.
- * @param save_max_f_genotype A bool that determines whether the genotype
- * with the maximum fitness should be saved into the genebank.
- * @param print_fitness_histo A bool that determines whether fitness
- * histograms should be written.
- * @param hist_fmax The maximum fitness value to be taken into account
- * for the fitness histograms.
- * @param hist_fstep The width of the individual bins in the fitness
- * histograms.
- **/
-
-void cAnalyzeUtil::PrintDetailedFitnessData(cWorld* world, ofstream &datafp,
-   ofstream & hist_fp, ofstream & histo_testCPU_fp, bool save_max_f_genotype,
-   bool print_fitness_histo, double hist_fmax, double hist_fstep)
-{
-  cPopulation* pop = &world->GetPopulation();
-  const int update = pop->GetStats().GetUpdate();
-  const double generation = pop->GetStats().SumGeneration().Average();
-
-  // the histogram variables
-  vector<int> histo;
-  vector<int> histo_testCPU;
-  int bins;
-
-  if ( print_fitness_histo ){
-    bins = (int) (hist_fmax / hist_fstep) + 1;
-    histo.resize( bins, 0 ); // resize and clear
-    histo_testCPU.resize( bins, 0 );
-  }
-
-  int n = 0;
-  int nhist_tot = 0;
-  int nhist_tot_testCPU = 0;
-  double fave = 0;
-  double fave_testCPU = 0;
-  double max_fitness = -1; // we set this to -1, so that even 0 is larger...
-  cGenotype * max_f_genotype = NULL;
-
-  for (int i = 0; i < pop->GetSize(); i++) {
-    if (pop->GetCell(i).IsOccupied() == false) continue;  // One use organisms.
-
-    cOrganism * organism = pop->GetCell(i).GetOrganism();
-    cGenotype * genotype = organism->GetGenotype();
-
-    cCPUTestInfo test_info;
-    world->GetTestCPU().TestGenome( test_info, genotype->GetGenome() );
-    // We calculate the fitness based on the current merit,
-    // but with the true gestation time. Also, we set the fitness
-    // to zero if the creature is not viable.
-    const double f = ( test_info.IsViable() ) ? organism->GetPhenotype().GetMerit().CalcFitness(test_info.GetTestOrganism()->GetPhenotype().GetGestationTime()) : 0;
-    const double f_testCPU = test_info.GetColonyFitness();
-
-    // Get the maximum fitness in the population
-    // Here, we want to count only organisms that can truly replicate,
-    // to avoid complications
-    if ( f_testCPU > max_fitness &&
-	 test_info.GetTestOrganism()->GetPhenotype().CopyTrue() ){
-      max_fitness = f_testCPU;
-      max_f_genotype = genotype;
-    }
-
-    fave += f;
-    fave_testCPU += f_testCPU;
-    n += 1;
-
-
-    // histogram
-    if ( print_fitness_histo && f < hist_fmax ){
-      histo[(int) (f / hist_fstep)] += 1;
-      nhist_tot += 1;
-    }
-
-    if ( print_fitness_histo && f_testCPU < hist_fmax ){
-      histo_testCPU[(int) (f_testCPU / hist_fstep)] += 1;
-      nhist_tot_testCPU += 1;
-    }
-  }
-
-  // determine the name of the maximum fitness genotype
-  cString max_f_name;
-  if ( max_f_genotype->GetThreshold() )
-    max_f_name = max_f_genotype->GetName();
-  else // we put the current update into the name, so that it becomes unique.
-     max_f_name.Set("%03d-no_name-u%i", max_f_genotype->GetLength(),
-		    update );
-
-  datafp << update                    << " "  // 1 update
-	 << generation                << " "  // 2 generation
-	 << fave/ (double) n          << " "  // 3 average fitness
-	 << fave_testCPU/ (double) n  << " "  // 4 average test fitness
-	 << n 	                      << " "  // 5 organism total
-	 << max_fitness               << " "  // 6 maximum fitness
-	 << max_f_name()	      << " "  // 7 maxfit genotype name
-	 << endl;
-
-  if (save_max_f_genotype) {
-    char filename[40];
-    sprintf( filename, "genebank/%s", max_f_name() );
-    cTestUtil::PrintGenome(world, max_f_genotype->GetGenome(), filename);
-  }
-
-  if (print_fitness_histo) {
-    hist_fp << update            << " "  // 1 update
-	    << generation        << " "  // 2 generation
-	    << fave/ (double) n  << " "; // 3 average fitness
-
-    // now output the fitness histo
-    vector<int>::const_iterator it = histo.begin();
-    for ( ; it != histo.end(); it++ )
-      hist_fp << (double) (*it) / (double) nhist_tot << " ";
-    hist_fp << endl;
-
-    histo_testCPU_fp << update                    << " "  // 1 update
-		     << generation                << " "  // 2 generation
-		     << fave_testCPU/ (double) n  << " "; // 3 average fitness
-
-    // now output the fitness histo
-    it = histo_testCPU.begin();
-    for ( ; it != histo_testCPU.end(); it++ )
-      histo_testCPU_fp << (double) (*it) / (double) nhist_tot_testCPU << " ";
-    histo_testCPU_fp << endl;
-  }
-}
-
-
-/**
- * This function goes through all genotypes currently present in the soup,
- * and writes into an output file the average Hamming distance between the
- * creatures in the population and a given reference genome.
- *
- * @param fp The stream into which the data should be saved.
- * @param reference_genome The reference genome.
- * @param save_creatures A bool that indicates whether creatures should be
- * saved into the genebank or not.
- **/
-
-void cAnalyzeUtil::PrintGeneticDistanceData(cWorld* world, ofstream & fp,
-					    const char * creature_name)
-{
-  cPopulation* pop = &world->GetPopulation();
-  double hamming_m1 = 0;
-  double hamming_m2 = 0;
-  int count = 0;
-  int dom_dist = 0;
-
-  // load the reference genome
-  cGenome reference_genome(cInstUtil::LoadGenome(creature_name, world->GetHardwareManager().GetInstSet()));
-
-  // get the info for the dominant genotype
-  cGenotype * cur_genotype = pop->GetGenebank().GetBestGenotype();
-  cGenome genome = cur_genotype->GetGenome();
-  dom_dist = cGenomeUtil::FindHammingDistance( reference_genome, genome );
-  hamming_m1 += dom_dist;
-  hamming_m2 += dom_dist*dom_dist;
-  count += cur_genotype->GetNumOrganisms();
-  // now cycle over the remaining genotypes
-  for (int i = 1; i < pop->GetGenebank().GetSize(); i++) {
-    cur_genotype = cur_genotype->GetNext();
-    cGenome genome = cur_genotype->GetGenome();
-
-    int dist = cGenomeUtil::FindHammingDistance( reference_genome, genome );
-    hamming_m1 += dist;
-    hamming_m2 += dist*dist;
-    count += cur_genotype->GetNumOrganisms();
-  }
-
-  hamming_m1 /= (double) count;
-  hamming_m2 /= (double) count;
-
-  fp << pop->GetStats().GetUpdate()          << " "  // 1 update
-     << hamming_m1 			     << " "  // ave. Hamming dist
-     << sqrt( ( hamming_m2 - hamming_m1*hamming_m1 ) / (double) count )
-                                             << " "  // std. error
-     << cGenomeUtil::FindHammingDistance( reference_genome,
-	      pop->GetGenebank().GetBestGenotype()->GetGenome() ) << " "
-     << endl;
-}
-
-
-/**
- * This function goes through all genotypes currently present in the soup,
- * and writes into an output file the names of the genotypes, the fitness
- * as determined in the test cpu, and the genetic distance to a reference
- * genome.
- *
- * @param fp The stream into which the data should be saved.
- * @param reference_genome The reference genome.
- * @param save_creatures A bool that indicates whether creatures should be
- * saved into the genebank or not.
- **/
-
-void cAnalyzeUtil::GeneticDistancePopDump(cWorld* world, ofstream & fp,
-			 const char * creature_name, bool save_creatures)
-{
-  cPopulation* pop = &world->GetPopulation();
-  double sum_fitness = 0;
-  int sum_num_organisms = 0;
-
-  // load the reference genome
-  cGenome reference_genome( cInstUtil::LoadGenome(creature_name, world->GetHardwareManager().GetInstSet()) );
-
-  // first, print out some documentation...
-  fp << "# (1) genotype name (2) fitness [test-cpu] (3) abundance (4) Hamming distance to reference (5) Levenstein distance to reference" << endl;
-  fp << "# reference genome is the START_CREATURE" << endl;
-
-  // cycle over all genotypes
-  cGenotype * cur_genotype = pop->GetGenebank().GetBestGenotype();
-  for (int i = 0; i < pop->GetGenebank().GetSize(); i++) {
-    const cGenome & genome = cur_genotype->GetGenome();
-    const int num_orgs = cur_genotype->GetNumOrganisms();
-
-    // now output
-
-    sum_fitness += cur_genotype->GetTestFitness() * num_orgs;
-    sum_num_organisms += num_orgs;
-
-    fp << cur_genotype->GetName()()       << " "  // 1 name
-       << cur_genotype->GetTestFitness()  << " "  // 2 fitness
-       << num_orgs                        << " "  // 3 abundance
-       << cGenomeUtil::FindHammingDistance(reference_genome, genome) << " "
-       << cGenomeUtil::FindEditDistance(reference_genome, genome) << " "  // 5
-       << genome.AsString()()             << " "  // 6 genome
-       << endl;
-
-    // save into genebank
-    if (save_creatures) {
-      char filename[40];
-      sprintf( filename, "genebank/%s", cur_genotype->GetName()() );
-      cTestUtil::PrintGenome(world, genome, filename);
-    }
-
-    // ...and advance to the next genotype...
-    cur_genotype = cur_genotype->GetNext();
-  }
-  fp << "# ave fitness from Test CPU's: "
-     << sum_fitness/sum_num_organisms << endl;
-}
-
-
-/**
- * This function goes through all creatures in the soup, and writes out
- * how many tasks the different creatures have done up to now. It counts
- * every task only once, i.e., if a creature does 'put' three times, that
- * will increase its count only by one.
- *
- * @param fp The file into which the result should be written.
- **/
-
-void cAnalyzeUtil::TaskSnapshot(cWorld* world, ofstream & fp)
-{
-  cPopulation* pop = &world->GetPopulation();
-  fp << "# (1) cell number\n# (2) number of rewarded tasks done so far\n# (3) total number of tasks done so far\n# (4) same as 2, but right before divide\n# (5) same as 3, but right before divide\n# (6) same as 2, but for parent\n# (7) same as 3, but for parent\n# (8) genotype fitness\n# (9) genotype name" << endl;
-
-  for (int i = 0; i < pop->GetSize(); i++) {
-    if (pop->GetCell(i).IsOccupied() == false) continue;
-    cOrganism * organism = pop->GetCell(i).GetOrganism();
-
-    // create a test-cpu for the current creature
-    cCPUTestInfo test_info;
-    world->GetTestCPU().TestGenome( test_info, organism->GetGenome() );
-    cPhenotype & test_phenotype = test_info.GetTestOrganism()->GetPhenotype();
-    cPhenotype & phenotype = organism->GetPhenotype();
-
-    int num_tasks = world->GetEnvironment().GetTaskLib().GetSize();
-    int sum_tasks_all = 0;
-    int sum_tasks_rewarded = 0;
-    int divide_sum_tasks_all = 0;
-    int divide_sum_tasks_rewarded = 0;
-    int parent_sum_tasks_all = 0;
-    int parent_sum_tasks_rewarded = 0;
-
-    for (int j = 0; j < num_tasks; j++) {
-      // get the number of bonuses for this task
-      int bonuses = 1; //phenotype.GetTaskLib().GetTaskNumBonus(j);
-      int task_count = ( phenotype.GetCurTaskCount()[j] == 0 ) ? 0 : 1;
-      int divide_tasks_count = (test_phenotype.GetLastTaskCount()[j] == 0)?0:1;
-      int parent_task_count = (phenotype.GetLastTaskCount()[j] == 0) ? 0 : 1;
-
-      // If only one bonus, this task is not rewarded, as last bonus is + 0.
-      if (bonuses > 1) {
-	sum_tasks_rewarded += task_count;
-	divide_sum_tasks_rewarded += divide_tasks_count;
-	parent_sum_tasks_rewarded += parent_task_count;
-      }
-      sum_tasks_all += task_count;
-      divide_sum_tasks_all += divide_tasks_count;
-      parent_sum_tasks_all += parent_task_count;
-    }
-
-    fp << i                          << " " // 1 cell number
-       << sum_tasks_rewarded         << " " // 2 number of tasks rewarded
-       << sum_tasks_all              << " " // 3 total number of tasks done
-       << divide_sum_tasks_rewarded  << " " // 4 num rewarded tasks on divide
-       << divide_sum_tasks_all       << " " // 5 num total tasks on divide
-       << parent_sum_tasks_rewarded  << " " // 6 parent number of tasks rewared
-       << parent_sum_tasks_all       << " " // 7 parent total num tasks done
-       << test_info.GetColonyFitness()         << " " // 8 genotype fitness
-       << organism->GetGenotype()->GetName()() << " " // 9 genotype name
-       << endl;
-  }
-}
-
-void cAnalyzeUtil::TaskGrid(cWorld* world, ofstream & fp)
-{ 
-  cPopulation* pop = &world->GetPopulation();
-  for (int i = 0; i < pop->GetWorldX(); i++) {
-    for (int j = 0; j < pop->GetWorldY(); j++) {
-      int task_sum = 0;
-      int cell_num = i*pop->GetWorldX()+j;
-      if (pop->GetCell(cell_num).IsOccupied() == true) {
-        cOrganism * organism = pop->GetCell(cell_num).GetOrganism();
-        cCPUTestInfo test_info;
-        world->GetTestCPU().TestGenome( test_info, organism->GetGenome() );
-        cPhenotype & test_phenotype = test_info.GetTestOrganism()->GetPhenotype();
-        int num_tasks = world->GetEnvironment().GetTaskLib().GetSize();   
-        for (int k = 0; k < num_tasks; k++) {
-          if (test_phenotype.GetLastTaskCount()[k]>0) {
-	    task_sum = task_sum + (int) pow(2.0,k); 
-          } 
-        }
-      }
-      fp << task_sum << " ";
-    }
-    fp << endl;
-  }
-}
-
-/**
- * This function prints all the tasks that viable creatures have performed
- * so far (compare with the event 'print_task_data', which prints all tasks.
- **/
-
-void cAnalyzeUtil::PrintViableTasksData(cWorld* world, ofstream & fp)
-{
-  const int num_tasks = world->GetNumTasks();
-  cPopulation* pop = &world->GetPopulation();
-
-  static vector<int> tasks(num_tasks);
-  vector<int>::iterator it;
-
-  // clear task vector
-  for (it = tasks.begin(); it != tasks.end(); it++)  (*it) = 0;
-
-  for (int i = 0; i < pop->GetSize(); i++) {
-    if (pop->GetCell(i).IsOccupied() == false) continue;
-    if (pop->GetCell(i).GetOrganism()->GetGenotype()->GetTestFitness() > 0.0) {
-      cPhenotype & phenotype = pop->GetCell(i).GetOrganism()->GetPhenotype();
-      for (int j = 0; j < num_tasks; j++) {
-	if (phenotype.GetCurTaskCount()[j] > 0)  tasks[j] += 1;
-      }
-    }
-  }
-
-  fp << pop->GetStats().GetUpdate();
-  for (it = tasks.begin(); it != tasks.end(); it++)  fp << " " << (*it);
-  fp<<endl;
-}
-
-
-void cAnalyzeUtil::PrintTreeDepths(cPopulation * pop, ofstream & fp)
-{
-  // cycle over all genotypes
-  cGenotype * genotype = pop->GetGenebank().GetBestGenotype();
-  for (int i = 0; i < pop->GetGenebank().GetSize(); i++) {
-    fp << genotype->GetID() << " "             // 1
-       << genotype->GetTestFitness() << " "    // 2
-       << genotype->GetNumOrganisms() << " "   // 3
-       << genotype->GetDepth() << " "          // 4
-       << endl;
-
-    // ...and advance to the next genotype...
-    genotype = genotype->GetNext();
-  }
-}
-
-
-void cAnalyzeUtil::PrintDepthHistogram(ofstream & fp, cPopulation * pop)
-{
-  // Output format:    update  min  max  histogram_values...
-  int min = INT_MAX;
-  int max = 0;
-  assert(fp.good());
-
-  // Two pass method
-
-  // Loop through all genotypes getting min and max values
-  cGenebank & genebank = pop->GetGenebank();
-  cGenotype * cur_genotype = genebank.GetBestGenotype();
-  for (int i = 0; i < genebank.GetSize(); i++) {
-    if (cur_genotype->GetDepth() < min) min = cur_genotype->GetDepth();
-    if (cur_genotype->GetDepth() > max) max = cur_genotype->GetDepth();
-    cur_genotype = cur_genotype->GetNext();
-  }
-  assert(max >= min);
-
-  // Allocate the array for the bins (& zero)
-  int * n = new int[max - min + 1];
-  for (int i = 0; i < max - min + 1; i++) n[i] = 0;
-
-  // Loop through all genotypes binning the values
-  cur_genotype = genebank.GetBestGenotype();
-  for (int i = 0; i < genebank.GetSize(); i++) {
-    n[cur_genotype->GetDepth() - min] += cur_genotype->GetNumOrganisms();
-    cur_genotype = cur_genotype->GetNext();
-  }
-
-  // Actual output
-  fp << pop->GetStats().GetUpdate() << " "
-     << min << " "
-     << max;
-
-  for (int i = 0; i < max - min + 1; i++)  fp << " " << n[i];
-  fp<<endl;
-}
-
-
-void cAnalyzeUtil::PrintGenotypeAbundanceHistogram(ofstream & fp,
-						   cPopulation * pop)
-{
-  assert(fp.good());
-
-  // Allocate array for the histogram & zero it
-  tArray <int> hist(pop->GetGenebank().GetBestGenotype()->GetNumOrganisms());
-  for (int i = 0; i < hist.GetSize(); i++) hist[i] = 0;
-
-  // Loop through all genotypes binning the values
-  cGenotype * cur_genotype = pop->GetGenebank().GetBestGenotype();
-  for (int i = 0; i < pop->GetGenebank().GetSize(); i++) {
-    assert( cur_genotype->GetNumOrganisms() - 1 >= 0 );
-    assert( cur_genotype->GetNumOrganisms() - 1 < hist.GetSize() );
-    hist[cur_genotype->GetNumOrganisms() - 1]++;
-    cur_genotype = cur_genotype->GetNext();
-  }
-
-  // Actual output
-  fp << pop->GetStats().GetUpdate() << " ";
-  for (int i = 0; i < hist.GetSize(); i++)  fp<<hist[i]<<" ";
-  fp << endl;
-}
-
-
-void cAnalyzeUtil::PrintSpeciesAbundanceHistogram(ofstream & fp,
-						  cPopulation * pop)
-{
-  int max = 0;
-  assert(fp.good());
-
-  // Find max species abundance...
-  cGenebank & genebank = pop->GetGenebank();
-  cSpecies * cur_species = genebank.GetFirstSpecies();
-  for (int i = 0; i < genebank.GetNumSpecies(); i++) {
-    if (max < cur_species->GetNumOrganisms()) {
-      max = cur_species->GetNumOrganisms();
-    }
-    cur_species = cur_species->GetNext();
-  }
-
-  // Allocate array for the histogram & zero it
-  tArray <int> hist(max);
-  for (int i = 0; i < hist.GetSize(); i++)  hist[i] = 0;
-
-  // Loop through all species binning the values
-  cur_species = genebank.GetFirstSpecies();
-  for (int i = 0; i < genebank.GetNumSpecies(); i++) {
-    assert( cur_species->GetNumOrganisms() - 1 >= 0 );
-    assert( cur_species->GetNumOrganisms() - 1 < hist.GetSize() );
-    hist[cur_species->GetNumOrganisms() -1]++;
-    cur_species = cur_species->GetNext();
-  }
-
-  // Actual output
-  fp << pop->GetStats().GetUpdate() << " ";
-  for (int i = 0; i < hist.GetSize(); i++)  fp<<hist[i]<<" ";
-  fp<<endl;
-}
-
-
-// this adds support for evan dorn's InstructionHistogramEvent.  -- kgn
-/**
- * Count the number of each instruction present in the population.  Output
- * this info to a log file
- **/
-void cAnalyzeUtil::PrintInstructionAbundanceHistogram(cWorld* world, ofstream & fp)
-{
-  cPopulation* pop = &world->GetPopulation();
-  int i,x,y;
-  int num_inst=0;
-  int mem_size=0;
-  int * inst_counts;
-  cCPUMemory cpu_mem; // cCPUMemory is a subclass of cGenome
-  assert(fp.good());
-
-  // ----- number of instructions available?
-  num_inst = world->GetNumInstructions();
-  inst_counts= new int[num_inst];
-
-  // ----- create and initialize counting array
-  inst_counts  = new int[num_inst];
-  for (i=0;i<num_inst;i++)
-    { inst_counts[i]=0;
-    }
-  
-  int num_cells = pop->GetSize();
-  //looping through all CPUs counting up instructions
-  for( x=0; x<num_cells; x++ )
-    { cPopulationCell & cell=pop->GetCell(x);
-      if (cell.IsOccupied())
-      {
-      // access this CPU's code block
-        cpu_mem=cell.GetOrganism()->GetHardware().GetMemory();
-        mem_size=cpu_mem.GetSize();
-        for (y=0; y<mem_size ; y++)
-    { inst_counts[(cpu_mem[y]).GetOp()]++;     
-    }  
-      }
-    }
-  
-  // ----- output instruction counts
-  for(i=0; i<num_inst; i++)
-    { fp<<inst_counts[i]<<" ";
-    }
-  fp<<endl;
-}
-

Deleted: branches/brysonda/source/main/cAnalyzeUtil.h
===================================================================
--- branches/brysonda/source/main/cAnalyzeUtil.h	2005-11-04 00:39:30 UTC (rev 368)
+++ branches/brysonda/source/main/cAnalyzeUtil.h	2005-11-04 03:50:46 UTC (rev 369)
@@ -1,72 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2001 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef ANALYZE_UTIL_HH
-#define ANALYZE_UTIL_HH
-
-#include <fstream>
-
-class cGenome;
-class cInstSet;
-class cPopulation;
-class cWorld;
-
-// This is a static class used to do various forms of complex analysis
-// on genomes.
-
-class cAnalyzeUtil {
-private:
-public:
-  // Generic test-CPU analysis
-  static void TestGenome(cWorld* world, const cGenome & genome, cInstSet & inst_set,
-			 std::ofstream & fp, int update);
-
-  static void TestInsSizeChangeRobustness(cWorld* world, std::ofstream & fp,
-                 const cInstSet & inst_set, const cGenome & in_genome,
-                 int num_trials, int update);
-
-
-  // Landscape-based analysis
-  static cGenome CalcLandscape(cWorld* world, int dist, const cGenome & genome,
-			       cInstSet & inst_set);
-  static void AnalyzeLandscape(cWorld* world, const cGenome & genome, cInstSet & inst_set,
-			       int sample_size=1000, int min_found=0,
-			       int max_sample_size=0, int update=-1);
-  static void PairTestLandscape(cWorld* world, const cGenome & genome, cInstSet & inst_set,
-				int sample_size=0, int update=-1);
-
-
-  // Population-wide analysis
-  static void CalcConsensus(cWorld* world, int lines_saved);
-
-  static void AnalyzePopulation(cWorld* world, std::ofstream & fp,
-				double sample_prob=1, bool landscape=false,
-				bool save_genotype=false);
-
-  static void PrintDetailedFitnessData(cWorld* world, std::ofstream & datafp,
-    std::ofstream & histofp, std::ofstream & histo_testCPU_fp, bool save_max_f_genotype,
-    bool print_fitness_histo, double hist_fmax, double hist_fstep);
-
-  static void PrintGeneticDistanceData(cWorld* world, std::ofstream & fp,
-				const char *creature_name );
-  static void GeneticDistancePopDump(cWorld* world, std::ofstream & fp,
-		    const char * creature_name, bool save_creatures=false);
-
-  static void TaskSnapshot(cWorld* world, std::ofstream & fp);
-  static void TaskGrid(cWorld* world, std::ofstream & fp);
-  static void PrintViableTasksData(cWorld* world, std::ofstream &fp);
-  static void PrintTreeDepths(cPopulation * pop, std::ofstream & fp);
-
-  static void PrintDepthHistogram(std::ofstream &fp, cPopulation * pop);
-  static void PrintGenotypeAbundanceHistogram(std::ofstream &fp, cPopulation * pop);
-  static void PrintSpeciesAbundanceHistogram(std::ofstream &fp, cPopulation * pop);
-
-  // this adds support for evan dorn's InstructionHistogramEvent.  -- kgn
-  static void PrintInstructionAbundanceHistogram(cWorld* world, std::ofstream &fp);
-  // -- kgn
-};
-#endif




More information about the Avida-cvs mailing list