[Avida-cvs] [Avida2-svn] r317 - in trunk/source: bindings/Boost.Python cpu event main testsuites/unit_testsuites testsuites/unit_testsuites/level_0 testsuites/unit_testsuites/level_1 viewers
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Fri Sep 16 15:30:28 PDT 2005
Author: brysonda
Date: 2005-09-16 18:19:23 -0400 (Fri, 16 Sep 2005)
New Revision: 317
Added:
trunk/source/main/cFitnessMatrix.cc
trunk/source/main/cFitnessMatrix.h
trunk/source/main/cGenebank.cc
trunk/source/main/cGenebank.h
trunk/source/main/cGenome.cc
trunk/source/main/cGenome.hh
trunk/source/main/cGenomeBatch.h
trunk/source/main/cGenomeUtil.cc
trunk/source/main/cGenomeUtil.h
trunk/source/main/cGenotype.cc
trunk/source/main/cGenotype.h
trunk/source/main/cGenotypeControl.cc
trunk/source/main/cGenotypeControl.h
trunk/source/main/cGenotype_BirthData.cc
trunk/source/main/cGenotype_BirthData.h
trunk/source/main/cGenotype_TestData.cc
trunk/source/main/cGenotype_TestData.h
trunk/source/main/cInjectGenebank.cc
trunk/source/main/cInjectGenebank.h
trunk/source/main/cInjectGenotype.cc
trunk/source/main/cInjectGenotype.h
trunk/source/main/cInjectGenotypeControl.cc
trunk/source/main/cInjectGenotypeControl.h
trunk/source/main/cInjectGenotypeElement.h
trunk/source/main/cInjectGenotypeQueue.cc
trunk/source/main/cInjectGenotypeQueue.h
trunk/source/main/cInjectGenotype_BirthData.cc
trunk/source/main/cInjectGenotype_BirthData.h
trunk/source/main/cInstLibBase.h
trunk/source/main/cInstSet.cc
trunk/source/main/cInstSet.h
trunk/source/main/cInstUtil.cc
trunk/source/main/cInstUtil.h
trunk/source/main/cInstruction.cc
trunk/source/main/cInstruction.h
Removed:
trunk/source/main/fitness_matrix.cc
trunk/source/main/fitness_matrix.hh
trunk/source/main/genebank.cc
trunk/source/main/genebank.hh
trunk/source/main/genome.cc
trunk/source/main/genome.hh
trunk/source/main/genome_util.cc
trunk/source/main/genome_util.hh
trunk/source/main/genotype.cc
trunk/source/main/genotype.hh
trunk/source/main/genotype_batch.hh
trunk/source/main/genotype_birth_data.cc
trunk/source/main/genotype_birth_data.hh
trunk/source/main/genotype_control.cc
trunk/source/main/genotype_control.hh
trunk/source/main/genotype_test_data.cc
trunk/source/main/genotype_test_data.hh
trunk/source/main/inject_genebank.cc
trunk/source/main/inject_genebank.hh
trunk/source/main/inject_genotype.cc
trunk/source/main/inject_genotype.hh
trunk/source/main/inject_genotype_birth_data.cc
trunk/source/main/inject_genotype_birth_data.hh
trunk/source/main/inject_genotype_control.cc
trunk/source/main/inject_genotype_control.hh
trunk/source/main/inject_genotype_element.hh
trunk/source/main/inject_genotype_queue.cc
trunk/source/main/inject_genotype_queue.hh
trunk/source/main/inst_lib_base.hh
trunk/source/main/inst_set.cc
trunk/source/main/inst_set.hh
trunk/source/main/inst_util.cc
trunk/source/main/inst_util.hh
trunk/source/main/instruction.cc
trunk/source/main/instruction.hh
Modified:
trunk/source/bindings/Boost.Python/4stack_head.pyste
trunk/source/bindings/Boost.Python/analyze_genotype.pyste
trunk/source/bindings/Boost.Python/analyze_util.pyste
trunk/source/bindings/Boost.Python/birth_chamber.pyste
trunk/source/bindings/Boost.Python/cpu_head.pyste
trunk/source/bindings/Boost.Python/fitness_matrix.pyste
trunk/source/bindings/Boost.Python/genebank.pyste
trunk/source/bindings/Boost.Python/genome.pyste
trunk/source/bindings/Boost.Python/genome_util.pyste
trunk/source/bindings/Boost.Python/genotype.pyste
trunk/source/bindings/Boost.Python/genotype_batch.pyste
trunk/source/bindings/Boost.Python/genotype_birth_data.pyste
trunk/source/bindings/Boost.Python/genotype_control.pyste
trunk/source/bindings/Boost.Python/genotype_test_data.pyste
trunk/source/bindings/Boost.Python/hardware_4stack.pyste
trunk/source/bindings/Boost.Python/hardware_4stack_thread.pyste
trunk/source/bindings/Boost.Python/hardware_base.pyste
trunk/source/bindings/Boost.Python/hardware_cpu.pyste
trunk/source/bindings/Boost.Python/hardware_factory.pyste
trunk/source/bindings/Boost.Python/hardware_util.pyste
trunk/source/bindings/Boost.Python/inject_genebank.pyste
trunk/source/bindings/Boost.Python/inject_genotype.pyste
trunk/source/bindings/Boost.Python/inject_genotype_birth_data.pyste
trunk/source/bindings/Boost.Python/inject_genotype_control.pyste
trunk/source/bindings/Boost.Python/inject_genotype_element.pyste
trunk/source/bindings/Boost.Python/inject_genotype_queue.pyste
trunk/source/bindings/Boost.Python/inst_lib_base.pyste
trunk/source/bindings/Boost.Python/inst_set.pyste
trunk/source/bindings/Boost.Python/inst_util.pyste
trunk/source/bindings/Boost.Python/instruction.pyste
trunk/source/bindings/Boost.Python/landscape.pyste
trunk/source/bindings/Boost.Python/lineage.pyste
trunk/source/bindings/Boost.Python/lineage_control.pyste
trunk/source/bindings/Boost.Python/mx_code_array.pyste
trunk/source/bindings/Boost.Python/organism.pyste
trunk/source/bindings/Boost.Python/population.pyste
trunk/source/bindings/Boost.Python/population_interface.pyste
trunk/source/bindings/Boost.Python/py_avida_driver-fixups.cc
trunk/source/bindings/Boost.Python/species.pyste
trunk/source/bindings/Boost.Python/species_control.pyste
trunk/source/bindings/Boost.Python/stats.pyste
trunk/source/bindings/Boost.Python/test_cpu.pyste
trunk/source/bindings/Boost.Python/test_util.pyste
trunk/source/cpu/cCPUMemory.h
trunk/source/cpu/cHardware4Stack.cc
trunk/source/cpu/cHardwareBase.cc
trunk/source/cpu/cHardwareBase.h
trunk/source/cpu/cHardwareCPU.cc
trunk/source/cpu/cHardwareFactory.cc
trunk/source/cpu/cHardwareSMT.cc
trunk/source/cpu/cHardwareStatusPrinter.cc
trunk/source/cpu/cHardwareUtil.cc
trunk/source/cpu/cHeadCPU.cc
trunk/source/cpu/cHeadMultiMem.cc
trunk/source/cpu/cInstLibCPU.h
trunk/source/cpu/cTestCPU.cc
trunk/source/cpu/cTestUtil.cc
trunk/source/cpu/tInstLib.h
trunk/source/event/cPopulationEventFactory.cc
trunk/source/main/CMakeLists.txt
trunk/source/main/cAnalyze.cc
trunk/source/main/cAnalyze.h
trunk/source/main/cAnalyzeGenotype.cc
trunk/source/main/cAnalyzeGenotype.h
trunk/source/main/cAnalyzeUtil.cc
trunk/source/main/cAvidaDriver_Population.cc
trunk/source/main/cBirthChamber.cc
trunk/source/main/cCallbackUtil.cc
trunk/source/main/cEnvironment.h
trunk/source/main/landscape.cc
trunk/source/main/landscape.hh
trunk/source/main/lineage.cc
trunk/source/main/lineage_control.cc
trunk/source/main/main_sub.pri
trunk/source/main/mx_code_array.cc
trunk/source/main/mx_code_array.hh
trunk/source/main/organism.cc
trunk/source/main/organism.hh
trunk/source/main/population.cc
trunk/source/main/species.cc
trunk/source/main/species.hh
trunk/source/main/species_control.cc
trunk/source/testsuites/unit_testsuites/fitness_matrix.t.cc
trunk/source/testsuites/unit_testsuites/genebank.t.cc
trunk/source/testsuites/unit_testsuites/genome.t.cc
trunk/source/testsuites/unit_testsuites/genome_util.t.cc
trunk/source/testsuites/unit_testsuites/genotype.t.cc
trunk/source/testsuites/unit_testsuites/genotype_batch.t.cc
trunk/source/testsuites/unit_testsuites/genotype_birth_data.t.cc
trunk/source/testsuites/unit_testsuites/genotype_control.t.cc
trunk/source/testsuites/unit_testsuites/inject_genebank.t.cc
trunk/source/testsuites/unit_testsuites/inject_genotype.t.cc
trunk/source/testsuites/unit_testsuites/inject_genotype_birth_data.t.cc
trunk/source/testsuites/unit_testsuites/inject_genotype_control.t.cc
trunk/source/testsuites/unit_testsuites/inject_genotype_element.t.cc
trunk/source/testsuites/unit_testsuites/inject_genotype_queue.t.cc
trunk/source/testsuites/unit_testsuites/inst_lib_base.t.cc
trunk/source/testsuites/unit_testsuites/inst_set.t.cc
trunk/source/testsuites/unit_testsuites/inst_util.t.cc
trunk/source/testsuites/unit_testsuites/level_0/genotype_test_data.t.cc
trunk/source/testsuites/unit_testsuites/level_1/instruction.t.cc
trunk/source/viewers/environment_screen.cc
trunk/source/viewers/hist_screen.cc
trunk/source/viewers/map_screen.cc
trunk/source/viewers/stats_screen.cc
trunk/source/viewers/symbol_util.cc
trunk/source/viewers/text_screen.cc
trunk/source/viewers/text_screen.hh
trunk/source/viewers/view.cc
trunk/source/viewers/zoom_screen.cc
Log:
Contining to rename main/. Incorrectly renamed genome.hh to cGenome.hh, will recommit shortly
Modified: trunk/source/bindings/Boost.Python/4stack_head.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/4stack_head.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/4stack_head.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -2,7 +2,7 @@
Import("cpu_head.pyste")
Include("cCPUMemory.h")
-Include("instruction.hh")
+Include("cInstruction.h")
Include("cHardwareBase.h")
cHeadMultiMem = Class("cHeadMultiMem", "cHeadMultiMem.h")
Modified: trunk/source/bindings/Boost.Python/analyze_genotype.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/analyze_genotype.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/analyze_genotype.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,4 +1,4 @@
-Include("inst_set.hh")
+Include("cInstSet.h")
cAnalyzeGenotype = Class("cAnalyzeGenotype", "cAnalyzeGenotype.h")
Modified: trunk/source/bindings/Boost.Python/analyze_util.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/analyze_util.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/analyze_util.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,6 +1,6 @@
Include("population.hh")
-Include("genome.hh")
-Include("inst_set.hh")
+Include("cGenome.h")
+Include("cInstSet.h")
cAnalyzeUtil = Class("cAnalyzeUtil", "cAnalyzeUtil.h")
Modified: trunk/source/bindings/Boost.Python/birth_chamber.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/birth_chamber.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/birth_chamber.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,6 +1,6 @@
Include("organism.hh")
-Include("genebank.hh")
+Include("cGenebank.h")
cBirthChamber = Class("cBirthChamber", "cBirthChamber.h")
Modified: trunk/source/bindings/Boost.Python/cpu_head.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/cpu_head.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/cpu_head.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,6 +1,6 @@
Include("cCPUMemory.h")
-Include("instruction.hh")
+Include("cInstruction.h")
Include("cHardwareBase.h")
Include("cCodeLabel.h")
Modified: trunk/source/bindings/Boost.Python/fitness_matrix.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/fitness_matrix.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/fitness_matrix.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
-Include("inst_set.hh")
+Include("cInstSet.h")
-cFitnessMatrix = Class("cFitnessMatrix", "fitness_matrix.hh")
+cFitnessMatrix = Class("cFitnessMatrix", "cFitnessMatrix.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/genebank.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/genebank.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/genebank.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,10 +1,10 @@
Include("stats.hh")
Include("species.hh")
-Include("genotype.hh")
-Include("genome.hh")
+Include("cGenotype.h")
+Include("cGenome.h")
-cGenebank = Class("cGenebank", "genebank.hh")
+cGenebank = Class("cGenebank", "cGenebank.h")
set_policy(cGenebank.AddGenotype, return_internal_reference())
set_policy(cGenebank.InjectGenotype, return_internal_reference())
set_policy(cGenebank.FindGenotype, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/genome.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/genome.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/genome.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,4 +1,4 @@
-cGenome = Class("cGenome", "genome.hh")
+cGenome = Class("cGenome", "cGenome.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/genome_util.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/genome_util.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/genome_util.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,4 +1,4 @@
-cGenomeUtil = Class("cGenomeUtil", "genome_util.hh")
+cGenomeUtil = Class("cGenomeUtil", "cGenomeUtil.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/genotype.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/genotype.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/genotype.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,9 +1,9 @@
Include("merit.hh")
Include("species.hh")
-Include("genebank.hh")
+Include("cGenebank.h")
-cGenotype = Class("cGenotype", "genotype.hh")
+cGenotype = Class("cGenotype", "cGenotype.h")
set_policy(cGenotype.GetGenome, return_internal_reference())
set_policy(cGenotype.GetParentGenotype, return_internal_reference())
set_policy(cGenotype.GetParent2Genotype, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/genotype_batch.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/genotype_batch.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/genotype_batch.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
-cGenotypeBatch = Class("cGenotypeBatch", "genotype_batch.hh")
+cGenotypeBatch = Class("cGenotypeBatch", "cGenotypeBatch.h")
set_policy(cGenotypeBatch.List, return_internal_reference())
set_policy(cGenotypeBatch.Name, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/genotype_birth_data.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/genotype_birth_data.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/genotype_birth_data.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,8 +1,8 @@
-Include("inst_set.hh")
+Include("cInstSet.h")
Include("species.hh")
-Include("genotype.hh")
+Include("cGenotype.h")
-cGenotype_BirthData = Class("cGenotype_BirthData", "genotype_birth_data.hh")
+cGenotype_BirthData = Class("cGenotype_BirthData", "cGenotype_BirthData.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/genotype_control.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/genotype_control.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/genotype_control.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,9 +1,9 @@
-Include("genebank.hh")
-Include("genotype.hh")
-Include("genome.hh")
+Include("cGenebank.h")
+Include("cGenotype.h")
+Include("cGenome.h")
-cGenotypeControl = Class("cGenotypeControl", "genotype_control.hh")
+cGenotypeControl = Class("cGenotypeControl", "cGenotypeControl.h")
set_policy(cGenotypeControl.GetBest, return_internal_reference())
set_policy(cGenotypeControl.GetCoalescent, return_internal_reference())
set_policy(cGenotypeControl.Find, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/genotype_test_data.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/genotype_test_data.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/genotype_test_data.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,3 +1,3 @@
-cGenotype_TestData = Class("cGenotype_TestData", "genotype_test_data.hh")
+cGenotype_TestData = Class("cGenotype_TestData", "cGenotype_TestData.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/hardware_4stack.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_4stack.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/hardware_4stack.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,7 +1,7 @@
Include("mutation.hh")
-Include("inject_genotype.hh")
-Include("inst_set.hh")
+Include("cInjectGenotype.h")
+Include("cInstSet.h")
Include("organism.hh")
Import("hardware_base.pyste")
Modified: trunk/source/bindings/Boost.Python/hardware_4stack_thread.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_4stack_thread.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/hardware_4stack_thread.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,6 +1,6 @@
Include("cHardwareBase.h")
-Include("inject_genotype.hh")
+Include("cInjectGenotype.h")
cHardware4Stack_Thread = Class("cHardware4Stack_Thread", "cHardware4Stack_Thread.h")
Modified: trunk/source/bindings/Boost.Python/hardware_base.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_base.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/hardware_base.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,9 +1,9 @@
Include("cCodeLabel.h")
Include("cCPUMemory.h")
-Include("genome.hh")
+Include("cGenome.h")
Include("cHardwareTracer.h")
-Include("inst_set.hh")
+Include("cInstSet.h")
Include("organism.hh")
cHardwareBase = Class("cHardwareBase", "cHardwareBase.h")
Modified: trunk/source/bindings/Boost.Python/hardware_cpu.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_cpu.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/hardware_cpu.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,7 +1,7 @@
Include("mutation.hh")
Include("cInstLibCPU.h")
-Include("inst_set.hh")
+Include("cInstSet.h")
Include("organism.hh")
Import("hardware_base.pyste")
Modified: trunk/source/bindings/Boost.Python/hardware_factory.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_factory.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/hardware_factory.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,7 +1,7 @@
Include("cHardwareBase.h")
Include("organism.hh")
-Include("inst_set.hh")
+Include("cInstSet.h")
cHardwareFactory = Class("cHardwareFactory", "cHardwareFactory.h")
set_policy(cHardwareFactory.Create, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/hardware_util.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_util.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/hardware_util.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
-Include("inst_set.hh")
+Include("cInstSet.h")
cHardwareUtil = Class("cHardwareUtil", "cHardwareUtil.h")
set_policy(cHardwareUtil.DefaultInstSet, return_value_policy(reference_existing_object))
Modified: trunk/source/bindings/Boost.Python/inject_genebank.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/inject_genebank.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/inject_genebank.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,9 +1,9 @@
Include("stats.hh")
-Include("inject_genotype.hh")
-Include("genome.hh")
+Include("cInjectGenotype.h")
+Include("cGenome.h")
-cInjectGenebank = Class("cInjectGenebank", "inject_genebank.hh")
+cInjectGenebank = Class("cInjectGenebank", "cInjectGenebank.h")
set_policy(cInjectGenebank.AddInjectGenotype, return_internal_reference())
set_policy(cInjectGenebank.FindInjectGenotype, return_internal_reference())
set_policy(cInjectGenebank.GetBestInjectGenotype, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/inject_genotype.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/inject_genotype.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/inject_genotype.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
-cInjectGenotype = Class("cInjectGenotype", "inject_genotype.hh")
+cInjectGenotype = Class("cInjectGenotype", "cInjectGenotype.h")
set_policy(cInjectGenotype.GetGenome, return_internal_reference())
set_policy(cInjectGenotype.GetParentGenotype, return_internal_reference())
set_policy(cInjectGenotype.GetName, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/inject_genotype_birth_data.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/inject_genotype_birth_data.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/inject_genotype_birth_data.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,6 +1,6 @@
-Include("inject_genotype.hh")
+Include("cInjectGenotype.h")
-cInjectGenotype_BirthData = Class("cInjectGenotype_BirthData", "inject_genotype_birth_data.hh")
+cInjectGenotype_BirthData = Class("cInjectGenotype_BirthData", "cInjectGenotype_BirthData.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/inject_genotype_control.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/inject_genotype_control.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/inject_genotype_control.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,9 +1,9 @@
-Include("inject_genebank.hh")
-Include("inject_genotype.hh")
-Include("genome.hh")
+Include("cInjectGenebank.h")
+Include("cInjectGenotype.h")
+Include("cGenome.h")
-cInjectGenotypeControl = Class("cInjectGenotypeControl", "inject_genotype_control.hh")
+cInjectGenotypeControl = Class("cInjectGenotypeControl", "cInjectGenotypeControl.h")
set_policy(cInjectGenotypeControl.GetBest, return_internal_reference())
set_policy(cInjectGenotypeControl.GetCoalescent, return_internal_reference())
set_policy(cInjectGenotypeControl.Find, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/inject_genotype_element.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/inject_genotype_element.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/inject_genotype_element.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,7 +1,7 @@
-Include("inject_genotype.hh")
+Include("cInjectGenotype.h")
-cInjectGenotypeElement = Class("cInjectGenotypeElement", "inject_genotype_element.hh")
+cInjectGenotypeElement = Class("cInjectGenotypeElement", "cInjectGenotypeElement.h")
set_policy(cInjectGenotypeElement.GetInjectGenotype, return_internal_reference())
set_policy(cInjectGenotypeElement.GetNext, return_internal_reference())
set_policy(cInjectGenotypeElement.GetPrev, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/inject_genotype_queue.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/inject_genotype_queue.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/inject_genotype_queue.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,8 +1,8 @@
-Include("genome.hh")
-Include("inject_genotype.hh")
+Include("cGenome.h")
+Include("cInjectGenotype.h")
-cInjectGenotypeQueue = Class("cInjectGenotypeQueue", "inject_genotype_queue.hh")
+cInjectGenotypeQueue = Class("cInjectGenotypeQueue", "cInjectGenotypeQueue.h")
set_policy(cInjectGenotypeQueue.Find, return_internal_reference())
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/inst_lib_base.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/inst_lib_base.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/inst_lib_base.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,7 +1,7 @@
Include("string.hh")
-cInstLibBase = Class("cInstLibBase", "inst_lib_base.hh")
+cInstLibBase = Class("cInstLibBase", "cInstLibBase.h")
set_policy(cInstLibBase.GetName, return_value_policy(reference_existing_object))
set_policy(cInstLibBase.GetNopName, return_value_policy(reference_existing_object))
set_policy(cInstLibBase.GetInstDefault, return_value_policy(reference_existing_object))
Modified: trunk/source/bindings/Boost.Python/inst_set.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/inst_set.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/inst_set.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
-cInstSet = Class("cInstSet", "inst_set.hh")
+cInstSet = Class("cInstSet", "cInstSet.h")
set_policy(cInstSet.GetInstLib, return_value_policy(reference_existing_object))
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/inst_util.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/inst_util.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/inst_util.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
-Include("inst_set.hh")
+Include("cInstSet.h")
-cInstUtil = Class("cInstUtil", "inst_util.hh")
+cInstUtil = Class("cInstUtil", "cInstUtil.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/instruction.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/instruction.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/instruction.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,4 +1,4 @@
-cInstruction = Class("cInstruction", "instruction.hh")
+cInstruction = Class("cInstruction", "cInstruction.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/landscape.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/landscape.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/landscape.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
-Include("inst_set.hh")
+Include("cInstSet.h")
Include("fstream")
Modified: trunk/source/bindings/Boost.Python/lineage.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/lineage.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/lineage.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
-Include("genotype.hh")
+Include("cGenotype.h")
cLineage = Class("cLineage", "lineage.hh")
Modified: trunk/source/bindings/Boost.Python/lineage_control.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/lineage_control.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/lineage_control.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,8 +1,8 @@
-Include("genebank.hh")
+Include("cGenebank.h")
Include("stats.hh")
Include("string.hh")
-Include("genotype.hh")
+Include("cGenotype.h")
Include("lineage.hh")
Include("organism.hh")
Modified: trunk/source/bindings/Boost.Python/mx_code_array.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/mx_code_array.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/mx_code_array.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,6 +1,6 @@
Include("my_code_array_less_than.hh")
-Include("genome.hh")
+Include("cGenome.h")
cMxCodeArray = Class("cMxCodeArray", "mx_code_array.hh")
Modified: trunk/source/bindings/Boost.Python/organism.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/organism.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/organism.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,10 +1,10 @@
Include("cEnvironment.h")
-Include("inject_genotype.hh")
+Include("cInjectGenotype.h")
Include("cHardwareBase.h")
Include("cCodeLabel.h")
Include("org_message.hh")
-Include("genotype.hh")
+Include("cGenotype.h")
Include("lineage.hh")
cOrganism = Class("cOrganism", "organism.hh")
Modified: trunk/source/bindings/Boost.Python/population.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/population.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/population.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,8 +1,8 @@
Include("change_list.hh")
Include("cEnvironment.h")
-Include("genebank.hh" )
-Include("inject_genebank.hh")
+Include("cGenebank.h" )
+Include("cInjectGenebank.h")
Include("lineage_control.hh")
Include("organism.hh")
Include("population_cell.hh")
Modified: trunk/source/bindings/Boost.Python/population_interface.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/population_interface.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/population_interface.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
-Include("genome.hh")
+Include("cGenome.h")
Include("cHardwareBase.h")
Include("organism.hh")
Include("org_message.hh")
Modified: trunk/source/bindings/Boost.Python/py_avida_driver-fixups.cc
===================================================================
--- trunk/source/bindings/Boost.Python/py_avida_driver-fixups.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/py_avida_driver-fixups.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -4,8 +4,8 @@
#include "cpu/cHardwareBase.h"
#include "cpu/cHardwareFactory.h"
#include "main/cConfig.h"
-#include "main/genebank.hh"
-#include "main/genotype.hh"
+#include "main/cGenebank.h"
+#include "main/cGenotype.h"
#include "main/organism.hh"
#include "main/population.hh"
#include "main/population_cell.hh"
Modified: trunk/source/bindings/Boost.Python/species.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/species.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/species.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
-Include("genotype.hh")
+Include("cGenotype.h")
cSpecies = Class("cSpecies", "species.hh")
set_policy(cSpecies.GetNext, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/species_control.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/species_control.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/species_control.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,7 +1,7 @@
-Include("genebank.hh")
+Include("cGenebank.h")
Include("species.hh")
-Include("genotype.hh")
+Include("cGenotype.h")
Include("stats.hh")
cSpeciesControl = Class("cSpeciesControl", "species_control.hh")
Modified: trunk/source/bindings/Boost.Python/stats.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/stats.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/stats.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,7 +1,7 @@
Include("data_file.hh")
-Include("genotype.hh")
-Include("inject_genotype.hh")
+Include("cGenotype.h")
+Include("cInjectGenotype.h")
cStats = Class("cStats", "stats.hh")
set_policy(cStats.GetDomGenotype, return_value_policy(reference_existing_object))
Modified: trunk/source/bindings/Boost.Python/test_cpu.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/test_cpu.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/test_cpu.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,8 +1,8 @@
Include("cCPUTestInfo.h")
Include("cEnvironment.h")
-Include("genome.hh")
-Include("inst_set.hh")
+Include("cGenome.h")
+Include("cInstSet.h")
Include("cPopulationInterface.h")
Include("resource_count.hh")
Modified: trunk/source/bindings/Boost.Python/test_util.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/test_util.pyste 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/bindings/Boost.Python/test_util.pyste 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,7 +1,7 @@
-Include("genome.hh")
-Include("inject_genotype.hh")
-Include("genotype.hh")
+Include("cGenome.h")
+Include("cInjectGenotype.h")
+Include("cGenotype.h")
cTestUtil = Class("cTestUtil", "cTestUtil.h")
Modified: trunk/source/cpu/cCPUMemory.h
===================================================================
--- trunk/source/cpu/cCPUMemory.h 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cCPUMemory.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -9,7 +9,7 @@
#define CPU_MEMORY_HH
#ifndef GENOME_HH
-#include "genome.hh"
+#include "cGenome.h"
#endif
#ifndef TARRAY_HH
#include "tArray.hh"
Modified: trunk/source/cpu/cHardware4Stack.cc
===================================================================
--- trunk/source/cpu/cHardware4Stack.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cHardware4Stack.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -12,9 +12,9 @@
#include "cConfig.h"
#include "cCPUTestInfo.h"
#include "functions.hh"
-#include "genome_util.hh"
-#include "inst_lib_base.hh"
-#include "inst_set.hh"
+#include "cGenomeUtil.h"
+#include "cInstLibBase.h"
+#include "cInstSet.h"
#include "cHardwareTracer.h"
#include "cHardwareTracer_4Stack.h"
#include "mutation.hh"
Modified: trunk/source/cpu/cHardwareBase.cc
===================================================================
--- trunk/source/cpu/cHardwareBase.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cHardwareBase.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -7,7 +7,7 @@
#include "cHardwareBase.h"
-#include "inst_set.hh"
+#include "cInstSet.h"
using namespace std;
Modified: trunk/source/cpu/cHardwareBase.h
===================================================================
--- trunk/source/cpu/cHardwareBase.h 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cHardwareBase.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -11,7 +11,7 @@
#include <iostream>
#ifndef INSTRUCTION_HH
-#include "instruction.hh"
+#include "cInstruction.h"
#endif
using namespace std;
Modified: trunk/source/cpu/cHardwareCPU.cc
===================================================================
--- trunk/source/cpu/cHardwareCPU.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cHardwareCPU.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -10,12 +10,12 @@
#include "cConfig.h"
#include "cCPUTestInfo.h"
#include "functions.hh"
-#include "genome_util.hh"
-#include "genotype.hh"
+#include "cGenomeUtil.h"
+#include "cGenotype.h"
#include "cHardwareTracer.h"
#include "cHardwareTracer_CPU.h"
#include "cInstLibCPU.h"
-#include "inst_set.hh"
+#include "cInstSet.h"
#include "mutation.hh"
#include "mutation_lib.hh"
#include "mutation_macros.hh"
Modified: trunk/source/cpu/cHardwareFactory.cc
===================================================================
--- trunk/source/cpu/cHardwareFactory.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cHardwareFactory.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -11,7 +11,7 @@
#include "cHardwareCPU.h"
#include "cHardware4Stack.h"
#include "cHardwareSMT.h"
-#include "inst_set.hh"
+#include "cInstSet.h"
#include "organism.hh"
using namespace std;
Modified: trunk/source/cpu/cHardwareSMT.cc
===================================================================
--- trunk/source/cpu/cHardwareSMT.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cHardwareSMT.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -12,9 +12,9 @@
#include "cConfig.h"
#include "cCPUTestInfo.h"
#include "functions.hh"
-#include "genome_util.hh"
-#include "inst_lib_base.hh"
-#include "inst_set.hh"
+#include "cGenomeUtil.h"
+#include "cInstLibBase.h"
+#include "cInstSet.h"
#include "cHardwareTracer.h"
//#include "cHardwareTracer_4Stack.h"
#include "mutation.hh"
Modified: trunk/source/cpu/cHardwareStatusPrinter.cc
===================================================================
--- trunk/source/cpu/cHardwareStatusPrinter.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cHardwareStatusPrinter.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -10,7 +10,7 @@
#include "cHardwareBase.h"
#include "cHardwareCPU.h"
#include "cHardwareStatusPrinter.h"
-#include "inst_set.hh"
+#include "cInstSet.h"
#include "organism.hh"
#include "string.hh"
#include "string_util.hh"
Modified: trunk/source/cpu/cHardwareUtil.cc
===================================================================
--- trunk/source/cpu/cHardwareUtil.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cHardwareUtil.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -31,7 +31,7 @@
#include "cInstLibCPU.h"
#endif
#ifndef INST_SET_HH
-#include "inst_set.hh"
+#include "cInstSet.h"
#endif
#ifndef TDICTIONARY_HH
#include "tDictionary.hh"
Modified: trunk/source/cpu/cHeadCPU.cc
===================================================================
--- trunk/source/cpu/cHeadCPU.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cHeadCPU.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -16,16 +16,16 @@
#include "cCodeLabel.h"
#endif
#ifndef GENOME_HH
-#include "genome.hh"
+#include "cGenome.h"
#endif
#ifndef HARDWARE_BASE_HH
#include "cHardwareBase.h"
#endif
#ifndef INST_SET_HH
-#include "inst_set.hh"
+#include "cInstSet.h"
#endif
#ifndef INSTRUCTION_HH
-#include "instruction.hh"
+#include "cInstruction.h"
#endif
#include <assert.h>
Modified: trunk/source/cpu/cHeadMultiMem.cc
===================================================================
--- trunk/source/cpu/cHeadMultiMem.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cHeadMultiMem.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -16,10 +16,10 @@
#include "cHardwareBase.h"
#endif
#ifndef INST_SET_HH
-#include "inst_set.hh"
+#include "cInstSet.h"
#endif
#ifndef INSTRUCTION_HH
-#include "instruction.hh"
+#include "cInstruction.h"
#endif
#include <assert.h>
Modified: trunk/source/cpu/cInstLibCPU.h
===================================================================
--- trunk/source/cpu/cInstLibCPU.h 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cInstLibCPU.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -3,14 +3,14 @@
#ifndef INST_LIB_BASE_HH
-#include "inst_lib_base.hh"
+#include "cInstLibBase.h"
#endif
#ifndef HARDWARE_CPU_HH
#include "cHardwareCPU.h"
#endif
#ifndef INSTRUCTION_HH
-#include "instruction.hh"
+#include "cInstruction.h"
#endif
///////////////
Modified: trunk/source/cpu/cTestCPU.cc
===================================================================
--- trunk/source/cpu/cTestCPU.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cTestCPU.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -13,8 +13,8 @@
#include "functions.hh"
#include "cHardwareBase.h"
#include "cHardwareStatusPrinter.h"
-#include "inst_set.hh"
-#include "inst_util.hh"
+#include "cInstSet.h"
+#include "cInstUtil.h"
#include "organism.hh"
#include "phenotype.hh"
#include "cPopulationInterface.h"
Modified: trunk/source/cpu/cTestUtil.cc
===================================================================
--- trunk/source/cpu/cTestUtil.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/cTestUtil.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -9,11 +9,11 @@
#include "cCPUTestInfo.h"
#include "cEnvironment.h"
-#include "genome.hh"
-#include "genotype.hh"
+#include "cGenome.h"
+#include "cGenotype.h"
#include "cHardwareBase.h"
-#include "inject_genotype.hh"
-#include "inst_util.hh"
+#include "cInjectGenotype.h"
+#include "cInstUtil.h"
#include "organism.hh"
#include "phenotype.hh"
#include "stats.hh"
Modified: trunk/source/cpu/tInstLib.h
===================================================================
--- trunk/source/cpu/tInstLib.h 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/cpu/tInstLib.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -14,7 +14,7 @@
#include "string.hh"
#endif
#ifndef INST_LIB_BASE_HH
-#include "inst_lib_base.hh"
+#include "cInstLibBase.h"
#endif
class cInstruction;
Modified: trunk/source/event/cPopulationEventFactory.cc
===================================================================
--- trunk/source/event/cPopulationEventFactory.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/event/cPopulationEventFactory.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -28,19 +28,19 @@
#include "cEvent.h"
#endif
#ifndef GENEBANK_HH
-#include "genebank.hh"
+#include "cGenebank.h"
#endif
#ifndef GENOTYPE_HH
-#include "genotype.hh"
+#include "cGenotype.h"
#endif
#ifndef INJECT_GENEBANK_HH
-#include "inject_genebank.hh"
+#include "cInjectGenebank.h"
#endif
#ifndef INJECT_GENOTYPE_HH
-#include "inject_genotype.hh"
+#include "cInjectGenotype.h"
#endif
#ifndef INST_UTIL_HH
-#include "inst_util.hh"
+#include "cInstUtil.h"
#endif
#ifndef LANDSCAPE_HH
#include "landscape.hh"
Modified: trunk/source/main/CMakeLists.txt
===================================================================
--- trunk/source/main/CMakeLists.txt 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/CMakeLists.txt 2005-09-16 22:19:23 UTC (rev 317)
@@ -12,22 +12,22 @@
cCallbackUtil.cc
cConfig.cc
cEnvironment.cc
- fitness_matrix.cc
- genebank.cc
- genome.cc
- genome_util.cc
- genotype.cc
- genotype_birth_data.cc
- genotype_control.cc
- genotype_test_data.cc
- inject_genebank.cc
- inject_genotype.cc
- inject_genotype_birth_data.cc
- inject_genotype_control.cc
- inject_genotype_queue.cc
- instruction.cc
- inst_set.cc
- inst_util.cc
+ cFitnessMatrix.cc
+ cGenebank.cc
+ cGenome.cc
+ cGenomeUtil.cc
+ cGenotype.cc
+ cGenotype_BirthData.cc
+ cGenotypeControl.cc
+ cGenotype_TestData.cc
+ cInjectGenebank.cc
+ cInjectGenotype.cc
+ cInjectGenotype_BirthData.cc
+ cInjectGenotypeControl.cc
+ cInjectGenotypeQueue.cc
+ cInstruction.cc
+ cInstSet.cc
+ cInstUtil.cc
landscape.cc
lineage.cc
lineage_control.cc
Modified: trunk/source/main/cAnalyze.cc
===================================================================
--- trunk/source/main/cAnalyze.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/cAnalyze.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -23,15 +23,15 @@
#include "cConfig.h"
#include "data_file.hh"
#include "cEnvironment.h"
-#include "fitness_matrix.hh"
-#include "genome_util.hh"
+#include "cFitnessMatrix.h"
+#include "cGenomeUtil.h"
#include "cHardwareBase.h"
#include "cHardwareStatusPrinter.h"
#include "cHardwareUtil.h"
#include "help_manager.hh"
#include "init_file.hh"
-#include "inst_set.hh"
-#include "inst_util.hh"
+#include "cInstSet.h"
+#include "cInstUtil.h"
#include "landscape.hh"
#include "phenotype.hh"
#include "species.hh"
Modified: trunk/source/main/cAnalyze.h
===================================================================
--- trunk/source/main/cAnalyze.h 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/cAnalyze.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -14,7 +14,7 @@
#include "data_file_manager.hh"
#endif
#ifndef GENOTYPE_BATCH_HH
-#include "genotype_batch.hh"
+#include "cGenotypeBatch.h"
#endif
#ifndef RANDOM_HH
#include "random.hh"
Modified: trunk/source/main/cAnalyzeGenotype.cc
===================================================================
--- trunk/source/main/cAnalyzeGenotype.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/cAnalyzeGenotype.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -9,7 +9,7 @@
#include "cConfig.h"
#include "cCPUTestInfo.h"
-#include "inst_set.hh"
+#include "cInstSet.h"
#include "landscape.hh"
#include "organism.hh"
#include "phenotype.hh"
Modified: trunk/source/main/cAnalyzeGenotype.h
===================================================================
--- trunk/source/main/cAnalyzeGenotype.h 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/cAnalyzeGenotype.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -14,7 +14,7 @@
#include "functions.hh"
#endif
#ifndef GENOME_HH
-#include "genome.hh"
+#include "cGenome.h"
#endif
#ifndef STRING_HH
#include "string.hh"
Modified: trunk/source/main/cAnalyzeUtil.cc
===================================================================
--- trunk/source/main/cAnalyzeUtil.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/cAnalyzeUtil.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -19,16 +19,16 @@
#include "cEnvironment.h"
#endif
#ifndef GENEBANK_HH
-#include "genebank.hh"
+#include "cGenebank.h"
#endif
#ifndef GENOME_HH
-#include "genome.hh"
+#include "cGenome.h"
#endif
#ifndef GENOME_UTIL_HH
-#include "genome_util.hh"
+#include "cGenomeUtil.h"
#endif
#ifndef GENOTYPE_HH
-#include "genotype.hh"
+#include "cGenotype.h"
#endif
#ifndef HARDWARE_BASE_HH
#include "cHardwareBase.h"
@@ -37,10 +37,10 @@
#include "histogram.hh"
#endif
#ifndef INST_SET_HH
-#include "inst_set.hh"
+#include "cInstSet.h"
#endif
#ifndef INST_UTIL_HH
-#include "inst_util.hh"
+#include "cInstUtil.h"
#endif
#ifndef LANDSCAPE_HH
#include "landscape.hh"
Modified: trunk/source/main/cAvidaDriver_Population.cc
===================================================================
--- trunk/source/main/cAvidaDriver_Population.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/cAvidaDriver_Population.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -13,8 +13,8 @@
#include "cConfig.h"
#include "cEventFactoryManager.h"
#include "cEventList.h"
-#include "genebank.hh"
-#include "genotype.hh"
+#include "cGenebank.h"
+#include "cGenotype.h"
#include "cHardwareBase.h"
#include "cHardwareFactory.h"
#include "init_file.hh"
Modified: trunk/source/main/cBirthChamber.cc
===================================================================
--- trunk/source/main/cBirthChamber.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/cBirthChamber.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -19,16 +19,16 @@
#include "functions.hh"
#endif
#ifndef GENEBANK_HH
-#include "genebank.hh"
+#include "cGenebank.h"
#endif
#ifndef GENOME_HH
-#include "genome.hh"
+#include "cGenome.h"
#endif
#ifndef GENOME_UTIL_HH
-#include "genome_util.hh"
+#include "cGenomeUtil.h"
#endif
#ifndef GENOTYPE_HH
-#include "genotype.hh"
+#include "cGenotype.h"
#endif
#ifndef ORGANISM_HH
#include "organism.hh"
Modified: trunk/source/main/cCallbackUtil.cc
===================================================================
--- trunk/source/main/cCallbackUtil.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/cCallbackUtil.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -25,7 +25,7 @@
#include "cEnvironment.h"
#endif
#ifndef GENOTYPE_HH
-#include "genotype.hh"
+#include "cGenotype.h"
#endif
#ifndef HARDWARE_BASE_HH
#include "cHardwareBase.h"
Modified: trunk/source/main/cEnvironment.h
===================================================================
--- trunk/source/main/cEnvironment.h 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/cEnvironment.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -9,7 +9,7 @@
#define ENVIRONMENT_HH
#ifndef INST_SET_HH
-#include "inst_set.hh"
+#include "cInstSet.h"
#endif
#ifndef MUTATION_LIB_HH
#include "mutation_lib.hh"
Copied: trunk/source/main/cFitnessMatrix.cc (from rev 313, trunk/source/main/fitness_matrix.cc)
===================================================================
--- trunk/source/main/fitness_matrix.cc 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cFitnessMatrix.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,669 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 FITNESS_MATRIX_HH
+#include "cFitnessMatrix.h"
+#endif
+
+#ifndef INST_SET_HH
+#include "cInstSet.h"
+#endif
+
+using namespace std;
+
+
+cFitnessMatrix::cFitnessMatrix( const cGenome & code, cInstSet * inst_set)
+ : m_start_genotype(code), m_inst_set( inst_set ), m_DFS_MaxDepth(0),
+ m_DFS_NumRecorded(0)
+{
+ m_start_genotype.SetNumInstructions( m_inst_set->GetSize());
+ m_start_genotype.CalcFitness();
+ m_data_set.insert(m_start_genotype);
+}
+
+cFitnessMatrix::~cFitnessMatrix()
+{
+}
+
+
+
+/*
+ A wrapper routine to call the depth limited search with appropriate
+ exception catching.
+ */
+
+void cFitnessMatrix::CollectData(ofstream& log_file)
+{
+ try
+ {
+
+ log_file << endl << "DOING DEPTH LIMITED SEARCH..." << endl << endl;
+
+ time(&m_search_start_time);
+ DepthLimitedSearch(m_start_genotype, log_file);
+ time(&m_search_end_time);
+ }
+ catch(bad_alloc& alloc_failure)
+ {
+ log_file << "DLS Exception: memory allocation failure" << endl;
+ }
+ catch(exception& std_ex)
+ {
+ log_file << "DLS Exception: " << std_ex.what() <<endl;
+ }
+ catch(...)
+ {
+ log_file << "DLS Exception: " << "unrecognized exception" << endl;
+ }
+
+}
+
+
+/*
+ Statistics collected at each node:
+ ----------------------------------
+
+ numNew = number of mutants alive and above threshold that have not
+ been seen before
+
+ numVisited = number of mutants that have been seen before (alive and
+ above threshold are considered only, because these are the only ones
+ stored in the data set)
+
+ numOK = number of mutants alive and above threshold (and new)
+
+ numBelowthresh = number of mutants alive and below threshold (these
+ could have been seen before because there is no record of them)
+
+ numDead = number of non-reproducing mutants (these could have been
+ seen before because there is no record of dead mutants)
+
+ Consequently, if we sum numOK+numBelowThresh+numDead for all nodes
+ then we will get the number of _unique_ genotypes inspected
+
+*/
+
+void cFitnessMatrix::DepthLimitedSearch(const cMxCodeArray& startNode, ofstream& log_file, int currDepth)
+{
+ if (currDepth == 0)
+ {
+ m_DFSNumDead.clear();
+ m_DFSNumBelowThresh.clear();
+ m_DFSNumOK.clear();
+ m_DFSNumNew.clear();
+ m_DFSNumVisited.clear();
+ m_DFSDepth.clear();
+ }
+
+
+ log_file << "cFitnessMatrix::DepthLimitedSearch, depth = " << currDepth << endl;
+
+ currDepth++;
+ if (currDepth > m_DFS_MaxDepth) m_DFS_MaxDepth = currDepth;
+ m_DFSDepth.push_back(currDepth);
+
+ list<cMxCodeArray> theMutants;
+
+ // statistics
+ short numDead = 0, numBelowThresh = 0, numOK = 0;
+ short numVisited = 0, numNew = 0;
+
+ // get the 1 mutants of the start node
+ startNode.Get1Mutants(theMutants);
+
+ list<cMxCodeArray>::iterator list_iter;
+ vector<cMxCodeArray> deleteMutants;
+ vector<cMxCodeArray>::iterator vect_iter;
+
+ // MyCodeArrayLessThan myLess;
+
+ for (list_iter = theMutants.begin(); list_iter != theMutants.end(); list_iter++)
+ {
+ // check if its already in the data set
+
+ set<cMxCodeArray, MyCodeArrayLessThan >::iterator data_iter;
+ pair< set<cMxCodeArray, MyCodeArrayLessThan >::iterator , bool> insert_result;
+
+ cMxCodeArray test_array = *list_iter;
+
+ data_iter = m_data_set.find(test_array);
+
+ if (data_iter == m_data_set.end())
+ {
+
+ list_iter->CalcFitness();
+ double fitness = list_iter->GetFitness();
+
+ if (fitness == 0.0)
+ {
+ numDead++;
+ deleteMutants.push_back(*list_iter);
+ }
+ else if (MutantOK(fitness))
+ {
+ insert_result = m_data_set.insert(*list_iter);
+
+ numNew++;
+ numOK++;
+ m_DFS_NumRecorded++;
+ }
+ else
+ {
+ numBelowThresh++;
+ deleteMutants.push_back(*list_iter);
+ }
+ }
+ // if its already in the data set delete from the list
+ else
+ {
+ // log_file << "Mutant already in Set!!!!" << endl;
+ numVisited++;
+ deleteMutants.push_back(*list_iter);
+ }
+ }
+
+ // delete the ones that are dead or already visited from list
+ for (vect_iter = deleteMutants.begin(); vect_iter != deleteMutants.end(); vect_iter++)
+ {
+ theMutants.remove(*vect_iter);
+ }
+
+ // save statistics of this node
+ m_DFSNumDead.push_back(numDead);
+ m_DFSNumBelowThresh.push_back(numBelowThresh);
+ m_DFSNumOK.push_back(numOK);
+ m_DFSNumNew.push_back(numNew);
+ m_DFSNumVisited.push_back(numVisited);
+
+ // call depth first search on each mutant in the list
+ if (currDepth < m_depth_limit)
+ {
+ for (list_iter = theMutants.begin(); list_iter != theMutants.end(); list_iter++)
+ {
+ DepthLimitedSearch(*list_iter, log_file, currDepth);
+ }
+ }
+
+}
+
+
+bool cFitnessMatrix::MutantOK(double fitness)
+{
+ return (fitness > m_fitness_threshhold);
+}
+
+
+/*
+ Diagonaliztion via repeated multiplication by a random vector.
+ Based on Claus' diagonalize.pl
+ */
+
+double cFitnessMatrix::Diagonalize(vector<double>& randomVect, int hamDistThresh, double errorRate, ofstream& log_file)
+{
+ // first all genotypes need their transition lists
+ this->MakeTransitionProbabilities(hamDistThresh, errorRate, log_file);
+
+ log_file << endl << "DIAGONALIZING... (error prob=" << errorRate << ")" << endl << endl;
+
+ // initialize the random vector
+ vector<double> norms;
+ MakeRandomVector(randomVect, m_data_set.size());
+
+ vector<double> result;
+ // do repeated multiplication
+ for (int i = 0; i < m_diag_iters; i++)
+ {
+ /*
+ norms.push_back(VectorNorm(randomVect));
+ VectorDivideBy(randomVect, norms.back());
+ MatrixVectorMultiply(randomVect, result);
+ randomVect = result;
+ */
+
+ MatrixVectorMultiply(randomVect, result);
+ norms.push_back(VectorNorm(result));
+ VectorDivideBy(result, norms.back());
+ randomVect = result;
+
+ log_file << "Vect Norm(" << i << "):" << norms.back() << endl;
+ }
+
+
+ return norms.back();
+}
+
+
+/*
+ Make transition lists for all the genotypes in the data set. The
+ algorithm for building the transition lists is O(n^2) - for every
+ genotype we have to look at all the other genotypes to make its
+ transition list.
+*/
+
+
+void cFitnessMatrix::MakeTransitionProbabilities(int hamDistThresh, double errorRate, ofstream& log_file)
+{
+
+ set<cMxCodeArray, MyCodeArrayLessThan >::iterator set_iter;
+ int num = 0;
+ int trans = 0;
+
+ log_file << endl << "MAKING TRANSITION PROBABILITIES... (error prob=" << errorRate << ")" << endl << endl;
+
+ for (set_iter = m_data_set.begin(); set_iter != m_data_set.end(); set_iter++, num++)
+ {
+ trans = (*set_iter).MakeTransitionList(m_data_set, hamDistThresh, errorRate);
+ log_file << num << ") " << trans << " transitions for " << (*set_iter).AsString() << endl;
+ }
+
+}
+
+
+void cFitnessMatrix::MakeRandomVector(vector<double>& newVect, int size)
+{
+ cRandom randy(time(NULL));
+
+ /* vector should be the size of the set + 1 - because the matrix
+ also has the "other" column. So thats why its '<='
+ */
+ for (int i = 0; i <= size; i++)
+ {
+ newVect.push_back(randy.GetDouble());
+ }
+
+}
+
+void cFitnessMatrix::VectorDivideBy(vector<double>& vect, double div)
+{
+ vector<double>::iterator vect_iter;
+
+ for(vect_iter = vect.begin(); vect_iter != vect.end(); vect_iter++)
+ {
+ *vect_iter /= div;
+ }
+}
+
+double cFitnessMatrix::VectorNorm(const vector<double> &vect)
+{
+ double norm = 0.0;
+ vector<double>::const_iterator vect_iter;
+
+ for(vect_iter = vect.begin(); vect_iter != vect.end(); vect_iter++)
+ {
+ norm = norm + (*vect_iter);
+ }
+
+ return norm;
+}
+
+
+/*
+ Perform the matrix vector multiplication using the sparse matrix
+ representation in the 'transition map' of the genotypes. The
+ transition map has entries for every genotype that it has a non-zero
+ probability of giving birth to.
+
+ This algorithm is iterating through the columns of the matrix and
+ adding each one's contributions to the appropriate rows of the
+ resulting vector. This is sort of the reverse of the normal row by
+ row dot product way of thinking about matrix-vector multiplication.
+
+ The true transition matrix has a last column of all zeros - the
+ probabilities that a dead genotype will give birth to a live one.
+ This is simply ignored because it doesn't effect the calculation
+ (and because we're using the actual data set to do the calculation
+ there isn't any good way to make a cMxCodeArray to represent dead
+ genotypes...)
+
+ */
+
+void cFitnessMatrix::MatrixVectorMultiply(const vector<double> &vect, vector<double>& result)
+{
+
+ result.clear();
+ result.resize(vect.size(), 0.0);
+
+ set<cMxCodeArray, MyCodeArrayLessThan >::iterator set_iter;
+
+ int column = 0;
+ for (set_iter = m_data_set.begin(); set_iter != m_data_set.end(); set_iter++, column++)
+ {
+ const map<int, double, less<int> > trans_map = (*set_iter).GetTransitionList();
+
+ map<int, double, less<int> >::const_iterator trans_iter;
+ for(trans_iter = trans_map.begin(); trans_iter != trans_map.end(); trans_iter++)
+ {
+ int row = (*trans_iter).first;
+ double transition_probability = (*trans_iter).second;
+
+ result[row] += vect[column] * transition_probability;
+ }
+
+ }
+
+}
+
+void cFitnessMatrix::PrintGenotypes(ostream &fp)
+{
+ int totNumDead=0, totNumBelowThresh=0, totNumOK=0;
+ int totNumNew=0, totNumVisited=0, totDepth=0;
+ int totNumDead2=0, totNumBelowThresh2=0, totNumOK2=0;
+ int totNumNew2=0, totNumVisited2=0, totDepth2=0;
+ int numNodes;
+ float avgNumDead=0.0, avgNumBelowThresh=0.0, avgNumOK=0.0;
+ float avgNumNew=0.0, avgNumVisited=0.0, avgDepth=0.0;
+ float sdNumDead=0.0, sdNumBelowThresh=0.0, sdNumOK=0.0;
+ float sdNumNew=0.0, sdNumVisited=0.0, sdDepth=0.0;
+
+ totNumDead = accumulate(m_DFSNumDead.begin(), m_DFSNumDead.end(), 0);
+ totNumBelowThresh = accumulate(m_DFSNumBelowThresh.begin(), m_DFSNumBelowThresh.end(), 0);
+ totNumOK = accumulate(m_DFSNumOK.begin(), m_DFSNumOK.end(), 0);
+ totNumNew = accumulate(m_DFSNumNew.begin(), m_DFSNumNew.end(), 0);
+ totNumVisited = accumulate(m_DFSNumVisited.begin(), m_DFSNumVisited.end(), 0);
+ totDepth = accumulate(m_DFSDepth.begin(), m_DFSDepth.end(), 0);
+
+ numNodes = m_DFSNumDead.size();
+
+ avgNumDead = ((float)totNumDead)/((float)numNodes);
+ avgNumBelowThresh = ((float)totNumBelowThresh)/((float)numNodes);
+ avgNumOK = ((float)totNumOK)/((float)numNodes);
+ avgNumNew = ((float)totNumNew)/((float)numNodes);
+ avgNumVisited = ((float)totNumVisited)/((float)numNodes);
+ avgDepth = ((float)totDepth)/((float)numNodes);
+
+ for (int i = 0; i < numNodes; i++)
+ {
+ totNumDead2 += m_DFSNumDead[i]*m_DFSNumDead[i];
+ totNumBelowThresh2 += m_DFSNumBelowThresh[i]*m_DFSNumBelowThresh[i];
+ totNumOK2 += m_DFSNumOK[i]*m_DFSNumOK[i];
+ totNumNew2 += m_DFSNumNew[i]*m_DFSNumNew[i];
+ totNumVisited2 += m_DFSNumVisited[i]*m_DFSNumVisited[i];
+ totDepth2 += m_DFSDepth[i]*m_DFSDepth[i];
+ }
+
+ sdNumDead = sqrt( ((float)totNumDead2)/((float)numNodes)
+ - (avgNumDead*avgNumDead));
+ sdNumBelowThresh = sqrt( ((float) totNumBelowThresh2)/((float) numNodes)
+ - (avgNumBelowThresh *avgNumBelowThresh ));
+ sdNumOK =sqrt( ((float) totNumOK2)/((float) numNodes)
+ - ( avgNumOK* avgNumOK)) ;
+ sdNumNew = sqrt( ((float) totNumNew2)/((float) numNodes)
+ - (avgNumNew * avgNumNew) );
+ sdNumVisited = sqrt( ((float) totNumVisited2)/((float) numNodes)
+ - (avgNumVisited * avgNumVisited) );
+ sdDepth = sqrt( ((float) totDepth2)/((float) numNodes)
+ - (avgDepth * avgDepth) );
+
+
+ fp << "#######################################################" << endl;
+ fp << "# DEPTH FIRST SEARCH RESULTS " << endl;
+ fp << "# Depth Limit: " << m_depth_limit << endl;
+ fp << "# Fitness Threshold Ratio: " << m_fitness_threshold_ratio << endl;
+ fp << "# Start time: " << asctime(localtime(&m_search_start_time));
+ fp << "# End Time: " << asctime(localtime(&m_search_end_time));
+ fp << "#######################################################" << endl;
+ fp << "# Total number of unique nodes checked: ";
+ fp << totNumDead + totNumOK + totNumBelowThresh << endl;
+ fp << "# Total number of unique living genotypes found: ";
+ fp << totNumOK + totNumBelowThresh << endl;
+ fp << "# Total number of unique dead genotypes found: ";
+ fp << totNumDead << endl;
+ fp << "# Total number of unique genotypes alive and below threshold found: " << endl;
+ fp << "# " << totNumBelowThresh << endl;
+ fp << "# Total number of unique genotypes alive and above threshold found: " << endl;
+ fp << "# " << totNumOK << endl;
+ fp << "# Number of Nodes Fully Explored (non-leaf, alive and above threshold): " << endl;
+ fp << "# " << numNodes << endl;
+ fp << "# Maximum Depth Visited: ";
+ fp << m_DFS_MaxDepth << endl;
+ fp << "# Number of 1-Mutants Dead at each node, avg - stand dev" << endl;
+ fp << "# " << avgNumDead << "\t\t" << sdNumDead << endl;
+ fp << "# Number of 1-Mutants Alive but Below Threshold at each node, avg - stand dev" << endl;
+ fp << "# " << avgNumBelowThresh << "\t\t" << sdNumBelowThresh << endl;
+ fp << "# Number of 1-Mutants alive and above threshold at each node, avg - stand dev" << endl;
+ fp << "# " << avgNumOK << "\t\t" << sdNumOK << endl;
+ fp << "# Number of New living, above threshold, 1-Mutants at each Node, avg - stand dev" << endl;
+ fp << "# " << avgNumNew << "\t\t" << sdNumNew << endl;
+ fp << "# Number of Already found living, above threshold 1-Mutants at each Node, avg - stand dev" << endl;
+ fp << "# " << avgNumVisited << "\t\t" << sdNumVisited << endl;
+ fp << "# Depth of Nodes in search, avg - stand dev" << endl;
+ fp << "# " << avgDepth << "\t\t" << sdDepth << endl;
+ fp << "#######################################################" << endl;
+ fp << "# Fitness:" << endl;
+
+ set<cMxCodeArray, MyCodeArrayLessThan >::iterator iter;
+ for(iter = m_data_set.begin(); iter != m_data_set.end(); iter++)
+ {
+ fp << (*iter).AsString() << "\t" <<(*iter).GetFitness() << "\t" << (*iter).GetMerit() << "\t" << (*iter).GetGestationTime() << endl;
+ }
+
+ fp << "#######################################################" << endl;
+
+}
+
+/*
+ PrintTransitionList gets m_data_set.size()+1 because there is the
+ extra row at the end for the "other" category. We also add an extra
+ row of zeros for the "other" (dead) genotypes so that we're actually
+ writing out a square matrix that can be processed by other programs
+ (Mathematica).
+
+ Note that this is actually printing the transpose of the transition
+ matrix, assuming the matrix rows represent the offspring genotypes
+ and the columns represent the parents and that the norm vector is a
+ column vector. (as discussed with Claus in March, 2001). But since
+ we're printing one parent genotype at a time there is just no
+ sensible way to print a column at a time...
+
+ Used for testing the diagonalization - this isn't really useful for
+ real experiments because the matrix will be thousands by thousands
+ big and printing it out is not feasible.
+
+ */
+
+void cFitnessMatrix::PrintTransitionMatrix(ostream &fp, int hamDistThresh, double errorRate, double avg_fitness, bool printMatrix)
+{
+
+ fp << endl << endl;
+ fp << "#######################################################" << endl;
+ fp << "TRANSITION PROBABILITIES" << endl;
+ fp << "#Hamming Distance Threshold" << endl;
+ fp << "# " << hamDistThresh << endl;
+ fp << "#Error Rate" << endl;
+ fp << "# " << errorRate << endl;
+ fp << "#Avg Fitness" << endl;
+ fp << "# " << avg_fitness << endl;
+ fp << "#######################################################" << endl;
+
+
+ if (printMatrix)
+ {
+ set<cMxCodeArray, MyCodeArrayLessThan >::iterator iter;
+ fp << "{" << endl;
+ int index = 0;
+ for(iter = m_data_set.begin(); iter != m_data_set.end(); iter++, index++)
+ {
+ (*iter).PrintTransitionList(fp, m_data_set.size()+1);
+ fp << "," << endl;
+ }
+
+
+ /*
+ Add the transition probabilities for "other" (dead) genotypes
+ so that we're actually writing out a square matrix that can be
+ processed by other programs (Mathematica)
+ */
+
+ fp << "{" ;
+ for (index = 0; index <= (int) m_data_set.size(); index++)
+ {
+ fp << 0.0;
+ if (index < (int) m_data_set.size())
+ fp << " , ";
+ }
+ fp << "}" << endl;
+
+ fp << "}";
+ }
+
+}
+
+
+
+void cFitnessMatrix::PrintHammingVector(ostream& fp,const vector<double>& dataVect, double errProb, double avgFit)
+{
+ vector<double> hamVect;
+
+ for (int i = 0; i < m_start_genotype.GetSize(); i++)
+ hamVect.push_back(0.0);
+
+ set<cMxCodeArray, MyCodeArrayLessThan >::iterator data_iter;
+
+ int index = 0;
+
+ for (data_iter = m_data_set.begin(); data_iter != m_data_set.end(); data_iter++, index++)
+ {
+ int dist = m_start_genotype.HammingDistance(*data_iter);
+ hamVect[dist] += dataVect[index];
+ }
+
+
+
+ fp << errProb << "\t";
+ fp << avgFit << "\t";
+
+ vector<double>::const_iterator vect_iter;
+
+ for(vect_iter = hamVect.begin(); vect_iter != hamVect.end(); vect_iter++)
+ {
+ fp << (*vect_iter) << "\t";
+ }
+
+ fp << endl;
+
+}
+
+
+void cFitnessMatrix::PrintFitnessVector(ostream& fp,const vector<double>& dataVect, double errProb, double avgFit, double maxFit, double step)
+{
+ vector<double> fitVect;
+
+ int maxi = (int) (maxFit /step) +1;
+
+ for (int i = 0; i < maxi; i++)
+ fitVect.push_back(0.0);
+
+ set<cMxCodeArray, MyCodeArrayLessThan >::iterator data_iter;
+
+ int index = 0;
+
+ for (data_iter = m_data_set.begin(); data_iter != m_data_set.end(); data_iter++, index++)
+ {
+ double f = (*data_iter).GetFitness();
+ fitVect[(int) (f/step)] += dataVect[index];
+ }
+ // the last contribution is of fitness zero:
+ fitVect[0] += dataVect[index];
+
+
+
+ fp << errProb << "\t";
+ fp << avgFit << "\t";
+
+ vector<double>::const_iterator vect_iter;
+
+ for(vect_iter = fitVect.begin(); vect_iter != fitVect.end(); vect_iter++)
+ {
+ fp << (*vect_iter) << "\t";
+ }
+
+ fp << endl;
+
+}
+
+void cFitnessMatrix::PrintFullVector(ostream& fp,const vector<double>& dataVect, double errProb, double avgFit)
+{
+ fp << errProb << "\t";
+ fp << avgFit << "\t";
+
+ vector<double>::const_iterator vect_iter;
+
+ for(vect_iter = dataVect.begin(); vect_iter != dataVect.end(); vect_iter++)
+ {
+ fp << (*vect_iter) << "\t";
+ }
+
+ fp << endl;
+}
+
+
+
+void cFitnessMatrix::CalcFitnessMatrix( int depth_limit, double fitness_threshold_ratio, int ham_thresh, double error_rate_min, double error_rate_max, double error_rate_step, double output_start, double output_step, int diag_iters, bool write_ham_vector, bool write_full_vector )
+{
+
+ /* set parameters (TODO: read these from event list) */
+
+ m_depth_limit = depth_limit;
+ m_fitness_threshold_ratio = fitness_threshold_ratio;
+ m_ham_thresh = ham_thresh;
+ m_error_rate_min = error_rate_min;
+ m_error_rate_max = error_rate_max;
+ m_error_rate_step = error_rate_step;
+ m_diag_iters = diag_iters;
+
+ m_fitness_threshhold = m_start_genotype.GetFitness() * m_fitness_threshold_ratio;
+
+ /* open files for output */
+
+ ofstream log_file("fitness_matrix.log");
+ ofstream genotype_file("found_genotypes.dat");
+ ofstream fit_vect_file("fitness_vect.dat");
+
+ ofstream ham_vect_file;
+ if (write_ham_vector)
+ ham_vect_file.open("hamming_vect.dat");
+ ofstream full_vect_file;
+ if (write_full_vector)
+ full_vect_file.open("full_vect.dat");
+
+
+ /* do the depth first search */
+
+ CollectData(log_file);
+ PrintGenotypes(genotype_file);
+ genotype_file.close();
+
+
+ /* diagonalize transition matrices at different copy error rates */
+
+ for (double error = m_error_rate_min; error <= m_error_rate_max; error += m_error_rate_step)
+ {
+ vector<double> dataVect;
+
+ double avg_fitness = Diagonalize(dataVect, m_ham_thresh, error, log_file);
+
+ PrintFitnessVector(fit_vect_file, dataVect, error, avg_fitness, output_start, output_step);
+
+ if ( write_ham_vector )
+ PrintHammingVector(ham_vect_file, dataVect, error, avg_fitness);
+
+ if ( write_full_vector )
+ PrintFullVector(full_vect_file, dataVect, error, avg_fitness);
+
+ }
+
+
+ /* close remaining files */
+
+ log_file.close();
+ fit_vect_file.close();
+ if ( write_ham_vector )
+ ham_vect_file.close();
+ if ( write_full_vector )
+ full_vect_file.close();
+}
+
Copied: trunk/source/main/cFitnessMatrix.h (from rev 313, trunk/source/main/fitness_matrix.hh)
Copied: trunk/source/main/cGenebank.cc (from rev 314, trunk/source/main/genebank.cc)
===================================================================
--- trunk/source/main/genebank.cc 2005-09-16 02:10:20 UTC (rev 314)
+++ trunk/source/main/cGenebank.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,926 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 GENEBANK_HH
+#include "cGenebank.h"
+#endif
+
+#ifndef CONFIG_HH
+#include "cConfig.h"
+#endif
+#ifndef GENOTYPE_HH
+#include "cGenotype.h"
+#endif
+#ifndef SPECIES_HH
+#include "species.hh"
+#endif
+#ifndef STATS_HH
+#include "stats.hh"
+#endif
+#ifndef TEST_UTIL_HH
+#include "cTestUtil.h"
+#endif
+
+
+using namespace std;
+
+
+///////////////
+// cGenebank
+///////////////
+
+cGenebank::cGenebank(cStats & _stats)
+ : stats(_stats)
+{
+ for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
+ genotype_count[i] = 0;
+ }
+
+ genotype_control = new cGenotypeControl(*this);
+ species_control = new cSpeciesControl(*this);
+
+}
+
+cGenebank::~cGenebank()
+{
+ delete genotype_control;
+ delete species_control;
+}
+
+void cGenebank::UpdateReset()
+{
+ static int genotype_dom_time = 0;
+ static int prev_dom = -1;
+
+ cGenotype * best_genotype = GetBestGenotype();
+
+ species_control->Purge(stats);
+ if (best_genotype && best_genotype->GetID() != prev_dom) {
+ genotype_dom_time = 0;
+ prev_dom = best_genotype->GetID();
+ }
+ else {
+ genotype_dom_time++;
+ if (genotype_dom_time == cConfig::GetGenotypePrintDom()) {
+ cString filename;
+ filename.Set("genebank/%s", best_genotype->GetName()());
+ cTestUtil::PrintGenome(best_genotype->GetGenome(),
+ filename, best_genotype, stats.GetUpdate());
+ }
+ }
+
+// tArray<int> hist_array(15);
+// hist_array.SetAll(0);
+// int total_gens = 0;
+
+// for (int i = 0; i < GENOTYPE_HASH_SIZE; i++) {
+// int cur_val = active_genotypes[i].GetSize();
+// total_gens += cur_val;
+// if (cur_val < 15) hist_array[cur_val]++;
+// else cout << cur_val << " ";
+// }
+// cout << endl;
+// for (int i = 0; i < 15; i++) {
+// cout << i << " : " << hist_array[i] << endl;
+// }
+// cout << "Total genotypes: " << total_gens << endl;
+}
+
+cString cGenebank::GetLabel(int in_size, int in_num)
+{
+ char alpha[6];
+ char full_name[12];
+ int i;
+
+ for (i = 4; i >= 0; i--) {
+ alpha[i] = (in_num % 26) + 'a';
+ in_num /= 26;
+ }
+ alpha[5] = '\0';
+
+ sprintf(full_name, "%03d-%s", in_size, alpha);
+
+ return full_name;
+}
+
+
+void cGenebank::AddGenotype(cGenotype * in_genotype, int list_num)
+{
+ assert( in_genotype != 0 );
+
+ if (list_num < 0) list_num = FindCRC(in_genotype->GetGenome());
+
+ active_genotypes[list_num].Push(in_genotype);
+ genotype_control->Insert(*in_genotype);
+ stats.AddGenotype(in_genotype->GetID());
+
+ // Speciation... If we are creating a new genotype here, we must
+ // initilize it to the species of its parent genotype.
+
+ cSpecies * parent_species = NULL;
+ if ( in_genotype->GetParentGenotype() != NULL) {
+ parent_species = in_genotype->GetParentGenotype()->GetSpecies();
+ }
+
+ in_genotype->SetSpecies(parent_species);
+ if (parent_species != NULL) parent_species->AddGenotype();
+}
+
+
+// Add a new genotype to the genebank. Take in parent genotypes to track
+// phylogenies (the second genotype is in the case of sexual organisms)
+
+cGenotype * cGenebank::AddGenotype(const cGenome & in_genome,
+ cGenotype * parent_genotype,
+ cGenotype * parent2_genotype)
+{
+ // Make sure we dont have a NULL parent -- if we do, we should be calling
+ // InjectGenotype().
+ assert (parent_genotype != NULL);
+
+ int list_num = FindCRC(in_genome);
+ cGenotype * found_genotype = FindGenotype(in_genome,
+ parent_genotype->GetLineageLabel(), list_num);
+
+ if (!found_genotype) {
+ found_genotype = new cGenotype(stats.GetUpdate());
+ found_genotype->SetGenome(in_genome);
+ found_genotype->SetParent(parent_genotype, parent2_genotype);
+ AddGenotype(found_genotype, list_num);
+ }
+
+ return found_genotype;
+}
+
+
+// Add a new genotype that has been injected from the outside to the genebank.
+// Take in a lineage label to track clades.
+
+cGenotype * cGenebank::InjectGenotype(const cGenome & in_genome,
+ int lineage_label)
+{
+ int list_num = FindCRC(in_genome);
+ cGenotype * found_genotype =
+ FindGenotype(in_genome, lineage_label, list_num);
+
+ if (!found_genotype) {
+ found_genotype = new cGenotype(stats.GetUpdate());
+ found_genotype->SetGenome(in_genome);
+ found_genotype->SetParent(NULL, NULL);
+ found_genotype->SetLineageLabel(lineage_label);
+ AddGenotype(found_genotype, list_num);
+ }
+
+ return found_genotype;
+}
+
+const cGenotype * cGenebank::FindGenotype(const cGenome & in_genome,
+ int lineage_label, int list_num) const
+{
+ if (list_num < 0) list_num = FindCRC(in_genome);
+
+ tConstListIterator<cGenotype> list_it(active_genotypes[list_num]);
+
+ // If the lineage label is -1, match any lineage...
+ if (lineage_label == -1) {
+ while (list_it.Next() != NULL) {
+ if (list_it.GetConst()->GetGenome() == in_genome) break;
+ }
+ }
+
+ // Otherwise, only match a genotype of the same lineage.
+ else {
+ while (list_it.Next() != NULL) {
+ if (list_it.GetConst()->GetGenome() == in_genome &&
+ list_it.GetConst()->GetLineageLabel() == lineage_label) break;
+ }
+ }
+
+ return list_it.GetConst();
+}
+
+cGenotype * cGenebank::FindGenotype(const cGenome & in_genome,
+ int lineage_label, int list_num)
+{
+ if (list_num < 0) list_num = FindCRC(in_genome);
+
+ tListIterator<cGenotype> list_it(active_genotypes[list_num]);
+ // If the lineage label is -1, match any lineage...
+ if (lineage_label == -1) {
+ while (list_it.Next() != NULL) {
+ if (list_it.Get()->GetGenome() == in_genome) break;
+ }
+ }
+
+ // Otherwise, only match a genotype of the same lineage.
+ else {
+ while (list_it.Next() != NULL) {
+ if (list_it.Get()->GetGenome() == in_genome &&
+ list_it.Get()->GetLineageLabel() == lineage_label) break;
+ }
+ }
+ return list_it.Get();
+}
+
+void cGenebank::RemoveGenotype(cGenotype & in_genotype)
+{
+ // If we are supposed to defer analysis of this genotype, do so...
+ if (in_genotype.GetDeferAdjust() == true) return;
+
+ // If this genotype is still active, mark it no longer active and
+ // take it out of the hash table so it doesn't have any new organisms
+ // assigned to it.
+
+ if (in_genotype.GetActive() == true) {
+ int list_num = FindCRC(in_genotype.GetGenome());
+ active_genotypes[list_num].Remove(&in_genotype);
+ genotype_control->Remove(in_genotype);
+ in_genotype.Deactivate(stats.GetUpdate());
+ if (cConfig::GetTrackMainLineage()) {
+ genotype_control->InsertHistoric(in_genotype);
+ }
+ }
+
+ // If we are tracking the main lineage, we only want to delete a
+ // genotype when all of its decendents have also died out.
+
+ const int lineage_type = cConfig::GetTrackMainLineage();
+ if (lineage_type > 0) {
+ // If there are more offspring genotypes, hold off on deletion...
+ if (in_genotype.GetNumOffspringGenotypes() != 0) return;
+
+ // If this is a dead end, delete it and recurse up...
+ cGenotype * parent = in_genotype.GetParentGenotype();
+ cGenotype * parent2 = in_genotype.GetParent2Genotype();
+
+ if (parent != NULL) {
+ parent->RemoveOffspringGenotype();
+
+ // Test to see if we need to update the coalescent genotype.
+ const int new_coal = genotype_control->UpdateCoalescent();
+ stats.SetCoalescentGenotypeDepth(new_coal);
+ // cout << "Set coalescent to " << found_gen->GetDepth() << endl;
+
+ if (parent->GetNumOrganisms() == 0) {
+ // Regardless, run RemoveGenotype on the parent.
+ RemoveGenotype(*parent);
+ }
+ }
+
+ if (lineage_type == 2 && parent2 != NULL) {
+ parent2->RemoveOffspringGenotype();
+
+ // Test to see if we need to update the coalescent genotype.
+ const int new_coal = genotype_control->UpdateCoalescent();
+ stats.SetCoalescentGenotypeDepth(new_coal);
+ // cout << "Set coalescent to " << found_gen->GetDepth() << endl;
+
+ if (parent2->GetNumOrganisms() == 0) {
+ // Regardless, run RemoveGenotype on the parent.
+ RemoveGenotype(*parent2);
+ }
+ }
+
+ genotype_control->RemoveHistoric(in_genotype);
+ }
+
+ // Handle the relevent statistics...
+ stats.RemoveGenotype(in_genotype.GetID(),
+ in_genotype.GetParentID(), in_genotype.GetParentDistance(),
+ in_genotype.GetDepth(), in_genotype.GetTotalOrganisms(),
+ in_genotype.GetTotalParasites(),
+ stats.GetUpdate() - in_genotype.GetUpdateBorn(),
+ in_genotype.GetLength());
+ if (in_genotype.GetThreshold()) {
+ stats.RemoveThreshold(in_genotype.GetID());
+ }
+
+
+ // Speciation... If a Threshold genotype was removed, the position of this
+ // species in the active list will at least shift, and it is possible that
+ // the species is made inactive, or removed all-togeather. If it is a non-
+ // threshold genotype, then the species will only be effected if this was
+ // the last genotype of that species.
+
+ cSpecies * cur_species = in_genotype.GetSpecies();
+ if (cur_species) {
+
+ // First, re-adjust the species.
+
+ cur_species->RemoveGenotype();
+
+ // Then, check to see how this species changes if it is a threshold.
+
+ if (in_genotype.GetThreshold()) {
+ cur_species->RemoveThreshold(in_genotype);
+
+ // If we are out of thresholds, move this species to the inactive
+ // list for now. Otherwise, just adjust it.
+
+ if (cur_species->GetNumThreshold() == 0) {
+ species_control->SetInactive(*cur_species);
+ }
+ else {
+ species_control->Adjust(*cur_species);
+ }
+ }
+
+ // Finally, remove the species completely if it has no genotypes left.
+
+ if (!cur_species->GetNumGenotypes()) {
+ species_control->SetGarbage(*cur_species);
+ }
+ }
+
+
+ delete &in_genotype;
+}
+
+void cGenebank::ThresholdGenotype(cGenotype & in_genotype)
+{
+ cSpecies * found_species = NULL;
+
+ in_genotype.SetName( GetLabel(in_genotype.GetLength(),
+ genotype_count[in_genotype.GetLength()]++) );
+ in_genotype.SetThreshold();
+
+ // If speciation is on, assign a species to the genotype now that it is
+ // threshold.
+
+ if (cConfig::GetSpeciesRecording()) {
+ // Record the old species to know if it changes.
+
+ cSpecies * old_species = in_genotype.GetSpecies();
+
+ // Determine the "proper" species.
+
+ found_species = species_control->Find(in_genotype,
+ cConfig::GetSpeciesRecording());
+
+ // If no species was found, create a new one.
+
+ if (!found_species) {
+ found_species = new cSpecies(in_genotype.GetGenome(), stats.GetUpdate());
+ if (in_genotype.GetSpecies())
+ found_species->SetParentID(in_genotype.GetSpecies()->GetID());
+ species_control->SetActive(*found_species);
+ stats.AddSpecies(found_species->GetID());
+
+ // Since this is a new species, see if we should be printing it.
+
+ if (cConfig::GetSpeciesPrint()) {
+ cString filename;
+ filename.Set("genebank/spec-%04d", found_species->GetID());
+ cTestUtil::PrintGenome(in_genotype.GetGenome(), filename,
+ &in_genotype, stats.GetUpdate());
+ }
+ }
+ else {
+ // If we are not creating a new species, but are adding a threshold
+ // to one which is currently in-active, make sure to move it back to
+ // the active list.
+
+ if (found_species->GetNumThreshold() == 0) {
+ species_control->SetActive(*found_species);
+ }
+ }
+
+ // Now that we know for sure what the species is, and that it is in
+ // the proper list, setup both the species and the genotype.
+
+ in_genotype.SetSpecies(found_species);
+ found_species->AddThreshold(in_genotype);
+
+ // Finally test to see if the species has been changed, and adjust
+ // accordingly.
+
+ if (found_species != old_species) {
+ found_species->AddGenotype();
+ if (old_species) {
+ old_species->RemoveGenotype();
+ if (old_species->GetNumGenotypes() == 0)
+ species_control->SetGarbage(*old_species);
+ }
+ }
+ else {
+ if (found_species->GetNumThreshold() > 1) {
+ species_control->Adjust(*found_species);
+ }
+ }
+ }
+
+ // Do the relevent statistics...
+
+ if (cConfig::GetSpeciesRecording()) {
+ stats.AddThreshold(in_genotype.GetID(), in_genotype.GetName()(),
+ found_species->GetID());
+ } else {
+ stats.AddThreshold(in_genotype.GetID(), in_genotype.GetName()());
+ }
+
+ // Print the genotype?
+
+ if (cConfig::GetGenotypePrint()) {
+ cString filename;
+ filename.Set("genebank/%s", in_genotype.GetName()());
+ cTestUtil::PrintGenome(in_genotype.GetGenome(), filename,
+ &in_genotype, stats.GetUpdate());
+ }
+}
+
+bool cGenebank::AdjustGenotype(cGenotype & in_genotype)
+{
+ if (!genotype_control->Adjust(in_genotype)) return false;
+
+ if ((in_genotype.GetNumOrganisms() >= cConfig::GetThreshold() ||
+ &in_genotype == genotype_control->GetBest()) &&
+ !(in_genotype.GetThreshold())) {
+ ThresholdGenotype(in_genotype);
+ }
+
+ return true;
+}
+
+bool cGenebank::SaveClone(ofstream & fp)
+{
+ // This method just save the counts at each size-class of genotypes.
+ // The rest is reconstructable.
+
+ // Save the numbers of organisms we're up to at each size.
+ fp << MAX_CREATURE_SIZE << " ";
+ for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
+ fp << genotype_count[i] << " ";
+ }
+
+ return true;
+}
+
+bool cGenebank::LoadClone(ifstream & fp)
+{
+ // This method just restores the counts at each size-class of genotypes.
+ // The rest of the loading process should be handled elsewhere.
+
+ // Load the numbers of organisms we're up to at each size.
+ int max_size;
+ fp >> max_size;
+ assert (max_size <= MAX_CREATURE_SIZE); // MAX_CREATURE_SIZE too small
+ for (int i = 0; i < max_size && i < MAX_CREATURE_SIZE; i++) {
+ fp >> genotype_count[i];
+ }
+
+ return true;
+}
+
+bool cGenebank::DumpTextSummary(ofstream & fp)
+{
+ genotype_control->Reset(0);
+ for (int i = 0; i < genotype_control->GetSize(); i++) {
+ cGenotype * genotype = genotype_control->Get(0);
+ fp << genotype->GetGenome().AsString() << " "
+ << genotype->GetNumOrganisms() << " "
+ << genotype->GetID() << endl;
+ genotype_control->Next(0);
+ }
+
+ return true;
+}
+
+bool cGenebank::PrintGenotypes(ofstream & fp, cString & data_fields,
+ int historic)
+{
+ bool print_id = false;
+ bool print_parent_id = false;
+ bool print_parent2_id = false;
+ bool print_parent_dist = false;
+ bool print_num_cpus = false;
+ bool print_total_cpus = false;
+ bool print_length = false;
+ bool print_merit = false;
+ bool print_gest_time = false;
+ bool print_fitness = false;
+ bool print_update_born = false;
+ bool print_update_dead = false;
+ bool print_depth = false;
+ bool print_lineage = false;
+ bool print_sequence = false;
+
+ cStringList fields(data_fields, ',');
+ if (fields.HasString("id") == true) print_id = true;
+ if (fields.HasString("parent_id") == true) print_parent_id = true;
+ if (fields.HasString("parent2_id") == true) print_parent2_id = true;
+ if (fields.HasString("parent_dist") == true) print_parent_dist = true;
+ if (fields.HasString("num_cpus") == true) print_num_cpus = true;
+ if (fields.HasString("total_cpus") == true) print_total_cpus = true;
+ if (fields.HasString("length") == true) print_length = true;
+ if (fields.HasString("merit") == true) print_merit = true;
+ if (fields.HasString("gest_time") == true) print_gest_time = true;
+ if (fields.HasString("fitness") == true) print_fitness = true;
+ if (fields.HasString("update_born") == true) print_update_born = true;
+ if (fields.HasString("update_dead") == true) print_update_dead = true;
+ if (fields.HasString("depth") == true) print_depth = true;
+ if (fields.HasString("lineage") == true) print_lineage = true;
+ if (fields.HasString("sequence") == true) print_sequence = true;
+ if (fields.HasString("all") == true) {
+ print_id = print_parent_id = print_parent2_id = print_parent_dist = true;
+ print_num_cpus = print_total_cpus = print_length = print_merit = true;
+ print_gest_time = print_fitness = print_update_born = true;
+ print_update_dead = print_depth = print_lineage = print_sequence = true;
+ }
+
+ // Print all of the header information...
+ fp << "#filetype genotype_data" << endl
+ << "#format ";
+
+ if (print_id == true) fp << "id ";
+ if (print_parent_id == true) fp << "parent_id ";
+ if (print_parent2_id == true) fp << "parent2_id ";
+ if (print_parent_dist == true) fp << "parent_dist ";
+ if (print_num_cpus == true) fp << "num_cpus ";
+ if (print_total_cpus == true) fp << "total_cpus ";
+ if (print_length == true) fp << "length ";
+ if (print_merit == true) fp << "merit ";
+ if (print_gest_time == true) fp << "gest_time ";
+ if (print_fitness == true) fp << "fitness ";
+ if (print_update_born == true) fp << "update_born ";
+ if (print_update_dead == true) fp << "update_dead ";
+ if (print_depth == true) fp << "depth ";
+ if (print_lineage == true) fp << "lineage ";
+ if (print_sequence == true) fp << "sequence ";
+ fp << endl;
+
+ // Print extra information about what data is in this file...
+ fp << "# Output is genotypes at update " << stats.GetUpdate();
+ if (historic == -1) fp << " including ALL ancestors";
+ else if (historic > 0) fp << " including ancestors for "
+ << historic << " updates.";
+ fp << endl;
+
+ // And give some information about what columns are available.
+ int cur_col = 1;
+ if (print_id) fp << "# " << cur_col++ << ": ID" << endl;
+ if (print_parent_id) fp << "# " << cur_col++ << ": parent ID" << endl;
+ if (print_parent2_id) fp << "# " << cur_col++ << ": parent2 ID" << endl;
+ if (print_parent_dist) fp << "# " << cur_col++ << ": parent distance" << endl;
+ if (print_num_cpus) fp << "# " << cur_col++ << ": number of orgranisms currently alive" << endl;
+ if (print_total_cpus) fp << "# " << cur_col++ << ": total number of organisms that ever existed" << endl;
+ if (print_length) fp << "# " << cur_col++ << ": length of genome" << endl;
+ if (print_merit) fp << "# " << cur_col++ << ": merit" << endl;
+ if (print_gest_time) fp << "# " << cur_col++ << ": gestation time" << endl;
+ if (print_fitness) fp << "# " << cur_col++ << ": fitness" << endl;
+ if (print_update_born) fp << "# " << cur_col++ << ": update born" << endl;
+ if (print_update_dead) fp << "# " << cur_col++ << ": update deactivated" << endl;
+ if (print_depth) fp << "# " << cur_col++ << ": depth in phylogentic tree" << endl;
+ if (print_lineage) fp << "# " << cur_col++ << ": lineage label of genotype" << endl;
+ if (print_sequence) fp << "# " << cur_col++ << ": genome of genotype" << endl;
+ fp << endl;
+
+ // Print the current population....
+ genotype_control->Reset(0);
+ for (int i = 0; i < genotype_control->GetSize(); i++) {
+ cGenotype * genotype = genotype_control->Get(0);
+
+ if (print_id) fp << genotype->GetID() << " ";
+ if (print_parent_id) fp << genotype->GetParentID() << " ";
+ if (print_parent2_id) fp << genotype->GetAncestorID(1) << " ";
+ if (print_parent_dist) fp << genotype->GetParentDistance() << " ";
+ if (print_num_cpus) fp << genotype->GetNumOrganisms() << " ";
+ if (print_total_cpus) fp << genotype->GetTotalOrganisms() << " ";
+ if (print_length) fp << genotype->GetLength() << " ";
+ if (print_merit) fp << genotype->GetMerit() << " ";
+ if (print_gest_time) fp << genotype->GetGestationTime() << " ";
+ if (print_fitness) fp << genotype->GetFitness() << " ";
+ if (print_update_born) fp << genotype->GetUpdateBorn() << " ";
+ if (print_update_dead) fp << genotype->GetUpdateDeactivated() << " ";
+ if (print_depth) fp << genotype->GetDepth() << " ";
+ if (print_lineage) fp << genotype->GetLineageLabel() << " ";
+ if (print_sequence) fp << genotype->GetGenome().AsString() << " ";
+ fp << endl;
+ genotype_control->Next(0);
+ }
+
+ // Print the historic population if we are supposed to.
+ if (historic == 0) return true;
+
+ // Start by calculating the update we should start printing from...
+ int start_update = 0;
+ if (historic > 0) start_update = stats.GetUpdate() - historic;
+
+ // Now loop through the remaining genotypes...
+ genotype_control->ResetHistoric(0);
+ for (int i = 0; i < genotype_control->GetHistoricCount(); i++) {
+ // Get the next genotype. Only print it if its in range...
+ cGenotype * genotype = genotype_control->Get(0);
+ if (genotype->GetUpdateDeactivated() < start_update) {
+ genotype_control->Next(0);
+ continue;
+ }
+
+ if (print_id) fp << genotype->GetID() << " ";
+ if (print_parent_id) fp << genotype->GetParentID() << " ";
+ if (print_parent2_id) fp << genotype->GetAncestorID(1) << " ";
+ if (print_parent_dist) fp << genotype->GetParentDistance() << " ";
+ if (print_num_cpus) fp << genotype->GetNumOrganisms() << " ";
+ if (print_total_cpus) fp << genotype->GetTotalOrganisms() << " ";
+ if (print_length) fp << genotype->GetLength() << " ";
+ if (print_merit) fp << genotype->GetMerit() << " ";
+ if (print_gest_time) fp << genotype->GetGestationTime() << " ";
+ if (print_fitness) fp << genotype->GetFitness() << " ";
+ if (print_update_born) fp << genotype->GetUpdateBorn() << " ";
+ if (print_update_dead) fp << genotype->GetUpdateDeactivated() << " ";
+ if (print_depth) fp << genotype->GetDepth() << " ";
+ if (print_lineage) fp << genotype->GetLineageLabel() << " ";
+ if (print_sequence) fp << genotype->GetGenome().AsString() << " ";
+ fp << endl;
+
+ // Move to the next genotype...
+ genotype_control->Next(0);
+ }
+
+
+ return true;
+}
+
+bool cGenebank::DumpDetailedSummary(ofstream & fp)
+{
+ genotype_control->Reset(0);
+ DumpDetailHeading(fp);
+ for (int i = 0; i < genotype_control->GetSize(); i++) {
+ DumpDetailedEntry(genotype_control->Get(0), fp);
+ genotype_control->Next(0);
+ }
+
+ return true;
+}
+
+bool cGenebank::DumpHistoricSummary(ofstream & fp, int back_dist)
+{
+ // Calculate the update we should start printing from...
+ int start_update = 0;
+ if (back_dist > 0) start_update = stats.GetUpdate() - back_dist;
+
+ // Loop through all defunct genotypes that we're saving.
+ DumpDetailHeading(fp);
+ genotype_control->ResetHistoric(0);
+ for (int i = 0; i < genotype_control->GetHistoricCount(); i++) {
+ // Get the next genotype. Only print it if its in range...
+ cGenotype * cur_genotype = genotype_control->Get(0);
+ if (cur_genotype->GetUpdateDeactivated() < start_update) {
+ genotype_control->Next(0);
+ continue;
+ }
+ DumpDetailedEntry(cur_genotype, fp);
+
+ // Move to the next genotype...
+ genotype_control->Next(0);
+ }
+
+ return true;
+}
+
+bool cGenebank::DumpDetailedSexSummary(ofstream & fp)
+{
+ genotype_control->Reset(0);
+ DumpDetailSexHeading(fp);
+ for (int i = 0; i < genotype_control->GetSize(); i++) {
+ DumpDetailedSexEntry(genotype_control->Get(0), fp);
+ genotype_control->Next(0);
+ }
+
+ return true;
+}
+
+bool cGenebank::DumpHistoricSexSummary(ofstream & fp)
+{
+ genotype_control->ResetHistoric(0);
+ DumpDetailSexHeading(fp);
+ for (int i = 0; i < genotype_control->GetHistoricCount(); i++) {
+ DumpDetailedSexEntry(genotype_control->Get(0), fp);
+ genotype_control->Next(0);
+ }
+
+ return true;
+}
+
+void cGenebank::DumpDetailHeading (ofstream & fp)
+{
+ fp << "#filetype genotype_data" << endl
+ << "#format id parent_id parent_dist num_cpus total_cpus length merit gest_time fitness update_born update_dead depth sequence" << endl
+ << endl
+ << "# 1: ID" << endl
+ << "# 2: parent ID" << endl
+ << "# 3: parent distance" << endl
+ << "# 4: number of orgranisms currently alive" << endl
+ << "# 5: total number of organisms that ever existed" << endl
+ << "# 6: length of genome" << endl
+ << "# 7: merit" << endl
+ << "# 8: gestation time" << endl
+ << "# 9: fitness" << endl
+ << "# 10: update born" << endl
+ << "# 11: update deactivated" << endl
+ << "# 12: depth in phylogentic tree" << endl
+ << "# 13: genome of organism" << endl << endl;
+}
+
+void cGenebank::DumpDetailSexHeading (ofstream & fp)
+{
+ fp << "#filetype genotype_data" << endl
+ << "#format id parent_id parent2_id parent_dist num_cpus total_cpus length merit gest_time fitness update_born update_dead depth sequence" << endl
+ << endl
+ << "# 1: ID" << endl
+ << "# 2: parent 1 ID " << endl
+ << "# 3: parent 2 ID" << endl
+ << "# 4: parent 1 distance" << endl
+ << "# 5: number of orgranisms currently alive" << endl
+ << "# 6: total number of organisms that ever existed" << endl
+ << "# 7: length of genome" << endl
+ << "# 8: merit" << endl
+ << "# 9: gestation time" << endl
+ << "# 10: fitness" << endl
+ << "# 11: update born" << endl
+ << "# 12: update deactivated" << endl
+ << "# 13: depth in phylogentic tree" << endl
+ << "# 14: genome of organism" << endl << endl;
+}
+
+void cGenebank::DumpDetailedEntry(cGenotype * genotype, ofstream & fp)
+{
+ fp << genotype->GetID() << " " // 1
+ << genotype->GetParentID() << " " // 2
+ // << genotype->GetAncestorID(1) << " " // 2b
+ << genotype->GetParentDistance() << " " // 3
+ << genotype->GetNumOrganisms() << " " // 4
+ << genotype->GetTotalOrganisms() << " " // 5
+ << genotype->GetLength() << " " // 6
+ << genotype->GetMerit() << " " // 7
+ << genotype->GetGestationTime() << " " // 8
+ << genotype->GetFitness() << " " // 9
+ << genotype->GetUpdateBorn() << " " // 10
+ << genotype->GetUpdateDeactivated() << " " // 11
+ << genotype->GetDepth() << " " // 12
+ << genotype->GetGenome().AsString() << " " // 13
+ << endl;
+}
+
+void cGenebank::DumpDetailedSexEntry(cGenotype * genotype, ofstream & fp)
+{
+ fp << genotype->GetID() << " " // 1
+ << genotype->GetAncestorID(0) << " " // 2
+ << genotype->GetAncestorID(1) << " " // 3
+ << genotype->GetParentDistance() << " " // 4
+ << genotype->GetNumOrganisms() << " " // 5
+ << genotype->GetTotalOrganisms() << " " // 6
+ << genotype->GetLength() << " " // 7
+ << genotype->GetMerit() << " " // 8
+ << genotype->GetGestationTime() << " " // 9
+ << genotype->GetFitness() << " " // 10
+ << genotype->GetUpdateBorn() << " " // 11
+ << genotype->GetUpdateDeactivated() << " " // 12
+ << genotype->GetDepth() << " " // 13
+ << genotype->GetGenome().AsString() << " " // 14
+ << endl;
+}
+
+bool cGenebank::OK()
+{
+ bool ret_value = true;
+
+ // Check components...
+
+ if (!genotype_control->OK() || !species_control->OK()) {
+ ret_value = false;
+ }
+
+ // Now to double check the numbers of genotypes (and threshold) for each
+ // species. This will only work if debug mode is on.
+
+#ifdef DEBUG
+ // Initialize debug routines in the species.
+
+ cSpecies * cur_species = NULL;
+ cSpecies * first_active = species_control->GetFirst();
+ cSpecies * first_inactive = species_control->GetFirstInactive();
+ cSpecies * first_garbage = species_control->GetFirstGarbage();
+
+ while (cur_species != first_active) {
+ if (!cur_species) cur_species = first_active;
+ cur_species->debug_num_genotypes = 0;
+ cur_species->debug_num_threshold = 0;
+ cur_species = cur_species->GetNext();
+ }
+
+ cur_species = NULL;
+ while (cur_species != first_inactive) {
+ if (!cur_species) cur_species = first_inactive;
+ cur_species->debug_num_genotypes = 0;
+ cur_species->debug_num_threshold = 0;
+ cur_species = cur_species->GetNext();
+ }
+
+ cur_species = NULL;
+ while (cur_species != first_garbage) {
+ if (!cur_species) cur_species = first_garbage;
+ cur_species->debug_num_genotypes = 0;
+ cur_species->debug_num_threshold = 0;
+ cur_species = cur_species->GetNext();
+ }
+
+
+ // Check the species for each genotype and place results in the species.
+
+ cGenotype * cur_gen = genotype_control->GetBest();
+ for (int i = 0; i < genotype_control->GetSize(); i++) {
+ if (cur_gen->GetSpecies()) {
+ cur_gen->GetSpecies()->debug_num_genotypes++;
+ if (cur_gen->GetThreshold()) {
+ cur_gen->GetSpecies()->debug_num_threshold++;
+ }
+ }
+ cur_gen = cur_gen->GetNext();
+ }
+
+ // Finally, make sure all the numbers match up.
+
+ cur_species = NULL;
+ while (cur_species != first_active) {
+ if (!cur_species) cur_species = first_active;
+ assert(cur_species->debug_num_genotypes == cur_species->GetNumGenotypes());
+ assert(cur_species->debug_num_threshold == cur_species->GetNumThreshold());
+ assert(cur_species->debug_num_genotypes >= cur_species->debug_num_threshold);
+
+ assert (cur_species->debug_num_threshold);
+ cur_species = cur_species->GetNext();
+ }
+
+ cur_species = NULL;
+ while (cur_species != first_inactive) {
+ if (!cur_species) cur_species = first_inactive;
+ assert(cur_species->debug_num_genotypes == cur_species->GetNumGenotypes());
+ assert(cur_species->debug_num_threshold == cur_species->GetNumThreshold());
+ assert(cur_species->debug_num_threshold);
+ assert(cur_species->debug_num_genotypes);
+ }
+
+ cur_species = NULL;
+ while (cur_species != first_garbage) {
+ if (!cur_species) cur_species = first_garbage;
+ assert(cur_species->debug_num_genotypes == 0 &&
+ cur_species->debug_num_threshold == 0);
+ }
+
+#endif
+
+ assert (ret_value == true);
+
+ return ret_value;
+}
+
+int cGenebank::CountNumCreatures()
+{
+ int i;
+ int total = 0;
+
+ genotype_control->Reset(0);
+ for (i = 0; i < genotype_control->GetSize(); i++) {
+ total += genotype_control->Get(0)->GetNumOrganisms();
+ genotype_control->Next(0);
+ }
+
+ return total;
+}
+
+
+unsigned int cGenebank::FindCRC(const cGenome & in_genome) const
+{
+ unsigned int total = 0;
+
+ for (int i = 0; i < in_genome.GetSize(); i++) {
+ total += (in_genome[i].GetOp() + 3) * i;
+ }
+
+ return total % GENOTYPE_HASH_SIZE;
+}
+
+void cGenebank::SpeciesTest(char * message, cGenotype & genotype)
+{
+// cSpecies * cur_species = genotype.GetSpecies();
+
+// if (cur_species) {
+// g_debug.Comment("UD %d: %s on genotype [%d] (size %d) of species [%d]",
+// stats.GetUpdate(), message, genotype.GetID(),
+// genotype.GetNumOrganisms(), cur_species->GetID());
+// } else {
+// g_debug.Comment("UD %d: %s on genotype [%d] (size %d) (no species)",
+// stats.GetUpdate(), message, genotype.GetID(),
+// genotype.GetNumOrganisms());
+// }
+
+// if (cur_species) {
+// g_debug.Comment(" Species [%d] has %d gen and %d thresh. (list %d)",
+// cur_species->GetID(), cur_species->GetNumGenotypes(),
+// cur_species->GetNumThreshold(), cur_species->GetQueueType());
+// }
+}
Copied: trunk/source/main/cGenebank.h (from rev 313, trunk/source/main/genebank.hh)
===================================================================
--- trunk/source/main/genebank.hh 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cGenebank.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,121 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 GENEBANK_HH
+#define GENEBANK_HH
+
+#include <fstream>
+
+#ifndef DEFS_HH
+#include "defs.hh"
+#endif
+#ifndef GENOTYPE_CONTROL_HH
+#include "cGenotypeControl.h"
+#endif
+#ifndef SPECIES_CONTROL_HH
+#include "species_control.hh"
+#endif
+#ifndef STRING_HH
+#include "string.hh"
+#endif
+#ifndef TLIST_HH
+#include "tList.hh"
+#endif
+
+template <class T> class tList; // array
+class cGenome;
+class cGenotype;
+class cGenotypeControl; // access
+class cSpeciesControl; // access
+class cStats;
+class cString; // aggregate
+
+class cGenebank {
+private:
+ unsigned int genotype_count[MAX_CREATURE_SIZE];
+ tList<cGenotype> active_genotypes[GENOTYPE_HASH_SIZE];
+ cGenotypeControl * genotype_control;
+ cSpeciesControl * species_control;
+ cStats & stats;
+
+private:
+ cString GetLabel(int in_size, int in_num);
+
+private:
+ // disabled copy constructor.
+ cGenebank(const cGenebank &);
+public:
+ cGenebank(cStats & _stats);
+ ~cGenebank();
+
+ void UpdateReset();
+
+ /**
+ * This function can be used to add a genotype that was created
+ * outside the genebank. In this case, the parameter in_list_num
+ * should not be given. Normally, genotypes are added through the
+ * function AddGenotype(const cGenome & in_genome,
+ * cGenotype * parent_genotype = NULL), which then calls this one.
+ **/
+ void AddGenotype(cGenotype *in_genotype, int list_num=-1);
+ cGenotype * AddGenotype(const cGenome & in_genome,
+ cGenotype * parent_genotype,
+ cGenotype * parent2_genotype);
+ cGenotype * InjectGenotype(const cGenome & in_genome, int lineage_label);
+ const cGenotype * FindGenotype(const cGenome & in_genome, int lineage_label,
+ int list_num=-1) const;
+ cGenotype * FindGenotype(const cGenome & in_genome, int lineage_label,
+ int list_num=-1);
+ void RemoveGenotype(cGenotype & in_genotype);
+ void ThresholdGenotype(cGenotype & in_genotype);
+ bool AdjustGenotype(cGenotype & in_genotype);
+
+ bool SaveClone(std::ofstream & fp);
+ bool LoadClone(std::ifstream & fp);
+ bool DumpTextSummary(std::ofstream & fp);
+ bool PrintGenotypes(std::ofstream & fp, cString & data_fields, int historic);
+ bool DumpDetailedSummary(std::ofstream & fp);
+ bool DumpDetailedSexSummary(std::ofstream & fp);
+ bool DumpHistoricSummary(std::ofstream & fp, int back_dist);
+ bool DumpHistoricSexSummary(std::ofstream & fp);
+ void DumpDetailHeading (std::ofstream & fp);
+ void DumpDetailSexHeading (std::ofstream & fp);
+ void DumpDetailedEntry(cGenotype * genotype, std::ofstream & fp);
+ void DumpDetailedSexEntry(cGenotype * genotype, std::ofstream & fp);
+ bool OK();
+
+ inline int GetSize() const { return genotype_control->GetSize(); }
+ inline cGenotype * GetBestGenotype() const
+ { return genotype_control->GetBest(); }
+ inline cGenotype * GetCoalescentGenotype() const
+ { return genotype_control->GetCoalescent(); }
+ inline cSpecies * GetFirstSpecies() const
+ { return species_control->GetFirst(); }
+
+ inline cGenotype * GetGenotype(int thread) const
+ { return genotype_control->Get(thread); }
+ inline cGenotype * NextGenotype(int thread) {
+ cGenotype * next = genotype_control->Next(thread);
+ return (next == genotype_control->GetBest()) ? (cGenotype*)NULL : next;
+ }
+ inline cGenotype * ResetThread(int thread)
+ { return genotype_control->Reset(thread); }
+
+ int CountNumCreatures();
+ inline int GetNumSpecies() const { return species_control->GetSize(); }
+ inline int CountSpecies() { return species_control->OK(); }
+ inline int FindPos(cGenotype & in_genotype, int max_depth = -1)
+ { return genotype_control->FindPos(in_genotype, max_depth); }
+ inline int FindPos(cSpecies & in_species, int max_depth = -1)
+ { return species_control->FindPos(in_species, max_depth); }
+
+ unsigned int FindCRC(const cGenome & in_genome) const;
+
+ void SpeciesTest(char * message, cGenotype & genotype);
+};
+
+#endif
Copied: trunk/source/main/cGenome.cc (from rev 313, trunk/source/main/genome.cc)
===================================================================
--- trunk/source/main/genome.cc 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cGenome.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,98 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 "cGenome.h"
+
+
+using namespace std;
+
+
+/////////////
+// cGenome
+/////////////
+
+cGenome::cGenome(int _size)
+ : genome(_size), active_size(_size)
+{
+}
+
+cGenome::cGenome(const cGenome & in_genome)
+ : genome(in_genome.GetSize()), active_size(in_genome.GetSize())
+{
+ for (int i = 0; i < active_size; i++) genome[i] = in_genome[i];
+}
+
+cGenome::cGenome(const cString & in_string)
+{
+ cString tmp_string(in_string);
+ tmp_string.RemoveChar('_'); // Remove all blanks from alignments...
+
+ active_size = tmp_string.GetSize();
+ genome.ResizeClear(active_size);
+ for (int i = 0; i < active_size; i++) {
+ genome[i].SetSymbol(tmp_string[i]);
+ }
+}
+
+cGenome::~cGenome()
+{
+}
+
+
+void cGenome::operator=(const cGenome & other_genome)
+{
+ // If we need to resize, do so...
+ active_size = other_genome.GetSize();
+ genome.ResizeClear(active_size);
+
+ // Now that both code arrays are the same size, copy the other one over.
+
+ for (int i = 0; i < active_size; i++) {
+ genome[i] = other_genome[i];
+ }
+}
+
+
+bool cGenome::operator==(const cGenome & other_genome) const
+{
+ // Make sure the sizes are the same.
+ if (active_size != other_genome.active_size) return false;
+
+ // Then go through line by line.
+ for (int i = 0; i < active_size; i++)
+ if (genome[i] != other_genome[i]) return false;
+
+ return true;
+}
+
+
+void cGenome::Copy(int to, int from)
+{
+ assert(to >= 0 && to < active_size);
+ assert(from >= 0 && from < active_size);
+ genome[to] = genome[from];
+}
+
+bool cGenome::OK() const
+{
+ assert (active_size <= genome.GetSize()); // active_size too large!
+
+ return true;
+}
+
+
+// Return the genome as an alphabetic string
+
+cString cGenome::AsString() const
+{
+ cString out_string(active_size);
+ for (int i = 0; i < active_size; i++) {
+ out_string[i] = genome[i].GetSymbol();
+ }
+
+ return out_string;
+}
Copied: trunk/source/main/cGenome.hh (from rev 313, trunk/source/main/genome.hh)
===================================================================
--- trunk/source/main/genome.hh 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cGenome.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,60 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 GENOME_HH
+#define GENOME_HH
+
+#include <assert.h>
+
+#ifndef INSTRUCTION_HH
+#include "cInstruction.h"
+#endif
+#ifndef STRING_HH
+#include "string.hh"
+#endif
+#ifndef TARRAY_HH
+#include "tArray.hh"
+#endif
+
+/**
+ * This class stores the genome of an Avida organism. Note that once created,
+ * a genome should not be modified; only the corresponding memory should be,
+ * before creating the genome. Keeping genome light-weight...
+ **/
+
+class cGenome {
+protected:
+ tArray<cInstruction> genome;
+ int active_size;
+
+public:
+ explicit cGenome(int _size);
+ cGenome(const cGenome & in_genome);
+ cGenome(const cString & in_string);
+ virtual ~cGenome();
+
+ virtual void operator=(const cGenome & other_genome);
+ virtual bool operator==(const cGenome & other_genome) const;
+ virtual bool operator!=(const cGenome & other_genome) const
+ { return !(this->operator==(other_genome)); }
+ virtual bool operator<(const cGenome & other_genome) const
+ { return AsString() < other_genome.AsString(); }
+
+ cInstruction & operator[](int index)
+ { assert(index >= 0 && index < active_size); return genome[index]; }
+ const cInstruction & operator[](int index) const
+ { assert(index >= 0 && index < active_size); return genome[index]; }
+
+ virtual void Copy(int to, int from);
+
+ bool OK() const;
+
+ int GetSize() const { return active_size; }
+ cString AsString() const;
+};
+
+#endif
Copied: trunk/source/main/cGenomeBatch.h (from rev 313, trunk/source/main/genotype_batch.hh)
Copied: trunk/source/main/cGenomeUtil.cc (from rev 313, trunk/source/main/genome_util.cc)
===================================================================
--- trunk/source/main/genome_util.cc 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cGenomeUtil.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,214 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 "cGenomeUtil.h"
+
+#include "functions.hh"
+#include "cGenome.h"
+
+
+using namespace std;
+
+
+int cGenomeUtil::FindInst(const cGenome & gen, const cInstruction & inst,
+ int start_index)
+{
+ assert(start_index < gen.GetSize()); // Starting search after genome end.
+
+ for(int i = start_index; i < gen.GetSize(); i++) {
+ if (gen[i] == inst) return i;
+ }
+
+ // Search failed
+ return -1;
+}
+
+
+int cGenomeUtil::FindOverlap(const cGenome & gen1, const cGenome & gen2,
+ int offset)
+{
+ assert(offset < gen1.GetSize());
+ assert(-offset < gen2.GetSize());
+
+ if (offset > 0) return Min(gen1.GetSize() - offset, gen2.GetSize());
+ // else
+ return Min(gen2.GetSize() + offset, gen1.GetSize());
+}
+
+
+int cGenomeUtil::FindHammingDistance(const cGenome &gen1, const cGenome &gen2,
+ int offset)
+{
+ const int start1 = (offset < 0) ? 0 : offset;
+ const int start2 = (offset > 0) ? 0 : -offset;
+ const int overlap = FindOverlap(gen1, gen2, offset);
+
+ // Initialize the hamming distance to anything protruding past the overlap.
+
+ int hamming_distance = gen1.GetSize() + gen2.GetSize() - 2 * overlap;
+
+ // Cycle through the overlap adding all differences to the distance.
+ for (int i = 0; i < overlap; i++) {
+ if (gen1[start1 + i] != gen2[start2 + i]) hamming_distance++;
+ }
+
+ return hamming_distance;
+}
+
+
+int cGenomeUtil::FindBestOffset(const cGenome & gen1, const cGenome & gen2)
+{
+ const int size1 = gen1.GetSize();
+ const int size2 = gen2.GetSize();
+
+ int best_offset = 0;
+ int cur_distance = FindHammingDistance(gen1, gen2);
+ int best_distance = cur_distance;
+
+ // Check positive offsets...
+ for (int i = 1; i < size1 || i < size2; i++) {
+ if (size1 + size2 - 2 * FindOverlap(gen1, gen2, i) > best_distance) break;
+ cur_distance = FindHammingDistance(gen1, gen2, i);
+ if (cur_distance < best_distance) {
+ best_distance = cur_distance;
+ best_offset = i;
+ }
+ }
+
+ // Check negative offsets...
+ for (int i = 1; i < size1 || i < size2; i++) {
+ if (size1 + size2 - 2 * FindOverlap(gen1, gen2, -i) > best_distance) break;
+ cur_distance = FindHammingDistance(gen1, gen2, -i);
+ if (cur_distance < best_distance) {
+ best_distance = cur_distance;
+ best_offset = -i;
+ }
+ }
+
+ return best_offset;
+}
+
+
+int cGenomeUtil::FindSlidingDistance(const cGenome &gen1, const cGenome &gen2)
+{
+ const int offset = FindBestOffset(gen1, gen2);
+ return FindHammingDistance(gen1, gen2, offset);
+}
+
+
+int cGenomeUtil::FindEditDistance(const cGenome & gen1, const cGenome & gen2)
+{
+ const int size1 = gen1.GetSize();
+ const int size2 = gen2.GetSize();
+
+ if (!size1) return size2;
+ if (!size2) return size1;
+
+ int * cur_row = new int[size1]; // The row we are calculating
+ int * prev_row = new int[size1]; // The last row we calculater
+
+ // Initialize the previous row to record the differece from nothing.
+ for (int i = 0; i < size1; i++) prev_row[i] = i + 1;
+
+ // Loop through each subsequent character in the test code
+ for (int i = 0; i < size2; i++) {
+ // Initialize the first entry in cur_row.
+ if (gen1[0] == gen2[i]) cur_row[0] = i;
+ else cur_row[0] = (i < prev_row[0]) ? (i+1) : (prev_row[0] + 1);
+
+ // Move down the cur_row and fill it out.
+ for (int j = 1; j < size1; j++) {
+ // If the values are equal, keep the value in the upper left.
+ if (gen1[j] == gen2[i]) {
+ cur_row[j] = prev_row[j-1];
+ }
+
+ // Otherwise, set the current position the the minimal of the three
+ // numbers above (insertion), to the left (deletion), or upper left
+ // (mutation) in the chart, plus one.
+ else {
+ cur_row[j] =
+ (prev_row[j] < prev_row[j-1]) ? prev_row[j] : prev_row[j-1];
+ if (cur_row[j-1] < cur_row[j]) cur_row[j] = cur_row[j-1];
+ cur_row[j]++;
+ }
+ }
+
+ // Swap cur_row and prev_row. (we only really need to move the cur row
+ // over to prev, but this saves us from having to keep re-allocating
+ // new rows. We recycle!
+ int * temp_row = cur_row;
+ cur_row = prev_row;
+ prev_row = temp_row;
+ }
+
+ // Now that we are done, return the bottom-right corner of the chart.
+
+ const int value = prev_row[size1 - 1];
+
+ delete [] cur_row;
+ delete [] prev_row;
+
+ return value;
+}
+
+
+cGenome cGenomeUtil::Crop(const cGenome & in_genome, int start, int end)
+{
+ assert(end > start); // Must have a positive length clip!
+ assert(in_genome.GetSize() >= end); // end must be < genome length
+ assert(start >= 0); // negative start illegal
+
+ const int out_length = end - start;
+ cGenome out_genome(out_length);
+ for (int i = 0; i < out_length; i++) {
+ out_genome[i] = in_genome[i+start];
+ }
+
+ return out_genome;
+}
+
+
+cGenome cGenomeUtil::Cut(const cGenome & in_genome, int start, int end)
+{
+ assert(end > start); // Must have a positive size cut!
+ assert(in_genome.GetSize() >= end); // end must be < genome length
+ assert(start >= 0); // negative start illegal
+
+ const int cut_length = end - start;
+ const int out_length = in_genome.GetSize() - cut_length;
+
+ assert(out_length > 0); // Can't cut everything!
+
+ cGenome out_genome(out_length);
+ for (int i = 0; i < start; i++) {
+ out_genome[i] = in_genome[i];
+ }
+ for (int i = start; i < out_length; i++) {
+ out_genome[i] = in_genome[i+cut_length];
+ }
+
+ return out_genome;
+}
+
+
+cGenome cGenomeUtil::Join(const cGenome & genome1, const cGenome & genome2)
+{
+ const int length1 = genome1.GetSize();
+ const int length2 = genome2.GetSize();
+ const int out_length = length1 + length2;
+
+ cGenome out_genome(out_length);
+ for (int i = 0; i < length1; i++) {
+ out_genome[i] = genome1[i];
+ }
+ for (int i = 0; i < length2; i++) {
+ out_genome[i+length1] = genome2[i];
+ }
+
+ return out_genome;
+}
Copied: trunk/source/main/cGenomeUtil.h (from rev 313, trunk/source/main/genome_util.hh)
===================================================================
--- trunk/source/main/genome_util.hh 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cGenomeUtil.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,39 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 GENOME_UTIL_HH
+#define GENOME_UTIL_HH
+
+#ifndef GENOME_HH
+#include "cGenome.h"
+#endif
+
+class cInstruction;
+class cGenomeUtil {
+public:
+ // ========= Detection =========
+ static int FindInst(const cGenome & gen, const cInstruction & inst,
+ int start_index=0);
+ static bool HasInst(const cGenome & gen, const cInstruction & inst)
+ { return ( FindInst(gen, inst) >= 0 ) ? true : false; }
+
+ // === Genetic distance tools ===
+ static int FindOverlap(const cGenome & gen1, const cGenome & gen2,
+ int offset = 0);
+ static int FindHammingDistance(const cGenome & gen1, const cGenome & gen2,
+ int offset = 0);
+ static int FindBestOffset(const cGenome & gen1, const cGenome & gen2);
+ static int FindSlidingDistance(const cGenome & gen1, const cGenome & gen2);
+ static int FindEditDistance(const cGenome & gen1, const cGenome & gen2);
+
+ // ===== Construction methods =====
+ static cGenome Crop(const cGenome & genome, int start, int end);
+ static cGenome Cut(const cGenome & genome, int start, int end);
+ static cGenome Join(const cGenome & genome1, const cGenome & genome2);
+};
+
+#endif
Copied: trunk/source/main/cGenotype.cc (from rev 314, trunk/source/main/genotype.cc)
===================================================================
--- trunk/source/main/genotype.cc 2005-09-16 02:10:20 UTC (rev 314)
+++ trunk/source/main/cGenotype.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,365 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 "cGenotype.h"
+
+#include "cConfig.h"
+#include "cCPUTestInfo.h"
+#include "cGenomeUtil.h"
+#include "merit.hh"
+#include "organism.hh"
+#include "phenotype.hh"
+#include "cTestCPU.h"
+#include "tools.hh"
+
+using namespace std;
+
+class cSpecies;
+
+///////////////////////////
+// cGenotype
+///////////////////////////
+
+cGenotype::cGenotype(int in_update_born, int in_id)
+ : genome(1)
+ , name("001-no_name")
+ , flag_threshold(false)
+ , is_active(true)
+ , defer_adjust(0)
+ , symbol(0)
+ , birth_data(in_update_born)
+ , num_organisms(0)
+ , last_num_organisms(0)
+ , total_organisms(0)
+ , total_parasites(0)
+ , species(NULL)
+ , next(NULL)
+ , prev(NULL)
+{
+ static int next_id = 1;
+
+ if ( in_id >= 0 )
+ next_id = in_id;
+
+ id_num = next_id++;
+}
+
+cGenotype::~cGenotype()
+{
+ // Reset some of the variables to make sure program will crash if a deleted
+ // cell is read!
+
+ symbol = '!';
+
+ num_organisms = -1;
+ total_organisms = -1;
+
+ next = NULL;
+ prev = NULL;
+}
+
+bool cGenotype::SaveClone(ofstream & fp)
+{
+ fp << id_num << " ";
+ fp << genome.GetSize() << " ";
+
+ for (int i = 0; i < genome.GetSize(); i++) {
+ fp << ((int) genome[i].GetOp()) << " ";
+ }
+
+ return true;
+}
+
+bool cGenotype::LoadClone(ifstream & fp)
+{
+ int genome_size = 0;
+
+ fp >> id_num;
+ fp >> genome_size;
+
+ genome = cGenome(genome_size);
+ for (int i = 0; i < genome_size; i++) {
+ cInstruction temp_inst;
+ int inst_op;
+ fp >> inst_op;
+ temp_inst.SetOp((UCHAR) inst_op);
+ genome[i] = temp_inst;
+ // @CAO add something here to load arguments for instructions.
+ }
+
+ return true;
+}
+
+bool cGenotype::OK()
+{
+ bool ret_value = true;
+
+ // Check the components...
+
+ if (!genome.OK()) ret_value = false;
+
+ // And the statistics
+ assert( id_num >= 0 && num_organisms >= 0 && total_organisms >= 0 );
+ assert( birth_data.update_born >= -1 && birth_data.parent_distance >= -1 );
+ assert( sum_copied_size.Sum() >= 0 && sum_exe_size.Sum() >= 0 );
+ assert( sum_gestation_time.Sum() >= 0 && sum_repro_rate.Sum() >= 0 );
+ assert( sum_merit.Sum() >= 0 && sum_fitness.Sum() >= 0 );
+ assert( tmp_sum_copied_size.Sum() >= 0 && tmp_sum_exe_size.Sum() >= 0 );
+ assert( tmp_sum_gestation_time.Sum() >= 0 && tmp_sum_repro_rate.Sum() >= 0 );
+ assert( tmp_sum_merit.Sum() >= 0 && tmp_sum_fitness.Sum() >= 0 );
+
+ return ret_value;
+}
+
+void cGenotype::SetParent(cGenotype * parent, cGenotype * parent2)
+{
+ birth_data.parent_genotype = parent;
+ birth_data.parent2_genotype = parent2;
+
+ // If we have a real parent genotype, collect other data about parent.
+ if (parent == NULL) return;
+ birth_data.ancestor_ids[0] = parent->GetID();
+ birth_data.ancestor_ids[2] = parent->GetAncestorID(0);
+ birth_data.ancestor_ids[3] = parent->GetAncestorID(1);
+ if (parent2 != NULL) {
+ birth_data.ancestor_ids[1] = parent2->GetID();
+ birth_data.ancestor_ids[4] = parent2->GetAncestorID(0);
+ birth_data.ancestor_ids[5] = parent2->GetAncestorID(1);
+ }
+
+ birth_data.parent_distance =
+ cGenomeUtil::FindEditDistance(genome, parent->genome);
+ birth_data.parent_species = parent->GetSpecies();
+ birth_data.gene_depth = parent->GetDepth() + 1;
+ birth_data.lineage_label = parent->GetLineageLabel();
+ parent->AddOffspringGenotype();
+ if (parent2 != NULL && cConfig::GetTrackMainLineage() == 2) {
+ parent2->AddOffspringGenotype();
+ }
+
+ // Initialize all stats to those of the parent genotype....
+ tmp_sum_copied_size.Add( parent->GetCopiedSize());
+ tmp_sum_exe_size.Add( parent->GetExecutedSize());
+ tmp_sum_gestation_time.Add( parent->GetGestationTime());
+ tmp_sum_repro_rate.Add( 1/parent->GetGestationTime());
+ tmp_sum_merit.Add( parent->GetMerit());
+ tmp_sum_fitness.Add( parent->GetFitness());
+}
+
+void cGenotype::Mutate() // Check each location to be mutated.
+{
+ int i;
+
+ for (i = 0; i < genome.GetSize(); i++) {
+ if (true) { // g_random.GetUInt()) { //@CAO always true!
+ genome[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
+ // Flag command as having been mutated? @CAO
+ }
+ }
+}
+
+void cGenotype::UpdateReset()
+{
+ last_num_organisms = num_organisms;
+ birth_data.birth_track.Next();
+ birth_data.death_track.Next();
+ birth_data.breed_out_track.Next();
+ birth_data.breed_true_track.Next();
+ birth_data.breed_in_track.Next();
+}
+
+void cGenotype::SetGenome(const cGenome & in_genome)
+{
+ genome = in_genome;
+ // Zero Stats
+ sum_copied_size.Clear();
+ sum_exe_size.Clear();
+ sum_gestation_time.Clear();
+ sum_repro_rate.Clear();
+ sum_merit.Clear();
+ sum_fitness.Clear();
+ tmp_sum_copied_size.Clear();
+ tmp_sum_exe_size.Clear();
+ tmp_sum_gestation_time.Clear();
+ tmp_sum_repro_rate.Clear();
+ tmp_sum_merit.Clear();
+ tmp_sum_fitness.Clear();
+
+ name.Set("%03d-no_name", genome.GetSize());
+}
+
+void cGenotype::CalcTestStats() const
+{
+ // cerr << ".......Calculating test stats..." << endl;
+
+ cCPUTestInfo test_info;
+ cTestCPU::TestGenome(test_info, genome);
+ test_data.is_viable = test_info.IsViable();
+
+ // Setup all possible test values.
+ cPhenotype & phenotype = test_info.GetTestOrganism()->GetPhenotype();
+ test_data.fitness = test_info.GetGenotypeFitness();
+ test_data.merit = phenotype.GetMerit().GetDouble();
+ test_data.gestation_time = phenotype.GetGestationTime();
+ test_data.executed_size = phenotype.GetExecutedSize();
+ test_data.copied_size = phenotype.GetCopiedSize();
+ test_data.colony_fitness = test_info.GetColonyFitness();
+ test_data.generations = test_info.GetMaxDepth();
+}
+
+
+bool cGenotype::GetTestViable() const {
+ if (test_data.fitness == -1) CalcTestStats();
+ return test_data.is_viable;
+}
+
+
+double cGenotype::GetTestFitness() const {
+ if (test_data.fitness == -1) CalcTestStats();
+ return test_data.fitness;
+}
+
+
+double cGenotype::GetTestMerit() const {
+ if (test_data.fitness == -1) CalcTestStats();
+ return test_data.merit;
+}
+
+
+int cGenotype::GetTestGestationTime() const {
+ if (test_data.fitness == -1) CalcTestStats();
+ return test_data.gestation_time;
+}
+
+
+int cGenotype::GetTestExecutedSize() const {
+ if (test_data.fitness == -1) CalcTestStats();
+ return test_data.executed_size;
+}
+
+
+int cGenotype::GetTestCopiedSize() const {
+ if (test_data.fitness == -1) CalcTestStats();
+ return test_data.copied_size;
+}
+
+
+double cGenotype::GetTestColonyFitness() const {
+ if (test_data.fitness == -1) CalcTestStats();
+ return test_data.colony_fitness;
+}
+
+
+int cGenotype::GetTestGenerations() const {
+ if (test_data.fitness == -1) CalcTestStats();
+ return test_data.generations;
+}
+
+void cGenotype::SetSpecies(cSpecies * in_species)
+{
+ species = in_species;
+}
+
+void cGenotype::AddMerit(const cMerit & in)
+{
+ sum_merit.Add(in.GetDouble());
+}
+
+void cGenotype::RemoveMerit(const cMerit & in)
+{
+ sum_merit.Subtract(in.GetDouble());
+}
+
+void cGenotype::Deactivate(int update)
+{
+ is_active = false;
+ birth_data.update_deactivated = update;
+}
+
+int cGenotype::GetPhyloDistance(cGenotype * test_genotype)
+{
+ if (GetID() == test_genotype->GetID()) {
+ return 0;
+ }
+ if (GetID() == test_genotype->GetAncestorID(0) || // Parent of test
+ GetID() == test_genotype->GetAncestorID(1) || // Parent of test
+ test_genotype->GetID() == GetAncestorID(0) || // Child of test
+ test_genotype->GetID() == GetAncestorID(1) // Child of test
+ ) {
+ return 1;
+ }
+ if (GetID() == test_genotype->GetAncestorID(2) || // Grandparent of test
+ GetID() == test_genotype->GetAncestorID(3) || // Grandparent of test
+ GetID() == test_genotype->GetAncestorID(4) || // Grandparent of test
+ GetID() == test_genotype->GetAncestorID(5) || // Grandparent of test
+ test_genotype->GetID() == GetAncestorID(2) || // Grandchild of test
+ test_genotype->GetID() == GetAncestorID(3) || // Grandchild of test
+ test_genotype->GetID() == GetAncestorID(4) || // Grandchild of test
+ test_genotype->GetID() == GetAncestorID(5) || // Grandchild of test
+ GetAncestorID(0) == test_genotype->GetAncestorID(0) || // Sibling of test
+ GetAncestorID(0) == test_genotype->GetAncestorID(1) || // Sibling of test
+ GetAncestorID(1) == test_genotype->GetAncestorID(0) || // Sibling of test
+ GetAncestorID(1) == test_genotype->GetAncestorID(1) // Sibling of test
+ ) {
+ return 2;
+ }
+ if (GetAncestorID(0) == test_genotype->GetAncestorID(2) || // Uncle of test
+ GetAncestorID(0) == test_genotype->GetAncestorID(3) || // Uncle of test
+ GetAncestorID(0) == test_genotype->GetAncestorID(4) || // Uncle of test
+ GetAncestorID(0) == test_genotype->GetAncestorID(5) || // Uncle of test
+ GetAncestorID(1) == test_genotype->GetAncestorID(2) || // Uncle of test
+ GetAncestorID(1) == test_genotype->GetAncestorID(3) || // Uncle of test
+ GetAncestorID(1) == test_genotype->GetAncestorID(4) || // Uncle of test
+ GetAncestorID(1) == test_genotype->GetAncestorID(5) || // Uncle of test
+ test_genotype->GetAncestorID(0) == GetAncestorID(2) || // Nephew of test
+ test_genotype->GetAncestorID(0) == GetAncestorID(3) || // Nephew of test
+ test_genotype->GetAncestorID(0) == GetAncestorID(4) || // Nephew of test
+ test_genotype->GetAncestorID(0) == GetAncestorID(5) || // Nephew of test
+ test_genotype->GetAncestorID(1) == GetAncestorID(2) || // Nephew of test
+ test_genotype->GetAncestorID(1) == GetAncestorID(3) || // Nephew of test
+ test_genotype->GetAncestorID(1) == GetAncestorID(4) || // Nephew of test
+ test_genotype->GetAncestorID(1) == GetAncestorID(5) // Nephew of test
+ ) {
+ return 3;
+ }
+
+ if (GetAncestorID(2) == test_genotype->GetAncestorID(2) || // First Cousins
+ GetAncestorID(2) == test_genotype->GetAncestorID(3) ||
+ GetAncestorID(2) == test_genotype->GetAncestorID(4) ||
+ GetAncestorID(2) == test_genotype->GetAncestorID(5) ||
+ GetAncestorID(3) == test_genotype->GetAncestorID(2) ||
+ GetAncestorID(3) == test_genotype->GetAncestorID(3) ||
+ GetAncestorID(3) == test_genotype->GetAncestorID(4) ||
+ GetAncestorID(3) == test_genotype->GetAncestorID(5) ||
+ GetAncestorID(4) == test_genotype->GetAncestorID(2) ||
+ GetAncestorID(4) == test_genotype->GetAncestorID(3) ||
+ GetAncestorID(4) == test_genotype->GetAncestorID(4) ||
+ GetAncestorID(4) == test_genotype->GetAncestorID(5) ||
+ GetAncestorID(5) == test_genotype->GetAncestorID(2) ||
+ GetAncestorID(5) == test_genotype->GetAncestorID(3) ||
+ GetAncestorID(5) == test_genotype->GetAncestorID(4) ||
+ GetAncestorID(5) == test_genotype->GetAncestorID(5)
+ ) {
+ return 4;
+ }
+
+ return 5;
+}
+
+
+int cGenotype::AddOrganism()
+{
+ total_organisms++;
+ return num_organisms++;
+}
+
+int cGenotype::RemoveOrganism()
+{
+ birth_data.death_track.Inc();
+ return num_organisms--;
+}
+
Copied: trunk/source/main/cGenotype.h (from rev 313, trunk/source/main/genotype.hh)
===================================================================
--- trunk/source/main/genotype.hh 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cGenotype.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,249 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 GENOTYPE_HH
+#define GENOTYPE_HH
+
+#include <fstream>
+
+#ifndef DOUBLE_SUM_HH
+#include "double_sum.hh"
+#endif
+#ifndef GENOME_HH
+#include "cGenome.h"
+#endif
+#ifndef GENOTYPE_BIRTH_DATA_HH
+#include "cGenotype_BirthData.h"
+#endif
+#ifndef GENOTYPE_TEST_DATA_HH
+#include "cGenotype_TestData.h"
+#endif
+#ifndef STRING_HH
+#include "string.hh"
+#endif
+
+class cSpecies;
+class cMerit;
+
+class cGenotype {
+private:
+ cGenome genome;
+ cString name;
+ bool flag_threshold;
+ bool is_active; // Is this genotype still alive?
+ int defer_adjust; // Don't adjust in the genebank until all are cleared.
+
+ int id_num;
+ char symbol;
+
+ mutable cGenotype_TestData test_data;
+ cGenotype_BirthData birth_data;
+
+ // Statistical info
+
+ int num_organisms;
+ int last_num_organisms;
+ int total_organisms;
+ int total_parasites;
+
+ cSpecies * species;
+
+ // Data Structure stuff...
+ cGenotype * next;
+ cGenotype * prev;
+
+
+ ////// Statistical info //////
+
+ // Collected on Divides
+ cDoubleSum sum_copied_size;
+ cDoubleSum sum_exe_size;
+
+ cDoubleSum sum_gestation_time;
+ cDoubleSum sum_repro_rate; // should make gestation obsolete (not new)
+
+ cDoubleSum sum_merit;
+ cDoubleSum sum_fitness;
+
+ // Temporary (Approx stats used before any divides done)
+ // Set in "SetParent"
+ cDoubleSum tmp_sum_copied_size;
+ cDoubleSum tmp_sum_exe_size;
+
+ cDoubleSum tmp_sum_gestation_time;
+ cDoubleSum tmp_sum_repro_rate;
+
+ cDoubleSum tmp_sum_merit;
+ cDoubleSum tmp_sum_fitness;
+
+ void CalcTestStats() const;
+public:
+ /**
+ * Constructs an empty genotype. Normally, in_id should not specified as
+ * parameter, because cGenotype keeps track of the last id given out, and
+ * choses a new one based on that. However, in some cases it is necessary
+ * to specify an id (e.g., when loading a history file from disk). Note
+ * that in this case, cGenotype does not check if the id has already been
+ * used before.
+ **/
+ cGenotype(int in_update_born = 0, int in_id = -1);
+ ~cGenotype();
+
+ bool SaveClone(std::ofstream & fp);
+ bool LoadClone(std::ifstream & fp);
+ bool OK();
+ void Mutate();
+ void UpdateReset();
+
+ void SetGenome(const cGenome & in_genome);
+ void SetSpecies(cSpecies * in_species);
+
+ // Test CPU info -- only used with limited options on.
+ bool GetTestViable() const;
+ double GetTestFitness() const;
+ double GetTestMerit() const;
+ int GetTestGestationTime() const;
+ int GetTestExecutedSize() const;
+ int GetTestCopiedSize() const;
+ double GetTestColonyFitness() const;
+ int GetTestGenerations() const;
+
+ void SetParent(cGenotype * parent, cGenotype * parent2);
+ void SetName(cString in_name) { name = in_name; }
+ void SetNext(cGenotype * in_next) { next = in_next; }
+ void SetPrev(cGenotype * in_prev) { prev = in_prev; }
+ void SetSymbol(char in_symbol) { symbol = in_symbol; }
+ inline void SetThreshold();
+ void IncDeferAdjust() { defer_adjust++; }
+ void DecDeferAdjust() { defer_adjust--; assert(defer_adjust >= 0); }
+ void SetLineageLabel(int in_label) { birth_data.lineage_label = in_label; }
+
+ // Setting New Stats
+ void AddCopiedSize (int in) { sum_copied_size.Add(in); }
+ void AddExecutedSize (int in) { sum_exe_size.Add(in); }
+ void AddGestationTime (int in) { sum_gestation_time.Add(in);
+ sum_repro_rate.Add(1/(double)in); }
+ void AddMerit (const cMerit & in);
+ void RemoveMerit (const cMerit & in);
+ void AddFitness (double in){
+ assert(in >= 0.0);
+ sum_fitness.Add(in);
+ }
+ void RemoveFitness (double in){
+ assert(in >= 0.0);
+ sum_fitness.Subtract(in);
+ }
+
+ //// Properties Native to Genotype ////
+ cGenome & GetGenome() { return genome; }
+ const cGenome & GetGenome() const { return genome; }
+ int GetLength() const { return genome.GetSize(); }
+
+ int GetBirths() const { return birth_data.birth_track.GetTotal(); }
+ int GetBreedOut() const { return birth_data.breed_out_track.GetTotal(); }
+ int GetBreedTrue() const { return birth_data.breed_true_track.GetTotal(); }
+ int GetBreedIn() const { return birth_data.breed_in_track.GetTotal(); }
+
+ int GetThisBirths() const { return birth_data.birth_track.GetCur(); }
+ int GetThisBreedOut() const { return birth_data.breed_out_track.GetCur(); }
+ int GetThisBreedTrue() const { return birth_data.breed_true_track.GetCur(); }
+ int GetThisBreedIn() const { return birth_data.breed_in_track.GetCur(); }
+
+ int GetThisDeaths() const { return birth_data.death_track.GetCur(); }
+
+ int GetLastNumOrganisms() const { return last_num_organisms; }
+ int GetLastBirths() const { return birth_data.birth_track.GetLast(); }
+ int GetLastBreedOut() const { return birth_data.breed_out_track.GetLast(); }
+ int GetLastBreedTrue() const { return birth_data.breed_true_track.GetLast();}
+ int GetLastBreedIn() const { return birth_data.breed_in_track.GetLast(); }
+
+ inline void SetBreedStats(cGenotype & daughter); // called by ActivateChild
+
+ //// Properties Averaged Over Creatues ////
+ double GetCopiedSize() const { return (sum_copied_size.Count()>0) ?
+ sum_copied_size.Average() : tmp_sum_copied_size.Average(); }
+ double GetExecutedSize() const { return (sum_exe_size.Count()>0) ?
+ sum_exe_size.Average() : tmp_sum_exe_size.Average(); }
+ double GetGestationTime() const { return (sum_gestation_time.Count()>0) ?
+ sum_gestation_time.Average() : tmp_sum_gestation_time.Average(); }
+ double GetReproRate() const { return (sum_repro_rate.Count()>0) ?
+ sum_repro_rate.Average() : tmp_sum_repro_rate.Average(); }
+ double GetMerit() const { return (sum_merit.Count()>0) ?
+ sum_merit.Average() : tmp_sum_merit.Average(); }
+ double GetFitness() const { return (sum_fitness.Count()>0) ?
+ sum_fitness.Average() : tmp_sum_fitness.Average(); }
+
+
+ // For tracking the genotype line back to the ancestor...
+ cGenotype * GetParentGenotype() { return birth_data.parent_genotype; }
+ cGenotype * GetParent2Genotype() { return birth_data.parent2_genotype; }
+ int GetNumOffspringGenotypes() const
+ { return birth_data.num_offspring_genotypes; }
+ void AddOffspringGenotype() { birth_data.num_offspring_genotypes++; }
+ void RemoveOffspringGenotype() { birth_data.num_offspring_genotypes--; }
+ bool GetActive() const { return is_active; }
+ bool GetDeferAdjust() const { return defer_adjust > 0; }
+ int GetUpdateDeactivated() { return birth_data.update_deactivated; }
+ void Deactivate(int update);
+
+ int GetUpdateBorn() const { return birth_data.update_born; }
+ int GetParentID() const { return birth_data.ancestor_ids[0]; }
+ int GetAncestorID(int anc) const { return birth_data.ancestor_ids[anc]; }
+ int GetParentDistance() const { return birth_data.parent_distance; }
+ int GetDepth() const { return birth_data.gene_depth; }
+ int GetLineageLabel() const { return birth_data.lineage_label; }
+ cString & GetName() { return name; }
+ cSpecies * GetSpecies() { return species; }
+ cSpecies * GetParentSpecies() { return birth_data.parent_species; }
+ cGenotype * GetNext() { return next; }
+ cGenotype * GetPrev() { return prev; }
+ bool GetThreshold() const { return flag_threshold; }
+ int GetID() const { return id_num; }
+ char GetSymbol() const { return symbol; }
+
+ // Calculate a crude phylogentic distance based off of tracking parents
+ // and grand-parents, including sexual tracking.
+ int GetPhyloDistance(cGenotype * test_genotype);
+
+ int AddOrganism();
+ int RemoveOrganism();
+ int AddParasite() { return ++total_parasites; }
+ void SwapOrganism() { total_organisms++; }
+ int GetNumOrganisms() { return num_organisms; }
+ int GetTotalOrganisms() { return total_organisms; }
+ int GetTotalParasites() { return total_parasites; }
+};
+
+// The genotype pointer template...
+
+
+
+// All the inline stuff...
+
+ ////////////////
+ // cGenotype //
+////////////////
+
+inline void cGenotype::SetThreshold()
+{
+ flag_threshold = true;
+ if (symbol == '.') symbol = '+';
+}
+
+
+inline void cGenotype::SetBreedStats(cGenotype & daughter)
+{
+ birth_data.birth_track.Inc();
+ if (daughter.id_num == id_num) {
+ birth_data.breed_true_track.Inc();
+ } else {
+ birth_data.breed_out_track.Inc();
+ daughter.birth_data.breed_in_track.Inc();
+ }
+}
+
+#endif
Copied: trunk/source/main/cGenotypeControl.cc (from rev 313, trunk/source/main/genotype_control.cc)
===================================================================
--- trunk/source/main/genotype_control.cc 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cGenotypeControl.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,288 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 GENOTYPE_CONTROL_HH
+#include "cGenotypeControl.h"
+#endif
+
+#ifndef DEFS_HH
+#include "defs.hh"
+#endif
+#ifndef GENEBANK_HH
+#include "cGenebank.h"
+#endif
+#ifndef GENOTYPE_HH
+#include "cGenotype.h"
+#endif
+
+///////////////////////
+// cGenotypeControl
+///////////////////////
+
+cGenotypeControl::cGenotypeControl(cGenebank & in_gb) : genebank(in_gb)
+{
+ size = 0;
+ best = NULL;
+ coalescent = NULL;
+ for (int i = 0; i < GENOTYPE_THREADS; i++) threads[i] = NULL;
+
+ historic_list = NULL;
+ historic_count = 0;
+}
+
+cGenotypeControl::~cGenotypeControl()
+{
+}
+
+bool cGenotypeControl::OK()
+{
+ int ret_value = true;
+
+ // Cycle through the list, making sure all connections are proper, size
+ // is correct, and all genotypes are OK().
+
+ cGenotype * cur_pos = best;
+ for (int i = 0; i < size; i++) {
+ if (!cur_pos->OK()) ret_value = false;
+ assert (cur_pos->GetNext()->GetPrev() == cur_pos);
+ cur_pos = cur_pos->GetNext();
+ }
+
+ assert (cur_pos == best);
+
+ return ret_value;
+}
+
+void cGenotypeControl::Insert(cGenotype & in_genotype, cGenotype * prev_genotype)
+{
+ if (prev_genotype == NULL) {
+ assert(size == 0); // Destroying a full genotype queue...
+
+ best = &in_genotype;
+ best->SetNext(best);
+ best->SetPrev(best);
+ }
+ else {
+ in_genotype.SetPrev(prev_genotype);
+ in_genotype.SetNext(prev_genotype->GetNext());
+ prev_genotype->SetNext(&in_genotype);
+ in_genotype.GetNext()->SetPrev(&in_genotype);
+ }
+
+ size++;
+}
+
+void cGenotypeControl::Remove(cGenotype & in_genotype)
+{
+ if (size == 1) {
+ best = NULL;
+ }
+ if (&in_genotype == best) {
+ best = best->GetNext();
+ }
+
+ in_genotype.GetNext()->SetPrev(in_genotype.GetPrev());
+ in_genotype.GetPrev()->SetNext(in_genotype.GetNext());
+ in_genotype.SetNext(NULL);
+ in_genotype.SetPrev(NULL);
+
+ size--;
+}
+
+void cGenotypeControl::RemoveHistoric(cGenotype & in_genotype)
+{
+ if (historic_count == 1) {
+ historic_list = NULL;
+ }
+ if (&in_genotype == historic_list) {
+ historic_list = historic_list->GetNext();
+ }
+
+ in_genotype.GetNext()->SetPrev(in_genotype.GetPrev());
+ in_genotype.GetPrev()->SetNext(in_genotype.GetNext());
+ in_genotype.SetNext(NULL);
+ in_genotype.SetPrev(NULL);
+
+ historic_count--;
+}
+
+void cGenotypeControl::InsertHistoric(cGenotype & in_genotype)
+{
+ if (historic_count == 0) {
+ in_genotype.SetNext(&in_genotype);
+ in_genotype.SetPrev(&in_genotype);
+ }
+ else {
+ in_genotype.SetPrev(historic_list->GetPrev());
+ in_genotype.SetNext(historic_list);
+ historic_list->GetPrev()->SetNext(&in_genotype);
+ historic_list->SetPrev(&in_genotype);
+ }
+
+ historic_list = &in_genotype;
+ historic_count++;
+}
+
+
+int cGenotypeControl::UpdateCoalescent()
+{
+ // Test to see if any updating needs to be done...
+ // Don't update active coalescent genotype, or if there is more than
+ // one offspring.
+ if (coalescent != NULL &&
+ (coalescent->GetNumOrganisms() > 0 ||
+ coalescent->GetNumOffspringGenotypes() > 1)) {
+ return coalescent->GetDepth();
+ }
+
+ // If there is no best, there is nothing to search through...
+ if (best == NULL) return -1;
+
+ // Find the new point...
+ cGenotype * test_gen = best;
+ cGenotype * found_gen = best;
+ cGenotype * parent_gen = best->GetParentGenotype();
+
+ while (parent_gen != NULL) {
+ // See if this genotype should be the new found genotype...
+ if (test_gen->GetNumOrganisms() > 0 ||
+ test_gen->GetNumOffspringGenotypes() > 1) {
+ found_gen = test_gen;
+ }
+
+ // Move to the next genotype...
+ test_gen = parent_gen;
+ parent_gen = test_gen->GetParentGenotype();
+ }
+
+ coalescent = found_gen;
+
+ return coalescent->GetDepth();
+}
+
+
+bool cGenotypeControl::CheckPos(cGenotype & in_genotype)
+{
+ int next_OK = false;
+ int prev_OK = false;
+
+ if (in_genotype.GetNumOrganisms() >= in_genotype.GetNext()->GetNumOrganisms()) {
+ next_OK =true;
+ }
+ if (in_genotype.GetNumOrganisms() <= in_genotype.GetPrev()->GetNumOrganisms()) {
+ prev_OK =true;
+ }
+
+ if ( (next_OK && prev_OK) ||
+ (&in_genotype == best && next_OK) ||
+ (&in_genotype == best->GetPrev() && prev_OK)) {
+ return true;
+ }
+
+ return false;
+}
+
+void cGenotypeControl::Insert(cGenotype & new_genotype)
+{
+ // If there is nothing in the list, add this.
+
+ if (size == 0) {
+ Insert(new_genotype, NULL);
+ }
+
+ // Otherwise tack it on the end.
+
+ else {
+ Insert(new_genotype, best->GetPrev());
+ }
+}
+
+bool cGenotypeControl::Adjust(cGenotype & in_genotype)
+{
+ cGenotype * cur_genotype = in_genotype.GetPrev();
+
+ // Check to see if this genotype should be removed completely.
+
+ if (in_genotype.GetNumOrganisms() == 0 &&
+ in_genotype.GetDeferAdjust() == false) {
+ genebank.RemoveGenotype(in_genotype);
+ return false;
+ }
+
+ // Do not adjust the position of this genotype if it was and still is the
+ // best genotype, or if it is otherwise in the proper spot...
+
+ if (CheckPos(in_genotype)) {
+ return true;
+ }
+
+ // Otherwise, remove it from the queue (for just the moment).
+
+ Remove(in_genotype);
+
+ // If this genotype is the best, put it there.
+
+ if (in_genotype.GetNumOrganisms() > best->GetNumOrganisms()) {
+ Insert(in_genotype, best->GetPrev());
+ best = &in_genotype;
+ return true;
+ }
+
+ // Finally, find out where this genotype *does* go.
+
+ while (cur_genotype->GetNumOrganisms() >= in_genotype.GetNumOrganisms() &&
+ cur_genotype != best->GetPrev()) {
+ cur_genotype = cur_genotype->GetNext();
+ }
+ while (cur_genotype->GetNumOrganisms() < in_genotype.GetNumOrganisms() &&
+ cur_genotype != best) {
+ cur_genotype = cur_genotype->GetPrev();
+ }
+
+ Insert(in_genotype, cur_genotype);
+
+ return true;
+}
+
+
+cGenotype * cGenotypeControl::Find(const cGenome & in_genome) const
+{
+ int i;
+ cGenotype * cur_genotype = best;
+
+ for (i = 0; i < size; i++) {
+ if (in_genome == cur_genotype->GetGenome()) {
+ return cur_genotype;
+ }
+ cur_genotype = cur_genotype->GetNext();
+ }
+
+ return NULL;
+}
+
+int cGenotypeControl::FindPos(cGenotype & in_genotype, int max_depth)
+{
+ cGenotype * temp_genotype = best;
+ if (max_depth < 0 || max_depth > size) max_depth = size;
+
+ for (int i = 0; i < max_depth; i++) {
+ if (temp_genotype == &in_genotype) return i;
+ temp_genotype = temp_genotype->GetNext();
+ }
+
+ return -1;
+}
+
+cGenotype * cGenotypeControl::Next(int thread)
+{
+ return threads[thread] = threads[thread]->GetNext();
+}
+
+cGenotype * cGenotypeControl::Prev(int thread)
+{
+ return threads[thread] = threads[thread]->GetPrev();
+}
Copied: trunk/source/main/cGenotypeControl.h (from rev 313, trunk/source/main/genotype_control.hh)
Copied: trunk/source/main/cGenotype_BirthData.cc (from rev 313, trunk/source/main/genotype_birth_data.cc)
===================================================================
--- trunk/source/main/genotype_birth_data.cc 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cGenotype_BirthData.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,37 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 GENOTYPE_BIRTH_DATA_HH
+#include "cGenotype_BirthData.h"
+#endif
+
+#ifndef DEFS_HH
+#include "defs.hh"
+#endif
+
+/////////////////////////
+// cGenotype_BirthData
+/////////////////////////
+
+cGenotype_BirthData::cGenotype_BirthData(int in_update_born)
+ : update_born(in_update_born)
+ , parent_distance(-1)
+ , gene_depth(0)
+ , update_deactivated(-1)
+ , parent_genotype(NULL)
+ , parent_species(NULL)
+ , num_offspring_genotypes(0)
+{
+ // @CAO: we should do a test to see if we have a sexual population. For now
+ // we will assume we do.
+ ancestor_ids.Resize(6);
+ ancestor_ids.SetAll(-1);
+}
+
+cGenotype_BirthData::~cGenotype_BirthData()
+{
+}
Copied: trunk/source/main/cGenotype_BirthData.h (from rev 313, trunk/source/main/genotype_birth_data.hh)
Copied: trunk/source/main/cGenotype_TestData.cc (from rev 313, trunk/source/main/genotype_test_data.cc)
===================================================================
--- trunk/source/main/genotype_test_data.cc 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cGenotype_TestData.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,23 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 GENOTYPE_TEST_DATA_HH
+#include "cGenotype_TestData.h"
+#endif
+
+////////////////////////
+// cGenotype_TestData
+////////////////////////
+
+cGenotype_TestData::cGenotype_TestData()
+ : fitness(-1)
+{
+}
+
+cGenotype_TestData::~cGenotype_TestData()
+{
+}
Copied: trunk/source/main/cGenotype_TestData.h (from rev 313, trunk/source/main/genotype_test_data.hh)
Copied: trunk/source/main/cInjectGenebank.cc (from rev 314, trunk/source/main/inject_genebank.cc)
===================================================================
--- trunk/source/main/inject_genebank.cc 2005-09-16 02:10:20 UTC (rev 314)
+++ trunk/source/main/cInjectGenebank.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,355 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 INJECT_GENEBANK_HH
+#include "cInjectGenebank.h"
+#endif
+
+#ifndef CONFIG_HH
+#include "cConfig.h"
+#endif
+#ifndef DATA_FILE_HH
+#include "data_file.hh"
+#endif
+#ifndef GENOME_HH
+#include "cGenome.h"
+#endif
+#ifndef INJECT_GENOTYPE_HH
+#include "cInjectGenotype.h"
+#endif
+#ifndef STATS_HH
+#include "stats.hh"
+#endif
+#ifndef TEST_UTIL_HH
+#include "cTestUtil.h"
+#endif
+
+using namespace std;
+
+////////////////////
+// cInjectGenebank
+////////////////////
+
+cInjectGenebank::cInjectGenebank(cStats & in_stats)
+ : stats(in_stats)
+{
+ for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
+ inject_genotype_count[i] = 0;
+ }
+
+ inject_genotype_control = new cInjectGenotypeControl(*this);
+
+}
+
+cInjectGenebank::~cInjectGenebank()
+{
+ delete inject_genotype_control;
+}
+
+void cInjectGenebank::UpdateReset()
+{
+ static int genotype_dom_time = 0;
+ static int prev_dom = -1;
+
+ cInjectGenotype * best_inject_genotype = GetBestInjectGenotype();
+
+ if (best_inject_genotype && best_inject_genotype->GetID() != prev_dom) {
+ genotype_dom_time = 0;
+ prev_dom = best_inject_genotype->GetID();
+ }
+ else {
+ genotype_dom_time++;
+ if (genotype_dom_time == cConfig::GetGenotypePrintDom()) {
+ cString filename;
+ filename.Set("genebank/%s", best_inject_genotype->GetName()());
+ cTestUtil::PrintGenome(best_inject_genotype, best_inject_genotype->GetGenome(),
+ filename, stats.GetUpdate());
+ }
+ }
+}
+
+cString cInjectGenebank::GetLabel(int in_size, int in_num)
+{
+ char alpha[6];
+ char full_name[12];
+ int i;
+
+ for (i = 4; i >= 0; i--) {
+ alpha[i] = (in_num % 26) + 'a';
+ in_num /= 26;
+ }
+ alpha[5] = '\0';
+
+ sprintf(full_name, "p%03d-%s", in_size, alpha);
+
+ return full_name;
+}
+
+void cInjectGenebank::AddInjectGenotype(cInjectGenotype * in_inject_genotype, int in_list_num)
+{
+ assert( in_inject_genotype != 0 );
+
+ if ( in_list_num < 0 )
+ in_list_num = FindCRC(in_inject_genotype->GetGenome()) % INJECTGENOTYPE_HASH_SIZE;
+
+ active_inject_genotypes[in_list_num].Insert(*in_inject_genotype);
+ inject_genotype_control->Insert(*in_inject_genotype);
+ //stats.AddGenotype(in_inject_genotype->GetID());
+}
+
+
+cInjectGenotype * cInjectGenebank::AddInjectGenotype(const cGenome & in_genome,
+ cInjectGenotype * parent_genotype)
+{
+ int list_num = FindCRC(in_genome) % INJECTGENOTYPE_HASH_SIZE;
+ cInjectGenotype * found_genotype;
+
+ found_genotype = active_inject_genotypes[list_num].Find(in_genome);
+
+ if (!found_genotype) {
+ found_genotype = new cInjectGenotype(stats.GetUpdate());
+ found_genotype->SetGenome(in_genome);
+ found_genotype->SetParent(parent_genotype);
+ if(parent_genotype!=NULL)
+ {
+ parent_genotype->SetCanReproduce();
+ }
+ AddInjectGenotype( found_genotype, list_num );
+ }
+ return found_genotype;
+}
+
+cInjectGenotype * cInjectGenebank::FindInjectGenotype(const cGenome & in_genome) const
+{
+ int list_num = FindCRC(in_genome) % INJECTGENOTYPE_HASH_SIZE;
+ return active_inject_genotypes[list_num].Find(in_genome);
+}
+
+void cInjectGenebank::RemoveInjectGenotype(cInjectGenotype & in_inject_genotype)
+{
+ // If this genotype is still active, mark it no longer active and
+ // take it out of the hash table so it doesn't have any new organisms
+ // assigned to it.
+
+ if (in_inject_genotype.GetActive() == true) {
+ int list_num = FindCRC(in_inject_genotype.GetGenome()) % INJECTGENOTYPE_HASH_SIZE;
+ active_inject_genotypes[list_num].Remove(in_inject_genotype);
+ inject_genotype_control->Remove(in_inject_genotype);
+ //in_inject_genotype.Deactivate(stats.GetUpdate());
+ if (cConfig::GetTrackMainLineage()) {
+ inject_genotype_control->InsertHistoric(in_inject_genotype);
+ }
+ }
+
+ // If we are tracking the main lineage, we only want to delete a
+ // genotype when all of its decendents have also died out.
+
+ /*if (cConfig::GetTrackMainLineage()) {
+ // If there are more offspring genotypes, hold off on deletion...
+ if (in_inject_genotype.GetNumOffspringGenotypes() != 0) return;
+
+ // If this is a dead end, delete it and recurse up...
+ cInjectGenotype * parent = in_inject_genotype.GetParentGenotype();
+ if (parent != NULL) {
+ parent->RemoveOffspringGenotype();
+
+ // Test to see if we need to update the coalescent genotype.
+ const int new_coal = inject_genotype_control->UpdateCoalescent();
+ stats.SetCoalescentGenotypeDepth(new_coal);
+ // cout << "Set coalescent to " << found_gen->GetDepth() << endl;
+
+ if (parent->GetNumInjected() == 0) {
+ // Regardless, run RemoveGenotype on the parent.
+ RemoveGenotype(*parent);
+ }
+ }
+
+ inject_genotype_control->RemoveHistoric(in_inject_genotype);
+ }
+
+ // Handle the relevent statistics...
+ stats.RemoveGenotype(in_inject_genotype.GetID(),
+ in_inject_genotype.GetParentID(), in_inject_genotype.GetParentDistance(),
+ in_inject_genotype.GetDepth(), in_inject_genotype.GetTotalOrganisms(),
+ in_inject_genotype.GetTotalParasites(),
+ stats.GetUpdate() - in_inject_genotype.GetUpdateBorn(),
+ in_inject_genotype.GetLength());
+ if (in_inject_genotype.GetThreshold()) {
+ stats.RemoveThreshold(in_inject_genotype.GetID());
+ }*/
+
+ delete &in_inject_genotype;
+}
+
+void cInjectGenebank::ThresholdInjectGenotype(cInjectGenotype & in_inject_genotype)
+{
+ in_inject_genotype.SetName( GetLabel(in_inject_genotype.GetLength(),
+ inject_genotype_count[in_inject_genotype.GetLength()]++) );
+ in_inject_genotype.SetThreshold();
+
+ //stats.AddThreshold(in_inject_genotype.GetID(), in_inject_genotype.GetName()());
+
+ // Print the genotype?
+
+ if (cConfig::GetGenotypePrint()) {
+ cString filename;
+ filename.Set("genebank/%s", in_inject_genotype.GetName()());
+ //cTestUtil::PrintGenome(in_inject_genotype.GetGenome(), filename,
+ // &in_inject_genotype, stats.GetUpdate());
+ }
+}
+
+bool cInjectGenebank::AdjustInjectGenotype(cInjectGenotype & in_inject_genotype)
+{
+ if (!inject_genotype_control->Adjust(in_inject_genotype)) return false;
+
+ if ((in_inject_genotype.GetNumInjected() >= cConfig::GetThreshold() ||
+ &in_inject_genotype == inject_genotype_control->GetBest()) &&
+ !(in_inject_genotype.GetThreshold())) {
+ ThresholdInjectGenotype(in_inject_genotype);
+ }
+
+ return true;
+}
+
+bool cInjectGenebank::SaveClone(ofstream & fp)
+{
+ // This method just save the counts at each size-class of genotypes.
+ // The rest is reconstructable.
+
+ // Save the numbers of organisms we're up to at each size.
+ fp << MAX_CREATURE_SIZE << " ";
+ for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
+ fp << inject_genotype_count[i] << " ";
+ }
+
+ return true;
+}
+
+bool cInjectGenebank::LoadClone(ifstream & fp)
+{
+ // This method just restores the counts at each size-class of genotypes.
+ // The rest of the loading process should be handled elsewhere.
+
+ // Load the numbers of organisms we're up to at each size.
+ int max_size;
+ fp >> max_size;
+ assert (max_size <= MAX_CREATURE_SIZE); // MAX_CREATURE_SIZE too small
+ for (int i = 0; i < max_size && i < MAX_CREATURE_SIZE; i++) {
+ fp >> inject_genotype_count[i];
+ }
+
+ return true;
+}
+
+bool cInjectGenebank::DumpTextSummary(ofstream & fp)
+{
+ inject_genotype_control->Reset(0);
+ for (int i = 0; i < inject_genotype_control->GetSize(); i++) {
+ cInjectGenotype * genotype = inject_genotype_control->Get(0);
+ fp << genotype->GetGenome().AsString() << " "
+ << genotype->GetNumInjected() << " "
+ << genotype->GetID() << endl;
+ inject_genotype_control->Next(0);
+ }
+
+ return true;
+}
+
+bool cInjectGenebank::DumpDetailedSummary(const cString & file, int update)
+{
+ inject_genotype_control->Reset(0);
+ for (int i = 0; i < inject_genotype_control->GetSize(); i++) {
+ DumpDetailedEntry(inject_genotype_control->Get(0), file, update);
+ inject_genotype_control->Next(0);
+ }
+ return true;
+}
+
+/*bool cInjectGenebank::DumpHistoricSummary(ofstream & fp)
+{
+ inject_genotype_control->ResetHistoric(0);
+ for (int i = 0; i < inject_genotype_control->GetHistoricCount(); i++) {
+ DumpDetailedEntry(inject_genotype_control->Get(0), fp);
+ inject_genotype_control->Next(0);
+ }
+
+ return true;
+}*/
+
+void cInjectGenebank::DumpDetailedEntry(cInjectGenotype * genotype, const cString & filename, int update)
+{
+ //if(genotype->CanReproduce())
+ // {
+ cDataFile & df = stats.GetDataFile(filename);
+
+ df.WriteComment( "Avida parasite dump data" );
+ df.WriteTimeStamp();
+
+ df.Write( genotype->GetID(), "parasite genotype ID");
+ df.Write( genotype->GetName(), "parasite genotype name");
+ df.Write( genotype->GetParentID(), "parasite parent ID");
+ df.Write( genotype->GetNumInjected(), "current number of injected creatures with this genotype");
+ df.Write( genotype->GetTotalInjected(), "total number of injected creatures with this genotype");
+ df.Write( genotype->GetLength(), "genotype length");
+ df.Write( genotype->GetUpdateBorn(), "update this genotype was born");
+ df.Write( genotype->CanReproduce(), "has this genotype reproduced?");
+ df.Write( genotype->GetGenome().AsString(), "genome of this genotype");
+ df.Endl();
+ //}
+}
+
+bool cInjectGenebank::OK()
+{
+ bool ret_value = true;
+ int i;
+
+ // Check components...
+
+ if (!inject_genotype_control->OK()) {
+ ret_value = false;
+ }
+
+ // Loop through all of the reference lists for matching genotypes...
+
+ for (i = 0; i < INJECTGENOTYPE_HASH_SIZE; i++) {
+ assert (active_inject_genotypes[i].OK());
+ }
+
+ assert (ret_value == true);
+
+ return ret_value;
+}
+
+int cInjectGenebank::CountNumCreatures()
+{
+ int i;
+ int total = 0;
+
+ inject_genotype_control->Reset(0);
+ for (i = 0; i < inject_genotype_control->GetSize(); i++) {
+ total += inject_genotype_control->Get(0)->GetNumInjected();
+ inject_genotype_control->Next(0);
+ }
+
+ return total;
+}
+
+
+unsigned int cInjectGenebank::FindCRC(const cGenome & in_genome) const
+{
+ unsigned int total = 13;
+ int i;
+
+ for (i = 0; i < in_genome.GetSize(); i++) {
+ total *= in_genome[i].GetOp() + 10 + i << 6;
+ total += 3;
+ }
+
+ return total;
+}
+
Copied: trunk/source/main/cInjectGenebank.h (from rev 313, trunk/source/main/inject_genebank.hh)
===================================================================
--- trunk/source/main/inject_genebank.hh 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cInjectGenebank.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,103 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 INJECT_GENEBANK_HH
+#define INJECT_GENEBANK_HH
+
+#include <fstream>
+
+#ifndef DEFS_HH
+#include "defs.hh"
+#endif
+#ifndef INJECT_GENEBANK_MACROS_HH
+#include "inject_genebank_macros.hh"
+#endif
+#ifndef INJECT_GENOTYPE_CONTROL_HH
+#include "cInjectGenotypeControl.h"
+#endif
+#ifndef INJECT_GENOTYPE_QUEUE_HH
+#include "cInjectGenotypeQueue.h"
+#endif
+#ifndef STRING_HH
+#include "string.hh"
+#endif
+
+class cGenome;
+class cStats;
+class cInjectGenotype;
+class cInjectGenotypeQueue; // array
+class cInjectGenotypeControl; // access
+class cStats;
+class cString; // aggregate
+class cInjectGenotype;
+class cGenome;
+
+class cInjectGenebank {
+private:
+ unsigned int inject_genotype_count[MAX_CREATURE_SIZE];
+ cInjectGenotypeQueue active_inject_genotypes[INJECTGENOTYPE_HASH_SIZE];
+ cInjectGenotypeControl * inject_genotype_control;
+ cStats & stats;
+
+private:
+ cString GetLabel(int in_size, int in_num);
+
+public:
+ cInjectGenebank(cStats & stats);
+ ~cInjectGenebank();
+
+ void UpdateReset();
+
+ /**
+ * This function can be used to add a injectgenotype that was created
+ * outside the genebank. In this case, the parameter in_list_num
+ * should not be given. Normally, injectgenotypes are added through the
+ * function AddInjectGenotype(const cGenome & in_genome,
+ * cInjectGenotype * parent_injectgenotype = NULL), which then calls this one.
+ **/
+ void AddInjectGenotype(cInjectGenotype *in_inject_genotype, int in_list_num = -1 );
+ cInjectGenotype * AddInjectGenotype(const cGenome & in_genome,
+ cInjectGenotype * parent_inject_genotype = NULL);
+ cInjectGenotype * FindInjectGenotype(const cGenome & in_genome) const;
+ void RemoveInjectGenotype(cInjectGenotype & in_inject_genotype);
+ void ThresholdInjectGenotype(cInjectGenotype & in_inject_genotype);
+ bool AdjustInjectGenotype(cInjectGenotype & in_inject_genotype);
+
+ bool SaveClone(std::ofstream & fp);
+ bool LoadClone(std::ifstream & fp);
+ bool DumpTextSummary(std::ofstream & fp);
+ //bool DumpDetailedSummary(std::ofstream & fp);
+ bool DumpDetailedSummary(const cString & file, int update);
+ /*
+ bool DumpHistoricSummary(std::ofstream & fp);
+ */
+ //void DumpDetailedEntry(cInjectGenotype * inject_genotype, std::ofstream & fp);
+ void DumpDetailedEntry(cInjectGenotype * inject_genotype, const cString & file, int update);
+ bool OK();
+
+ inline int GetSize() const { return inject_genotype_control->GetSize(); }
+ inline cInjectGenotype * GetBestInjectGenotype() const
+ { return inject_genotype_control->GetBest(); }
+ inline cInjectGenotype * GetCoalescentInjectGenotype() const
+ { return inject_genotype_control->GetCoalescent(); }
+
+ inline cInjectGenotype * GetInjectGenotype(int thread) const
+ { return inject_genotype_control->Get(thread); }
+ inline cInjectGenotype * NextInjectGenotype(int thread) {
+ cInjectGenotype * next = inject_genotype_control->Next(thread);
+ return (next == inject_genotype_control->GetBest()) ? (cInjectGenotype*)NULL : next;
+ }
+ inline cInjectGenotype * ResetThread(int thread)
+ { return inject_genotype_control->Reset(thread); }
+
+ int CountNumCreatures();
+ inline int FindPos(cInjectGenotype & in_inject_genotype, int max_depth = -1)
+ { return inject_genotype_control->FindPos(in_inject_genotype, max_depth); }
+ unsigned int FindCRC(const cGenome & in_genome) const;
+};
+
+#endif
Copied: trunk/source/main/cInjectGenotype.cc (from rev 314, trunk/source/main/inject_genotype.cc)
===================================================================
--- trunk/source/main/inject_genotype.cc 2005-09-16 02:10:20 UTC (rev 314)
+++ trunk/source/main/cInjectGenotype.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,162 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 INJECT_GENOTYPE_HH
+#include "cInjectGenotype.h"
+#endif
+
+#ifndef CONFIG_HH
+#include "cConfig.h"
+#endif
+#ifndef TOOLS_HH
+#include "tools.hh"
+#endif
+
+using namespace std;
+
+
+
+///////////////////////////
+// cInjectGenotype
+///////////////////////////
+
+cInjectGenotype::cInjectGenotype(int in_update_born, int in_id)
+ : genome(1)
+ , name("p001-no_name")
+ , flag_threshold(false)
+ , is_active(true)
+ , can_reproduce(false)
+ , defer_adjust(0)
+ , symbol(0)
+ , birth_data(in_update_born)
+ , num_injected(0)
+ , last_num_injected(0)
+ , total_injected(0)
+ , next(NULL)
+ , prev(NULL)
+{
+ static int next_id = 1;
+
+ if ( in_id >= 0 )
+ next_id = in_id;
+
+ id_num = next_id++;
+}
+
+cInjectGenotype::~cInjectGenotype()
+{
+ // Reset some of the variables to make sure program will crash if a deleted
+ // cell is read!
+ symbol = '!';
+
+ num_injected = -1;
+ total_injected = -1;
+
+ next = NULL;
+ prev = NULL;
+}
+
+bool cInjectGenotype::SaveClone(ofstream & fp)
+{
+ fp << id_num << " ";
+ fp << genome.GetSize() << " ";
+
+ for (int i = 0; i < genome.GetSize(); i++) {
+ fp << ((int) genome[i].GetOp()) << " ";
+ }
+
+ return true;
+}
+
+bool cInjectGenotype::LoadClone(ifstream & fp)
+{
+ int genome_size = 0;
+
+ fp >> id_num;
+ fp >> genome_size;
+
+ genome = cGenome(genome_size);
+ for (int i = 0; i < genome_size; i++) {
+ cInstruction temp_inst;
+ int inst_op;
+ fp >> inst_op;
+ temp_inst.SetOp((UCHAR) inst_op);
+ genome[i] = temp_inst;
+ // @CAO add something here to load arguments for instructions.
+ }
+
+ return true;
+}
+
+bool cInjectGenotype::OK()
+{
+ bool ret_value = true;
+
+ // Check the components...
+
+ if (!genome.OK()) ret_value = false;
+
+ // And the statistics
+ assert( id_num >= 0 && num_injected >= 0 && total_injected >= 0 );
+ assert( birth_data.update_born >= -1);
+
+ return ret_value;
+}
+
+void cInjectGenotype::SetParent(cInjectGenotype * parent)
+{
+ birth_data.parent_genotype = parent;
+
+ // If we have a real parent genotype, collect other data about parent.
+ if (parent == NULL) return;
+ birth_data.parent_id = parent->GetID();
+ birth_data.gene_depth = parent->GetDepth() + 1;
+ parent->AddOffspringGenotype();
+}
+
+void cInjectGenotype::Mutate() // Check each location to be mutated.
+{
+ int i;
+
+ for (i = 0; i < genome.GetSize(); i++) {
+ genome[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
+ }
+
+}
+
+void cInjectGenotype::UpdateReset()
+{
+ last_num_injected = num_injected;
+ birth_data.birth_track.Next();
+ birth_data.death_track.Next();
+}
+
+void cInjectGenotype::SetGenome(const cGenome & in_genome)
+{
+ genome = in_genome;
+
+ name.Set("p%03d-no_name", genome.GetSize());
+}
+
+void cInjectGenotype::Deactivate(int update)
+{
+ is_active = false;
+ birth_data.update_deactivated = update;
+}
+
+int cInjectGenotype::AddParasite()
+{
+ total_injected++;
+ return num_injected++;
+}
+
+int cInjectGenotype::RemoveParasite()
+{
+ //birth_data.death_track.Inc();
+ return num_injected--;
+}
+
Copied: trunk/source/main/cInjectGenotype.h (from rev 313, trunk/source/main/inject_genotype.hh)
===================================================================
--- trunk/source/main/inject_genotype.hh 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cInjectGenotype.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,254 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 INJECT_GENOTYPE_HH
+#define INJECT_GENOTYPE_HH
+
+#include <fstream>
+
+#ifndef GENOME_HH
+#include "cGenome.h"
+#endif
+#ifndef INJECT_GENOTYPE_BIRTH_DATA_HH
+#include "cInjectGenotype_BirthData.h"
+#endif
+#ifndef STRING_HH
+#include "string.hh"
+#endif
+
+/*class cInjectGenotype_TestData {
+public:
+ cGenotype_TestData();
+ ~cGenotype_TestData();
+
+ bool is_viable;
+
+ double fitness;
+ double merit;
+ int gestation_time;
+ int executed_size;
+ int copied_size;
+ double colony_fitness;
+ int generations;
+ };*/
+
+class cGenome; // aggregate
+class cString; // aggregate
+class cInjectGenotype_BirthData; // aggregate
+
+class cInjectGenotype {
+private:
+ cGenome genome;
+ cString name;
+ bool flag_threshold;
+ bool is_active; // Is this genotype still alive?
+ bool can_reproduce; // Can this genotype reproduce?
+ int defer_adjust; // Don't adjust in the genebank until all are cleared.
+
+ int id_num;
+ char symbol;
+
+ //mutable cGenotype_TestData test_data;
+ cInjectGenotype_BirthData birth_data;
+
+ // Statistical info
+
+ int num_injected;
+ int last_num_injected;
+ int total_injected;
+ //int total_parasites;
+
+ //cSpecies * species;
+
+ // Data Structure stuff...
+ cInjectGenotype * next;
+ cInjectGenotype * prev;
+
+
+ ////// Statistical info //////
+
+ // Collected on Divides
+ //cDoubleSum sum_copied_size;
+ //cDoubleSum sum_exe_size;
+
+ //cDoubleSum sum_gestation_time;
+ //cDoubleSum sum_repro_rate; // should make gestation obsolete (not new)
+
+ //cDoubleSum sum_merit;
+ //cDoubleSum sum_fitness;
+
+ // Temporary (Approx stats used before any divides done)
+ // Set in "SetParent"
+ //cDoubleSum tmp_sum_copied_size;
+ //cDoubleSum tmp_sum_exe_size;
+
+ //cDoubleSum tmp_sum_gestation_time;
+ //cDoubleSum tmp_sum_repro_rate;
+
+ //cDoubleSum tmp_sum_merit;
+ //cDoubleSum tmp_sum_fitness;
+
+ void CalcTestStats() const;
+public:
+ /**
+ * Constructs an empty genotype. Normally, in_id should not specified as
+ * parameter, because cGenotype keeps track of the last id given out, and
+ * choses a new one based on that. However, in some cases it is necessary
+ * to specify an id (e.g., when loading a history file from disk). Note
+ * that in this case, cGenotype does not check if the id has already been
+ * used before.
+ **/
+ cInjectGenotype(int in_update_born = 0, int in_id = -1);
+ ~cInjectGenotype();
+
+ bool SaveClone(std::ofstream & fp);
+ bool LoadClone(std::ifstream & fp);
+ bool OK();
+ void Mutate();
+ void UpdateReset();
+
+ void SetGenome(const cGenome & in_genome);
+ //void SetSpecies(cSpecies * in_species);
+
+ // Test CPU info -- only used with limited options on.
+ //bool GetTestViable() const;
+ //double GetTestFitness() const;
+ //double GetTestMerit() const;
+ //int GetTestGestationTime() const;
+ //int GetTestExecutedSize() const;
+ //int GetTestCopiedSize() const;
+ //double GetTestColonyFitness() const;
+ //int GetTestGenerations() const;
+
+ void SetParent(cInjectGenotype * parent);
+ void SetUpdateBorn (int update) { birth_data.update_born = update; }
+ void SetName(cString in_name) { name = in_name; }
+ void SetNext(cInjectGenotype * in_next) { next = in_next; }
+ void SetPrev(cInjectGenotype * in_prev) { prev = in_prev; }
+ void SetSymbol(char in_symbol) { symbol = in_symbol; }
+ void SetCanReproduce() { can_reproduce = true; }
+ inline void SetThreshold();
+ void IncDeferAdjust() { defer_adjust++; }
+ void DecDeferAdjust() { defer_adjust--; assert(defer_adjust >= 0); }
+
+ // Setting New Stats
+ //void AddCopiedSize (int in) { sum_copied_size.Add(in); }
+ //void AddExecutedSize (int in) { sum_exe_size.Add(in); }
+ //void AddGestationTime (int in) { sum_gestation_time.Add(in);
+ // sum_repro_rate.Add(1/(double)in); }
+ //void AddMerit (const cMerit & in);
+ //void RemoveMerit (const cMerit & in);
+ //void AddFitness (double in){
+ // assert(in >= 0.0);
+ // sum_fitness.Add(in);
+ //}
+ //void RemoveFitness (double in){
+ // assert(in >= 0.0);
+ // sum_fitness.Subtract(in);
+ //}
+
+ //// Properties Native to Genotype ////
+ cGenome & GetGenome() { return genome; }
+ const cGenome & GetGenome() const { return genome; }
+ int GetLength() const { return genome.GetSize(); }
+
+ //int GetBirths() const { return birth_data.birth_track.GetTotal(); }
+ //int GetBreedOut() const { return birth_data.breed_out_track.GetTotal(); }
+ //int GetBreedTrue() const { return birth_data.breed_true_track.GetTotal(); }
+ //int GetBreedIn() const { return birth_data.breed_in_track.GetTotal(); }
+
+ //int GetThisBirths() const { return birth_data.birth_track.GetCur(); }
+ //int GetThisBreedOut() const { return birth_data.breed_out_track.GetCur(); }
+ //int GetThisBreedTrue() const { return birth_data.breed_true_track.GetCur(); }
+ //int GetThisBreedIn() const { return birth_data.breed_in_track.GetCur(); }
+
+ //int GetThisDeaths() const { return birth_data.death_track.GetCur(); }
+
+ //int GetLastNumOrganisms() const { return last_num_organisms; }
+ //int GetLastBirths() const { return birth_data.birth_track.GetLast(); }
+ //int GetLastBreedOut() const { return birth_data.breed_out_track.GetLast(); }
+ //int GetLastBreedTrue() const { return birth_data.breed_true_track.GetLast();}
+ //int GetLastBreedIn() const { return birth_data.breed_in_track.GetLast(); }
+
+ //inline void SetBreedStats(cGenotype & daughter); // called by ActivateChild
+
+ //// Properties Averaged Over Creatues ////
+ //double GetCopiedSize() const { return (sum_copied_size.Count()>0) ?
+ // sum_copied_size.Average() : tmp_sum_copied_size.Average(); }
+ //double GetExecutedSize() const { return (sum_exe_size.Count()>0) ?
+ // sum_exe_size.Average() : tmp_sum_exe_size.Average(); }
+ //double GetGestationTime() const { return (sum_gestation_time.Count()>0) ?
+ // sum_gestation_time.Average() : tmp_sum_gestation_time.Average(); }
+ //double GetReproRate() const { return (sum_repro_rate.Count()>0) ?
+ // sum_repro_rate.Average() : tmp_sum_repro_rate.Average(); }
+ //double GetMerit() const { return (sum_merit.Count()>0) ?
+ // sum_merit.Average() : tmp_sum_merit.Average(); }
+ //double GetFitness() const { return (sum_fitness.Count()>0) ?
+ // sum_fitness.Average() : tmp_sum_fitness.Average(); }
+
+
+ // For tracking the genotype line back to the ancestor...
+ cInjectGenotype * GetParentGenotype() { return birth_data.parent_genotype; }
+ int GetNumOffspringGenotypes() const
+ { return birth_data.num_offspring_genotypes; }
+ void AddOffspringGenotype() { birth_data.num_offspring_genotypes++; }
+ void RemoveOffspringGenotype() { birth_data.num_offspring_genotypes--; }
+ bool GetActive() const { return is_active; }
+ // bool GetDeferAdjust() const { return defer_adjust > 0; }
+ int GetUpdateDeactivated() { return birth_data.update_deactivated; }
+ void Deactivate(int update);
+
+ bool CanReproduce() { return can_reproduce; }
+ int GetUpdateBorn() { return birth_data.update_born; }
+ int GetParentID() { return birth_data.parent_id; }
+ //int GetParentDistance() { return birth_data.parent_distance; }
+ int GetDepth() { return birth_data.gene_depth; }
+ cString & GetName() { return name; }
+ cInjectGenotype * GetNext() { return next; }
+ cInjectGenotype * GetPrev() { return prev; }
+ bool GetThreshold() const { return flag_threshold; }
+ int GetID() const { return id_num; }
+ char GetSymbol() const { return symbol; }
+
+ int AddParasite();
+ int RemoveParasite();
+ //int AddParasite() { return ++total_parasites; }
+ //void SwapOrganism() { total_organisms++; }
+ int GetNumInjected() { return num_injected; }
+ int GetTotalInjected() { return total_injected; }
+ //int GetTotalParasites() { return total_parasites; }
+};
+
+// The genotype pointer template...
+
+
+
+// All the inline stuff...
+
+ ////////////////
+ // cGenotype //
+////////////////
+
+inline void cInjectGenotype::SetThreshold()
+{
+ flag_threshold = true;
+ if (symbol == '.') symbol = '+';
+}
+
+/*
+inline void cGenotype::SetBreedStats(cGenotype & daughter)
+{
+ birth_data.birth_track.Inc();
+ if (daughter.id_num == id_num) {
+ birth_data.breed_true_track.Inc();
+ } else {
+ birth_data.breed_out_track.Inc();
+ daughter.birth_data.breed_in_track.Inc();
+ }
+}*/
+
+#endif
Copied: trunk/source/main/cInjectGenotypeControl.cc (from rev 313, trunk/source/main/inject_genotype_control.cc)
===================================================================
--- trunk/source/main/inject_genotype_control.cc 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cInjectGenotypeControl.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,288 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 INJECT_GENOTYPE_CONTROL_HH
+#include "cInjectGenotypeControl.h"
+#endif
+
+#ifndef DEFS_HH
+#include "defs.hh"
+#endif
+#ifndef INJECT_GENEBANK_HH
+#include "cInjectGenebank.h"
+#endif
+#ifndef INJECT_GENOTYPE_HH
+#include "cInjectGenotype.h"
+#endif
+
+////////////////////////////
+// cInjectGenotypeControl
+////////////////////////////
+
+cInjectGenotypeControl::cInjectGenotypeControl(cInjectGenebank & in_gb) : genebank(in_gb)
+{
+ size = 0;
+ best = NULL;
+ coalescent = NULL;
+ for (int i = 0; i < INJECTGENOTYPE_THREADS; i++) threads[i] = NULL;
+
+ historic_list = NULL;
+ historic_count = 0;
+}
+
+cInjectGenotypeControl::~cInjectGenotypeControl()
+{
+}
+
+bool cInjectGenotypeControl::OK()
+{
+ int ret_value = true;
+
+ // Cycle through the list, making sure all connections are proper, size
+ // is correct, and all genotypes are OK().
+
+ cInjectGenotype * cur_pos = best;
+ for (int i = 0; i < size; i++) {
+ if (!cur_pos->OK()) ret_value = false;
+ assert (cur_pos->GetNext()->GetPrev() == cur_pos);
+ cur_pos = cur_pos->GetNext();
+ }
+
+ assert (cur_pos == best);
+
+ return ret_value;
+}
+
+void cInjectGenotypeControl::Insert(cInjectGenotype & in_inject_genotype, cInjectGenotype * prev_genotype)
+{
+ if (prev_genotype == NULL) {
+ assert(size == 0); // Destroying a full genotype queue...
+
+ best = &in_inject_genotype;
+ best->SetNext(best);
+ best->SetPrev(best);
+ }
+ else {
+ in_inject_genotype.SetPrev(prev_genotype);
+ in_inject_genotype.SetNext(prev_genotype->GetNext());
+ prev_genotype->SetNext(&in_inject_genotype);
+ in_inject_genotype.GetNext()->SetPrev(&in_inject_genotype);
+ }
+
+ size++;
+}
+
+void cInjectGenotypeControl::Remove(cInjectGenotype & in_inject_genotype)
+{
+ if (size == 1) {
+ best = NULL;
+ }
+ if (&in_inject_genotype == best) {
+ best = best->GetNext();
+ }
+
+ in_inject_genotype.GetNext()->SetPrev(in_inject_genotype.GetPrev());
+ in_inject_genotype.GetPrev()->SetNext(in_inject_genotype.GetNext());
+ in_inject_genotype.SetNext(NULL);
+ in_inject_genotype.SetPrev(NULL);
+
+ size--;
+}
+
+void cInjectGenotypeControl::RemoveHistoric(cInjectGenotype & in_inject_genotype)
+{
+ if (historic_count == 1) {
+ historic_list = NULL;
+ }
+ if (&in_inject_genotype == historic_list) {
+ historic_list = historic_list->GetNext();
+ }
+
+ in_inject_genotype.GetNext()->SetPrev(in_inject_genotype.GetPrev());
+ in_inject_genotype.GetPrev()->SetNext(in_inject_genotype.GetNext());
+ in_inject_genotype.SetNext(NULL);
+ in_inject_genotype.SetPrev(NULL);
+
+ historic_count--;
+}
+
+void cInjectGenotypeControl::InsertHistoric(cInjectGenotype & in_inject_genotype)
+{
+ if (historic_count == 0) {
+ in_inject_genotype.SetNext(&in_inject_genotype);
+ in_inject_genotype.SetPrev(&in_inject_genotype);
+ }
+ else {
+ in_inject_genotype.SetPrev(historic_list->GetPrev());
+ in_inject_genotype.SetNext(historic_list);
+ historic_list->GetPrev()->SetNext(&in_inject_genotype);
+ historic_list->SetPrev(&in_inject_genotype);
+ }
+
+ historic_list = &in_inject_genotype;
+ historic_count++;
+}
+
+/*int cInjectGenotypeControl::UpdateCoalescent()
+{
+ // Test to see if any updating needs to be done...
+ // Don't update active coalescent genotype, or if there is more than
+ // one offspring.
+ if (coalescent != NULL &&
+ (coalescent->GetNumInjected() > 0) ||
+ coalescent->GetNumOffspringGenotypes() > 1) ) {
+ return coalescent->GetDepth();
+ }
+
+ // If there is no best, there is nothing to search through...
+ if (best == NULL) return -1;
+
+ // Find the new point...
+ cInjectGenotype * test_gen = best;
+ cInjectGenotype * found_gen = best;
+ cInjectGenotype * parent_gen = best->GetParentGenotype();
+
+ while (parent_gen != NULL) {
+ // See if this genotype should be the new found genotype...
+ if (test_gen->GetNumOrganisms() > 0 ||
+ test_gen->GetNumOffspringGenotypes() > 1) {
+ found_gen = test_gen;
+ }
+
+ // Move to the next genotype...
+ test_gen = parent_gen;
+ parent_gen = test_gen->GetParentGenotype();
+ }
+
+ coalescent = found_gen;
+
+ return coalescent->GetDepth();
+}*/
+
+
+bool cInjectGenotypeControl::CheckPos(cInjectGenotype & in_inject_genotype)
+{
+ int next_OK = false;
+ int prev_OK = false;
+
+ if (in_inject_genotype.GetNumInjected() >= in_inject_genotype.GetNext()->GetNumInjected()) {
+ next_OK =true;
+ }
+ if (in_inject_genotype.GetNumInjected() <= in_inject_genotype.GetPrev()->GetNumInjected()) {
+ prev_OK =true;
+ }
+
+ if ((&in_inject_genotype == best && next_OK) ||
+ (next_OK && prev_OK) ||
+ (&in_inject_genotype == best->GetPrev() && prev_OK)) {
+ return true;
+ }
+
+ return false;
+}
+
+void cInjectGenotypeControl::Insert(cInjectGenotype & new_genotype)
+{
+ // If there is nothing in the list, add this.
+
+ if (size == 0) {
+ Insert(new_genotype, NULL);
+ }
+
+ // Otherwise tack it on the end.
+
+ else {
+ Insert(new_genotype, best->GetPrev());
+ }
+}
+
+bool cInjectGenotypeControl::Adjust(cInjectGenotype & in_inject_genotype)
+{
+ //if (in_inject_genotype.GetDeferAdjust() == true) return true;
+
+ cInjectGenotype * cur_inject_genotype = in_inject_genotype.GetPrev();
+
+ // Check to see if this genotype should be removed completely.
+
+ if (in_inject_genotype.GetNumInjected() == 0) {
+ genebank.RemoveInjectGenotype(in_inject_genotype);
+ return false;
+ }
+
+ // Do not adjust if this was and still is the best genotype, or is
+ // otherwise in the proper spot...
+
+ if (CheckPos(in_inject_genotype)) {
+ return true;
+ }
+
+ // Otherwise, remove it from the queue for just the moment.
+
+ Remove(in_inject_genotype);
+
+ // Also, if this genotype is the best, put it there.
+
+ if (in_inject_genotype.GetNumInjected() > best->GetNumInjected()) {
+ Insert(in_inject_genotype, best->GetPrev());
+ best = &in_inject_genotype;
+ return true;
+ }
+
+ // Finally, find out where this genotype *does* go.
+
+ while (cur_inject_genotype->GetNumInjected() >= in_inject_genotype.GetNumInjected() &&
+ cur_inject_genotype != best->GetPrev()) {
+ cur_inject_genotype = cur_inject_genotype->GetNext();
+ }
+ while (cur_inject_genotype->GetNumInjected() < in_inject_genotype.GetNumInjected() &&
+ cur_inject_genotype != best) {
+ cur_inject_genotype = cur_inject_genotype->GetPrev();
+ }
+
+ Insert(in_inject_genotype, cur_inject_genotype);
+
+ return true;
+}
+
+
+cInjectGenotype * cInjectGenotypeControl::Find(const cGenome & in_genome) const
+{
+ int i;
+ cInjectGenotype * cur_inject_genotype = best;
+
+ for (i = 0; i < size; i++) {
+ if (in_genome == cur_inject_genotype->GetGenome()) {
+ return cur_inject_genotype;
+ }
+ cur_inject_genotype = cur_inject_genotype->GetNext();
+ }
+
+ return NULL;
+}
+
+int cInjectGenotypeControl::FindPos(cInjectGenotype & in_inject_genotype, int max_depth)
+{
+ cInjectGenotype * temp_genotype = best;
+ if (max_depth < 0 || max_depth > size) max_depth = size;
+
+ for (int i = 0; i < max_depth; i++) {
+ if (temp_genotype == &in_inject_genotype) return i;
+ temp_genotype = temp_genotype->GetNext();
+ }
+
+ return -1;
+}
+
+cInjectGenotype * cInjectGenotypeControl::Next(int thread)
+{
+ return threads[thread] = threads[thread]->GetNext();
+}
+
+cInjectGenotype * cInjectGenotypeControl::Prev(int thread)
+{
+ return threads[thread] = threads[thread]->GetPrev();
+}
Copied: trunk/source/main/cInjectGenotypeControl.h (from rev 313, trunk/source/main/inject_genotype_control.hh)
Copied: trunk/source/main/cInjectGenotypeElement.h (from rev 313, trunk/source/main/inject_genotype_element.hh)
Copied: trunk/source/main/cInjectGenotypeQueue.cc (from rev 313, trunk/source/main/inject_genotype_queue.cc)
===================================================================
--- trunk/source/main/inject_genotype_queue.cc 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cInjectGenotypeQueue.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,104 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 INJECT_GENOTYPE_QUEUE_HH
+#include "cInjectGenotypeQueue.h"
+#endif
+
+#ifndef INJECT_GENOTYPE_HH
+#include "cInjectGenotype.h"
+#endif
+
+#include <assert.h>
+
+/////////////////////
+// cInjectGenotypeQueue
+/////////////////////
+
+cInjectGenotypeQueue::cInjectGenotypeQueue()
+{
+ size = 0;
+ root.SetNext(&root);
+ root.SetPrev(&root);
+}
+
+
+cInjectGenotypeQueue::~cInjectGenotypeQueue()
+{
+ while (root.GetNext() != &root) {
+ Remove(root.GetNext());
+ }
+}
+
+bool cInjectGenotypeQueue::OK()
+{
+ bool result = true;
+ int count = 0;
+
+ for (cInjectGenotypeElement * temp_element = root.GetNext();
+ temp_element != &root;
+ temp_element = temp_element->GetNext()) {
+ assert (temp_element->GetNext()->GetPrev() == temp_element);
+ assert (temp_element->GetInjectGenotype()->GetID() >= 0);
+
+ count++;
+ assert (count <= size);
+ }
+
+ assert (count == size);
+
+ return result;
+}
+
+void cInjectGenotypeQueue::Insert(cInjectGenotype & in_inject_genotype)
+{
+ cInjectGenotypeElement * new_element = new cInjectGenotypeElement(&in_inject_genotype);
+ new_element->SetNext(root.GetNext());
+ new_element->SetPrev(&root);
+ root.GetNext()->SetPrev(new_element);
+ root.SetNext(new_element);
+ size++;
+}
+
+void cInjectGenotypeQueue::Remove(cInjectGenotype & in_inject_genotype)
+{
+ cInjectGenotypeElement * cur_element;
+
+ for (cur_element = root.GetNext();
+ cur_element != &root;
+ cur_element = cur_element->GetNext()) {
+ if (cur_element->GetInjectGenotype() == &in_inject_genotype) break;
+ }
+
+ assert (cur_element != &root);
+
+ Remove(cur_element);
+}
+
+void cInjectGenotypeQueue::Remove(cInjectGenotypeElement * in_element)
+{
+ in_element->GetPrev()->SetNext(in_element->GetNext());
+ in_element->GetNext()->SetPrev(in_element->GetPrev());
+ in_element->SetNext(NULL);
+ in_element->SetPrev(NULL);
+ delete(in_element);
+
+ size--;
+}
+
+cInjectGenotype * cInjectGenotypeQueue::Find(const cGenome & in_genome) const
+{
+ for (cInjectGenotypeElement * cur_element = root.GetNext();
+ cur_element != &root;
+ cur_element = cur_element->GetNext()) {
+ if (cur_element->GetInjectGenotype()->GetGenome() == in_genome) {
+ return cur_element->GetInjectGenotype();
+ }
+ }
+
+ return NULL;
+}
Copied: trunk/source/main/cInjectGenotypeQueue.h (from rev 313, trunk/source/main/inject_genotype_queue.hh)
===================================================================
--- trunk/source/main/inject_genotype_queue.hh 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cInjectGenotypeQueue.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,34 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 INJECT_GENOTYPE_QUEUE_HH
+#define INJECT_GENOTYPE_QUEUE_HH
+
+#ifndef INJECT_GENOTYPE_ELEMENT_HH
+#include "cInjectGenotypeElement.h"
+#endif
+
+class cInjectGenotype;
+class cGenome;
+class cInjectGenotypeQueue {
+private:
+ int size;
+ cInjectGenotypeElement root;
+
+ void Remove(cInjectGenotypeElement * in_element);
+public:
+ cInjectGenotypeQueue();
+ ~cInjectGenotypeQueue();
+
+ bool OK();
+
+ void Insert(cInjectGenotype & in_inject_genotype);
+ void Remove(cInjectGenotype & in_inject_genotype);
+ cInjectGenotype * Find(const cGenome & in_genome) const;
+};
+
+#endif
Copied: trunk/source/main/cInjectGenotype_BirthData.cc (from rev 313, trunk/source/main/inject_genotype_birth_data.cc)
===================================================================
--- trunk/source/main/inject_genotype_birth_data.cc 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cInjectGenotype_BirthData.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,32 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 INJECT_GENOTYPE_BIRTH_DATA_HH
+#include "cInjectGenotype_BirthData.h"
+#endif
+
+#ifndef DEFS_HH
+#include "defs.hh"
+#endif
+
+/////////////////////////
+// cInjectGenotype_BirthData
+/////////////////////////
+
+cInjectGenotype_BirthData::cInjectGenotype_BirthData(int in_update_born)
+ : update_born(in_update_born)
+ , parent_id(-1)
+ , gene_depth(0)
+ , update_deactivated(-1)
+ , parent_genotype(NULL)
+ , num_offspring_genotypes(0)
+{
+}
+
+cInjectGenotype_BirthData::~cInjectGenotype_BirthData()
+{
+}
Copied: trunk/source/main/cInjectGenotype_BirthData.h (from rev 313, trunk/source/main/inject_genotype_birth_data.hh)
Copied: trunk/source/main/cInstLibBase.h (from rev 313, trunk/source/main/inst_lib_base.hh)
===================================================================
--- trunk/source/main/inst_lib_base.hh 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cInstLibBase.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 INST_LIB_BASE_HH
+#define INST_LIB_BASE_HH
+
+#ifndef INSTRUCTION_HH
+#include "cInstruction.h"
+#endif
+
+class cString;
+class cInstLibBase {
+public:
+ virtual ~cInstLibBase() { ; }
+ virtual const cString &GetName(const unsigned int id) = 0;
+ virtual const cString &GetNopName(const unsigned int id) = 0;
+ virtual int GetNopMod(const unsigned int id) = 0;
+ virtual int GetNopMod(const cInstruction & inst) = 0;
+ virtual int GetSize() = 0;
+ virtual int GetNumNops() = 0;
+ virtual cInstruction GetInst(const cString & in_name) = 0;
+ virtual const cInstruction & GetInstDefault() = 0;
+ virtual const cInstruction & GetInstError() = 0;
+};
+
+#endif
Copied: trunk/source/main/cInstSet.cc (from rev 313, trunk/source/main/inst_set.cc)
===================================================================
--- trunk/source/main/inst_set.cc 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cInstSet.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,148 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 INST_SET_HH
+#include "cInstSet.h"
+#endif
+
+#ifndef STRING_UTIL_HH
+#include "string_util.hh"
+#endif
+#ifndef TOOLS_HH
+#include "tools.hh"
+#endif
+
+using namespace std;
+
+//////////////////////
+// cInstSet
+//////////////////////
+
+// Initialize static variables
+const cInstruction cInstSet::inst_default( 0 );
+cInstruction cInstSet::inst_default2( 0 );
+cInstruction cInstSet::inst_error2 ( 255 );
+
+cInstSet::cInstSet()
+{
+}
+
+cInstSet::cInstSet(const cInstSet & in_inst_set)
+ : m_inst_lib(in_inst_set.m_inst_lib)
+ , m_lib_name_map(in_inst_set.m_lib_name_map)
+ , m_lib_nopmod_map(in_inst_set.m_lib_nopmod_map)
+ , mutation_chart2(in_inst_set.mutation_chart2)
+{
+}
+
+cInstSet::~cInstSet()
+{
+}
+
+cInstSet & cInstSet::operator=(const cInstSet & _in)
+{
+ m_inst_lib = _in.m_inst_lib;
+ m_lib_name_map = _in.m_lib_name_map;
+ m_lib_nopmod_map = _in.m_lib_nopmod_map;
+ mutation_chart2 = _in.mutation_chart2;
+ return *this;
+}
+
+bool cInstSet::OK() const
+{
+ assert(m_lib_name_map.GetSize() < 256);
+ assert(m_lib_nopmod_map.GetSize() < m_lib_name_map.GetSize());
+
+ // Make sure that all of the redundancies are represented the appropriate
+ // number of times.
+ tArray<int> test_redundancy2(m_lib_name_map.GetSize());
+ test_redundancy2.SetAll(0);
+ for (int i = 0; i < mutation_chart2.GetSize(); i++) {
+ int test_id = mutation_chart2[i];
+ test_redundancy2[test_id]++;
+ }
+ for (int i = 0; i < m_lib_name_map.GetSize(); i++) {
+ assert(m_lib_name_map[i].redundancy == test_redundancy2[i]);
+ }
+
+ return true;
+}
+
+cInstruction cInstSet::GetRandomInst() const
+{
+ int inst_op = mutation_chart2[g_random.GetUInt(mutation_chart2.GetSize())];
+ return cInstruction(inst_op);
+}
+
+int cInstSet::Add2(
+ const int lib_fun_id,
+ const int redundancy,
+ const int ft_cost,
+ const int cost,
+ const double prob_fail
+)
+{
+ const int inst_id = m_lib_name_map.GetSize();
+
+ assert(inst_id < 255);
+
+ // Increase the size of the array...
+ m_lib_name_map.Resize(inst_id + 1);
+
+ // Setup the new function...
+ m_lib_name_map[inst_id].lib_fun_id = lib_fun_id;
+ m_lib_name_map[inst_id].redundancy = redundancy;
+ m_lib_name_map[inst_id].cost = cost;
+ m_lib_name_map[inst_id].ft_cost = ft_cost;
+ m_lib_name_map[inst_id].prob_fail = prob_fail;
+
+ const int total_redundancy = mutation_chart2.GetSize();
+ mutation_chart2.Resize(total_redundancy + redundancy);
+ for (int i = 0; i < redundancy; i++) {
+ mutation_chart2[total_redundancy + i] = inst_id;
+ }
+
+ return inst_id;
+}
+
+int cInstSet::AddNop2(
+ const int lib_nopmod_id,
+ const int redundancy,
+ const int ft_cost,
+ const int cost,
+ const double prob_fail
+)
+{
+ // Assert nops are at the _beginning_ of an inst_set.
+ assert(m_lib_name_map.GetSize() == m_lib_nopmod_map.GetSize());
+
+ const int inst_id = Add2(lib_nopmod_id, redundancy, ft_cost, cost, prob_fail);
+
+ m_lib_nopmod_map.Resize(inst_id + 1);
+ m_lib_nopmod_map[inst_id] = lib_nopmod_id;
+
+ return inst_id;
+}
+
+cString cInstSet::FindBestMatch(const cString & in_name) const
+{
+ int best_dist = 1024;
+ cString best_name("");
+
+ for (int i = 0; i < m_lib_name_map.GetSize(); i++) {
+ const cString & cur_name = m_inst_lib->GetName(m_lib_name_map[i].lib_fun_id);
+ const int cur_dist = cStringUtil::EditDistance(cur_name, in_name);
+ if (cur_dist < best_dist) {
+ best_dist = cur_dist;
+ best_name = cur_name;
+ }
+ if (cur_dist == 0) break;
+ }
+
+ return best_name;
+}
+
Copied: trunk/source/main/cInstSet.h (from rev 313, trunk/source/main/inst_set.hh)
===================================================================
--- trunk/source/main/inst_set.hh 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cInstSet.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,198 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 INST_SET_HH
+#define INST_SET_HH
+
+#include <iostream>
+
+#ifndef STRING_HH
+#include "string.hh"
+#endif
+#ifndef TARRAY_HH
+#include "tArray.hh"
+#endif
+#ifndef INSTRUCTION_HH
+#include "cInstruction.h"
+#endif
+#ifndef INST_LIB_BASE_HH
+#include "cInstLibBase.h"
+#endif
+
+using namespace std;
+
+// A typdef to simplify having an instruction point to methods in the
+// cHardwareBase object and its dirivitives...
+class cHardwareBase;
+
+// moved to cpu/hardware_method.hh for porting to gcc 3.1 -- k
+//typedef bool (cHardwareBase::*tHardwareMethod)();
+
+class cInstLibBase;
+
+/**
+ * This class is used to create a mapping from the command strings in
+ * an organism's genome into real methods in one of the hardware objects. This
+ * object has been designed to allow easy manipulation of the instruction
+ * sets, as well as multiple instruction sets within a single soup (just
+ * attach different cInstSet objects to different hardware.
+ **/
+
+class cInstLibBase; // access
+template <class T> class tArray; // aggregate
+class cInstruction; // access
+class cString; // access
+
+class cInstSet {
+public:
+ cInstLibBase *m_inst_lib;
+ class cInstEntry2 {
+ public:
+ int lib_fun_id;
+ int redundancy; // Weight in instruction set (not impl.)
+ int cost; // additional time spent to exectute inst.
+ int ft_cost; // time spent first time exec (in add to cost)
+ double prob_fail; // probability of failing to execute inst
+ };
+ tArray<cInstEntry2> m_lib_name_map;
+ tArray<int> m_lib_nopmod_map;
+ tArray<int> mutation_chart2; // ID's represented by redundancy values.
+ // Static components...
+ static cInstruction inst_error2;
+ // static const cInstruction inst_none;
+ static cInstruction inst_default2;
+
+ // Static components...
+ //static const cInstruction inst_error;
+ // static const cInstruction inst_none;
+ static const cInstruction inst_default;
+
+public:
+ cInstSet();
+ cInstSet(const cInstSet & in_inst_set);
+ ~cInstSet();
+
+ cInstSet & operator=(const cInstSet & _in);
+
+ bool OK() const;
+
+ // Accessors
+ const cString & GetName(int id) const
+ {
+ return m_inst_lib->GetName(m_lib_name_map[id].lib_fun_id);
+ }
+ const cString & GetName(const cInstruction & inst) const
+ {
+ return GetName(inst.GetOp());
+ }
+ int GetCost(const cInstruction & inst) const
+ {
+ return m_lib_name_map[inst.GetOp()].cost;
+ }
+ int GetFTCost(const cInstruction & inst) const
+ {
+ return m_lib_name_map[inst.GetOp()].ft_cost;
+ }
+ double GetProbFail(const cInstruction & inst) const
+ {
+ return m_lib_name_map[inst.GetOp()].prob_fail;
+ }
+ int GetRedundancy(const cInstruction & inst) const
+ {
+ return m_lib_name_map[inst.GetOp()].redundancy;
+ }
+
+ int GetLibFunctionIndex(const cInstruction & inst) const
+ {
+ return m_lib_name_map[inst.GetOp()].lib_fun_id;
+ }
+
+ int GetNopMod(const cInstruction & inst) const
+ {
+ return m_inst_lib->GetNopMod(m_lib_nopmod_map[inst.GetOp()]);
+ }
+
+ cInstruction GetRandomInst() const;
+ int GetRandFunctionIndex() const
+ {
+ return m_lib_name_map[ GetRandomInst().GetOp() ].lib_fun_id;
+ }
+
+ int GetSize() const {
+ return m_lib_name_map.GetSize();
+ }
+ int GetNumNops() const {
+ return m_lib_nopmod_map.GetSize();
+ }
+
+ // Instruction Analysis.
+ int IsNop(const cInstruction & inst) const
+ {
+ return (inst.GetOp() < m_lib_nopmod_map.GetSize());
+ }
+
+ // Insertion of new instructions...
+ int Add2(
+ const int lib_fun_id,
+ const int redundancy=1,
+ const int ft_cost=0,
+ const int cost=0,
+ const double prob_fail=0.0
+ );
+ int AddNop2(
+ const int lib_nopmod_id,
+ const int redundancy=1,
+ const int ft_cost=0,
+ const int cost=0,
+ const double prob_fail=0.0
+ );
+
+ // accessors for instruction library
+ cInstLibBase *GetInstLib(){ return m_inst_lib; }
+ void SetInstLib(cInstLibBase *inst_lib){
+ m_inst_lib = inst_lib;
+ inst_error2 = inst_lib->GetInstError();
+ inst_default2 = inst_lib->GetInstDefault();
+ }
+
+ inline cInstruction GetInst(const cString & in_name) const;
+ cString FindBestMatch(const cString & in_name) const;
+
+ // Static methods..
+ static const cInstruction & GetInstDefault() {
+ return inst_default2;
+ }
+ static const cInstruction & GetInstError() {
+ return inst_error2;
+ }
+ // static const cInstruction & GetInstNone() { return inst_none; }
+};
+
+
+inline cInstruction cInstSet::GetInst(const cString & in_name) const
+{
+ for (int i = 0; i < m_lib_name_map.GetSize(); i++) {
+ if (m_inst_lib->GetName(m_lib_name_map[i].lib_fun_id) == in_name) {
+ return cInstruction(i);
+ }
+ }
+
+ // @CAO Hacking this to make sure we don't have defaults...
+ cerr << "Error: Unknown instruction '" << in_name << "'. Exiting..." << endl;
+ exit(1);
+
+
+ // Adding default answer if nothing is found...
+ /*
+ FIXME: this return value is supposed to be cInstSet::GetInstError
+ which should be the same as m_inst_lib->GetInstError().
+ -- kgn
+ */
+ return cInstruction(0);
+}
+
+#endif
Copied: trunk/source/main/cInstUtil.cc (from rev 313, trunk/source/main/inst_util.cc)
===================================================================
--- trunk/source/main/inst_util.cc 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cInstUtil.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,109 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 "cInstUtil.h"
+
+#include "string.hh"
+#include "file.hh"
+
+#ifndef INIT_FILE_HH
+#include "init_file.hh"
+#endif
+
+#include "cInstSet.h"
+#include "cGenome.h"
+
+
+using namespace std;
+
+
+cGenome cInstUtil::LoadGenome(const cString & filename,
+ const cInstSet & inst_set)
+{
+ cInitFile input_file(filename);
+ if (!input_file.IsOpen()) {
+ cerr << "Cannot open file: " << filename << endl;
+ return cGenome(0);
+ }
+ input_file.Load();
+ input_file.Compress();
+ input_file.Close();
+
+ // Setup the code array...
+ cGenome new_genome(input_file.GetNumLines());
+
+ for (int line_num = 0; line_num < new_genome.GetSize(); line_num++) {
+ cString cur_line = input_file.GetLine(line_num);
+ new_genome[line_num] = inst_set.GetInst(cur_line);
+
+ if (new_genome[line_num] == cInstSet::GetInstError()) {
+ // You're using the wrong instruction set! YOU FOOL!
+ cerr << "Cannot load organism '" << filename << "'" << endl
+ << " Unknown line: " << cur_line
+ << " (best match is '" << inst_set.FindBestMatch(cur_line) << "')"
+ << endl;
+ exit(1);
+ }
+ }
+
+ if(new_genome.GetSize()==0)
+ cerr << "Warning: Genome size is 0!" << endl;
+
+ return new_genome;
+}
+
+cGenome cInstUtil::LoadInternalGenome(istream & fp, const cInstSet &inst_set)
+{
+ assert(fp.good()); // Invalid stream to load genome from!
+
+ int num_lines = -1;
+ fp >> num_lines;
+
+ if (num_lines <= 0) { return cGenome(1); }
+
+ // Setup the code array...
+ cGenome new_genome(num_lines);
+ cString cur_line;
+
+ for (int line_num = 0; line_num < new_genome.GetSize(); line_num++) {
+ fp >> cur_line;
+ new_genome[line_num] = inst_set.GetInst(cur_line);
+
+ if (new_genome[line_num] == cInstSet::GetInstError()) {
+ // You're using the wrong instruction set! YOU FOOL!
+ cerr << "Cannot load creature from stream:" << endl
+ << " Unknown line: " << cur_line << endl;
+ }
+ }
+ return new_genome;
+}
+
+void cInstUtil::SaveGenome(ostream & fp, const cInstSet & inst_set,
+ const cGenome & gen)
+{
+ for (int i = 0; i < gen.GetSize(); i++) {
+ fp << inst_set.GetName(gen[i]) << endl;
+ }
+}
+
+void cInstUtil::SaveInternalGenome(ostream & fp, const cInstSet & inst_set,
+ const cGenome & gen)
+{
+ fp << gen.GetSize() << endl;
+ SaveGenome(fp, inst_set, gen);
+}
+
+
+cGenome cInstUtil::RandomGenome(int length, const cInstSet & inst_set)
+{
+ cGenome genome(length);
+ for (int i = 0; i < length; i++) {
+ genome[i] = inst_set.GetRandomInst();
+ }
+ return genome;
+}
+
Copied: trunk/source/main/cInstUtil.h (from rev 313, trunk/source/main/inst_util.hh)
===================================================================
--- trunk/source/main/inst_util.hh 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cInstUtil.h 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,39 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 INST_UTIL_HH
+#define INST_UTIL_HH
+
+#include <iostream>
+
+#ifndef GENOME_HH
+#include "cGenome.h"
+#endif
+
+class cInitFile;
+class cInstSet;
+class cString;
+class cInstUtil {
+public:
+
+ // ========= Genome-File Interaction =========
+ // Saving and loading of files. These functions assume that the genome is
+ // the only thing in the file unless 'Internal' is in the function name
+ // (Internal genomes must begin with a number that indicates genome length)
+
+ static cGenome LoadGenome(const cString &filename, const cInstSet &inst_set);
+ static cGenome LoadInternalGenome(std::istream & fp, const cInstSet &inst_set);
+ static void SaveGenome(std::ostream &fp, const cInstSet & inst_set,
+ const cGenome &gen);
+ static void SaveInternalGenome(std::ostream &fp, const cInstSet &inst_set,
+ const cGenome &gen);
+
+ // ========= Genome Construction =========
+ static cGenome RandomGenome(int length, const cInstSet & inst_set);
+};
+
+#endif
Copied: trunk/source/main/cInstruction.cc (from rev 313, trunk/source/main/instruction.cc)
===================================================================
--- trunk/source/main/instruction.cc 2005-09-15 23:16:19 UTC (rev 313)
+++ trunk/source/main/cInstruction.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -0,0 +1,27 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 "cInstruction.h"
+
+
+char cInstruction::GetSymbol() const
+{
+ if (operand < 26) return operand + 'a';
+ if (operand < 52) return operand - 26 + 'A';
+ if (operand < 62) return operand - 52 + '0';
+ if (operand == 255) return '_';
+ return '?';
+}
+
+void cInstruction::SetSymbol(char symbol)
+{
+ if (symbol >= 'a' && symbol <= 'z') operand = symbol - 'a';
+ else if (symbol >= 'A' && symbol <= 'Z') operand = symbol - 'A' + 26;
+ else if (symbol >= '0' && symbol <= '9') operand = symbol - '0' + 52;
+ else operand = 254;
+}
+
Copied: trunk/source/main/cInstruction.h (from rev 313, trunk/source/main/instruction.hh)
Deleted: trunk/source/main/fitness_matrix.cc
===================================================================
--- trunk/source/main/fitness_matrix.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/fitness_matrix.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,669 +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 FITNESS_MATRIX_HH
-#include "fitness_matrix.hh"
-#endif
-
-#ifndef INST_SET_HH
-#include "inst_set.hh"
-#endif
-
-using namespace std;
-
-
-cFitnessMatrix::cFitnessMatrix( const cGenome & code, cInstSet * inst_set)
- : m_start_genotype(code), m_inst_set( inst_set ), m_DFS_MaxDepth(0),
- m_DFS_NumRecorded(0)
-{
- m_start_genotype.SetNumInstructions( m_inst_set->GetSize());
- m_start_genotype.CalcFitness();
- m_data_set.insert(m_start_genotype);
-}
-
-cFitnessMatrix::~cFitnessMatrix()
-{
-}
-
-
-
-/*
- A wrapper routine to call the depth limited search with appropriate
- exception catching.
- */
-
-void cFitnessMatrix::CollectData(ofstream& log_file)
-{
- try
- {
-
- log_file << endl << "DOING DEPTH LIMITED SEARCH..." << endl << endl;
-
- time(&m_search_start_time);
- DepthLimitedSearch(m_start_genotype, log_file);
- time(&m_search_end_time);
- }
- catch(bad_alloc& alloc_failure)
- {
- log_file << "DLS Exception: memory allocation failure" << endl;
- }
- catch(exception& std_ex)
- {
- log_file << "DLS Exception: " << std_ex.what() <<endl;
- }
- catch(...)
- {
- log_file << "DLS Exception: " << "unrecognized exception" << endl;
- }
-
-}
-
-
-/*
- Statistics collected at each node:
- ----------------------------------
-
- numNew = number of mutants alive and above threshold that have not
- been seen before
-
- numVisited = number of mutants that have been seen before (alive and
- above threshold are considered only, because these are the only ones
- stored in the data set)
-
- numOK = number of mutants alive and above threshold (and new)
-
- numBelowthresh = number of mutants alive and below threshold (these
- could have been seen before because there is no record of them)
-
- numDead = number of non-reproducing mutants (these could have been
- seen before because there is no record of dead mutants)
-
- Consequently, if we sum numOK+numBelowThresh+numDead for all nodes
- then we will get the number of _unique_ genotypes inspected
-
-*/
-
-void cFitnessMatrix::DepthLimitedSearch(const cMxCodeArray& startNode, ofstream& log_file, int currDepth)
-{
- if (currDepth == 0)
- {
- m_DFSNumDead.clear();
- m_DFSNumBelowThresh.clear();
- m_DFSNumOK.clear();
- m_DFSNumNew.clear();
- m_DFSNumVisited.clear();
- m_DFSDepth.clear();
- }
-
-
- log_file << "cFitnessMatrix::DepthLimitedSearch, depth = " << currDepth << endl;
-
- currDepth++;
- if (currDepth > m_DFS_MaxDepth) m_DFS_MaxDepth = currDepth;
- m_DFSDepth.push_back(currDepth);
-
- list<cMxCodeArray> theMutants;
-
- // statistics
- short numDead = 0, numBelowThresh = 0, numOK = 0;
- short numVisited = 0, numNew = 0;
-
- // get the 1 mutants of the start node
- startNode.Get1Mutants(theMutants);
-
- list<cMxCodeArray>::iterator list_iter;
- vector<cMxCodeArray> deleteMutants;
- vector<cMxCodeArray>::iterator vect_iter;
-
- // MyCodeArrayLessThan myLess;
-
- for (list_iter = theMutants.begin(); list_iter != theMutants.end(); list_iter++)
- {
- // check if its already in the data set
-
- set<cMxCodeArray, MyCodeArrayLessThan >::iterator data_iter;
- pair< set<cMxCodeArray, MyCodeArrayLessThan >::iterator , bool> insert_result;
-
- cMxCodeArray test_array = *list_iter;
-
- data_iter = m_data_set.find(test_array);
-
- if (data_iter == m_data_set.end())
- {
-
- list_iter->CalcFitness();
- double fitness = list_iter->GetFitness();
-
- if (fitness == 0.0)
- {
- numDead++;
- deleteMutants.push_back(*list_iter);
- }
- else if (MutantOK(fitness))
- {
- insert_result = m_data_set.insert(*list_iter);
-
- numNew++;
- numOK++;
- m_DFS_NumRecorded++;
- }
- else
- {
- numBelowThresh++;
- deleteMutants.push_back(*list_iter);
- }
- }
- // if its already in the data set delete from the list
- else
- {
- // log_file << "Mutant already in Set!!!!" << endl;
- numVisited++;
- deleteMutants.push_back(*list_iter);
- }
- }
-
- // delete the ones that are dead or already visited from list
- for (vect_iter = deleteMutants.begin(); vect_iter != deleteMutants.end(); vect_iter++)
- {
- theMutants.remove(*vect_iter);
- }
-
- // save statistics of this node
- m_DFSNumDead.push_back(numDead);
- m_DFSNumBelowThresh.push_back(numBelowThresh);
- m_DFSNumOK.push_back(numOK);
- m_DFSNumNew.push_back(numNew);
- m_DFSNumVisited.push_back(numVisited);
-
- // call depth first search on each mutant in the list
- if (currDepth < m_depth_limit)
- {
- for (list_iter = theMutants.begin(); list_iter != theMutants.end(); list_iter++)
- {
- DepthLimitedSearch(*list_iter, log_file, currDepth);
- }
- }
-
-}
-
-
-bool cFitnessMatrix::MutantOK(double fitness)
-{
- return (fitness > m_fitness_threshhold);
-}
-
-
-/*
- Diagonaliztion via repeated multiplication by a random vector.
- Based on Claus' diagonalize.pl
- */
-
-double cFitnessMatrix::Diagonalize(vector<double>& randomVect, int hamDistThresh, double errorRate, ofstream& log_file)
-{
- // first all genotypes need their transition lists
- this->MakeTransitionProbabilities(hamDistThresh, errorRate, log_file);
-
- log_file << endl << "DIAGONALIZING... (error prob=" << errorRate << ")" << endl << endl;
-
- // initialize the random vector
- vector<double> norms;
- MakeRandomVector(randomVect, m_data_set.size());
-
- vector<double> result;
- // do repeated multiplication
- for (int i = 0; i < m_diag_iters; i++)
- {
- /*
- norms.push_back(VectorNorm(randomVect));
- VectorDivideBy(randomVect, norms.back());
- MatrixVectorMultiply(randomVect, result);
- randomVect = result;
- */
-
- MatrixVectorMultiply(randomVect, result);
- norms.push_back(VectorNorm(result));
- VectorDivideBy(result, norms.back());
- randomVect = result;
-
- log_file << "Vect Norm(" << i << "):" << norms.back() << endl;
- }
-
-
- return norms.back();
-}
-
-
-/*
- Make transition lists for all the genotypes in the data set. The
- algorithm for building the transition lists is O(n^2) - for every
- genotype we have to look at all the other genotypes to make its
- transition list.
-*/
-
-
-void cFitnessMatrix::MakeTransitionProbabilities(int hamDistThresh, double errorRate, ofstream& log_file)
-{
-
- set<cMxCodeArray, MyCodeArrayLessThan >::iterator set_iter;
- int num = 0;
- int trans = 0;
-
- log_file << endl << "MAKING TRANSITION PROBABILITIES... (error prob=" << errorRate << ")" << endl << endl;
-
- for (set_iter = m_data_set.begin(); set_iter != m_data_set.end(); set_iter++, num++)
- {
- trans = (*set_iter).MakeTransitionList(m_data_set, hamDistThresh, errorRate);
- log_file << num << ") " << trans << " transitions for " << (*set_iter).AsString() << endl;
- }
-
-}
-
-
-void cFitnessMatrix::MakeRandomVector(vector<double>& newVect, int size)
-{
- cRandom randy(time(NULL));
-
- /* vector should be the size of the set + 1 - because the matrix
- also has the "other" column. So thats why its '<='
- */
- for (int i = 0; i <= size; i++)
- {
- newVect.push_back(randy.GetDouble());
- }
-
-}
-
-void cFitnessMatrix::VectorDivideBy(vector<double>& vect, double div)
-{
- vector<double>::iterator vect_iter;
-
- for(vect_iter = vect.begin(); vect_iter != vect.end(); vect_iter++)
- {
- *vect_iter /= div;
- }
-}
-
-double cFitnessMatrix::VectorNorm(const vector<double> &vect)
-{
- double norm = 0.0;
- vector<double>::const_iterator vect_iter;
-
- for(vect_iter = vect.begin(); vect_iter != vect.end(); vect_iter++)
- {
- norm = norm + (*vect_iter);
- }
-
- return norm;
-}
-
-
-/*
- Perform the matrix vector multiplication using the sparse matrix
- representation in the 'transition map' of the genotypes. The
- transition map has entries for every genotype that it has a non-zero
- probability of giving birth to.
-
- This algorithm is iterating through the columns of the matrix and
- adding each one's contributions to the appropriate rows of the
- resulting vector. This is sort of the reverse of the normal row by
- row dot product way of thinking about matrix-vector multiplication.
-
- The true transition matrix has a last column of all zeros - the
- probabilities that a dead genotype will give birth to a live one.
- This is simply ignored because it doesn't effect the calculation
- (and because we're using the actual data set to do the calculation
- there isn't any good way to make a cMxCodeArray to represent dead
- genotypes...)
-
- */
-
-void cFitnessMatrix::MatrixVectorMultiply(const vector<double> &vect, vector<double>& result)
-{
-
- result.clear();
- result.resize(vect.size(), 0.0);
-
- set<cMxCodeArray, MyCodeArrayLessThan >::iterator set_iter;
-
- int column = 0;
- for (set_iter = m_data_set.begin(); set_iter != m_data_set.end(); set_iter++, column++)
- {
- const map<int, double, less<int> > trans_map = (*set_iter).GetTransitionList();
-
- map<int, double, less<int> >::const_iterator trans_iter;
- for(trans_iter = trans_map.begin(); trans_iter != trans_map.end(); trans_iter++)
- {
- int row = (*trans_iter).first;
- double transition_probability = (*trans_iter).second;
-
- result[row] += vect[column] * transition_probability;
- }
-
- }
-
-}
-
-void cFitnessMatrix::PrintGenotypes(ostream &fp)
-{
- int totNumDead=0, totNumBelowThresh=0, totNumOK=0;
- int totNumNew=0, totNumVisited=0, totDepth=0;
- int totNumDead2=0, totNumBelowThresh2=0, totNumOK2=0;
- int totNumNew2=0, totNumVisited2=0, totDepth2=0;
- int numNodes;
- float avgNumDead=0.0, avgNumBelowThresh=0.0, avgNumOK=0.0;
- float avgNumNew=0.0, avgNumVisited=0.0, avgDepth=0.0;
- float sdNumDead=0.0, sdNumBelowThresh=0.0, sdNumOK=0.0;
- float sdNumNew=0.0, sdNumVisited=0.0, sdDepth=0.0;
-
- totNumDead = accumulate(m_DFSNumDead.begin(), m_DFSNumDead.end(), 0);
- totNumBelowThresh = accumulate(m_DFSNumBelowThresh.begin(), m_DFSNumBelowThresh.end(), 0);
- totNumOK = accumulate(m_DFSNumOK.begin(), m_DFSNumOK.end(), 0);
- totNumNew = accumulate(m_DFSNumNew.begin(), m_DFSNumNew.end(), 0);
- totNumVisited = accumulate(m_DFSNumVisited.begin(), m_DFSNumVisited.end(), 0);
- totDepth = accumulate(m_DFSDepth.begin(), m_DFSDepth.end(), 0);
-
- numNodes = m_DFSNumDead.size();
-
- avgNumDead = ((float)totNumDead)/((float)numNodes);
- avgNumBelowThresh = ((float)totNumBelowThresh)/((float)numNodes);
- avgNumOK = ((float)totNumOK)/((float)numNodes);
- avgNumNew = ((float)totNumNew)/((float)numNodes);
- avgNumVisited = ((float)totNumVisited)/((float)numNodes);
- avgDepth = ((float)totDepth)/((float)numNodes);
-
- for (int i = 0; i < numNodes; i++)
- {
- totNumDead2 += m_DFSNumDead[i]*m_DFSNumDead[i];
- totNumBelowThresh2 += m_DFSNumBelowThresh[i]*m_DFSNumBelowThresh[i];
- totNumOK2 += m_DFSNumOK[i]*m_DFSNumOK[i];
- totNumNew2 += m_DFSNumNew[i]*m_DFSNumNew[i];
- totNumVisited2 += m_DFSNumVisited[i]*m_DFSNumVisited[i];
- totDepth2 += m_DFSDepth[i]*m_DFSDepth[i];
- }
-
- sdNumDead = sqrt( ((float)totNumDead2)/((float)numNodes)
- - (avgNumDead*avgNumDead));
- sdNumBelowThresh = sqrt( ((float) totNumBelowThresh2)/((float) numNodes)
- - (avgNumBelowThresh *avgNumBelowThresh ));
- sdNumOK =sqrt( ((float) totNumOK2)/((float) numNodes)
- - ( avgNumOK* avgNumOK)) ;
- sdNumNew = sqrt( ((float) totNumNew2)/((float) numNodes)
- - (avgNumNew * avgNumNew) );
- sdNumVisited = sqrt( ((float) totNumVisited2)/((float) numNodes)
- - (avgNumVisited * avgNumVisited) );
- sdDepth = sqrt( ((float) totDepth2)/((float) numNodes)
- - (avgDepth * avgDepth) );
-
-
- fp << "#######################################################" << endl;
- fp << "# DEPTH FIRST SEARCH RESULTS " << endl;
- fp << "# Depth Limit: " << m_depth_limit << endl;
- fp << "# Fitness Threshold Ratio: " << m_fitness_threshold_ratio << endl;
- fp << "# Start time: " << asctime(localtime(&m_search_start_time));
- fp << "# End Time: " << asctime(localtime(&m_search_end_time));
- fp << "#######################################################" << endl;
- fp << "# Total number of unique nodes checked: ";
- fp << totNumDead + totNumOK + totNumBelowThresh << endl;
- fp << "# Total number of unique living genotypes found: ";
- fp << totNumOK + totNumBelowThresh << endl;
- fp << "# Total number of unique dead genotypes found: ";
- fp << totNumDead << endl;
- fp << "# Total number of unique genotypes alive and below threshold found: " << endl;
- fp << "# " << totNumBelowThresh << endl;
- fp << "# Total number of unique genotypes alive and above threshold found: " << endl;
- fp << "# " << totNumOK << endl;
- fp << "# Number of Nodes Fully Explored (non-leaf, alive and above threshold): " << endl;
- fp << "# " << numNodes << endl;
- fp << "# Maximum Depth Visited: ";
- fp << m_DFS_MaxDepth << endl;
- fp << "# Number of 1-Mutants Dead at each node, avg - stand dev" << endl;
- fp << "# " << avgNumDead << "\t\t" << sdNumDead << endl;
- fp << "# Number of 1-Mutants Alive but Below Threshold at each node, avg - stand dev" << endl;
- fp << "# " << avgNumBelowThresh << "\t\t" << sdNumBelowThresh << endl;
- fp << "# Number of 1-Mutants alive and above threshold at each node, avg - stand dev" << endl;
- fp << "# " << avgNumOK << "\t\t" << sdNumOK << endl;
- fp << "# Number of New living, above threshold, 1-Mutants at each Node, avg - stand dev" << endl;
- fp << "# " << avgNumNew << "\t\t" << sdNumNew << endl;
- fp << "# Number of Already found living, above threshold 1-Mutants at each Node, avg - stand dev" << endl;
- fp << "# " << avgNumVisited << "\t\t" << sdNumVisited << endl;
- fp << "# Depth of Nodes in search, avg - stand dev" << endl;
- fp << "# " << avgDepth << "\t\t" << sdDepth << endl;
- fp << "#######################################################" << endl;
- fp << "# Fitness:" << endl;
-
- set<cMxCodeArray, MyCodeArrayLessThan >::iterator iter;
- for(iter = m_data_set.begin(); iter != m_data_set.end(); iter++)
- {
- fp << (*iter).AsString() << "\t" <<(*iter).GetFitness() << "\t" << (*iter).GetMerit() << "\t" << (*iter).GetGestationTime() << endl;
- }
-
- fp << "#######################################################" << endl;
-
-}
-
-/*
- PrintTransitionList gets m_data_set.size()+1 because there is the
- extra row at the end for the "other" category. We also add an extra
- row of zeros for the "other" (dead) genotypes so that we're actually
- writing out a square matrix that can be processed by other programs
- (Mathematica).
-
- Note that this is actually printing the transpose of the transition
- matrix, assuming the matrix rows represent the offspring genotypes
- and the columns represent the parents and that the norm vector is a
- column vector. (as discussed with Claus in March, 2001). But since
- we're printing one parent genotype at a time there is just no
- sensible way to print a column at a time...
-
- Used for testing the diagonalization - this isn't really useful for
- real experiments because the matrix will be thousands by thousands
- big and printing it out is not feasible.
-
- */
-
-void cFitnessMatrix::PrintTransitionMatrix(ostream &fp, int hamDistThresh, double errorRate, double avg_fitness, bool printMatrix)
-{
-
- fp << endl << endl;
- fp << "#######################################################" << endl;
- fp << "TRANSITION PROBABILITIES" << endl;
- fp << "#Hamming Distance Threshold" << endl;
- fp << "# " << hamDistThresh << endl;
- fp << "#Error Rate" << endl;
- fp << "# " << errorRate << endl;
- fp << "#Avg Fitness" << endl;
- fp << "# " << avg_fitness << endl;
- fp << "#######################################################" << endl;
-
-
- if (printMatrix)
- {
- set<cMxCodeArray, MyCodeArrayLessThan >::iterator iter;
- fp << "{" << endl;
- int index = 0;
- for(iter = m_data_set.begin(); iter != m_data_set.end(); iter++, index++)
- {
- (*iter).PrintTransitionList(fp, m_data_set.size()+1);
- fp << "," << endl;
- }
-
-
- /*
- Add the transition probabilities for "other" (dead) genotypes
- so that we're actually writing out a square matrix that can be
- processed by other programs (Mathematica)
- */
-
- fp << "{" ;
- for (index = 0; index <= (int) m_data_set.size(); index++)
- {
- fp << 0.0;
- if (index < (int) m_data_set.size())
- fp << " , ";
- }
- fp << "}" << endl;
-
- fp << "}";
- }
-
-}
-
-
-
-void cFitnessMatrix::PrintHammingVector(ostream& fp,const vector<double>& dataVect, double errProb, double avgFit)
-{
- vector<double> hamVect;
-
- for (int i = 0; i < m_start_genotype.GetSize(); i++)
- hamVect.push_back(0.0);
-
- set<cMxCodeArray, MyCodeArrayLessThan >::iterator data_iter;
-
- int index = 0;
-
- for (data_iter = m_data_set.begin(); data_iter != m_data_set.end(); data_iter++, index++)
- {
- int dist = m_start_genotype.HammingDistance(*data_iter);
- hamVect[dist] += dataVect[index];
- }
-
-
-
- fp << errProb << "\t";
- fp << avgFit << "\t";
-
- vector<double>::const_iterator vect_iter;
-
- for(vect_iter = hamVect.begin(); vect_iter != hamVect.end(); vect_iter++)
- {
- fp << (*vect_iter) << "\t";
- }
-
- fp << endl;
-
-}
-
-
-void cFitnessMatrix::PrintFitnessVector(ostream& fp,const vector<double>& dataVect, double errProb, double avgFit, double maxFit, double step)
-{
- vector<double> fitVect;
-
- int maxi = (int) (maxFit /step) +1;
-
- for (int i = 0; i < maxi; i++)
- fitVect.push_back(0.0);
-
- set<cMxCodeArray, MyCodeArrayLessThan >::iterator data_iter;
-
- int index = 0;
-
- for (data_iter = m_data_set.begin(); data_iter != m_data_set.end(); data_iter++, index++)
- {
- double f = (*data_iter).GetFitness();
- fitVect[(int) (f/step)] += dataVect[index];
- }
- // the last contribution is of fitness zero:
- fitVect[0] += dataVect[index];
-
-
-
- fp << errProb << "\t";
- fp << avgFit << "\t";
-
- vector<double>::const_iterator vect_iter;
-
- for(vect_iter = fitVect.begin(); vect_iter != fitVect.end(); vect_iter++)
- {
- fp << (*vect_iter) << "\t";
- }
-
- fp << endl;
-
-}
-
-void cFitnessMatrix::PrintFullVector(ostream& fp,const vector<double>& dataVect, double errProb, double avgFit)
-{
- fp << errProb << "\t";
- fp << avgFit << "\t";
-
- vector<double>::const_iterator vect_iter;
-
- for(vect_iter = dataVect.begin(); vect_iter != dataVect.end(); vect_iter++)
- {
- fp << (*vect_iter) << "\t";
- }
-
- fp << endl;
-}
-
-
-
-void cFitnessMatrix::CalcFitnessMatrix( int depth_limit, double fitness_threshold_ratio, int ham_thresh, double error_rate_min, double error_rate_max, double error_rate_step, double output_start, double output_step, int diag_iters, bool write_ham_vector, bool write_full_vector )
-{
-
- /* set parameters (TODO: read these from event list) */
-
- m_depth_limit = depth_limit;
- m_fitness_threshold_ratio = fitness_threshold_ratio;
- m_ham_thresh = ham_thresh;
- m_error_rate_min = error_rate_min;
- m_error_rate_max = error_rate_max;
- m_error_rate_step = error_rate_step;
- m_diag_iters = diag_iters;
-
- m_fitness_threshhold = m_start_genotype.GetFitness() * m_fitness_threshold_ratio;
-
- /* open files for output */
-
- ofstream log_file("fitness_matrix.log");
- ofstream genotype_file("found_genotypes.dat");
- ofstream fit_vect_file("fitness_vect.dat");
-
- ofstream ham_vect_file;
- if (write_ham_vector)
- ham_vect_file.open("hamming_vect.dat");
- ofstream full_vect_file;
- if (write_full_vector)
- full_vect_file.open("full_vect.dat");
-
-
- /* do the depth first search */
-
- CollectData(log_file);
- PrintGenotypes(genotype_file);
- genotype_file.close();
-
-
- /* diagonalize transition matrices at different copy error rates */
-
- for (double error = m_error_rate_min; error <= m_error_rate_max; error += m_error_rate_step)
- {
- vector<double> dataVect;
-
- double avg_fitness = Diagonalize(dataVect, m_ham_thresh, error, log_file);
-
- PrintFitnessVector(fit_vect_file, dataVect, error, avg_fitness, output_start, output_step);
-
- if ( write_ham_vector )
- PrintHammingVector(ham_vect_file, dataVect, error, avg_fitness);
-
- if ( write_full_vector )
- PrintFullVector(full_vect_file, dataVect, error, avg_fitness);
-
- }
-
-
- /* close remaining files */
-
- log_file.close();
- fit_vect_file.close();
- if ( write_ham_vector )
- ham_vect_file.close();
- if ( write_full_vector )
- full_vect_file.close();
-}
-
Deleted: trunk/source/main/fitness_matrix.hh
===================================================================
--- trunk/source/main/fitness_matrix.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/fitness_matrix.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,151 +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 FITNESS_MATRIX_HH
-#define FITNESS_MATRIX_HH
-
-#include <numeric>
-#include <iomanip>
-#include <iostream>
-#include <set>
-#include <vector>
-#include <map>
-#include <list>
-#include <sys/timeb.h>
-
-#ifndef DEFS_HH
-#include "defs.hh"
-#endif
-#ifndef MX_CODE_ARRAY_HH
-#include "mx_code_array.hh"
-#endif
-#ifndef MY_CODE_ARRAY_LESS_THAN_HH
-#include "my_code_array_less_than.hh"
-#endif
-#ifndef ORGANISM_HH
-#include "organism.hh"
-#endif
-#ifndef STATS_HH
-#include "stats.hh"
-#endif
-#ifndef STRING_UTIL_HH
-#include "string_util.hh"
-#endif
-#ifndef TOOLS_HH
-#include "tools.hh"
-#endif
-
-class cGenome;
-class cInstSet;
-class MyCodeArrayLessThan;
-class cFitnessMatrix {
-private:
-
- /* genome data */
- cMxCodeArray m_start_genotype;
- cInstSet *m_inst_set;
- std::set<cMxCodeArray, MyCodeArrayLessThan > m_data_set;
- double m_fitness_threshhold;
-
- /* parameters for search */
- int m_depth_limit;
- double m_fitness_threshold_ratio;
-
- /* parameters for diagonalization */
- int m_ham_thresh;
- double m_error_rate_min;
- double m_error_rate_max;
- double m_error_rate_step;
- int m_diag_iters;
-
-
- /* statistics of search */
- std::vector<int> m_DFSNumDead;
- std::vector<int> m_DFSNumBelowThresh;
- std::vector<int> m_DFSNumOK;
- std::vector<int> m_DFSNumNew;
- std::vector<int> m_DFSNumVisited;
- std::vector<int> m_DFSDepth;
- int m_DFS_MaxDepth;
- int m_DFS_NumRecorded;
- time_t m_search_start_time;
- time_t m_search_end_time;
-
-
- /* Methods for Depth-Limited Search of Genotype Space */
-
- void DepthLimitedSearch(const cMxCodeArray& startNode, std::ofstream& log_file, int currDepth=0);
- bool MutantOK(double fitness);
- void CollectData(std::ofstream& log_file);
-
-
- /* Methods for Diagonalization of Transition Matrix */
-
- double Diagonalize(std::vector<double>& randomVect, int hamDistThresh,
- double errorRate, std::ofstream& logfile);
- void MakeRandomVector(std::vector<double>& newVect, int size);
- void VectorDivideBy(std::vector<double>& vect, double div);
- double VectorNorm(const std::vector<double> &vect);
- void MatrixVectorMultiply(const std::vector<double>& vect, std::vector<double>& result);
- void MakeTransitionProbabilities(int hamDistThresh, double errorRate,
- std::ofstream& logfile);
-
-
- /* Data Output */
-
- void PrintGenotypes(std::ostream &fp);
- void PrintTransitionMatrix(std::ostream& fp, int hamDistThresh, double errorRate, double avg_fitness, bool printMatrix=false);
- void PrintHammingVector(std::ostream& fp,const std::vector<double>& dataVect, double errProb, double avgFit);
- void PrintFitnessVector(std::ostream& fp,const std::vector<double>& dataVect, double errProb, double avgFit, double maxFit, double step);
- void PrintFullVector(std::ostream& fp, const std::vector<double>& dataVect, double errProb, double avgFit);
-
-
-public:
- cFitnessMatrix(const cGenome &, cInstSet * inst_set);
- ~cFitnessMatrix();
-
- /**
- * The main entry function.
- *
- * @param depth_limit Limits the depth of the search
- * (how far should we go out in Hamming distance).
- *
- * @param fitness_threshold_ratio Creatures with fitnesses below the
- * starting fitness times this value are rejected
- *
- * @param ham_thresh The threshold for the construction of the matrix
- * (what transitions are included).
- *
- * @param error_rate_min The minimum error rate for which the matrix
- * should be diagonalized.
- *
- * @param error_rate_max The maximum error rate for which the matrix
- * should be diagonalized.
- *
- * @param error_rate_step The interval between two error rates at which
- * the matrix gets diagonalized.
- *
- * @param vect_fmax The maximum fitness to be considered in the output
- * vector. (We output concentrations of genotypes in bins of given fitness
- * width. This is the maximum fitness we consider).
- *
- * @param vect_fstep The width of the fitness bins for output.
- *
- * @param diag_iters The number of iterations for the diagonalization
- * of the matrix.
- *
- * @param write_ham_vector Should we also write a concentration vector
- * grouped according to Hamming distances?
- *
- * @param write_full_vector Should we also write the full concentration
- * vector?
- **/
- void CalcFitnessMatrix( int depth_limit, double fitness_threshold_ratio, int ham_thresh, double error_rate_min, double error_rate_max, double error_rate_step, double vect_fmax, double vect_fstep, int diag_iters, bool write_ham_vector, bool write_full_vector );
-
-};
-
-#endif
Deleted: trunk/source/main/genebank.cc
===================================================================
--- trunk/source/main/genebank.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genebank.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,926 +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 GENEBANK_HH
-#include "genebank.hh"
-#endif
-
-#ifndef CONFIG_HH
-#include "cConfig.h"
-#endif
-#ifndef GENOTYPE_HH
-#include "genotype.hh"
-#endif
-#ifndef SPECIES_HH
-#include "species.hh"
-#endif
-#ifndef STATS_HH
-#include "stats.hh"
-#endif
-#ifndef TEST_UTIL_HH
-#include "cTestUtil.h"
-#endif
-
-
-using namespace std;
-
-
-///////////////
-// cGenebank
-///////////////
-
-cGenebank::cGenebank(cStats & _stats)
- : stats(_stats)
-{
- for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
- genotype_count[i] = 0;
- }
-
- genotype_control = new cGenotypeControl(*this);
- species_control = new cSpeciesControl(*this);
-
-}
-
-cGenebank::~cGenebank()
-{
- delete genotype_control;
- delete species_control;
-}
-
-void cGenebank::UpdateReset()
-{
- static int genotype_dom_time = 0;
- static int prev_dom = -1;
-
- cGenotype * best_genotype = GetBestGenotype();
-
- species_control->Purge(stats);
- if (best_genotype && best_genotype->GetID() != prev_dom) {
- genotype_dom_time = 0;
- prev_dom = best_genotype->GetID();
- }
- else {
- genotype_dom_time++;
- if (genotype_dom_time == cConfig::GetGenotypePrintDom()) {
- cString filename;
- filename.Set("genebank/%s", best_genotype->GetName()());
- cTestUtil::PrintGenome(best_genotype->GetGenome(),
- filename, best_genotype, stats.GetUpdate());
- }
- }
-
-// tArray<int> hist_array(15);
-// hist_array.SetAll(0);
-// int total_gens = 0;
-
-// for (int i = 0; i < GENOTYPE_HASH_SIZE; i++) {
-// int cur_val = active_genotypes[i].GetSize();
-// total_gens += cur_val;
-// if (cur_val < 15) hist_array[cur_val]++;
-// else cout << cur_val << " ";
-// }
-// cout << endl;
-// for (int i = 0; i < 15; i++) {
-// cout << i << " : " << hist_array[i] << endl;
-// }
-// cout << "Total genotypes: " << total_gens << endl;
-}
-
-cString cGenebank::GetLabel(int in_size, int in_num)
-{
- char alpha[6];
- char full_name[12];
- int i;
-
- for (i = 4; i >= 0; i--) {
- alpha[i] = (in_num % 26) + 'a';
- in_num /= 26;
- }
- alpha[5] = '\0';
-
- sprintf(full_name, "%03d-%s", in_size, alpha);
-
- return full_name;
-}
-
-
-void cGenebank::AddGenotype(cGenotype * in_genotype, int list_num)
-{
- assert( in_genotype != 0 );
-
- if (list_num < 0) list_num = FindCRC(in_genotype->GetGenome());
-
- active_genotypes[list_num].Push(in_genotype);
- genotype_control->Insert(*in_genotype);
- stats.AddGenotype(in_genotype->GetID());
-
- // Speciation... If we are creating a new genotype here, we must
- // initilize it to the species of its parent genotype.
-
- cSpecies * parent_species = NULL;
- if ( in_genotype->GetParentGenotype() != NULL) {
- parent_species = in_genotype->GetParentGenotype()->GetSpecies();
- }
-
- in_genotype->SetSpecies(parent_species);
- if (parent_species != NULL) parent_species->AddGenotype();
-}
-
-
-// Add a new genotype to the genebank. Take in parent genotypes to track
-// phylogenies (the second genotype is in the case of sexual organisms)
-
-cGenotype * cGenebank::AddGenotype(const cGenome & in_genome,
- cGenotype * parent_genotype,
- cGenotype * parent2_genotype)
-{
- // Make sure we dont have a NULL parent -- if we do, we should be calling
- // InjectGenotype().
- assert (parent_genotype != NULL);
-
- int list_num = FindCRC(in_genome);
- cGenotype * found_genotype = FindGenotype(in_genome,
- parent_genotype->GetLineageLabel(), list_num);
-
- if (!found_genotype) {
- found_genotype = new cGenotype(stats.GetUpdate());
- found_genotype->SetGenome(in_genome);
- found_genotype->SetParent(parent_genotype, parent2_genotype);
- AddGenotype(found_genotype, list_num);
- }
-
- return found_genotype;
-}
-
-
-// Add a new genotype that has been injected from the outside to the genebank.
-// Take in a lineage label to track clades.
-
-cGenotype * cGenebank::InjectGenotype(const cGenome & in_genome,
- int lineage_label)
-{
- int list_num = FindCRC(in_genome);
- cGenotype * found_genotype =
- FindGenotype(in_genome, lineage_label, list_num);
-
- if (!found_genotype) {
- found_genotype = new cGenotype(stats.GetUpdate());
- found_genotype->SetGenome(in_genome);
- found_genotype->SetParent(NULL, NULL);
- found_genotype->SetLineageLabel(lineage_label);
- AddGenotype(found_genotype, list_num);
- }
-
- return found_genotype;
-}
-
-const cGenotype * cGenebank::FindGenotype(const cGenome & in_genome,
- int lineage_label, int list_num) const
-{
- if (list_num < 0) list_num = FindCRC(in_genome);
-
- tConstListIterator<cGenotype> list_it(active_genotypes[list_num]);
-
- // If the lineage label is -1, match any lineage...
- if (lineage_label == -1) {
- while (list_it.Next() != NULL) {
- if (list_it.GetConst()->GetGenome() == in_genome) break;
- }
- }
-
- // Otherwise, only match a genotype of the same lineage.
- else {
- while (list_it.Next() != NULL) {
- if (list_it.GetConst()->GetGenome() == in_genome &&
- list_it.GetConst()->GetLineageLabel() == lineage_label) break;
- }
- }
-
- return list_it.GetConst();
-}
-
-cGenotype * cGenebank::FindGenotype(const cGenome & in_genome,
- int lineage_label, int list_num)
-{
- if (list_num < 0) list_num = FindCRC(in_genome);
-
- tListIterator<cGenotype> list_it(active_genotypes[list_num]);
- // If the lineage label is -1, match any lineage...
- if (lineage_label == -1) {
- while (list_it.Next() != NULL) {
- if (list_it.Get()->GetGenome() == in_genome) break;
- }
- }
-
- // Otherwise, only match a genotype of the same lineage.
- else {
- while (list_it.Next() != NULL) {
- if (list_it.Get()->GetGenome() == in_genome &&
- list_it.Get()->GetLineageLabel() == lineage_label) break;
- }
- }
- return list_it.Get();
-}
-
-void cGenebank::RemoveGenotype(cGenotype & in_genotype)
-{
- // If we are supposed to defer analysis of this genotype, do so...
- if (in_genotype.GetDeferAdjust() == true) return;
-
- // If this genotype is still active, mark it no longer active and
- // take it out of the hash table so it doesn't have any new organisms
- // assigned to it.
-
- if (in_genotype.GetActive() == true) {
- int list_num = FindCRC(in_genotype.GetGenome());
- active_genotypes[list_num].Remove(&in_genotype);
- genotype_control->Remove(in_genotype);
- in_genotype.Deactivate(stats.GetUpdate());
- if (cConfig::GetTrackMainLineage()) {
- genotype_control->InsertHistoric(in_genotype);
- }
- }
-
- // If we are tracking the main lineage, we only want to delete a
- // genotype when all of its decendents have also died out.
-
- const int lineage_type = cConfig::GetTrackMainLineage();
- if (lineage_type > 0) {
- // If there are more offspring genotypes, hold off on deletion...
- if (in_genotype.GetNumOffspringGenotypes() != 0) return;
-
- // If this is a dead end, delete it and recurse up...
- cGenotype * parent = in_genotype.GetParentGenotype();
- cGenotype * parent2 = in_genotype.GetParent2Genotype();
-
- if (parent != NULL) {
- parent->RemoveOffspringGenotype();
-
- // Test to see if we need to update the coalescent genotype.
- const int new_coal = genotype_control->UpdateCoalescent();
- stats.SetCoalescentGenotypeDepth(new_coal);
- // cout << "Set coalescent to " << found_gen->GetDepth() << endl;
-
- if (parent->GetNumOrganisms() == 0) {
- // Regardless, run RemoveGenotype on the parent.
- RemoveGenotype(*parent);
- }
- }
-
- if (lineage_type == 2 && parent2 != NULL) {
- parent2->RemoveOffspringGenotype();
-
- // Test to see if we need to update the coalescent genotype.
- const int new_coal = genotype_control->UpdateCoalescent();
- stats.SetCoalescentGenotypeDepth(new_coal);
- // cout << "Set coalescent to " << found_gen->GetDepth() << endl;
-
- if (parent2->GetNumOrganisms() == 0) {
- // Regardless, run RemoveGenotype on the parent.
- RemoveGenotype(*parent2);
- }
- }
-
- genotype_control->RemoveHistoric(in_genotype);
- }
-
- // Handle the relevent statistics...
- stats.RemoveGenotype(in_genotype.GetID(),
- in_genotype.GetParentID(), in_genotype.GetParentDistance(),
- in_genotype.GetDepth(), in_genotype.GetTotalOrganisms(),
- in_genotype.GetTotalParasites(),
- stats.GetUpdate() - in_genotype.GetUpdateBorn(),
- in_genotype.GetLength());
- if (in_genotype.GetThreshold()) {
- stats.RemoveThreshold(in_genotype.GetID());
- }
-
-
- // Speciation... If a Threshold genotype was removed, the position of this
- // species in the active list will at least shift, and it is possible that
- // the species is made inactive, or removed all-togeather. If it is a non-
- // threshold genotype, then the species will only be effected if this was
- // the last genotype of that species.
-
- cSpecies * cur_species = in_genotype.GetSpecies();
- if (cur_species) {
-
- // First, re-adjust the species.
-
- cur_species->RemoveGenotype();
-
- // Then, check to see how this species changes if it is a threshold.
-
- if (in_genotype.GetThreshold()) {
- cur_species->RemoveThreshold(in_genotype);
-
- // If we are out of thresholds, move this species to the inactive
- // list for now. Otherwise, just adjust it.
-
- if (cur_species->GetNumThreshold() == 0) {
- species_control->SetInactive(*cur_species);
- }
- else {
- species_control->Adjust(*cur_species);
- }
- }
-
- // Finally, remove the species completely if it has no genotypes left.
-
- if (!cur_species->GetNumGenotypes()) {
- species_control->SetGarbage(*cur_species);
- }
- }
-
-
- delete &in_genotype;
-}
-
-void cGenebank::ThresholdGenotype(cGenotype & in_genotype)
-{
- cSpecies * found_species = NULL;
-
- in_genotype.SetName( GetLabel(in_genotype.GetLength(),
- genotype_count[in_genotype.GetLength()]++) );
- in_genotype.SetThreshold();
-
- // If speciation is on, assign a species to the genotype now that it is
- // threshold.
-
- if (cConfig::GetSpeciesRecording()) {
- // Record the old species to know if it changes.
-
- cSpecies * old_species = in_genotype.GetSpecies();
-
- // Determine the "proper" species.
-
- found_species = species_control->Find(in_genotype,
- cConfig::GetSpeciesRecording());
-
- // If no species was found, create a new one.
-
- if (!found_species) {
- found_species = new cSpecies(in_genotype.GetGenome(), stats.GetUpdate());
- if (in_genotype.GetSpecies())
- found_species->SetParentID(in_genotype.GetSpecies()->GetID());
- species_control->SetActive(*found_species);
- stats.AddSpecies(found_species->GetID());
-
- // Since this is a new species, see if we should be printing it.
-
- if (cConfig::GetSpeciesPrint()) {
- cString filename;
- filename.Set("genebank/spec-%04d", found_species->GetID());
- cTestUtil::PrintGenome(in_genotype.GetGenome(), filename,
- &in_genotype, stats.GetUpdate());
- }
- }
- else {
- // If we are not creating a new species, but are adding a threshold
- // to one which is currently in-active, make sure to move it back to
- // the active list.
-
- if (found_species->GetNumThreshold() == 0) {
- species_control->SetActive(*found_species);
- }
- }
-
- // Now that we know for sure what the species is, and that it is in
- // the proper list, setup both the species and the genotype.
-
- in_genotype.SetSpecies(found_species);
- found_species->AddThreshold(in_genotype);
-
- // Finally test to see if the species has been changed, and adjust
- // accordingly.
-
- if (found_species != old_species) {
- found_species->AddGenotype();
- if (old_species) {
- old_species->RemoveGenotype();
- if (old_species->GetNumGenotypes() == 0)
- species_control->SetGarbage(*old_species);
- }
- }
- else {
- if (found_species->GetNumThreshold() > 1) {
- species_control->Adjust(*found_species);
- }
- }
- }
-
- // Do the relevent statistics...
-
- if (cConfig::GetSpeciesRecording()) {
- stats.AddThreshold(in_genotype.GetID(), in_genotype.GetName()(),
- found_species->GetID());
- } else {
- stats.AddThreshold(in_genotype.GetID(), in_genotype.GetName()());
- }
-
- // Print the genotype?
-
- if (cConfig::GetGenotypePrint()) {
- cString filename;
- filename.Set("genebank/%s", in_genotype.GetName()());
- cTestUtil::PrintGenome(in_genotype.GetGenome(), filename,
- &in_genotype, stats.GetUpdate());
- }
-}
-
-bool cGenebank::AdjustGenotype(cGenotype & in_genotype)
-{
- if (!genotype_control->Adjust(in_genotype)) return false;
-
- if ((in_genotype.GetNumOrganisms() >= cConfig::GetThreshold() ||
- &in_genotype == genotype_control->GetBest()) &&
- !(in_genotype.GetThreshold())) {
- ThresholdGenotype(in_genotype);
- }
-
- return true;
-}
-
-bool cGenebank::SaveClone(ofstream & fp)
-{
- // This method just save the counts at each size-class of genotypes.
- // The rest is reconstructable.
-
- // Save the numbers of organisms we're up to at each size.
- fp << MAX_CREATURE_SIZE << " ";
- for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
- fp << genotype_count[i] << " ";
- }
-
- return true;
-}
-
-bool cGenebank::LoadClone(ifstream & fp)
-{
- // This method just restores the counts at each size-class of genotypes.
- // The rest of the loading process should be handled elsewhere.
-
- // Load the numbers of organisms we're up to at each size.
- int max_size;
- fp >> max_size;
- assert (max_size <= MAX_CREATURE_SIZE); // MAX_CREATURE_SIZE too small
- for (int i = 0; i < max_size && i < MAX_CREATURE_SIZE; i++) {
- fp >> genotype_count[i];
- }
-
- return true;
-}
-
-bool cGenebank::DumpTextSummary(ofstream & fp)
-{
- genotype_control->Reset(0);
- for (int i = 0; i < genotype_control->GetSize(); i++) {
- cGenotype * genotype = genotype_control->Get(0);
- fp << genotype->GetGenome().AsString() << " "
- << genotype->GetNumOrganisms() << " "
- << genotype->GetID() << endl;
- genotype_control->Next(0);
- }
-
- return true;
-}
-
-bool cGenebank::PrintGenotypes(ofstream & fp, cString & data_fields,
- int historic)
-{
- bool print_id = false;
- bool print_parent_id = false;
- bool print_parent2_id = false;
- bool print_parent_dist = false;
- bool print_num_cpus = false;
- bool print_total_cpus = false;
- bool print_length = false;
- bool print_merit = false;
- bool print_gest_time = false;
- bool print_fitness = false;
- bool print_update_born = false;
- bool print_update_dead = false;
- bool print_depth = false;
- bool print_lineage = false;
- bool print_sequence = false;
-
- cStringList fields(data_fields, ',');
- if (fields.HasString("id") == true) print_id = true;
- if (fields.HasString("parent_id") == true) print_parent_id = true;
- if (fields.HasString("parent2_id") == true) print_parent2_id = true;
- if (fields.HasString("parent_dist") == true) print_parent_dist = true;
- if (fields.HasString("num_cpus") == true) print_num_cpus = true;
- if (fields.HasString("total_cpus") == true) print_total_cpus = true;
- if (fields.HasString("length") == true) print_length = true;
- if (fields.HasString("merit") == true) print_merit = true;
- if (fields.HasString("gest_time") == true) print_gest_time = true;
- if (fields.HasString("fitness") == true) print_fitness = true;
- if (fields.HasString("update_born") == true) print_update_born = true;
- if (fields.HasString("update_dead") == true) print_update_dead = true;
- if (fields.HasString("depth") == true) print_depth = true;
- if (fields.HasString("lineage") == true) print_lineage = true;
- if (fields.HasString("sequence") == true) print_sequence = true;
- if (fields.HasString("all") == true) {
- print_id = print_parent_id = print_parent2_id = print_parent_dist = true;
- print_num_cpus = print_total_cpus = print_length = print_merit = true;
- print_gest_time = print_fitness = print_update_born = true;
- print_update_dead = print_depth = print_lineage = print_sequence = true;
- }
-
- // Print all of the header information...
- fp << "#filetype genotype_data" << endl
- << "#format ";
-
- if (print_id == true) fp << "id ";
- if (print_parent_id == true) fp << "parent_id ";
- if (print_parent2_id == true) fp << "parent2_id ";
- if (print_parent_dist == true) fp << "parent_dist ";
- if (print_num_cpus == true) fp << "num_cpus ";
- if (print_total_cpus == true) fp << "total_cpus ";
- if (print_length == true) fp << "length ";
- if (print_merit == true) fp << "merit ";
- if (print_gest_time == true) fp << "gest_time ";
- if (print_fitness == true) fp << "fitness ";
- if (print_update_born == true) fp << "update_born ";
- if (print_update_dead == true) fp << "update_dead ";
- if (print_depth == true) fp << "depth ";
- if (print_lineage == true) fp << "lineage ";
- if (print_sequence == true) fp << "sequence ";
- fp << endl;
-
- // Print extra information about what data is in this file...
- fp << "# Output is genotypes at update " << stats.GetUpdate();
- if (historic == -1) fp << " including ALL ancestors";
- else if (historic > 0) fp << " including ancestors for "
- << historic << " updates.";
- fp << endl;
-
- // And give some information about what columns are available.
- int cur_col = 1;
- if (print_id) fp << "# " << cur_col++ << ": ID" << endl;
- if (print_parent_id) fp << "# " << cur_col++ << ": parent ID" << endl;
- if (print_parent2_id) fp << "# " << cur_col++ << ": parent2 ID" << endl;
- if (print_parent_dist) fp << "# " << cur_col++ << ": parent distance" << endl;
- if (print_num_cpus) fp << "# " << cur_col++ << ": number of orgranisms currently alive" << endl;
- if (print_total_cpus) fp << "# " << cur_col++ << ": total number of organisms that ever existed" << endl;
- if (print_length) fp << "# " << cur_col++ << ": length of genome" << endl;
- if (print_merit) fp << "# " << cur_col++ << ": merit" << endl;
- if (print_gest_time) fp << "# " << cur_col++ << ": gestation time" << endl;
- if (print_fitness) fp << "# " << cur_col++ << ": fitness" << endl;
- if (print_update_born) fp << "# " << cur_col++ << ": update born" << endl;
- if (print_update_dead) fp << "# " << cur_col++ << ": update deactivated" << endl;
- if (print_depth) fp << "# " << cur_col++ << ": depth in phylogentic tree" << endl;
- if (print_lineage) fp << "# " << cur_col++ << ": lineage label of genotype" << endl;
- if (print_sequence) fp << "# " << cur_col++ << ": genome of genotype" << endl;
- fp << endl;
-
- // Print the current population....
- genotype_control->Reset(0);
- for (int i = 0; i < genotype_control->GetSize(); i++) {
- cGenotype * genotype = genotype_control->Get(0);
-
- if (print_id) fp << genotype->GetID() << " ";
- if (print_parent_id) fp << genotype->GetParentID() << " ";
- if (print_parent2_id) fp << genotype->GetAncestorID(1) << " ";
- if (print_parent_dist) fp << genotype->GetParentDistance() << " ";
- if (print_num_cpus) fp << genotype->GetNumOrganisms() << " ";
- if (print_total_cpus) fp << genotype->GetTotalOrganisms() << " ";
- if (print_length) fp << genotype->GetLength() << " ";
- if (print_merit) fp << genotype->GetMerit() << " ";
- if (print_gest_time) fp << genotype->GetGestationTime() << " ";
- if (print_fitness) fp << genotype->GetFitness() << " ";
- if (print_update_born) fp << genotype->GetUpdateBorn() << " ";
- if (print_update_dead) fp << genotype->GetUpdateDeactivated() << " ";
- if (print_depth) fp << genotype->GetDepth() << " ";
- if (print_lineage) fp << genotype->GetLineageLabel() << " ";
- if (print_sequence) fp << genotype->GetGenome().AsString() << " ";
- fp << endl;
- genotype_control->Next(0);
- }
-
- // Print the historic population if we are supposed to.
- if (historic == 0) return true;
-
- // Start by calculating the update we should start printing from...
- int start_update = 0;
- if (historic > 0) start_update = stats.GetUpdate() - historic;
-
- // Now loop through the remaining genotypes...
- genotype_control->ResetHistoric(0);
- for (int i = 0; i < genotype_control->GetHistoricCount(); i++) {
- // Get the next genotype. Only print it if its in range...
- cGenotype * genotype = genotype_control->Get(0);
- if (genotype->GetUpdateDeactivated() < start_update) {
- genotype_control->Next(0);
- continue;
- }
-
- if (print_id) fp << genotype->GetID() << " ";
- if (print_parent_id) fp << genotype->GetParentID() << " ";
- if (print_parent2_id) fp << genotype->GetAncestorID(1) << " ";
- if (print_parent_dist) fp << genotype->GetParentDistance() << " ";
- if (print_num_cpus) fp << genotype->GetNumOrganisms() << " ";
- if (print_total_cpus) fp << genotype->GetTotalOrganisms() << " ";
- if (print_length) fp << genotype->GetLength() << " ";
- if (print_merit) fp << genotype->GetMerit() << " ";
- if (print_gest_time) fp << genotype->GetGestationTime() << " ";
- if (print_fitness) fp << genotype->GetFitness() << " ";
- if (print_update_born) fp << genotype->GetUpdateBorn() << " ";
- if (print_update_dead) fp << genotype->GetUpdateDeactivated() << " ";
- if (print_depth) fp << genotype->GetDepth() << " ";
- if (print_lineage) fp << genotype->GetLineageLabel() << " ";
- if (print_sequence) fp << genotype->GetGenome().AsString() << " ";
- fp << endl;
-
- // Move to the next genotype...
- genotype_control->Next(0);
- }
-
-
- return true;
-}
-
-bool cGenebank::DumpDetailedSummary(ofstream & fp)
-{
- genotype_control->Reset(0);
- DumpDetailHeading(fp);
- for (int i = 0; i < genotype_control->GetSize(); i++) {
- DumpDetailedEntry(genotype_control->Get(0), fp);
- genotype_control->Next(0);
- }
-
- return true;
-}
-
-bool cGenebank::DumpHistoricSummary(ofstream & fp, int back_dist)
-{
- // Calculate the update we should start printing from...
- int start_update = 0;
- if (back_dist > 0) start_update = stats.GetUpdate() - back_dist;
-
- // Loop through all defunct genotypes that we're saving.
- DumpDetailHeading(fp);
- genotype_control->ResetHistoric(0);
- for (int i = 0; i < genotype_control->GetHistoricCount(); i++) {
- // Get the next genotype. Only print it if its in range...
- cGenotype * cur_genotype = genotype_control->Get(0);
- if (cur_genotype->GetUpdateDeactivated() < start_update) {
- genotype_control->Next(0);
- continue;
- }
- DumpDetailedEntry(cur_genotype, fp);
-
- // Move to the next genotype...
- genotype_control->Next(0);
- }
-
- return true;
-}
-
-bool cGenebank::DumpDetailedSexSummary(ofstream & fp)
-{
- genotype_control->Reset(0);
- DumpDetailSexHeading(fp);
- for (int i = 0; i < genotype_control->GetSize(); i++) {
- DumpDetailedSexEntry(genotype_control->Get(0), fp);
- genotype_control->Next(0);
- }
-
- return true;
-}
-
-bool cGenebank::DumpHistoricSexSummary(ofstream & fp)
-{
- genotype_control->ResetHistoric(0);
- DumpDetailSexHeading(fp);
- for (int i = 0; i < genotype_control->GetHistoricCount(); i++) {
- DumpDetailedSexEntry(genotype_control->Get(0), fp);
- genotype_control->Next(0);
- }
-
- return true;
-}
-
-void cGenebank::DumpDetailHeading (ofstream & fp)
-{
- fp << "#filetype genotype_data" << endl
- << "#format id parent_id parent_dist num_cpus total_cpus length merit gest_time fitness update_born update_dead depth sequence" << endl
- << endl
- << "# 1: ID" << endl
- << "# 2: parent ID" << endl
- << "# 3: parent distance" << endl
- << "# 4: number of orgranisms currently alive" << endl
- << "# 5: total number of organisms that ever existed" << endl
- << "# 6: length of genome" << endl
- << "# 7: merit" << endl
- << "# 8: gestation time" << endl
- << "# 9: fitness" << endl
- << "# 10: update born" << endl
- << "# 11: update deactivated" << endl
- << "# 12: depth in phylogentic tree" << endl
- << "# 13: genome of organism" << endl << endl;
-}
-
-void cGenebank::DumpDetailSexHeading (ofstream & fp)
-{
- fp << "#filetype genotype_data" << endl
- << "#format id parent_id parent2_id parent_dist num_cpus total_cpus length merit gest_time fitness update_born update_dead depth sequence" << endl
- << endl
- << "# 1: ID" << endl
- << "# 2: parent 1 ID " << endl
- << "# 3: parent 2 ID" << endl
- << "# 4: parent 1 distance" << endl
- << "# 5: number of orgranisms currently alive" << endl
- << "# 6: total number of organisms that ever existed" << endl
- << "# 7: length of genome" << endl
- << "# 8: merit" << endl
- << "# 9: gestation time" << endl
- << "# 10: fitness" << endl
- << "# 11: update born" << endl
- << "# 12: update deactivated" << endl
- << "# 13: depth in phylogentic tree" << endl
- << "# 14: genome of organism" << endl << endl;
-}
-
-void cGenebank::DumpDetailedEntry(cGenotype * genotype, ofstream & fp)
-{
- fp << genotype->GetID() << " " // 1
- << genotype->GetParentID() << " " // 2
- // << genotype->GetAncestorID(1) << " " // 2b
- << genotype->GetParentDistance() << " " // 3
- << genotype->GetNumOrganisms() << " " // 4
- << genotype->GetTotalOrganisms() << " " // 5
- << genotype->GetLength() << " " // 6
- << genotype->GetMerit() << " " // 7
- << genotype->GetGestationTime() << " " // 8
- << genotype->GetFitness() << " " // 9
- << genotype->GetUpdateBorn() << " " // 10
- << genotype->GetUpdateDeactivated() << " " // 11
- << genotype->GetDepth() << " " // 12
- << genotype->GetGenome().AsString() << " " // 13
- << endl;
-}
-
-void cGenebank::DumpDetailedSexEntry(cGenotype * genotype, ofstream & fp)
-{
- fp << genotype->GetID() << " " // 1
- << genotype->GetAncestorID(0) << " " // 2
- << genotype->GetAncestorID(1) << " " // 3
- << genotype->GetParentDistance() << " " // 4
- << genotype->GetNumOrganisms() << " " // 5
- << genotype->GetTotalOrganisms() << " " // 6
- << genotype->GetLength() << " " // 7
- << genotype->GetMerit() << " " // 8
- << genotype->GetGestationTime() << " " // 9
- << genotype->GetFitness() << " " // 10
- << genotype->GetUpdateBorn() << " " // 11
- << genotype->GetUpdateDeactivated() << " " // 12
- << genotype->GetDepth() << " " // 13
- << genotype->GetGenome().AsString() << " " // 14
- << endl;
-}
-
-bool cGenebank::OK()
-{
- bool ret_value = true;
-
- // Check components...
-
- if (!genotype_control->OK() || !species_control->OK()) {
- ret_value = false;
- }
-
- // Now to double check the numbers of genotypes (and threshold) for each
- // species. This will only work if debug mode is on.
-
-#ifdef DEBUG
- // Initialize debug routines in the species.
-
- cSpecies * cur_species = NULL;
- cSpecies * first_active = species_control->GetFirst();
- cSpecies * first_inactive = species_control->GetFirstInactive();
- cSpecies * first_garbage = species_control->GetFirstGarbage();
-
- while (cur_species != first_active) {
- if (!cur_species) cur_species = first_active;
- cur_species->debug_num_genotypes = 0;
- cur_species->debug_num_threshold = 0;
- cur_species = cur_species->GetNext();
- }
-
- cur_species = NULL;
- while (cur_species != first_inactive) {
- if (!cur_species) cur_species = first_inactive;
- cur_species->debug_num_genotypes = 0;
- cur_species->debug_num_threshold = 0;
- cur_species = cur_species->GetNext();
- }
-
- cur_species = NULL;
- while (cur_species != first_garbage) {
- if (!cur_species) cur_species = first_garbage;
- cur_species->debug_num_genotypes = 0;
- cur_species->debug_num_threshold = 0;
- cur_species = cur_species->GetNext();
- }
-
-
- // Check the species for each genotype and place results in the species.
-
- cGenotype * cur_gen = genotype_control->GetBest();
- for (int i = 0; i < genotype_control->GetSize(); i++) {
- if (cur_gen->GetSpecies()) {
- cur_gen->GetSpecies()->debug_num_genotypes++;
- if (cur_gen->GetThreshold()) {
- cur_gen->GetSpecies()->debug_num_threshold++;
- }
- }
- cur_gen = cur_gen->GetNext();
- }
-
- // Finally, make sure all the numbers match up.
-
- cur_species = NULL;
- while (cur_species != first_active) {
- if (!cur_species) cur_species = first_active;
- assert(cur_species->debug_num_genotypes == cur_species->GetNumGenotypes());
- assert(cur_species->debug_num_threshold == cur_species->GetNumThreshold());
- assert(cur_species->debug_num_genotypes >= cur_species->debug_num_threshold);
-
- assert (cur_species->debug_num_threshold);
- cur_species = cur_species->GetNext();
- }
-
- cur_species = NULL;
- while (cur_species != first_inactive) {
- if (!cur_species) cur_species = first_inactive;
- assert(cur_species->debug_num_genotypes == cur_species->GetNumGenotypes());
- assert(cur_species->debug_num_threshold == cur_species->GetNumThreshold());
- assert(cur_species->debug_num_threshold);
- assert(cur_species->debug_num_genotypes);
- }
-
- cur_species = NULL;
- while (cur_species != first_garbage) {
- if (!cur_species) cur_species = first_garbage;
- assert(cur_species->debug_num_genotypes == 0 &&
- cur_species->debug_num_threshold == 0);
- }
-
-#endif
-
- assert (ret_value == true);
-
- return ret_value;
-}
-
-int cGenebank::CountNumCreatures()
-{
- int i;
- int total = 0;
-
- genotype_control->Reset(0);
- for (i = 0; i < genotype_control->GetSize(); i++) {
- total += genotype_control->Get(0)->GetNumOrganisms();
- genotype_control->Next(0);
- }
-
- return total;
-}
-
-
-unsigned int cGenebank::FindCRC(const cGenome & in_genome) const
-{
- unsigned int total = 0;
-
- for (int i = 0; i < in_genome.GetSize(); i++) {
- total += (in_genome[i].GetOp() + 3) * i;
- }
-
- return total % GENOTYPE_HASH_SIZE;
-}
-
-void cGenebank::SpeciesTest(char * message, cGenotype & genotype)
-{
-// cSpecies * cur_species = genotype.GetSpecies();
-
-// if (cur_species) {
-// g_debug.Comment("UD %d: %s on genotype [%d] (size %d) of species [%d]",
-// stats.GetUpdate(), message, genotype.GetID(),
-// genotype.GetNumOrganisms(), cur_species->GetID());
-// } else {
-// g_debug.Comment("UD %d: %s on genotype [%d] (size %d) (no species)",
-// stats.GetUpdate(), message, genotype.GetID(),
-// genotype.GetNumOrganisms());
-// }
-
-// if (cur_species) {
-// g_debug.Comment(" Species [%d] has %d gen and %d thresh. (list %d)",
-// cur_species->GetID(), cur_species->GetNumGenotypes(),
-// cur_species->GetNumThreshold(), cur_species->GetQueueType());
-// }
-}
Deleted: trunk/source/main/genebank.hh
===================================================================
--- trunk/source/main/genebank.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genebank.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,121 +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 GENEBANK_HH
-#define GENEBANK_HH
-
-#include <fstream>
-
-#ifndef DEFS_HH
-#include "defs.hh"
-#endif
-#ifndef GENOTYPE_CONTROL_HH
-#include "genotype_control.hh"
-#endif
-#ifndef SPECIES_CONTROL_HH
-#include "species_control.hh"
-#endif
-#ifndef STRING_HH
-#include "string.hh"
-#endif
-#ifndef TLIST_HH
-#include "tList.hh"
-#endif
-
-template <class T> class tList; // array
-class cGenome;
-class cGenotype;
-class cGenotypeControl; // access
-class cSpeciesControl; // access
-class cStats;
-class cString; // aggregate
-
-class cGenebank {
-private:
- unsigned int genotype_count[MAX_CREATURE_SIZE];
- tList<cGenotype> active_genotypes[GENOTYPE_HASH_SIZE];
- cGenotypeControl * genotype_control;
- cSpeciesControl * species_control;
- cStats & stats;
-
-private:
- cString GetLabel(int in_size, int in_num);
-
-private:
- // disabled copy constructor.
- cGenebank(const cGenebank &);
-public:
- cGenebank(cStats & _stats);
- ~cGenebank();
-
- void UpdateReset();
-
- /**
- * This function can be used to add a genotype that was created
- * outside the genebank. In this case, the parameter in_list_num
- * should not be given. Normally, genotypes are added through the
- * function AddGenotype(const cGenome & in_genome,
- * cGenotype * parent_genotype = NULL), which then calls this one.
- **/
- void AddGenotype(cGenotype *in_genotype, int list_num=-1);
- cGenotype * AddGenotype(const cGenome & in_genome,
- cGenotype * parent_genotype,
- cGenotype * parent2_genotype);
- cGenotype * InjectGenotype(const cGenome & in_genome, int lineage_label);
- const cGenotype * FindGenotype(const cGenome & in_genome, int lineage_label,
- int list_num=-1) const;
- cGenotype * FindGenotype(const cGenome & in_genome, int lineage_label,
- int list_num=-1);
- void RemoveGenotype(cGenotype & in_genotype);
- void ThresholdGenotype(cGenotype & in_genotype);
- bool AdjustGenotype(cGenotype & in_genotype);
-
- bool SaveClone(std::ofstream & fp);
- bool LoadClone(std::ifstream & fp);
- bool DumpTextSummary(std::ofstream & fp);
- bool PrintGenotypes(std::ofstream & fp, cString & data_fields, int historic);
- bool DumpDetailedSummary(std::ofstream & fp);
- bool DumpDetailedSexSummary(std::ofstream & fp);
- bool DumpHistoricSummary(std::ofstream & fp, int back_dist);
- bool DumpHistoricSexSummary(std::ofstream & fp);
- void DumpDetailHeading (std::ofstream & fp);
- void DumpDetailSexHeading (std::ofstream & fp);
- void DumpDetailedEntry(cGenotype * genotype, std::ofstream & fp);
- void DumpDetailedSexEntry(cGenotype * genotype, std::ofstream & fp);
- bool OK();
-
- inline int GetSize() const { return genotype_control->GetSize(); }
- inline cGenotype * GetBestGenotype() const
- { return genotype_control->GetBest(); }
- inline cGenotype * GetCoalescentGenotype() const
- { return genotype_control->GetCoalescent(); }
- inline cSpecies * GetFirstSpecies() const
- { return species_control->GetFirst(); }
-
- inline cGenotype * GetGenotype(int thread) const
- { return genotype_control->Get(thread); }
- inline cGenotype * NextGenotype(int thread) {
- cGenotype * next = genotype_control->Next(thread);
- return (next == genotype_control->GetBest()) ? (cGenotype*)NULL : next;
- }
- inline cGenotype * ResetThread(int thread)
- { return genotype_control->Reset(thread); }
-
- int CountNumCreatures();
- inline int GetNumSpecies() const { return species_control->GetSize(); }
- inline int CountSpecies() { return species_control->OK(); }
- inline int FindPos(cGenotype & in_genotype, int max_depth = -1)
- { return genotype_control->FindPos(in_genotype, max_depth); }
- inline int FindPos(cSpecies & in_species, int max_depth = -1)
- { return species_control->FindPos(in_species, max_depth); }
-
- unsigned int FindCRC(const cGenome & in_genome) const;
-
- void SpeciesTest(char * message, cGenotype & genotype);
-};
-
-#endif
Deleted: trunk/source/main/genome.cc
===================================================================
--- trunk/source/main/genome.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genome.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,98 +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 "genome.hh"
-
-
-using namespace std;
-
-
-/////////////
-// cGenome
-/////////////
-
-cGenome::cGenome(int _size)
- : genome(_size), active_size(_size)
-{
-}
-
-cGenome::cGenome(const cGenome & in_genome)
- : genome(in_genome.GetSize()), active_size(in_genome.GetSize())
-{
- for (int i = 0; i < active_size; i++) genome[i] = in_genome[i];
-}
-
-cGenome::cGenome(const cString & in_string)
-{
- cString tmp_string(in_string);
- tmp_string.RemoveChar('_'); // Remove all blanks from alignments...
-
- active_size = tmp_string.GetSize();
- genome.ResizeClear(active_size);
- for (int i = 0; i < active_size; i++) {
- genome[i].SetSymbol(tmp_string[i]);
- }
-}
-
-cGenome::~cGenome()
-{
-}
-
-
-void cGenome::operator=(const cGenome & other_genome)
-{
- // If we need to resize, do so...
- active_size = other_genome.GetSize();
- genome.ResizeClear(active_size);
-
- // Now that both code arrays are the same size, copy the other one over.
-
- for (int i = 0; i < active_size; i++) {
- genome[i] = other_genome[i];
- }
-}
-
-
-bool cGenome::operator==(const cGenome & other_genome) const
-{
- // Make sure the sizes are the same.
- if (active_size != other_genome.active_size) return false;
-
- // Then go through line by line.
- for (int i = 0; i < active_size; i++)
- if (genome[i] != other_genome[i]) return false;
-
- return true;
-}
-
-
-void cGenome::Copy(int to, int from)
-{
- assert(to >= 0 && to < active_size);
- assert(from >= 0 && from < active_size);
- genome[to] = genome[from];
-}
-
-bool cGenome::OK() const
-{
- assert (active_size <= genome.GetSize()); // active_size too large!
-
- return true;
-}
-
-
-// Return the genome as an alphabetic string
-
-cString cGenome::AsString() const
-{
- cString out_string(active_size);
- for (int i = 0; i < active_size; i++) {
- out_string[i] = genome[i].GetSymbol();
- }
-
- return out_string;
-}
Deleted: trunk/source/main/genome.hh
===================================================================
--- trunk/source/main/genome.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genome.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,60 +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 GENOME_HH
-#define GENOME_HH
-
-#include <assert.h>
-
-#ifndef INSTRUCTION_HH
-#include "instruction.hh"
-#endif
-#ifndef STRING_HH
-#include "string.hh"
-#endif
-#ifndef TARRAY_HH
-#include "tArray.hh"
-#endif
-
-/**
- * This class stores the genome of an Avida organism. Note that once created,
- * a genome should not be modified; only the corresponding memory should be,
- * before creating the genome. Keeping genome light-weight...
- **/
-
-class cGenome {
-protected:
- tArray<cInstruction> genome;
- int active_size;
-
-public:
- explicit cGenome(int _size);
- cGenome(const cGenome & in_genome);
- cGenome(const cString & in_string);
- virtual ~cGenome();
-
- virtual void operator=(const cGenome & other_genome);
- virtual bool operator==(const cGenome & other_genome) const;
- virtual bool operator!=(const cGenome & other_genome) const
- { return !(this->operator==(other_genome)); }
- virtual bool operator<(const cGenome & other_genome) const
- { return AsString() < other_genome.AsString(); }
-
- cInstruction & operator[](int index)
- { assert(index >= 0 && index < active_size); return genome[index]; }
- const cInstruction & operator[](int index) const
- { assert(index >= 0 && index < active_size); return genome[index]; }
-
- virtual void Copy(int to, int from);
-
- bool OK() const;
-
- int GetSize() const { return active_size; }
- cString AsString() const;
-};
-
-#endif
Deleted: trunk/source/main/genome_util.cc
===================================================================
--- trunk/source/main/genome_util.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genome_util.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,214 +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 "genome_util.hh"
-
-#include "functions.hh"
-#include "genome.hh"
-
-
-using namespace std;
-
-
-int cGenomeUtil::FindInst(const cGenome & gen, const cInstruction & inst,
- int start_index)
-{
- assert(start_index < gen.GetSize()); // Starting search after genome end.
-
- for(int i = start_index; i < gen.GetSize(); i++) {
- if (gen[i] == inst) return i;
- }
-
- // Search failed
- return -1;
-}
-
-
-int cGenomeUtil::FindOverlap(const cGenome & gen1, const cGenome & gen2,
- int offset)
-{
- assert(offset < gen1.GetSize());
- assert(-offset < gen2.GetSize());
-
- if (offset > 0) return Min(gen1.GetSize() - offset, gen2.GetSize());
- // else
- return Min(gen2.GetSize() + offset, gen1.GetSize());
-}
-
-
-int cGenomeUtil::FindHammingDistance(const cGenome &gen1, const cGenome &gen2,
- int offset)
-{
- const int start1 = (offset < 0) ? 0 : offset;
- const int start2 = (offset > 0) ? 0 : -offset;
- const int overlap = FindOverlap(gen1, gen2, offset);
-
- // Initialize the hamming distance to anything protruding past the overlap.
-
- int hamming_distance = gen1.GetSize() + gen2.GetSize() - 2 * overlap;
-
- // Cycle through the overlap adding all differences to the distance.
- for (int i = 0; i < overlap; i++) {
- if (gen1[start1 + i] != gen2[start2 + i]) hamming_distance++;
- }
-
- return hamming_distance;
-}
-
-
-int cGenomeUtil::FindBestOffset(const cGenome & gen1, const cGenome & gen2)
-{
- const int size1 = gen1.GetSize();
- const int size2 = gen2.GetSize();
-
- int best_offset = 0;
- int cur_distance = FindHammingDistance(gen1, gen2);
- int best_distance = cur_distance;
-
- // Check positive offsets...
- for (int i = 1; i < size1 || i < size2; i++) {
- if (size1 + size2 - 2 * FindOverlap(gen1, gen2, i) > best_distance) break;
- cur_distance = FindHammingDistance(gen1, gen2, i);
- if (cur_distance < best_distance) {
- best_distance = cur_distance;
- best_offset = i;
- }
- }
-
- // Check negative offsets...
- for (int i = 1; i < size1 || i < size2; i++) {
- if (size1 + size2 - 2 * FindOverlap(gen1, gen2, -i) > best_distance) break;
- cur_distance = FindHammingDistance(gen1, gen2, -i);
- if (cur_distance < best_distance) {
- best_distance = cur_distance;
- best_offset = -i;
- }
- }
-
- return best_offset;
-}
-
-
-int cGenomeUtil::FindSlidingDistance(const cGenome &gen1, const cGenome &gen2)
-{
- const int offset = FindBestOffset(gen1, gen2);
- return FindHammingDistance(gen1, gen2, offset);
-}
-
-
-int cGenomeUtil::FindEditDistance(const cGenome & gen1, const cGenome & gen2)
-{
- const int size1 = gen1.GetSize();
- const int size2 = gen2.GetSize();
-
- if (!size1) return size2;
- if (!size2) return size1;
-
- int * cur_row = new int[size1]; // The row we are calculating
- int * prev_row = new int[size1]; // The last row we calculater
-
- // Initialize the previous row to record the differece from nothing.
- for (int i = 0; i < size1; i++) prev_row[i] = i + 1;
-
- // Loop through each subsequent character in the test code
- for (int i = 0; i < size2; i++) {
- // Initialize the first entry in cur_row.
- if (gen1[0] == gen2[i]) cur_row[0] = i;
- else cur_row[0] = (i < prev_row[0]) ? (i+1) : (prev_row[0] + 1);
-
- // Move down the cur_row and fill it out.
- for (int j = 1; j < size1; j++) {
- // If the values are equal, keep the value in the upper left.
- if (gen1[j] == gen2[i]) {
- cur_row[j] = prev_row[j-1];
- }
-
- // Otherwise, set the current position the the minimal of the three
- // numbers above (insertion), to the left (deletion), or upper left
- // (mutation) in the chart, plus one.
- else {
- cur_row[j] =
- (prev_row[j] < prev_row[j-1]) ? prev_row[j] : prev_row[j-1];
- if (cur_row[j-1] < cur_row[j]) cur_row[j] = cur_row[j-1];
- cur_row[j]++;
- }
- }
-
- // Swap cur_row and prev_row. (we only really need to move the cur row
- // over to prev, but this saves us from having to keep re-allocating
- // new rows. We recycle!
- int * temp_row = cur_row;
- cur_row = prev_row;
- prev_row = temp_row;
- }
-
- // Now that we are done, return the bottom-right corner of the chart.
-
- const int value = prev_row[size1 - 1];
-
- delete [] cur_row;
- delete [] prev_row;
-
- return value;
-}
-
-
-cGenome cGenomeUtil::Crop(const cGenome & in_genome, int start, int end)
-{
- assert(end > start); // Must have a positive length clip!
- assert(in_genome.GetSize() >= end); // end must be < genome length
- assert(start >= 0); // negative start illegal
-
- const int out_length = end - start;
- cGenome out_genome(out_length);
- for (int i = 0; i < out_length; i++) {
- out_genome[i] = in_genome[i+start];
- }
-
- return out_genome;
-}
-
-
-cGenome cGenomeUtil::Cut(const cGenome & in_genome, int start, int end)
-{
- assert(end > start); // Must have a positive size cut!
- assert(in_genome.GetSize() >= end); // end must be < genome length
- assert(start >= 0); // negative start illegal
-
- const int cut_length = end - start;
- const int out_length = in_genome.GetSize() - cut_length;
-
- assert(out_length > 0); // Can't cut everything!
-
- cGenome out_genome(out_length);
- for (int i = 0; i < start; i++) {
- out_genome[i] = in_genome[i];
- }
- for (int i = start; i < out_length; i++) {
- out_genome[i] = in_genome[i+cut_length];
- }
-
- return out_genome;
-}
-
-
-cGenome cGenomeUtil::Join(const cGenome & genome1, const cGenome & genome2)
-{
- const int length1 = genome1.GetSize();
- const int length2 = genome2.GetSize();
- const int out_length = length1 + length2;
-
- cGenome out_genome(out_length);
- for (int i = 0; i < length1; i++) {
- out_genome[i] = genome1[i];
- }
- for (int i = 0; i < length2; i++) {
- out_genome[i+length1] = genome2[i];
- }
-
- return out_genome;
-}
Deleted: trunk/source/main/genome_util.hh
===================================================================
--- trunk/source/main/genome_util.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genome_util.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,39 +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 GENOME_UTIL_HH
-#define GENOME_UTIL_HH
-
-#ifndef GENOME_HH
-#include "genome.hh"
-#endif
-
-class cInstruction;
-class cGenomeUtil {
-public:
- // ========= Detection =========
- static int FindInst(const cGenome & gen, const cInstruction & inst,
- int start_index=0);
- static bool HasInst(const cGenome & gen, const cInstruction & inst)
- { return ( FindInst(gen, inst) >= 0 ) ? true : false; }
-
- // === Genetic distance tools ===
- static int FindOverlap(const cGenome & gen1, const cGenome & gen2,
- int offset = 0);
- static int FindHammingDistance(const cGenome & gen1, const cGenome & gen2,
- int offset = 0);
- static int FindBestOffset(const cGenome & gen1, const cGenome & gen2);
- static int FindSlidingDistance(const cGenome & gen1, const cGenome & gen2);
- static int FindEditDistance(const cGenome & gen1, const cGenome & gen2);
-
- // ===== Construction methods =====
- static cGenome Crop(const cGenome & genome, int start, int end);
- static cGenome Cut(const cGenome & genome, int start, int end);
- static cGenome Join(const cGenome & genome1, const cGenome & genome2);
-};
-
-#endif
Deleted: trunk/source/main/genotype.cc
===================================================================
--- trunk/source/main/genotype.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genotype.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,365 +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 "genotype.hh"
-
-#include "cConfig.h"
-#include "cCPUTestInfo.h"
-#include "genome_util.hh"
-#include "merit.hh"
-#include "organism.hh"
-#include "phenotype.hh"
-#include "cTestCPU.h"
-#include "tools.hh"
-
-using namespace std;
-
-class cSpecies;
-
-///////////////////////////
-// cGenotype
-///////////////////////////
-
-cGenotype::cGenotype(int in_update_born, int in_id)
- : genome(1)
- , name("001-no_name")
- , flag_threshold(false)
- , is_active(true)
- , defer_adjust(0)
- , symbol(0)
- , birth_data(in_update_born)
- , num_organisms(0)
- , last_num_organisms(0)
- , total_organisms(0)
- , total_parasites(0)
- , species(NULL)
- , next(NULL)
- , prev(NULL)
-{
- static int next_id = 1;
-
- if ( in_id >= 0 )
- next_id = in_id;
-
- id_num = next_id++;
-}
-
-cGenotype::~cGenotype()
-{
- // Reset some of the variables to make sure program will crash if a deleted
- // cell is read!
-
- symbol = '!';
-
- num_organisms = -1;
- total_organisms = -1;
-
- next = NULL;
- prev = NULL;
-}
-
-bool cGenotype::SaveClone(ofstream & fp)
-{
- fp << id_num << " ";
- fp << genome.GetSize() << " ";
-
- for (int i = 0; i < genome.GetSize(); i++) {
- fp << ((int) genome[i].GetOp()) << " ";
- }
-
- return true;
-}
-
-bool cGenotype::LoadClone(ifstream & fp)
-{
- int genome_size = 0;
-
- fp >> id_num;
- fp >> genome_size;
-
- genome = cGenome(genome_size);
- for (int i = 0; i < genome_size; i++) {
- cInstruction temp_inst;
- int inst_op;
- fp >> inst_op;
- temp_inst.SetOp((UCHAR) inst_op);
- genome[i] = temp_inst;
- // @CAO add something here to load arguments for instructions.
- }
-
- return true;
-}
-
-bool cGenotype::OK()
-{
- bool ret_value = true;
-
- // Check the components...
-
- if (!genome.OK()) ret_value = false;
-
- // And the statistics
- assert( id_num >= 0 && num_organisms >= 0 && total_organisms >= 0 );
- assert( birth_data.update_born >= -1 && birth_data.parent_distance >= -1 );
- assert( sum_copied_size.Sum() >= 0 && sum_exe_size.Sum() >= 0 );
- assert( sum_gestation_time.Sum() >= 0 && sum_repro_rate.Sum() >= 0 );
- assert( sum_merit.Sum() >= 0 && sum_fitness.Sum() >= 0 );
- assert( tmp_sum_copied_size.Sum() >= 0 && tmp_sum_exe_size.Sum() >= 0 );
- assert( tmp_sum_gestation_time.Sum() >= 0 && tmp_sum_repro_rate.Sum() >= 0 );
- assert( tmp_sum_merit.Sum() >= 0 && tmp_sum_fitness.Sum() >= 0 );
-
- return ret_value;
-}
-
-void cGenotype::SetParent(cGenotype * parent, cGenotype * parent2)
-{
- birth_data.parent_genotype = parent;
- birth_data.parent2_genotype = parent2;
-
- // If we have a real parent genotype, collect other data about parent.
- if (parent == NULL) return;
- birth_data.ancestor_ids[0] = parent->GetID();
- birth_data.ancestor_ids[2] = parent->GetAncestorID(0);
- birth_data.ancestor_ids[3] = parent->GetAncestorID(1);
- if (parent2 != NULL) {
- birth_data.ancestor_ids[1] = parent2->GetID();
- birth_data.ancestor_ids[4] = parent2->GetAncestorID(0);
- birth_data.ancestor_ids[5] = parent2->GetAncestorID(1);
- }
-
- birth_data.parent_distance =
- cGenomeUtil::FindEditDistance(genome, parent->genome);
- birth_data.parent_species = parent->GetSpecies();
- birth_data.gene_depth = parent->GetDepth() + 1;
- birth_data.lineage_label = parent->GetLineageLabel();
- parent->AddOffspringGenotype();
- if (parent2 != NULL && cConfig::GetTrackMainLineage() == 2) {
- parent2->AddOffspringGenotype();
- }
-
- // Initialize all stats to those of the parent genotype....
- tmp_sum_copied_size.Add( parent->GetCopiedSize());
- tmp_sum_exe_size.Add( parent->GetExecutedSize());
- tmp_sum_gestation_time.Add( parent->GetGestationTime());
- tmp_sum_repro_rate.Add( 1/parent->GetGestationTime());
- tmp_sum_merit.Add( parent->GetMerit());
- tmp_sum_fitness.Add( parent->GetFitness());
-}
-
-void cGenotype::Mutate() // Check each location to be mutated.
-{
- int i;
-
- for (i = 0; i < genome.GetSize(); i++) {
- if (true) { // g_random.GetUInt()) { //@CAO always true!
- genome[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
- // Flag command as having been mutated? @CAO
- }
- }
-}
-
-void cGenotype::UpdateReset()
-{
- last_num_organisms = num_organisms;
- birth_data.birth_track.Next();
- birth_data.death_track.Next();
- birth_data.breed_out_track.Next();
- birth_data.breed_true_track.Next();
- birth_data.breed_in_track.Next();
-}
-
-void cGenotype::SetGenome(const cGenome & in_genome)
-{
- genome = in_genome;
- // Zero Stats
- sum_copied_size.Clear();
- sum_exe_size.Clear();
- sum_gestation_time.Clear();
- sum_repro_rate.Clear();
- sum_merit.Clear();
- sum_fitness.Clear();
- tmp_sum_copied_size.Clear();
- tmp_sum_exe_size.Clear();
- tmp_sum_gestation_time.Clear();
- tmp_sum_repro_rate.Clear();
- tmp_sum_merit.Clear();
- tmp_sum_fitness.Clear();
-
- name.Set("%03d-no_name", genome.GetSize());
-}
-
-void cGenotype::CalcTestStats() const
-{
- // cerr << ".......Calculating test stats..." << endl;
-
- cCPUTestInfo test_info;
- cTestCPU::TestGenome(test_info, genome);
- test_data.is_viable = test_info.IsViable();
-
- // Setup all possible test values.
- cPhenotype & phenotype = test_info.GetTestOrganism()->GetPhenotype();
- test_data.fitness = test_info.GetGenotypeFitness();
- test_data.merit = phenotype.GetMerit().GetDouble();
- test_data.gestation_time = phenotype.GetGestationTime();
- test_data.executed_size = phenotype.GetExecutedSize();
- test_data.copied_size = phenotype.GetCopiedSize();
- test_data.colony_fitness = test_info.GetColonyFitness();
- test_data.generations = test_info.GetMaxDepth();
-}
-
-
-bool cGenotype::GetTestViable() const {
- if (test_data.fitness == -1) CalcTestStats();
- return test_data.is_viable;
-}
-
-
-double cGenotype::GetTestFitness() const {
- if (test_data.fitness == -1) CalcTestStats();
- return test_data.fitness;
-}
-
-
-double cGenotype::GetTestMerit() const {
- if (test_data.fitness == -1) CalcTestStats();
- return test_data.merit;
-}
-
-
-int cGenotype::GetTestGestationTime() const {
- if (test_data.fitness == -1) CalcTestStats();
- return test_data.gestation_time;
-}
-
-
-int cGenotype::GetTestExecutedSize() const {
- if (test_data.fitness == -1) CalcTestStats();
- return test_data.executed_size;
-}
-
-
-int cGenotype::GetTestCopiedSize() const {
- if (test_data.fitness == -1) CalcTestStats();
- return test_data.copied_size;
-}
-
-
-double cGenotype::GetTestColonyFitness() const {
- if (test_data.fitness == -1) CalcTestStats();
- return test_data.colony_fitness;
-}
-
-
-int cGenotype::GetTestGenerations() const {
- if (test_data.fitness == -1) CalcTestStats();
- return test_data.generations;
-}
-
-void cGenotype::SetSpecies(cSpecies * in_species)
-{
- species = in_species;
-}
-
-void cGenotype::AddMerit(const cMerit & in)
-{
- sum_merit.Add(in.GetDouble());
-}
-
-void cGenotype::RemoveMerit(const cMerit & in)
-{
- sum_merit.Subtract(in.GetDouble());
-}
-
-void cGenotype::Deactivate(int update)
-{
- is_active = false;
- birth_data.update_deactivated = update;
-}
-
-int cGenotype::GetPhyloDistance(cGenotype * test_genotype)
-{
- if (GetID() == test_genotype->GetID()) {
- return 0;
- }
- if (GetID() == test_genotype->GetAncestorID(0) || // Parent of test
- GetID() == test_genotype->GetAncestorID(1) || // Parent of test
- test_genotype->GetID() == GetAncestorID(0) || // Child of test
- test_genotype->GetID() == GetAncestorID(1) // Child of test
- ) {
- return 1;
- }
- if (GetID() == test_genotype->GetAncestorID(2) || // Grandparent of test
- GetID() == test_genotype->GetAncestorID(3) || // Grandparent of test
- GetID() == test_genotype->GetAncestorID(4) || // Grandparent of test
- GetID() == test_genotype->GetAncestorID(5) || // Grandparent of test
- test_genotype->GetID() == GetAncestorID(2) || // Grandchild of test
- test_genotype->GetID() == GetAncestorID(3) || // Grandchild of test
- test_genotype->GetID() == GetAncestorID(4) || // Grandchild of test
- test_genotype->GetID() == GetAncestorID(5) || // Grandchild of test
- GetAncestorID(0) == test_genotype->GetAncestorID(0) || // Sibling of test
- GetAncestorID(0) == test_genotype->GetAncestorID(1) || // Sibling of test
- GetAncestorID(1) == test_genotype->GetAncestorID(0) || // Sibling of test
- GetAncestorID(1) == test_genotype->GetAncestorID(1) // Sibling of test
- ) {
- return 2;
- }
- if (GetAncestorID(0) == test_genotype->GetAncestorID(2) || // Uncle of test
- GetAncestorID(0) == test_genotype->GetAncestorID(3) || // Uncle of test
- GetAncestorID(0) == test_genotype->GetAncestorID(4) || // Uncle of test
- GetAncestorID(0) == test_genotype->GetAncestorID(5) || // Uncle of test
- GetAncestorID(1) == test_genotype->GetAncestorID(2) || // Uncle of test
- GetAncestorID(1) == test_genotype->GetAncestorID(3) || // Uncle of test
- GetAncestorID(1) == test_genotype->GetAncestorID(4) || // Uncle of test
- GetAncestorID(1) == test_genotype->GetAncestorID(5) || // Uncle of test
- test_genotype->GetAncestorID(0) == GetAncestorID(2) || // Nephew of test
- test_genotype->GetAncestorID(0) == GetAncestorID(3) || // Nephew of test
- test_genotype->GetAncestorID(0) == GetAncestorID(4) || // Nephew of test
- test_genotype->GetAncestorID(0) == GetAncestorID(5) || // Nephew of test
- test_genotype->GetAncestorID(1) == GetAncestorID(2) || // Nephew of test
- test_genotype->GetAncestorID(1) == GetAncestorID(3) || // Nephew of test
- test_genotype->GetAncestorID(1) == GetAncestorID(4) || // Nephew of test
- test_genotype->GetAncestorID(1) == GetAncestorID(5) // Nephew of test
- ) {
- return 3;
- }
-
- if (GetAncestorID(2) == test_genotype->GetAncestorID(2) || // First Cousins
- GetAncestorID(2) == test_genotype->GetAncestorID(3) ||
- GetAncestorID(2) == test_genotype->GetAncestorID(4) ||
- GetAncestorID(2) == test_genotype->GetAncestorID(5) ||
- GetAncestorID(3) == test_genotype->GetAncestorID(2) ||
- GetAncestorID(3) == test_genotype->GetAncestorID(3) ||
- GetAncestorID(3) == test_genotype->GetAncestorID(4) ||
- GetAncestorID(3) == test_genotype->GetAncestorID(5) ||
- GetAncestorID(4) == test_genotype->GetAncestorID(2) ||
- GetAncestorID(4) == test_genotype->GetAncestorID(3) ||
- GetAncestorID(4) == test_genotype->GetAncestorID(4) ||
- GetAncestorID(4) == test_genotype->GetAncestorID(5) ||
- GetAncestorID(5) == test_genotype->GetAncestorID(2) ||
- GetAncestorID(5) == test_genotype->GetAncestorID(3) ||
- GetAncestorID(5) == test_genotype->GetAncestorID(4) ||
- GetAncestorID(5) == test_genotype->GetAncestorID(5)
- ) {
- return 4;
- }
-
- return 5;
-}
-
-
-int cGenotype::AddOrganism()
-{
- total_organisms++;
- return num_organisms++;
-}
-
-int cGenotype::RemoveOrganism()
-{
- birth_data.death_track.Inc();
- return num_organisms--;
-}
-
Deleted: trunk/source/main/genotype.hh
===================================================================
--- trunk/source/main/genotype.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genotype.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,249 +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 GENOTYPE_HH
-#define GENOTYPE_HH
-
-#include <fstream>
-
-#ifndef DOUBLE_SUM_HH
-#include "double_sum.hh"
-#endif
-#ifndef GENOME_HH
-#include "genome.hh"
-#endif
-#ifndef GENOTYPE_BIRTH_DATA_HH
-#include "genotype_birth_data.hh"
-#endif
-#ifndef GENOTYPE_TEST_DATA_HH
-#include "genotype_test_data.hh"
-#endif
-#ifndef STRING_HH
-#include "string.hh"
-#endif
-
-class cSpecies;
-class cMerit;
-
-class cGenotype {
-private:
- cGenome genome;
- cString name;
- bool flag_threshold;
- bool is_active; // Is this genotype still alive?
- int defer_adjust; // Don't adjust in the genebank until all are cleared.
-
- int id_num;
- char symbol;
-
- mutable cGenotype_TestData test_data;
- cGenotype_BirthData birth_data;
-
- // Statistical info
-
- int num_organisms;
- int last_num_organisms;
- int total_organisms;
- int total_parasites;
-
- cSpecies * species;
-
- // Data Structure stuff...
- cGenotype * next;
- cGenotype * prev;
-
-
- ////// Statistical info //////
-
- // Collected on Divides
- cDoubleSum sum_copied_size;
- cDoubleSum sum_exe_size;
-
- cDoubleSum sum_gestation_time;
- cDoubleSum sum_repro_rate; // should make gestation obsolete (not new)
-
- cDoubleSum sum_merit;
- cDoubleSum sum_fitness;
-
- // Temporary (Approx stats used before any divides done)
- // Set in "SetParent"
- cDoubleSum tmp_sum_copied_size;
- cDoubleSum tmp_sum_exe_size;
-
- cDoubleSum tmp_sum_gestation_time;
- cDoubleSum tmp_sum_repro_rate;
-
- cDoubleSum tmp_sum_merit;
- cDoubleSum tmp_sum_fitness;
-
- void CalcTestStats() const;
-public:
- /**
- * Constructs an empty genotype. Normally, in_id should not specified as
- * parameter, because cGenotype keeps track of the last id given out, and
- * choses a new one based on that. However, in some cases it is necessary
- * to specify an id (e.g., when loading a history file from disk). Note
- * that in this case, cGenotype does not check if the id has already been
- * used before.
- **/
- cGenotype(int in_update_born = 0, int in_id = -1);
- ~cGenotype();
-
- bool SaveClone(std::ofstream & fp);
- bool LoadClone(std::ifstream & fp);
- bool OK();
- void Mutate();
- void UpdateReset();
-
- void SetGenome(const cGenome & in_genome);
- void SetSpecies(cSpecies * in_species);
-
- // Test CPU info -- only used with limited options on.
- bool GetTestViable() const;
- double GetTestFitness() const;
- double GetTestMerit() const;
- int GetTestGestationTime() const;
- int GetTestExecutedSize() const;
- int GetTestCopiedSize() const;
- double GetTestColonyFitness() const;
- int GetTestGenerations() const;
-
- void SetParent(cGenotype * parent, cGenotype * parent2);
- void SetName(cString in_name) { name = in_name; }
- void SetNext(cGenotype * in_next) { next = in_next; }
- void SetPrev(cGenotype * in_prev) { prev = in_prev; }
- void SetSymbol(char in_symbol) { symbol = in_symbol; }
- inline void SetThreshold();
- void IncDeferAdjust() { defer_adjust++; }
- void DecDeferAdjust() { defer_adjust--; assert(defer_adjust >= 0); }
- void SetLineageLabel(int in_label) { birth_data.lineage_label = in_label; }
-
- // Setting New Stats
- void AddCopiedSize (int in) { sum_copied_size.Add(in); }
- void AddExecutedSize (int in) { sum_exe_size.Add(in); }
- void AddGestationTime (int in) { sum_gestation_time.Add(in);
- sum_repro_rate.Add(1/(double)in); }
- void AddMerit (const cMerit & in);
- void RemoveMerit (const cMerit & in);
- void AddFitness (double in){
- assert(in >= 0.0);
- sum_fitness.Add(in);
- }
- void RemoveFitness (double in){
- assert(in >= 0.0);
- sum_fitness.Subtract(in);
- }
-
- //// Properties Native to Genotype ////
- cGenome & GetGenome() { return genome; }
- const cGenome & GetGenome() const { return genome; }
- int GetLength() const { return genome.GetSize(); }
-
- int GetBirths() const { return birth_data.birth_track.GetTotal(); }
- int GetBreedOut() const { return birth_data.breed_out_track.GetTotal(); }
- int GetBreedTrue() const { return birth_data.breed_true_track.GetTotal(); }
- int GetBreedIn() const { return birth_data.breed_in_track.GetTotal(); }
-
- int GetThisBirths() const { return birth_data.birth_track.GetCur(); }
- int GetThisBreedOut() const { return birth_data.breed_out_track.GetCur(); }
- int GetThisBreedTrue() const { return birth_data.breed_true_track.GetCur(); }
- int GetThisBreedIn() const { return birth_data.breed_in_track.GetCur(); }
-
- int GetThisDeaths() const { return birth_data.death_track.GetCur(); }
-
- int GetLastNumOrganisms() const { return last_num_organisms; }
- int GetLastBirths() const { return birth_data.birth_track.GetLast(); }
- int GetLastBreedOut() const { return birth_data.breed_out_track.GetLast(); }
- int GetLastBreedTrue() const { return birth_data.breed_true_track.GetLast();}
- int GetLastBreedIn() const { return birth_data.breed_in_track.GetLast(); }
-
- inline void SetBreedStats(cGenotype & daughter); // called by ActivateChild
-
- //// Properties Averaged Over Creatues ////
- double GetCopiedSize() const { return (sum_copied_size.Count()>0) ?
- sum_copied_size.Average() : tmp_sum_copied_size.Average(); }
- double GetExecutedSize() const { return (sum_exe_size.Count()>0) ?
- sum_exe_size.Average() : tmp_sum_exe_size.Average(); }
- double GetGestationTime() const { return (sum_gestation_time.Count()>0) ?
- sum_gestation_time.Average() : tmp_sum_gestation_time.Average(); }
- double GetReproRate() const { return (sum_repro_rate.Count()>0) ?
- sum_repro_rate.Average() : tmp_sum_repro_rate.Average(); }
- double GetMerit() const { return (sum_merit.Count()>0) ?
- sum_merit.Average() : tmp_sum_merit.Average(); }
- double GetFitness() const { return (sum_fitness.Count()>0) ?
- sum_fitness.Average() : tmp_sum_fitness.Average(); }
-
-
- // For tracking the genotype line back to the ancestor...
- cGenotype * GetParentGenotype() { return birth_data.parent_genotype; }
- cGenotype * GetParent2Genotype() { return birth_data.parent2_genotype; }
- int GetNumOffspringGenotypes() const
- { return birth_data.num_offspring_genotypes; }
- void AddOffspringGenotype() { birth_data.num_offspring_genotypes++; }
- void RemoveOffspringGenotype() { birth_data.num_offspring_genotypes--; }
- bool GetActive() const { return is_active; }
- bool GetDeferAdjust() const { return defer_adjust > 0; }
- int GetUpdateDeactivated() { return birth_data.update_deactivated; }
- void Deactivate(int update);
-
- int GetUpdateBorn() const { return birth_data.update_born; }
- int GetParentID() const { return birth_data.ancestor_ids[0]; }
- int GetAncestorID(int anc) const { return birth_data.ancestor_ids[anc]; }
- int GetParentDistance() const { return birth_data.parent_distance; }
- int GetDepth() const { return birth_data.gene_depth; }
- int GetLineageLabel() const { return birth_data.lineage_label; }
- cString & GetName() { return name; }
- cSpecies * GetSpecies() { return species; }
- cSpecies * GetParentSpecies() { return birth_data.parent_species; }
- cGenotype * GetNext() { return next; }
- cGenotype * GetPrev() { return prev; }
- bool GetThreshold() const { return flag_threshold; }
- int GetID() const { return id_num; }
- char GetSymbol() const { return symbol; }
-
- // Calculate a crude phylogentic distance based off of tracking parents
- // and grand-parents, including sexual tracking.
- int GetPhyloDistance(cGenotype * test_genotype);
-
- int AddOrganism();
- int RemoveOrganism();
- int AddParasite() { return ++total_parasites; }
- void SwapOrganism() { total_organisms++; }
- int GetNumOrganisms() { return num_organisms; }
- int GetTotalOrganisms() { return total_organisms; }
- int GetTotalParasites() { return total_parasites; }
-};
-
-// The genotype pointer template...
-
-
-
-// All the inline stuff...
-
- ////////////////
- // cGenotype //
-////////////////
-
-inline void cGenotype::SetThreshold()
-{
- flag_threshold = true;
- if (symbol == '.') symbol = '+';
-}
-
-
-inline void cGenotype::SetBreedStats(cGenotype & daughter)
-{
- birth_data.birth_track.Inc();
- if (daughter.id_num == id_num) {
- birth_data.breed_true_track.Inc();
- } else {
- birth_data.breed_out_track.Inc();
- daughter.birth_data.breed_in_track.Inc();
- }
-}
-
-#endif
Deleted: trunk/source/main/genotype_batch.hh
===================================================================
--- trunk/source/main/genotype_batch.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genotype_batch.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,47 +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 GENOTYPE_BATCH_HH
-#define GENOTYPE_BATCH_HH
-
-#ifndef STRING_HH
-#include "string.hh"
-#endif
-#ifndef TLIST_HH
-#include "tList.hh"
-#endif
-
-// cGenotypeBatch : Collection of cAnalyzeGenotypes
-
-template <class T> class tList; // aggregate
-class cString; // aggregate
-class cAnalyzeGenotype;
-
-class cGenotypeBatch {
-private:
- tListPlus<cAnalyzeGenotype> genotype_list;
- cString name;
- bool is_lineage;
- bool is_aligned;
-private:
- // disabled copy constructor.
- cGenotypeBatch(const cGenotypeBatch &);
-public:
- cGenotypeBatch() : name(""), is_lineage(false), is_aligned(false) { ; }
- ~cGenotypeBatch() { ; }
-
- tListPlus<cAnalyzeGenotype> & List() { return genotype_list; }
- cString & Name() { return name; }
- bool IsLineage() { return is_lineage; }
- bool IsAligned() { return is_aligned; }
-
- void SetLineage(bool _val=true) { is_lineage = _val; }
- void SetAligned(bool _val=true) { is_aligned = _val; }
-
-};
-
-#endif
Deleted: trunk/source/main/genotype_birth_data.cc
===================================================================
--- trunk/source/main/genotype_birth_data.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genotype_birth_data.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -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 GENOTYPE_BIRTH_DATA_HH
-#include "genotype_birth_data.hh"
-#endif
-
-#ifndef DEFS_HH
-#include "defs.hh"
-#endif
-
-/////////////////////////
-// cGenotype_BirthData
-/////////////////////////
-
-cGenotype_BirthData::cGenotype_BirthData(int in_update_born)
- : update_born(in_update_born)
- , parent_distance(-1)
- , gene_depth(0)
- , update_deactivated(-1)
- , parent_genotype(NULL)
- , parent_species(NULL)
- , num_offspring_genotypes(0)
-{
- // @CAO: we should do a test to see if we have a sexual population. For now
- // we will assume we do.
- ancestor_ids.Resize(6);
- ancestor_ids.SetAll(-1);
-}
-
-cGenotype_BirthData::~cGenotype_BirthData()
-{
-}
Deleted: trunk/source/main/genotype_birth_data.hh
===================================================================
--- trunk/source/main/genotype_birth_data.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genotype_birth_data.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,50 +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 GENOTYPE_BIRTH_DATA_HH
-#define GENOTYPE_BIRTH_DATA_HH
-
-#ifndef COUNT_TRACKER_HH
-#include "count_tracker.hh"
-#endif
-
-#ifndef TARRAY_HH
-#include "tArray.hh"
-#endif
-
-class cGenotype;
-class cSpecies;
-class cGenotype_BirthData {
-public:
- cGenotype_BirthData(int in_update_born);
- ~cGenotype_BirthData();
-
- cCountTracker birth_track;
- cCountTracker death_track;
- cCountTracker breed_in_track;
- cCountTracker breed_true_track;
- cCountTracker breed_out_track;
-
- int update_born; // Update genotype was first created
- int parent_distance; // Genetic distance from parent genotype
- int gene_depth; // depth in the phylogenetic tree from ancestor
- int lineage_label; // Unique label for the lineage of this genotype.
-
- int update_deactivated; // If not, when did it get deactivated?
- cGenotype * parent_genotype; // Pointer to parent genotype...
- cGenotype * parent2_genotype; // Pointer to secondary parent genotype...
- cSpecies * parent_species;
- int num_offspring_genotypes; // Num offspring genotypes still in memory.
-
- // Ancestral IDs. This array contains all of the information about the
- // ids of the ancestors. It will have one entry if this is an asexual
- // population, otherwise:
- // [0]=parent1, [1]=parent2, [2]&[3]=grandparents 1, [4]&[5]=grandparents 2
- tArray<int> ancestor_ids;
-};
-
-#endif
Deleted: trunk/source/main/genotype_control.cc
===================================================================
--- trunk/source/main/genotype_control.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genotype_control.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,288 +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 GENOTYPE_CONTROL_HH
-#include "genotype_control.hh"
-#endif
-
-#ifndef DEFS_HH
-#include "defs.hh"
-#endif
-#ifndef GENEBANK_HH
-#include "genebank.hh"
-#endif
-#ifndef GENOTYPE_HH
-#include "genotype.hh"
-#endif
-
-///////////////////////
-// cGenotypeControl
-///////////////////////
-
-cGenotypeControl::cGenotypeControl(cGenebank & in_gb) : genebank(in_gb)
-{
- size = 0;
- best = NULL;
- coalescent = NULL;
- for (int i = 0; i < GENOTYPE_THREADS; i++) threads[i] = NULL;
-
- historic_list = NULL;
- historic_count = 0;
-}
-
-cGenotypeControl::~cGenotypeControl()
-{
-}
-
-bool cGenotypeControl::OK()
-{
- int ret_value = true;
-
- // Cycle through the list, making sure all connections are proper, size
- // is correct, and all genotypes are OK().
-
- cGenotype * cur_pos = best;
- for (int i = 0; i < size; i++) {
- if (!cur_pos->OK()) ret_value = false;
- assert (cur_pos->GetNext()->GetPrev() == cur_pos);
- cur_pos = cur_pos->GetNext();
- }
-
- assert (cur_pos == best);
-
- return ret_value;
-}
-
-void cGenotypeControl::Insert(cGenotype & in_genotype, cGenotype * prev_genotype)
-{
- if (prev_genotype == NULL) {
- assert(size == 0); // Destroying a full genotype queue...
-
- best = &in_genotype;
- best->SetNext(best);
- best->SetPrev(best);
- }
- else {
- in_genotype.SetPrev(prev_genotype);
- in_genotype.SetNext(prev_genotype->GetNext());
- prev_genotype->SetNext(&in_genotype);
- in_genotype.GetNext()->SetPrev(&in_genotype);
- }
-
- size++;
-}
-
-void cGenotypeControl::Remove(cGenotype & in_genotype)
-{
- if (size == 1) {
- best = NULL;
- }
- if (&in_genotype == best) {
- best = best->GetNext();
- }
-
- in_genotype.GetNext()->SetPrev(in_genotype.GetPrev());
- in_genotype.GetPrev()->SetNext(in_genotype.GetNext());
- in_genotype.SetNext(NULL);
- in_genotype.SetPrev(NULL);
-
- size--;
-}
-
-void cGenotypeControl::RemoveHistoric(cGenotype & in_genotype)
-{
- if (historic_count == 1) {
- historic_list = NULL;
- }
- if (&in_genotype == historic_list) {
- historic_list = historic_list->GetNext();
- }
-
- in_genotype.GetNext()->SetPrev(in_genotype.GetPrev());
- in_genotype.GetPrev()->SetNext(in_genotype.GetNext());
- in_genotype.SetNext(NULL);
- in_genotype.SetPrev(NULL);
-
- historic_count--;
-}
-
-void cGenotypeControl::InsertHistoric(cGenotype & in_genotype)
-{
- if (historic_count == 0) {
- in_genotype.SetNext(&in_genotype);
- in_genotype.SetPrev(&in_genotype);
- }
- else {
- in_genotype.SetPrev(historic_list->GetPrev());
- in_genotype.SetNext(historic_list);
- historic_list->GetPrev()->SetNext(&in_genotype);
- historic_list->SetPrev(&in_genotype);
- }
-
- historic_list = &in_genotype;
- historic_count++;
-}
-
-
-int cGenotypeControl::UpdateCoalescent()
-{
- // Test to see if any updating needs to be done...
- // Don't update active coalescent genotype, or if there is more than
- // one offspring.
- if (coalescent != NULL &&
- (coalescent->GetNumOrganisms() > 0 ||
- coalescent->GetNumOffspringGenotypes() > 1)) {
- return coalescent->GetDepth();
- }
-
- // If there is no best, there is nothing to search through...
- if (best == NULL) return -1;
-
- // Find the new point...
- cGenotype * test_gen = best;
- cGenotype * found_gen = best;
- cGenotype * parent_gen = best->GetParentGenotype();
-
- while (parent_gen != NULL) {
- // See if this genotype should be the new found genotype...
- if (test_gen->GetNumOrganisms() > 0 ||
- test_gen->GetNumOffspringGenotypes() > 1) {
- found_gen = test_gen;
- }
-
- // Move to the next genotype...
- test_gen = parent_gen;
- parent_gen = test_gen->GetParentGenotype();
- }
-
- coalescent = found_gen;
-
- return coalescent->GetDepth();
-}
-
-
-bool cGenotypeControl::CheckPos(cGenotype & in_genotype)
-{
- int next_OK = false;
- int prev_OK = false;
-
- if (in_genotype.GetNumOrganisms() >= in_genotype.GetNext()->GetNumOrganisms()) {
- next_OK =true;
- }
- if (in_genotype.GetNumOrganisms() <= in_genotype.GetPrev()->GetNumOrganisms()) {
- prev_OK =true;
- }
-
- if ( (next_OK && prev_OK) ||
- (&in_genotype == best && next_OK) ||
- (&in_genotype == best->GetPrev() && prev_OK)) {
- return true;
- }
-
- return false;
-}
-
-void cGenotypeControl::Insert(cGenotype & new_genotype)
-{
- // If there is nothing in the list, add this.
-
- if (size == 0) {
- Insert(new_genotype, NULL);
- }
-
- // Otherwise tack it on the end.
-
- else {
- Insert(new_genotype, best->GetPrev());
- }
-}
-
-bool cGenotypeControl::Adjust(cGenotype & in_genotype)
-{
- cGenotype * cur_genotype = in_genotype.GetPrev();
-
- // Check to see if this genotype should be removed completely.
-
- if (in_genotype.GetNumOrganisms() == 0 &&
- in_genotype.GetDeferAdjust() == false) {
- genebank.RemoveGenotype(in_genotype);
- return false;
- }
-
- // Do not adjust the position of this genotype if it was and still is the
- // best genotype, or if it is otherwise in the proper spot...
-
- if (CheckPos(in_genotype)) {
- return true;
- }
-
- // Otherwise, remove it from the queue (for just the moment).
-
- Remove(in_genotype);
-
- // If this genotype is the best, put it there.
-
- if (in_genotype.GetNumOrganisms() > best->GetNumOrganisms()) {
- Insert(in_genotype, best->GetPrev());
- best = &in_genotype;
- return true;
- }
-
- // Finally, find out where this genotype *does* go.
-
- while (cur_genotype->GetNumOrganisms() >= in_genotype.GetNumOrganisms() &&
- cur_genotype != best->GetPrev()) {
- cur_genotype = cur_genotype->GetNext();
- }
- while (cur_genotype->GetNumOrganisms() < in_genotype.GetNumOrganisms() &&
- cur_genotype != best) {
- cur_genotype = cur_genotype->GetPrev();
- }
-
- Insert(in_genotype, cur_genotype);
-
- return true;
-}
-
-
-cGenotype * cGenotypeControl::Find(const cGenome & in_genome) const
-{
- int i;
- cGenotype * cur_genotype = best;
-
- for (i = 0; i < size; i++) {
- if (in_genome == cur_genotype->GetGenome()) {
- return cur_genotype;
- }
- cur_genotype = cur_genotype->GetNext();
- }
-
- return NULL;
-}
-
-int cGenotypeControl::FindPos(cGenotype & in_genotype, int max_depth)
-{
- cGenotype * temp_genotype = best;
- if (max_depth < 0 || max_depth > size) max_depth = size;
-
- for (int i = 0; i < max_depth; i++) {
- if (temp_genotype == &in_genotype) return i;
- temp_genotype = temp_genotype->GetNext();
- }
-
- return -1;
-}
-
-cGenotype * cGenotypeControl::Next(int thread)
-{
- return threads[thread] = threads[thread]->GetNext();
-}
-
-cGenotype * cGenotypeControl::Prev(int thread)
-{
- return threads[thread] = threads[thread]->GetPrev();
-}
Deleted: trunk/source/main/genotype_control.hh
===================================================================
--- trunk/source/main/genotype_control.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genotype_control.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,62 +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 GENOTYPE_CONTROL_HH
-#define GENOTYPE_CONTROL_HH
-
-#ifndef GENOTYPE_MACROS_HH
-#include "genotype_macros.hh"
-#endif
-
-class cGenebank;
-class cGenome;
-class cGenotype;
-class cGenotypeControl {
-private:
- int size;
- cGenotype * best;
- cGenotype * coalescent;
- cGenotype * threads[GENOTYPE_THREADS];
- cGenebank & genebank;
-
- cGenotype * historic_list;
- int historic_count;
-
- void Insert(cGenotype & in_genotype, cGenotype * prev_genotype);
- bool CheckPos(cGenotype & in_genotype);
-public:
- cGenotypeControl(cGenebank & in_gb);
- ~cGenotypeControl();
-
- bool OK();
- void Remove(cGenotype & in_genotype);
- void Insert(cGenotype & new_genotype);
- bool Adjust(cGenotype & in_genotype);
-
- void RemoveHistoric(cGenotype & in_genotype);
- void InsertHistoric(cGenotype & in_genotype);
- int GetHistoricCount() { return historic_count; }
-
- int UpdateCoalescent();
-
- inline int GetSize() const { return size; }
- inline cGenotype * GetBest() const { return best; }
- inline cGenotype * GetCoalescent() const { return coalescent; }
-
- cGenotype * Find(const cGenome & in_genome) const;
- int FindPos(cGenotype & in_genotype, int max_depth = -1);
-
- inline cGenotype * Get(int thread) const { return threads[thread]; }
- inline cGenotype * Reset(int thread)
- { return threads[thread] = best; }
- inline cGenotype * ResetHistoric(int thread)
- { return threads[thread] = historic_list; }
- cGenotype * Next(int thread);
- cGenotype * Prev(int thread);
-};
-
-#endif
Deleted: trunk/source/main/genotype_test_data.cc
===================================================================
--- trunk/source/main/genotype_test_data.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genotype_test_data.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,23 +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 GENOTYPE_TEST_DATA_HH
-#include "genotype_test_data.hh"
-#endif
-
-////////////////////////
-// cGenotype_TestData
-////////////////////////
-
-cGenotype_TestData::cGenotype_TestData()
- : fitness(-1)
-{
-}
-
-cGenotype_TestData::~cGenotype_TestData()
-{
-}
Deleted: trunk/source/main/genotype_test_data.hh
===================================================================
--- trunk/source/main/genotype_test_data.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/genotype_test_data.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,27 +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 GENOTYPE_TEST_DATA_HH
-#define GENOTYPE_TEST_DATA_HH
-
-class cGenotype_TestData {
-public:
- cGenotype_TestData();
- ~cGenotype_TestData();
-
- bool is_viable;
-
- double fitness;
- double merit;
- int gestation_time;
- int executed_size;
- int copied_size;
- double colony_fitness;
- int generations;
-};
-
-#endif
Deleted: trunk/source/main/inject_genebank.cc
===================================================================
--- trunk/source/main/inject_genebank.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inject_genebank.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,355 +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 INJECT_GENEBANK_HH
-#include "inject_genebank.hh"
-#endif
-
-#ifndef CONFIG_HH
-#include "cConfig.h"
-#endif
-#ifndef DATA_FILE_HH
-#include "data_file.hh"
-#endif
-#ifndef GENOME_HH
-#include "genome.hh"
-#endif
-#ifndef INJECT_GENOTYPE_HH
-#include "inject_genotype.hh"
-#endif
-#ifndef STATS_HH
-#include "stats.hh"
-#endif
-#ifndef TEST_UTIL_HH
-#include "cTestUtil.h"
-#endif
-
-using namespace std;
-
-////////////////////
-// cInjectGenebank
-////////////////////
-
-cInjectGenebank::cInjectGenebank(cStats & in_stats)
- : stats(in_stats)
-{
- for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
- inject_genotype_count[i] = 0;
- }
-
- inject_genotype_control = new cInjectGenotypeControl(*this);
-
-}
-
-cInjectGenebank::~cInjectGenebank()
-{
- delete inject_genotype_control;
-}
-
-void cInjectGenebank::UpdateReset()
-{
- static int genotype_dom_time = 0;
- static int prev_dom = -1;
-
- cInjectGenotype * best_inject_genotype = GetBestInjectGenotype();
-
- if (best_inject_genotype && best_inject_genotype->GetID() != prev_dom) {
- genotype_dom_time = 0;
- prev_dom = best_inject_genotype->GetID();
- }
- else {
- genotype_dom_time++;
- if (genotype_dom_time == cConfig::GetGenotypePrintDom()) {
- cString filename;
- filename.Set("genebank/%s", best_inject_genotype->GetName()());
- cTestUtil::PrintGenome(best_inject_genotype, best_inject_genotype->GetGenome(),
- filename, stats.GetUpdate());
- }
- }
-}
-
-cString cInjectGenebank::GetLabel(int in_size, int in_num)
-{
- char alpha[6];
- char full_name[12];
- int i;
-
- for (i = 4; i >= 0; i--) {
- alpha[i] = (in_num % 26) + 'a';
- in_num /= 26;
- }
- alpha[5] = '\0';
-
- sprintf(full_name, "p%03d-%s", in_size, alpha);
-
- return full_name;
-}
-
-void cInjectGenebank::AddInjectGenotype(cInjectGenotype * in_inject_genotype, int in_list_num)
-{
- assert( in_inject_genotype != 0 );
-
- if ( in_list_num < 0 )
- in_list_num = FindCRC(in_inject_genotype->GetGenome()) % INJECTGENOTYPE_HASH_SIZE;
-
- active_inject_genotypes[in_list_num].Insert(*in_inject_genotype);
- inject_genotype_control->Insert(*in_inject_genotype);
- //stats.AddGenotype(in_inject_genotype->GetID());
-}
-
-
-cInjectGenotype * cInjectGenebank::AddInjectGenotype(const cGenome & in_genome,
- cInjectGenotype * parent_genotype)
-{
- int list_num = FindCRC(in_genome) % INJECTGENOTYPE_HASH_SIZE;
- cInjectGenotype * found_genotype;
-
- found_genotype = active_inject_genotypes[list_num].Find(in_genome);
-
- if (!found_genotype) {
- found_genotype = new cInjectGenotype(stats.GetUpdate());
- found_genotype->SetGenome(in_genome);
- found_genotype->SetParent(parent_genotype);
- if(parent_genotype!=NULL)
- {
- parent_genotype->SetCanReproduce();
- }
- AddInjectGenotype( found_genotype, list_num );
- }
- return found_genotype;
-}
-
-cInjectGenotype * cInjectGenebank::FindInjectGenotype(const cGenome & in_genome) const
-{
- int list_num = FindCRC(in_genome) % INJECTGENOTYPE_HASH_SIZE;
- return active_inject_genotypes[list_num].Find(in_genome);
-}
-
-void cInjectGenebank::RemoveInjectGenotype(cInjectGenotype & in_inject_genotype)
-{
- // If this genotype is still active, mark it no longer active and
- // take it out of the hash table so it doesn't have any new organisms
- // assigned to it.
-
- if (in_inject_genotype.GetActive() == true) {
- int list_num = FindCRC(in_inject_genotype.GetGenome()) % INJECTGENOTYPE_HASH_SIZE;
- active_inject_genotypes[list_num].Remove(in_inject_genotype);
- inject_genotype_control->Remove(in_inject_genotype);
- //in_inject_genotype.Deactivate(stats.GetUpdate());
- if (cConfig::GetTrackMainLineage()) {
- inject_genotype_control->InsertHistoric(in_inject_genotype);
- }
- }
-
- // If we are tracking the main lineage, we only want to delete a
- // genotype when all of its decendents have also died out.
-
- /*if (cConfig::GetTrackMainLineage()) {
- // If there are more offspring genotypes, hold off on deletion...
- if (in_inject_genotype.GetNumOffspringGenotypes() != 0) return;
-
- // If this is a dead end, delete it and recurse up...
- cInjectGenotype * parent = in_inject_genotype.GetParentGenotype();
- if (parent != NULL) {
- parent->RemoveOffspringGenotype();
-
- // Test to see if we need to update the coalescent genotype.
- const int new_coal = inject_genotype_control->UpdateCoalescent();
- stats.SetCoalescentGenotypeDepth(new_coal);
- // cout << "Set coalescent to " << found_gen->GetDepth() << endl;
-
- if (parent->GetNumInjected() == 0) {
- // Regardless, run RemoveGenotype on the parent.
- RemoveGenotype(*parent);
- }
- }
-
- inject_genotype_control->RemoveHistoric(in_inject_genotype);
- }
-
- // Handle the relevent statistics...
- stats.RemoveGenotype(in_inject_genotype.GetID(),
- in_inject_genotype.GetParentID(), in_inject_genotype.GetParentDistance(),
- in_inject_genotype.GetDepth(), in_inject_genotype.GetTotalOrganisms(),
- in_inject_genotype.GetTotalParasites(),
- stats.GetUpdate() - in_inject_genotype.GetUpdateBorn(),
- in_inject_genotype.GetLength());
- if (in_inject_genotype.GetThreshold()) {
- stats.RemoveThreshold(in_inject_genotype.GetID());
- }*/
-
- delete &in_inject_genotype;
-}
-
-void cInjectGenebank::ThresholdInjectGenotype(cInjectGenotype & in_inject_genotype)
-{
- in_inject_genotype.SetName( GetLabel(in_inject_genotype.GetLength(),
- inject_genotype_count[in_inject_genotype.GetLength()]++) );
- in_inject_genotype.SetThreshold();
-
- //stats.AddThreshold(in_inject_genotype.GetID(), in_inject_genotype.GetName()());
-
- // Print the genotype?
-
- if (cConfig::GetGenotypePrint()) {
- cString filename;
- filename.Set("genebank/%s", in_inject_genotype.GetName()());
- //cTestUtil::PrintGenome(in_inject_genotype.GetGenome(), filename,
- // &in_inject_genotype, stats.GetUpdate());
- }
-}
-
-bool cInjectGenebank::AdjustInjectGenotype(cInjectGenotype & in_inject_genotype)
-{
- if (!inject_genotype_control->Adjust(in_inject_genotype)) return false;
-
- if ((in_inject_genotype.GetNumInjected() >= cConfig::GetThreshold() ||
- &in_inject_genotype == inject_genotype_control->GetBest()) &&
- !(in_inject_genotype.GetThreshold())) {
- ThresholdInjectGenotype(in_inject_genotype);
- }
-
- return true;
-}
-
-bool cInjectGenebank::SaveClone(ofstream & fp)
-{
- // This method just save the counts at each size-class of genotypes.
- // The rest is reconstructable.
-
- // Save the numbers of organisms we're up to at each size.
- fp << MAX_CREATURE_SIZE << " ";
- for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
- fp << inject_genotype_count[i] << " ";
- }
-
- return true;
-}
-
-bool cInjectGenebank::LoadClone(ifstream & fp)
-{
- // This method just restores the counts at each size-class of genotypes.
- // The rest of the loading process should be handled elsewhere.
-
- // Load the numbers of organisms we're up to at each size.
- int max_size;
- fp >> max_size;
- assert (max_size <= MAX_CREATURE_SIZE); // MAX_CREATURE_SIZE too small
- for (int i = 0; i < max_size && i < MAX_CREATURE_SIZE; i++) {
- fp >> inject_genotype_count[i];
- }
-
- return true;
-}
-
-bool cInjectGenebank::DumpTextSummary(ofstream & fp)
-{
- inject_genotype_control->Reset(0);
- for (int i = 0; i < inject_genotype_control->GetSize(); i++) {
- cInjectGenotype * genotype = inject_genotype_control->Get(0);
- fp << genotype->GetGenome().AsString() << " "
- << genotype->GetNumInjected() << " "
- << genotype->GetID() << endl;
- inject_genotype_control->Next(0);
- }
-
- return true;
-}
-
-bool cInjectGenebank::DumpDetailedSummary(const cString & file, int update)
-{
- inject_genotype_control->Reset(0);
- for (int i = 0; i < inject_genotype_control->GetSize(); i++) {
- DumpDetailedEntry(inject_genotype_control->Get(0), file, update);
- inject_genotype_control->Next(0);
- }
- return true;
-}
-
-/*bool cInjectGenebank::DumpHistoricSummary(ofstream & fp)
-{
- inject_genotype_control->ResetHistoric(0);
- for (int i = 0; i < inject_genotype_control->GetHistoricCount(); i++) {
- DumpDetailedEntry(inject_genotype_control->Get(0), fp);
- inject_genotype_control->Next(0);
- }
-
- return true;
-}*/
-
-void cInjectGenebank::DumpDetailedEntry(cInjectGenotype * genotype, const cString & filename, int update)
-{
- //if(genotype->CanReproduce())
- // {
- cDataFile & df = stats.GetDataFile(filename);
-
- df.WriteComment( "Avida parasite dump data" );
- df.WriteTimeStamp();
-
- df.Write( genotype->GetID(), "parasite genotype ID");
- df.Write( genotype->GetName(), "parasite genotype name");
- df.Write( genotype->GetParentID(), "parasite parent ID");
- df.Write( genotype->GetNumInjected(), "current number of injected creatures with this genotype");
- df.Write( genotype->GetTotalInjected(), "total number of injected creatures with this genotype");
- df.Write( genotype->GetLength(), "genotype length");
- df.Write( genotype->GetUpdateBorn(), "update this genotype was born");
- df.Write( genotype->CanReproduce(), "has this genotype reproduced?");
- df.Write( genotype->GetGenome().AsString(), "genome of this genotype");
- df.Endl();
- //}
-}
-
-bool cInjectGenebank::OK()
-{
- bool ret_value = true;
- int i;
-
- // Check components...
-
- if (!inject_genotype_control->OK()) {
- ret_value = false;
- }
-
- // Loop through all of the reference lists for matching genotypes...
-
- for (i = 0; i < INJECTGENOTYPE_HASH_SIZE; i++) {
- assert (active_inject_genotypes[i].OK());
- }
-
- assert (ret_value == true);
-
- return ret_value;
-}
-
-int cInjectGenebank::CountNumCreatures()
-{
- int i;
- int total = 0;
-
- inject_genotype_control->Reset(0);
- for (i = 0; i < inject_genotype_control->GetSize(); i++) {
- total += inject_genotype_control->Get(0)->GetNumInjected();
- inject_genotype_control->Next(0);
- }
-
- return total;
-}
-
-
-unsigned int cInjectGenebank::FindCRC(const cGenome & in_genome) const
-{
- unsigned int total = 13;
- int i;
-
- for (i = 0; i < in_genome.GetSize(); i++) {
- total *= in_genome[i].GetOp() + 10 + i << 6;
- total += 3;
- }
-
- return total;
-}
-
Deleted: trunk/source/main/inject_genebank.hh
===================================================================
--- trunk/source/main/inject_genebank.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inject_genebank.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,103 +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 INJECT_GENEBANK_HH
-#define INJECT_GENEBANK_HH
-
-#include <fstream>
-
-#ifndef DEFS_HH
-#include "defs.hh"
-#endif
-#ifndef INJECT_GENEBANK_MACROS_HH
-#include "inject_genebank_macros.hh"
-#endif
-#ifndef INJECT_GENOTYPE_CONTROL_HH
-#include "inject_genotype_control.hh"
-#endif
-#ifndef INJECT_GENOTYPE_QUEUE_HH
-#include "inject_genotype_queue.hh"
-#endif
-#ifndef STRING_HH
-#include "string.hh"
-#endif
-
-class cGenome;
-class cStats;
-class cInjectGenotype;
-class cInjectGenotypeQueue; // array
-class cInjectGenotypeControl; // access
-class cStats;
-class cString; // aggregate
-class cInjectGenotype;
-class cGenome;
-
-class cInjectGenebank {
-private:
- unsigned int inject_genotype_count[MAX_CREATURE_SIZE];
- cInjectGenotypeQueue active_inject_genotypes[INJECTGENOTYPE_HASH_SIZE];
- cInjectGenotypeControl * inject_genotype_control;
- cStats & stats;
-
-private:
- cString GetLabel(int in_size, int in_num);
-
-public:
- cInjectGenebank(cStats & stats);
- ~cInjectGenebank();
-
- void UpdateReset();
-
- /**
- * This function can be used to add a injectgenotype that was created
- * outside the genebank. In this case, the parameter in_list_num
- * should not be given. Normally, injectgenotypes are added through the
- * function AddInjectGenotype(const cGenome & in_genome,
- * cInjectGenotype * parent_injectgenotype = NULL), which then calls this one.
- **/
- void AddInjectGenotype(cInjectGenotype *in_inject_genotype, int in_list_num = -1 );
- cInjectGenotype * AddInjectGenotype(const cGenome & in_genome,
- cInjectGenotype * parent_inject_genotype = NULL);
- cInjectGenotype * FindInjectGenotype(const cGenome & in_genome) const;
- void RemoveInjectGenotype(cInjectGenotype & in_inject_genotype);
- void ThresholdInjectGenotype(cInjectGenotype & in_inject_genotype);
- bool AdjustInjectGenotype(cInjectGenotype & in_inject_genotype);
-
- bool SaveClone(std::ofstream & fp);
- bool LoadClone(std::ifstream & fp);
- bool DumpTextSummary(std::ofstream & fp);
- //bool DumpDetailedSummary(std::ofstream & fp);
- bool DumpDetailedSummary(const cString & file, int update);
- /*
- bool DumpHistoricSummary(std::ofstream & fp);
- */
- //void DumpDetailedEntry(cInjectGenotype * inject_genotype, std::ofstream & fp);
- void DumpDetailedEntry(cInjectGenotype * inject_genotype, const cString & file, int update);
- bool OK();
-
- inline int GetSize() const { return inject_genotype_control->GetSize(); }
- inline cInjectGenotype * GetBestInjectGenotype() const
- { return inject_genotype_control->GetBest(); }
- inline cInjectGenotype * GetCoalescentInjectGenotype() const
- { return inject_genotype_control->GetCoalescent(); }
-
- inline cInjectGenotype * GetInjectGenotype(int thread) const
- { return inject_genotype_control->Get(thread); }
- inline cInjectGenotype * NextInjectGenotype(int thread) {
- cInjectGenotype * next = inject_genotype_control->Next(thread);
- return (next == inject_genotype_control->GetBest()) ? (cInjectGenotype*)NULL : next;
- }
- inline cInjectGenotype * ResetThread(int thread)
- { return inject_genotype_control->Reset(thread); }
-
- int CountNumCreatures();
- inline int FindPos(cInjectGenotype & in_inject_genotype, int max_depth = -1)
- { return inject_genotype_control->FindPos(in_inject_genotype, max_depth); }
- unsigned int FindCRC(const cGenome & in_genome) const;
-};
-
-#endif
Deleted: trunk/source/main/inject_genotype.cc
===================================================================
--- trunk/source/main/inject_genotype.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inject_genotype.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,162 +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 INJECT_GENOTYPE_HH
-#include "inject_genotype.hh"
-#endif
-
-#ifndef CONFIG_HH
-#include "cConfig.h"
-#endif
-#ifndef TOOLS_HH
-#include "tools.hh"
-#endif
-
-using namespace std;
-
-
-
-///////////////////////////
-// cInjectGenotype
-///////////////////////////
-
-cInjectGenotype::cInjectGenotype(int in_update_born, int in_id)
- : genome(1)
- , name("p001-no_name")
- , flag_threshold(false)
- , is_active(true)
- , can_reproduce(false)
- , defer_adjust(0)
- , symbol(0)
- , birth_data(in_update_born)
- , num_injected(0)
- , last_num_injected(0)
- , total_injected(0)
- , next(NULL)
- , prev(NULL)
-{
- static int next_id = 1;
-
- if ( in_id >= 0 )
- next_id = in_id;
-
- id_num = next_id++;
-}
-
-cInjectGenotype::~cInjectGenotype()
-{
- // Reset some of the variables to make sure program will crash if a deleted
- // cell is read!
- symbol = '!';
-
- num_injected = -1;
- total_injected = -1;
-
- next = NULL;
- prev = NULL;
-}
-
-bool cInjectGenotype::SaveClone(ofstream & fp)
-{
- fp << id_num << " ";
- fp << genome.GetSize() << " ";
-
- for (int i = 0; i < genome.GetSize(); i++) {
- fp << ((int) genome[i].GetOp()) << " ";
- }
-
- return true;
-}
-
-bool cInjectGenotype::LoadClone(ifstream & fp)
-{
- int genome_size = 0;
-
- fp >> id_num;
- fp >> genome_size;
-
- genome = cGenome(genome_size);
- for (int i = 0; i < genome_size; i++) {
- cInstruction temp_inst;
- int inst_op;
- fp >> inst_op;
- temp_inst.SetOp((UCHAR) inst_op);
- genome[i] = temp_inst;
- // @CAO add something here to load arguments for instructions.
- }
-
- return true;
-}
-
-bool cInjectGenotype::OK()
-{
- bool ret_value = true;
-
- // Check the components...
-
- if (!genome.OK()) ret_value = false;
-
- // And the statistics
- assert( id_num >= 0 && num_injected >= 0 && total_injected >= 0 );
- assert( birth_data.update_born >= -1);
-
- return ret_value;
-}
-
-void cInjectGenotype::SetParent(cInjectGenotype * parent)
-{
- birth_data.parent_genotype = parent;
-
- // If we have a real parent genotype, collect other data about parent.
- if (parent == NULL) return;
- birth_data.parent_id = parent->GetID();
- birth_data.gene_depth = parent->GetDepth() + 1;
- parent->AddOffspringGenotype();
-}
-
-void cInjectGenotype::Mutate() // Check each location to be mutated.
-{
- int i;
-
- for (i = 0; i < genome.GetSize(); i++) {
- genome[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
- }
-
-}
-
-void cInjectGenotype::UpdateReset()
-{
- last_num_injected = num_injected;
- birth_data.birth_track.Next();
- birth_data.death_track.Next();
-}
-
-void cInjectGenotype::SetGenome(const cGenome & in_genome)
-{
- genome = in_genome;
-
- name.Set("p%03d-no_name", genome.GetSize());
-}
-
-void cInjectGenotype::Deactivate(int update)
-{
- is_active = false;
- birth_data.update_deactivated = update;
-}
-
-int cInjectGenotype::AddParasite()
-{
- total_injected++;
- return num_injected++;
-}
-
-int cInjectGenotype::RemoveParasite()
-{
- //birth_data.death_track.Inc();
- return num_injected--;
-}
-
Deleted: trunk/source/main/inject_genotype.hh
===================================================================
--- trunk/source/main/inject_genotype.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inject_genotype.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,254 +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 INJECT_GENOTYPE_HH
-#define INJECT_GENOTYPE_HH
-
-#include <fstream>
-
-#ifndef GENOME_HH
-#include "genome.hh"
-#endif
-#ifndef INJECT_GENOTYPE_BIRTH_DATA_HH
-#include "inject_genotype_birth_data.hh"
-#endif
-#ifndef STRING_HH
-#include "string.hh"
-#endif
-
-/*class cInjectGenotype_TestData {
-public:
- cGenotype_TestData();
- ~cGenotype_TestData();
-
- bool is_viable;
-
- double fitness;
- double merit;
- int gestation_time;
- int executed_size;
- int copied_size;
- double colony_fitness;
- int generations;
- };*/
-
-class cGenome; // aggregate
-class cString; // aggregate
-class cInjectGenotype_BirthData; // aggregate
-
-class cInjectGenotype {
-private:
- cGenome genome;
- cString name;
- bool flag_threshold;
- bool is_active; // Is this genotype still alive?
- bool can_reproduce; // Can this genotype reproduce?
- int defer_adjust; // Don't adjust in the genebank until all are cleared.
-
- int id_num;
- char symbol;
-
- //mutable cGenotype_TestData test_data;
- cInjectGenotype_BirthData birth_data;
-
- // Statistical info
-
- int num_injected;
- int last_num_injected;
- int total_injected;
- //int total_parasites;
-
- //cSpecies * species;
-
- // Data Structure stuff...
- cInjectGenotype * next;
- cInjectGenotype * prev;
-
-
- ////// Statistical info //////
-
- // Collected on Divides
- //cDoubleSum sum_copied_size;
- //cDoubleSum sum_exe_size;
-
- //cDoubleSum sum_gestation_time;
- //cDoubleSum sum_repro_rate; // should make gestation obsolete (not new)
-
- //cDoubleSum sum_merit;
- //cDoubleSum sum_fitness;
-
- // Temporary (Approx stats used before any divides done)
- // Set in "SetParent"
- //cDoubleSum tmp_sum_copied_size;
- //cDoubleSum tmp_sum_exe_size;
-
- //cDoubleSum tmp_sum_gestation_time;
- //cDoubleSum tmp_sum_repro_rate;
-
- //cDoubleSum tmp_sum_merit;
- //cDoubleSum tmp_sum_fitness;
-
- void CalcTestStats() const;
-public:
- /**
- * Constructs an empty genotype. Normally, in_id should not specified as
- * parameter, because cGenotype keeps track of the last id given out, and
- * choses a new one based on that. However, in some cases it is necessary
- * to specify an id (e.g., when loading a history file from disk). Note
- * that in this case, cGenotype does not check if the id has already been
- * used before.
- **/
- cInjectGenotype(int in_update_born = 0, int in_id = -1);
- ~cInjectGenotype();
-
- bool SaveClone(std::ofstream & fp);
- bool LoadClone(std::ifstream & fp);
- bool OK();
- void Mutate();
- void UpdateReset();
-
- void SetGenome(const cGenome & in_genome);
- //void SetSpecies(cSpecies * in_species);
-
- // Test CPU info -- only used with limited options on.
- //bool GetTestViable() const;
- //double GetTestFitness() const;
- //double GetTestMerit() const;
- //int GetTestGestationTime() const;
- //int GetTestExecutedSize() const;
- //int GetTestCopiedSize() const;
- //double GetTestColonyFitness() const;
- //int GetTestGenerations() const;
-
- void SetParent(cInjectGenotype * parent);
- void SetUpdateBorn (int update) { birth_data.update_born = update; }
- void SetName(cString in_name) { name = in_name; }
- void SetNext(cInjectGenotype * in_next) { next = in_next; }
- void SetPrev(cInjectGenotype * in_prev) { prev = in_prev; }
- void SetSymbol(char in_symbol) { symbol = in_symbol; }
- void SetCanReproduce() { can_reproduce = true; }
- inline void SetThreshold();
- void IncDeferAdjust() { defer_adjust++; }
- void DecDeferAdjust() { defer_adjust--; assert(defer_adjust >= 0); }
-
- // Setting New Stats
- //void AddCopiedSize (int in) { sum_copied_size.Add(in); }
- //void AddExecutedSize (int in) { sum_exe_size.Add(in); }
- //void AddGestationTime (int in) { sum_gestation_time.Add(in);
- // sum_repro_rate.Add(1/(double)in); }
- //void AddMerit (const cMerit & in);
- //void RemoveMerit (const cMerit & in);
- //void AddFitness (double in){
- // assert(in >= 0.0);
- // sum_fitness.Add(in);
- //}
- //void RemoveFitness (double in){
- // assert(in >= 0.0);
- // sum_fitness.Subtract(in);
- //}
-
- //// Properties Native to Genotype ////
- cGenome & GetGenome() { return genome; }
- const cGenome & GetGenome() const { return genome; }
- int GetLength() const { return genome.GetSize(); }
-
- //int GetBirths() const { return birth_data.birth_track.GetTotal(); }
- //int GetBreedOut() const { return birth_data.breed_out_track.GetTotal(); }
- //int GetBreedTrue() const { return birth_data.breed_true_track.GetTotal(); }
- //int GetBreedIn() const { return birth_data.breed_in_track.GetTotal(); }
-
- //int GetThisBirths() const { return birth_data.birth_track.GetCur(); }
- //int GetThisBreedOut() const { return birth_data.breed_out_track.GetCur(); }
- //int GetThisBreedTrue() const { return birth_data.breed_true_track.GetCur(); }
- //int GetThisBreedIn() const { return birth_data.breed_in_track.GetCur(); }
-
- //int GetThisDeaths() const { return birth_data.death_track.GetCur(); }
-
- //int GetLastNumOrganisms() const { return last_num_organisms; }
- //int GetLastBirths() const { return birth_data.birth_track.GetLast(); }
- //int GetLastBreedOut() const { return birth_data.breed_out_track.GetLast(); }
- //int GetLastBreedTrue() const { return birth_data.breed_true_track.GetLast();}
- //int GetLastBreedIn() const { return birth_data.breed_in_track.GetLast(); }
-
- //inline void SetBreedStats(cGenotype & daughter); // called by ActivateChild
-
- //// Properties Averaged Over Creatues ////
- //double GetCopiedSize() const { return (sum_copied_size.Count()>0) ?
- // sum_copied_size.Average() : tmp_sum_copied_size.Average(); }
- //double GetExecutedSize() const { return (sum_exe_size.Count()>0) ?
- // sum_exe_size.Average() : tmp_sum_exe_size.Average(); }
- //double GetGestationTime() const { return (sum_gestation_time.Count()>0) ?
- // sum_gestation_time.Average() : tmp_sum_gestation_time.Average(); }
- //double GetReproRate() const { return (sum_repro_rate.Count()>0) ?
- // sum_repro_rate.Average() : tmp_sum_repro_rate.Average(); }
- //double GetMerit() const { return (sum_merit.Count()>0) ?
- // sum_merit.Average() : tmp_sum_merit.Average(); }
- //double GetFitness() const { return (sum_fitness.Count()>0) ?
- // sum_fitness.Average() : tmp_sum_fitness.Average(); }
-
-
- // For tracking the genotype line back to the ancestor...
- cInjectGenotype * GetParentGenotype() { return birth_data.parent_genotype; }
- int GetNumOffspringGenotypes() const
- { return birth_data.num_offspring_genotypes; }
- void AddOffspringGenotype() { birth_data.num_offspring_genotypes++; }
- void RemoveOffspringGenotype() { birth_data.num_offspring_genotypes--; }
- bool GetActive() const { return is_active; }
- // bool GetDeferAdjust() const { return defer_adjust > 0; }
- int GetUpdateDeactivated() { return birth_data.update_deactivated; }
- void Deactivate(int update);
-
- bool CanReproduce() { return can_reproduce; }
- int GetUpdateBorn() { return birth_data.update_born; }
- int GetParentID() { return birth_data.parent_id; }
- //int GetParentDistance() { return birth_data.parent_distance; }
- int GetDepth() { return birth_data.gene_depth; }
- cString & GetName() { return name; }
- cInjectGenotype * GetNext() { return next; }
- cInjectGenotype * GetPrev() { return prev; }
- bool GetThreshold() const { return flag_threshold; }
- int GetID() const { return id_num; }
- char GetSymbol() const { return symbol; }
-
- int AddParasite();
- int RemoveParasite();
- //int AddParasite() { return ++total_parasites; }
- //void SwapOrganism() { total_organisms++; }
- int GetNumInjected() { return num_injected; }
- int GetTotalInjected() { return total_injected; }
- //int GetTotalParasites() { return total_parasites; }
-};
-
-// The genotype pointer template...
-
-
-
-// All the inline stuff...
-
- ////////////////
- // cGenotype //
-////////////////
-
-inline void cInjectGenotype::SetThreshold()
-{
- flag_threshold = true;
- if (symbol == '.') symbol = '+';
-}
-
-/*
-inline void cGenotype::SetBreedStats(cGenotype & daughter)
-{
- birth_data.birth_track.Inc();
- if (daughter.id_num == id_num) {
- birth_data.breed_true_track.Inc();
- } else {
- birth_data.breed_out_track.Inc();
- daughter.birth_data.breed_in_track.Inc();
- }
-}*/
-
-#endif
Deleted: trunk/source/main/inject_genotype_birth_data.cc
===================================================================
--- trunk/source/main/inject_genotype_birth_data.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inject_genotype_birth_data.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,32 +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 INJECT_GENOTYPE_BIRTH_DATA_HH
-#include "inject_genotype_birth_data.hh"
-#endif
-
-#ifndef DEFS_HH
-#include "defs.hh"
-#endif
-
-/////////////////////////
-// cInjectGenotype_BirthData
-/////////////////////////
-
-cInjectGenotype_BirthData::cInjectGenotype_BirthData(int in_update_born)
- : update_born(in_update_born)
- , parent_id(-1)
- , gene_depth(0)
- , update_deactivated(-1)
- , parent_genotype(NULL)
- , num_offspring_genotypes(0)
-{
-}
-
-cInjectGenotype_BirthData::~cInjectGenotype_BirthData()
-{
-}
Deleted: trunk/source/main/inject_genotype_birth_data.hh
===================================================================
--- trunk/source/main/inject_genotype_birth_data.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inject_genotype_birth_data.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,38 +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 INJECT_GENOTYPE_BIRTH_DATA_HH
-#define INJECT_GENOTYPE_BIRTH_DATA_HH
-
-#ifndef COUNT_TRACKER_HH
-#include "count_tracker.hh"
-#endif
-
-class cInjectGenotype;
-class cInjectGenotype_BirthData {
-public:
- cInjectGenotype_BirthData(int in_update_born);
- ~cInjectGenotype_BirthData();
-
- cCountTracker birth_track;
- cCountTracker death_track;
- //cCountTracker breed_in_track;
- //cCountTracker breed_true_track;
- //cCountTracker breed_out_track;
-
- int update_born; // Update genotype was first created
- int parent_id; // ID of parent genotype
- //int parent_distance; // Genetic distance from parent genotype
- int gene_depth; // depth in the phylogenetic tree from ancestor
-
- int update_deactivated; // If not, when did it get deactivated?
- cInjectGenotype * parent_genotype; // Pointer to parent genotype...
- //cSpecies * parent_species;
- int num_offspring_genotypes; // Num offspring genotypes still in memory.
-};
-
-#endif
Deleted: trunk/source/main/inject_genotype_control.cc
===================================================================
--- trunk/source/main/inject_genotype_control.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inject_genotype_control.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,288 +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 INJECT_GENOTYPE_CONTROL_HH
-#include "inject_genotype_control.hh"
-#endif
-
-#ifndef DEFS_HH
-#include "defs.hh"
-#endif
-#ifndef INJECT_GENEBANK_HH
-#include "inject_genebank.hh"
-#endif
-#ifndef INJECT_GENOTYPE_HH
-#include "inject_genotype.hh"
-#endif
-
-////////////////////////////
-// cInjectGenotypeControl
-////////////////////////////
-
-cInjectGenotypeControl::cInjectGenotypeControl(cInjectGenebank & in_gb) : genebank(in_gb)
-{
- size = 0;
- best = NULL;
- coalescent = NULL;
- for (int i = 0; i < INJECTGENOTYPE_THREADS; i++) threads[i] = NULL;
-
- historic_list = NULL;
- historic_count = 0;
-}
-
-cInjectGenotypeControl::~cInjectGenotypeControl()
-{
-}
-
-bool cInjectGenotypeControl::OK()
-{
- int ret_value = true;
-
- // Cycle through the list, making sure all connections are proper, size
- // is correct, and all genotypes are OK().
-
- cInjectGenotype * cur_pos = best;
- for (int i = 0; i < size; i++) {
- if (!cur_pos->OK()) ret_value = false;
- assert (cur_pos->GetNext()->GetPrev() == cur_pos);
- cur_pos = cur_pos->GetNext();
- }
-
- assert (cur_pos == best);
-
- return ret_value;
-}
-
-void cInjectGenotypeControl::Insert(cInjectGenotype & in_inject_genotype, cInjectGenotype * prev_genotype)
-{
- if (prev_genotype == NULL) {
- assert(size == 0); // Destroying a full genotype queue...
-
- best = &in_inject_genotype;
- best->SetNext(best);
- best->SetPrev(best);
- }
- else {
- in_inject_genotype.SetPrev(prev_genotype);
- in_inject_genotype.SetNext(prev_genotype->GetNext());
- prev_genotype->SetNext(&in_inject_genotype);
- in_inject_genotype.GetNext()->SetPrev(&in_inject_genotype);
- }
-
- size++;
-}
-
-void cInjectGenotypeControl::Remove(cInjectGenotype & in_inject_genotype)
-{
- if (size == 1) {
- best = NULL;
- }
- if (&in_inject_genotype == best) {
- best = best->GetNext();
- }
-
- in_inject_genotype.GetNext()->SetPrev(in_inject_genotype.GetPrev());
- in_inject_genotype.GetPrev()->SetNext(in_inject_genotype.GetNext());
- in_inject_genotype.SetNext(NULL);
- in_inject_genotype.SetPrev(NULL);
-
- size--;
-}
-
-void cInjectGenotypeControl::RemoveHistoric(cInjectGenotype & in_inject_genotype)
-{
- if (historic_count == 1) {
- historic_list = NULL;
- }
- if (&in_inject_genotype == historic_list) {
- historic_list = historic_list->GetNext();
- }
-
- in_inject_genotype.GetNext()->SetPrev(in_inject_genotype.GetPrev());
- in_inject_genotype.GetPrev()->SetNext(in_inject_genotype.GetNext());
- in_inject_genotype.SetNext(NULL);
- in_inject_genotype.SetPrev(NULL);
-
- historic_count--;
-}
-
-void cInjectGenotypeControl::InsertHistoric(cInjectGenotype & in_inject_genotype)
-{
- if (historic_count == 0) {
- in_inject_genotype.SetNext(&in_inject_genotype);
- in_inject_genotype.SetPrev(&in_inject_genotype);
- }
- else {
- in_inject_genotype.SetPrev(historic_list->GetPrev());
- in_inject_genotype.SetNext(historic_list);
- historic_list->GetPrev()->SetNext(&in_inject_genotype);
- historic_list->SetPrev(&in_inject_genotype);
- }
-
- historic_list = &in_inject_genotype;
- historic_count++;
-}
-
-/*int cInjectGenotypeControl::UpdateCoalescent()
-{
- // Test to see if any updating needs to be done...
- // Don't update active coalescent genotype, or if there is more than
- // one offspring.
- if (coalescent != NULL &&
- (coalescent->GetNumInjected() > 0) ||
- coalescent->GetNumOffspringGenotypes() > 1) ) {
- return coalescent->GetDepth();
- }
-
- // If there is no best, there is nothing to search through...
- if (best == NULL) return -1;
-
- // Find the new point...
- cInjectGenotype * test_gen = best;
- cInjectGenotype * found_gen = best;
- cInjectGenotype * parent_gen = best->GetParentGenotype();
-
- while (parent_gen != NULL) {
- // See if this genotype should be the new found genotype...
- if (test_gen->GetNumOrganisms() > 0 ||
- test_gen->GetNumOffspringGenotypes() > 1) {
- found_gen = test_gen;
- }
-
- // Move to the next genotype...
- test_gen = parent_gen;
- parent_gen = test_gen->GetParentGenotype();
- }
-
- coalescent = found_gen;
-
- return coalescent->GetDepth();
-}*/
-
-
-bool cInjectGenotypeControl::CheckPos(cInjectGenotype & in_inject_genotype)
-{
- int next_OK = false;
- int prev_OK = false;
-
- if (in_inject_genotype.GetNumInjected() >= in_inject_genotype.GetNext()->GetNumInjected()) {
- next_OK =true;
- }
- if (in_inject_genotype.GetNumInjected() <= in_inject_genotype.GetPrev()->GetNumInjected()) {
- prev_OK =true;
- }
-
- if ((&in_inject_genotype == best && next_OK) ||
- (next_OK && prev_OK) ||
- (&in_inject_genotype == best->GetPrev() && prev_OK)) {
- return true;
- }
-
- return false;
-}
-
-void cInjectGenotypeControl::Insert(cInjectGenotype & new_genotype)
-{
- // If there is nothing in the list, add this.
-
- if (size == 0) {
- Insert(new_genotype, NULL);
- }
-
- // Otherwise tack it on the end.
-
- else {
- Insert(new_genotype, best->GetPrev());
- }
-}
-
-bool cInjectGenotypeControl::Adjust(cInjectGenotype & in_inject_genotype)
-{
- //if (in_inject_genotype.GetDeferAdjust() == true) return true;
-
- cInjectGenotype * cur_inject_genotype = in_inject_genotype.GetPrev();
-
- // Check to see if this genotype should be removed completely.
-
- if (in_inject_genotype.GetNumInjected() == 0) {
- genebank.RemoveInjectGenotype(in_inject_genotype);
- return false;
- }
-
- // Do not adjust if this was and still is the best genotype, or is
- // otherwise in the proper spot...
-
- if (CheckPos(in_inject_genotype)) {
- return true;
- }
-
- // Otherwise, remove it from the queue for just the moment.
-
- Remove(in_inject_genotype);
-
- // Also, if this genotype is the best, put it there.
-
- if (in_inject_genotype.GetNumInjected() > best->GetNumInjected()) {
- Insert(in_inject_genotype, best->GetPrev());
- best = &in_inject_genotype;
- return true;
- }
-
- // Finally, find out where this genotype *does* go.
-
- while (cur_inject_genotype->GetNumInjected() >= in_inject_genotype.GetNumInjected() &&
- cur_inject_genotype != best->GetPrev()) {
- cur_inject_genotype = cur_inject_genotype->GetNext();
- }
- while (cur_inject_genotype->GetNumInjected() < in_inject_genotype.GetNumInjected() &&
- cur_inject_genotype != best) {
- cur_inject_genotype = cur_inject_genotype->GetPrev();
- }
-
- Insert(in_inject_genotype, cur_inject_genotype);
-
- return true;
-}
-
-
-cInjectGenotype * cInjectGenotypeControl::Find(const cGenome & in_genome) const
-{
- int i;
- cInjectGenotype * cur_inject_genotype = best;
-
- for (i = 0; i < size; i++) {
- if (in_genome == cur_inject_genotype->GetGenome()) {
- return cur_inject_genotype;
- }
- cur_inject_genotype = cur_inject_genotype->GetNext();
- }
-
- return NULL;
-}
-
-int cInjectGenotypeControl::FindPos(cInjectGenotype & in_inject_genotype, int max_depth)
-{
- cInjectGenotype * temp_genotype = best;
- if (max_depth < 0 || max_depth > size) max_depth = size;
-
- for (int i = 0; i < max_depth; i++) {
- if (temp_genotype == &in_inject_genotype) return i;
- temp_genotype = temp_genotype->GetNext();
- }
-
- return -1;
-}
-
-cInjectGenotype * cInjectGenotypeControl::Next(int thread)
-{
- return threads[thread] = threads[thread]->GetNext();
-}
-
-cInjectGenotype * cInjectGenotypeControl::Prev(int thread)
-{
- return threads[thread] = threads[thread]->GetPrev();
-}
Deleted: trunk/source/main/inject_genotype_control.hh
===================================================================
--- trunk/source/main/inject_genotype_control.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inject_genotype_control.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,64 +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 INJECT_GENOTYPE_CONTROL_HH
-#define INJECT_GENOTYPE_CONTROL_HH
-
-#ifndef INJECT_GENEBANK_MACROS_HH
-#include "inject_genebank_macros.hh"
-#endif
-
-class cGenome;
-class cInjectGenotype;
-class cInjectGenebank;
-class cInjectGenotypeControl {
-private:
- int size;
- cInjectGenotype * best;
- cInjectGenotype * coalescent;
- cInjectGenotype * threads[INJECTGENOTYPE_THREADS];
- cInjectGenebank & genebank;
-
- cInjectGenotype * historic_list;
- int historic_count;
-
- void Insert(cInjectGenotype & in_inject_genotype, cInjectGenotype * prev_inject_genotype);
- bool CheckPos(cInjectGenotype & in_inject_genotype);
-public:
- cInjectGenotypeControl(cInjectGenebank & in_gb);
- ~cInjectGenotypeControl();
-
- bool OK();
- void Remove(cInjectGenotype & in_inject_genotype);
- void Insert(cInjectGenotype & new_inject_genotype);
- bool Adjust(cInjectGenotype & in_inject_genotype);
-
- void RemoveHistoric(cInjectGenotype & in_inject_genotype);
- void InsertHistoric(cInjectGenotype & in_inject_genotype);
- int GetHistoricCount() { return historic_count; }
-
- /*
- int UpdateCoalescent();
- */
-
- inline int GetSize() const { return size; }
- inline cInjectGenotype * GetBest() const { return best; }
- inline cInjectGenotype * GetCoalescent() const { return coalescent; }
-
- cInjectGenotype * Find(const cGenome & in_genome) const;
- int FindPos(cInjectGenotype & in_inject_genotype, int max_depth = -1);
-
- inline cInjectGenotype * Get(int thread) const { return threads[thread]; }
- inline cInjectGenotype * Reset(int thread)
- { return threads[thread] = best; }
- inline cInjectGenotype * ResetHistoric(int thread)
- { return threads[thread] = historic_list; }
- cInjectGenotype * Next(int thread);
- cInjectGenotype * Prev(int thread);
-};
-
-#endif
Deleted: trunk/source/main/inject_genotype_element.hh
===================================================================
--- trunk/source/main/inject_genotype_element.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inject_genotype_element.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,35 +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 INJECT_GENOTYPE_ELEMENT_HH
-#define INJECT_GENOTYPE_ELEMENT_HH
-
-#ifndef DEFS_HH
-#include "defs.hh"
-#endif
-
-class cInjectGenotype;
-class cInjectGenotypeElement {
-private:
- cInjectGenotype * inject_genotype;
- cInjectGenotypeElement * next;
- cInjectGenotypeElement * prev;
-public:
- inline cInjectGenotypeElement(cInjectGenotype * in_gen=NULL) : inject_genotype(in_gen) {
- next = NULL; prev = NULL;
- }
- inline ~cInjectGenotypeElement() { ; }
-
- inline cInjectGenotype * GetInjectGenotype() const { return inject_genotype; }
- inline cInjectGenotypeElement * GetNext() const { return next; }
- inline cInjectGenotypeElement * GetPrev() const { return prev; }
-
- inline void SetNext(cInjectGenotypeElement * in_next) { next = in_next; }
- inline void SetPrev(cInjectGenotypeElement * in_prev) { prev = in_prev; }
-};
-
-#endif
Deleted: trunk/source/main/inject_genotype_queue.cc
===================================================================
--- trunk/source/main/inject_genotype_queue.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inject_genotype_queue.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,104 +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 INJECT_GENOTYPE_QUEUE_HH
-#include "inject_genotype_queue.hh"
-#endif
-
-#ifndef INJECT_GENOTYPE_HH
-#include "inject_genotype.hh"
-#endif
-
-#include <assert.h>
-
-/////////////////////
-// cInjectGenotypeQueue
-/////////////////////
-
-cInjectGenotypeQueue::cInjectGenotypeQueue()
-{
- size = 0;
- root.SetNext(&root);
- root.SetPrev(&root);
-}
-
-
-cInjectGenotypeQueue::~cInjectGenotypeQueue()
-{
- while (root.GetNext() != &root) {
- Remove(root.GetNext());
- }
-}
-
-bool cInjectGenotypeQueue::OK()
-{
- bool result = true;
- int count = 0;
-
- for (cInjectGenotypeElement * temp_element = root.GetNext();
- temp_element != &root;
- temp_element = temp_element->GetNext()) {
- assert (temp_element->GetNext()->GetPrev() == temp_element);
- assert (temp_element->GetInjectGenotype()->GetID() >= 0);
-
- count++;
- assert (count <= size);
- }
-
- assert (count == size);
-
- return result;
-}
-
-void cInjectGenotypeQueue::Insert(cInjectGenotype & in_inject_genotype)
-{
- cInjectGenotypeElement * new_element = new cInjectGenotypeElement(&in_inject_genotype);
- new_element->SetNext(root.GetNext());
- new_element->SetPrev(&root);
- root.GetNext()->SetPrev(new_element);
- root.SetNext(new_element);
- size++;
-}
-
-void cInjectGenotypeQueue::Remove(cInjectGenotype & in_inject_genotype)
-{
- cInjectGenotypeElement * cur_element;
-
- for (cur_element = root.GetNext();
- cur_element != &root;
- cur_element = cur_element->GetNext()) {
- if (cur_element->GetInjectGenotype() == &in_inject_genotype) break;
- }
-
- assert (cur_element != &root);
-
- Remove(cur_element);
-}
-
-void cInjectGenotypeQueue::Remove(cInjectGenotypeElement * in_element)
-{
- in_element->GetPrev()->SetNext(in_element->GetNext());
- in_element->GetNext()->SetPrev(in_element->GetPrev());
- in_element->SetNext(NULL);
- in_element->SetPrev(NULL);
- delete(in_element);
-
- size--;
-}
-
-cInjectGenotype * cInjectGenotypeQueue::Find(const cGenome & in_genome) const
-{
- for (cInjectGenotypeElement * cur_element = root.GetNext();
- cur_element != &root;
- cur_element = cur_element->GetNext()) {
- if (cur_element->GetInjectGenotype()->GetGenome() == in_genome) {
- return cur_element->GetInjectGenotype();
- }
- }
-
- return NULL;
-}
Deleted: trunk/source/main/inject_genotype_queue.hh
===================================================================
--- trunk/source/main/inject_genotype_queue.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inject_genotype_queue.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,34 +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 INJECT_GENOTYPE_QUEUE_HH
-#define INJECT_GENOTYPE_QUEUE_HH
-
-#ifndef INJECT_GENOTYPE_ELEMENT_HH
-#include "inject_genotype_element.hh"
-#endif
-
-class cInjectGenotype;
-class cGenome;
-class cInjectGenotypeQueue {
-private:
- int size;
- cInjectGenotypeElement root;
-
- void Remove(cInjectGenotypeElement * in_element);
-public:
- cInjectGenotypeQueue();
- ~cInjectGenotypeQueue();
-
- bool OK();
-
- void Insert(cInjectGenotype & in_inject_genotype);
- void Remove(cInjectGenotype & in_inject_genotype);
- cInjectGenotype * Find(const cGenome & in_genome) const;
-};
-
-#endif
Deleted: trunk/source/main/inst_lib_base.hh
===================================================================
--- trunk/source/main/inst_lib_base.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inst_lib_base.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,30 +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 INST_LIB_BASE_HH
-#define INST_LIB_BASE_HH
-
-#ifndef INSTRUCTION_HH
-#include "instruction.hh"
-#endif
-
-class cString;
-class cInstLibBase {
-public:
- virtual ~cInstLibBase() { ; }
- virtual const cString &GetName(const unsigned int id) = 0;
- virtual const cString &GetNopName(const unsigned int id) = 0;
- virtual int GetNopMod(const unsigned int id) = 0;
- virtual int GetNopMod(const cInstruction & inst) = 0;
- virtual int GetSize() = 0;
- virtual int GetNumNops() = 0;
- virtual cInstruction GetInst(const cString & in_name) = 0;
- virtual const cInstruction & GetInstDefault() = 0;
- virtual const cInstruction & GetInstError() = 0;
-};
-
-#endif
Deleted: trunk/source/main/inst_set.cc
===================================================================
--- trunk/source/main/inst_set.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inst_set.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,148 +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 INST_SET_HH
-#include "inst_set.hh"
-#endif
-
-#ifndef STRING_UTIL_HH
-#include "string_util.hh"
-#endif
-#ifndef TOOLS_HH
-#include "tools.hh"
-#endif
-
-using namespace std;
-
-//////////////////////
-// cInstSet
-//////////////////////
-
-// Initialize static variables
-const cInstruction cInstSet::inst_default( 0 );
-cInstruction cInstSet::inst_default2( 0 );
-cInstruction cInstSet::inst_error2 ( 255 );
-
-cInstSet::cInstSet()
-{
-}
-
-cInstSet::cInstSet(const cInstSet & in_inst_set)
- : m_inst_lib(in_inst_set.m_inst_lib)
- , m_lib_name_map(in_inst_set.m_lib_name_map)
- , m_lib_nopmod_map(in_inst_set.m_lib_nopmod_map)
- , mutation_chart2(in_inst_set.mutation_chart2)
-{
-}
-
-cInstSet::~cInstSet()
-{
-}
-
-cInstSet & cInstSet::operator=(const cInstSet & _in)
-{
- m_inst_lib = _in.m_inst_lib;
- m_lib_name_map = _in.m_lib_name_map;
- m_lib_nopmod_map = _in.m_lib_nopmod_map;
- mutation_chart2 = _in.mutation_chart2;
- return *this;
-}
-
-bool cInstSet::OK() const
-{
- assert(m_lib_name_map.GetSize() < 256);
- assert(m_lib_nopmod_map.GetSize() < m_lib_name_map.GetSize());
-
- // Make sure that all of the redundancies are represented the appropriate
- // number of times.
- tArray<int> test_redundancy2(m_lib_name_map.GetSize());
- test_redundancy2.SetAll(0);
- for (int i = 0; i < mutation_chart2.GetSize(); i++) {
- int test_id = mutation_chart2[i];
- test_redundancy2[test_id]++;
- }
- for (int i = 0; i < m_lib_name_map.GetSize(); i++) {
- assert(m_lib_name_map[i].redundancy == test_redundancy2[i]);
- }
-
- return true;
-}
-
-cInstruction cInstSet::GetRandomInst() const
-{
- int inst_op = mutation_chart2[g_random.GetUInt(mutation_chart2.GetSize())];
- return cInstruction(inst_op);
-}
-
-int cInstSet::Add2(
- const int lib_fun_id,
- const int redundancy,
- const int ft_cost,
- const int cost,
- const double prob_fail
-)
-{
- const int inst_id = m_lib_name_map.GetSize();
-
- assert(inst_id < 255);
-
- // Increase the size of the array...
- m_lib_name_map.Resize(inst_id + 1);
-
- // Setup the new function...
- m_lib_name_map[inst_id].lib_fun_id = lib_fun_id;
- m_lib_name_map[inst_id].redundancy = redundancy;
- m_lib_name_map[inst_id].cost = cost;
- m_lib_name_map[inst_id].ft_cost = ft_cost;
- m_lib_name_map[inst_id].prob_fail = prob_fail;
-
- const int total_redundancy = mutation_chart2.GetSize();
- mutation_chart2.Resize(total_redundancy + redundancy);
- for (int i = 0; i < redundancy; i++) {
- mutation_chart2[total_redundancy + i] = inst_id;
- }
-
- return inst_id;
-}
-
-int cInstSet::AddNop2(
- const int lib_nopmod_id,
- const int redundancy,
- const int ft_cost,
- const int cost,
- const double prob_fail
-)
-{
- // Assert nops are at the _beginning_ of an inst_set.
- assert(m_lib_name_map.GetSize() == m_lib_nopmod_map.GetSize());
-
- const int inst_id = Add2(lib_nopmod_id, redundancy, ft_cost, cost, prob_fail);
-
- m_lib_nopmod_map.Resize(inst_id + 1);
- m_lib_nopmod_map[inst_id] = lib_nopmod_id;
-
- return inst_id;
-}
-
-cString cInstSet::FindBestMatch(const cString & in_name) const
-{
- int best_dist = 1024;
- cString best_name("");
-
- for (int i = 0; i < m_lib_name_map.GetSize(); i++) {
- const cString & cur_name = m_inst_lib->GetName(m_lib_name_map[i].lib_fun_id);
- const int cur_dist = cStringUtil::EditDistance(cur_name, in_name);
- if (cur_dist < best_dist) {
- best_dist = cur_dist;
- best_name = cur_name;
- }
- if (cur_dist == 0) break;
- }
-
- return best_name;
-}
-
Deleted: trunk/source/main/inst_set.hh
===================================================================
--- trunk/source/main/inst_set.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inst_set.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,198 +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 INST_SET_HH
-#define INST_SET_HH
-
-#include <iostream>
-
-#ifndef STRING_HH
-#include "string.hh"
-#endif
-#ifndef TARRAY_HH
-#include "tArray.hh"
-#endif
-#ifndef INSTRUCTION_HH
-#include "instruction.hh"
-#endif
-#ifndef INST_LIB_BASE_HH
-#include "inst_lib_base.hh"
-#endif
-
-using namespace std;
-
-// A typdef to simplify having an instruction point to methods in the
-// cHardwareBase object and its dirivitives...
-class cHardwareBase;
-
-// moved to cpu/hardware_method.hh for porting to gcc 3.1 -- k
-//typedef bool (cHardwareBase::*tHardwareMethod)();
-
-class cInstLibBase;
-
-/**
- * This class is used to create a mapping from the command strings in
- * an organism's genome into real methods in one of the hardware objects. This
- * object has been designed to allow easy manipulation of the instruction
- * sets, as well as multiple instruction sets within a single soup (just
- * attach different cInstSet objects to different hardware.
- **/
-
-class cInstLibBase; // access
-template <class T> class tArray; // aggregate
-class cInstruction; // access
-class cString; // access
-
-class cInstSet {
-public:
- cInstLibBase *m_inst_lib;
- class cInstEntry2 {
- public:
- int lib_fun_id;
- int redundancy; // Weight in instruction set (not impl.)
- int cost; // additional time spent to exectute inst.
- int ft_cost; // time spent first time exec (in add to cost)
- double prob_fail; // probability of failing to execute inst
- };
- tArray<cInstEntry2> m_lib_name_map;
- tArray<int> m_lib_nopmod_map;
- tArray<int> mutation_chart2; // ID's represented by redundancy values.
- // Static components...
- static cInstruction inst_error2;
- // static const cInstruction inst_none;
- static cInstruction inst_default2;
-
- // Static components...
- //static const cInstruction inst_error;
- // static const cInstruction inst_none;
- static const cInstruction inst_default;
-
-public:
- cInstSet();
- cInstSet(const cInstSet & in_inst_set);
- ~cInstSet();
-
- cInstSet & operator=(const cInstSet & _in);
-
- bool OK() const;
-
- // Accessors
- const cString & GetName(int id) const
- {
- return m_inst_lib->GetName(m_lib_name_map[id].lib_fun_id);
- }
- const cString & GetName(const cInstruction & inst) const
- {
- return GetName(inst.GetOp());
- }
- int GetCost(const cInstruction & inst) const
- {
- return m_lib_name_map[inst.GetOp()].cost;
- }
- int GetFTCost(const cInstruction & inst) const
- {
- return m_lib_name_map[inst.GetOp()].ft_cost;
- }
- double GetProbFail(const cInstruction & inst) const
- {
- return m_lib_name_map[inst.GetOp()].prob_fail;
- }
- int GetRedundancy(const cInstruction & inst) const
- {
- return m_lib_name_map[inst.GetOp()].redundancy;
- }
-
- int GetLibFunctionIndex(const cInstruction & inst) const
- {
- return m_lib_name_map[inst.GetOp()].lib_fun_id;
- }
-
- int GetNopMod(const cInstruction & inst) const
- {
- return m_inst_lib->GetNopMod(m_lib_nopmod_map[inst.GetOp()]);
- }
-
- cInstruction GetRandomInst() const;
- int GetRandFunctionIndex() const
- {
- return m_lib_name_map[ GetRandomInst().GetOp() ].lib_fun_id;
- }
-
- int GetSize() const {
- return m_lib_name_map.GetSize();
- }
- int GetNumNops() const {
- return m_lib_nopmod_map.GetSize();
- }
-
- // Instruction Analysis.
- int IsNop(const cInstruction & inst) const
- {
- return (inst.GetOp() < m_lib_nopmod_map.GetSize());
- }
-
- // Insertion of new instructions...
- int Add2(
- const int lib_fun_id,
- const int redundancy=1,
- const int ft_cost=0,
- const int cost=0,
- const double prob_fail=0.0
- );
- int AddNop2(
- const int lib_nopmod_id,
- const int redundancy=1,
- const int ft_cost=0,
- const int cost=0,
- const double prob_fail=0.0
- );
-
- // accessors for instruction library
- cInstLibBase *GetInstLib(){ return m_inst_lib; }
- void SetInstLib(cInstLibBase *inst_lib){
- m_inst_lib = inst_lib;
- inst_error2 = inst_lib->GetInstError();
- inst_default2 = inst_lib->GetInstDefault();
- }
-
- inline cInstruction GetInst(const cString & in_name) const;
- cString FindBestMatch(const cString & in_name) const;
-
- // Static methods..
- static const cInstruction & GetInstDefault() {
- return inst_default2;
- }
- static const cInstruction & GetInstError() {
- return inst_error2;
- }
- // static const cInstruction & GetInstNone() { return inst_none; }
-};
-
-
-inline cInstruction cInstSet::GetInst(const cString & in_name) const
-{
- for (int i = 0; i < m_lib_name_map.GetSize(); i++) {
- if (m_inst_lib->GetName(m_lib_name_map[i].lib_fun_id) == in_name) {
- return cInstruction(i);
- }
- }
-
- // @CAO Hacking this to make sure we don't have defaults...
- cerr << "Error: Unknown instruction '" << in_name << "'. Exiting..." << endl;
- exit(1);
-
-
- // Adding default answer if nothing is found...
- /*
- FIXME: this return value is supposed to be cInstSet::GetInstError
- which should be the same as m_inst_lib->GetInstError().
- -- kgn
- */
- return cInstruction(0);
-}
-
-#endif
Deleted: trunk/source/main/inst_util.cc
===================================================================
--- trunk/source/main/inst_util.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inst_util.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,109 +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 "inst_util.hh"
-
-#include "string.hh"
-#include "file.hh"
-
-#ifndef INIT_FILE_HH
-#include "init_file.hh"
-#endif
-
-#include "inst_set.hh"
-#include "genome.hh"
-
-
-using namespace std;
-
-
-cGenome cInstUtil::LoadGenome(const cString & filename,
- const cInstSet & inst_set)
-{
- cInitFile input_file(filename);
- if (!input_file.IsOpen()) {
- cerr << "Cannot open file: " << filename << endl;
- return cGenome(0);
- }
- input_file.Load();
- input_file.Compress();
- input_file.Close();
-
- // Setup the code array...
- cGenome new_genome(input_file.GetNumLines());
-
- for (int line_num = 0; line_num < new_genome.GetSize(); line_num++) {
- cString cur_line = input_file.GetLine(line_num);
- new_genome[line_num] = inst_set.GetInst(cur_line);
-
- if (new_genome[line_num] == cInstSet::GetInstError()) {
- // You're using the wrong instruction set! YOU FOOL!
- cerr << "Cannot load organism '" << filename << "'" << endl
- << " Unknown line: " << cur_line
- << " (best match is '" << inst_set.FindBestMatch(cur_line) << "')"
- << endl;
- exit(1);
- }
- }
-
- if(new_genome.GetSize()==0)
- cerr << "Warning: Genome size is 0!" << endl;
-
- return new_genome;
-}
-
-cGenome cInstUtil::LoadInternalGenome(istream & fp, const cInstSet &inst_set)
-{
- assert(fp.good()); // Invalid stream to load genome from!
-
- int num_lines = -1;
- fp >> num_lines;
-
- if (num_lines <= 0) { return cGenome(1); }
-
- // Setup the code array...
- cGenome new_genome(num_lines);
- cString cur_line;
-
- for (int line_num = 0; line_num < new_genome.GetSize(); line_num++) {
- fp >> cur_line;
- new_genome[line_num] = inst_set.GetInst(cur_line);
-
- if (new_genome[line_num] == cInstSet::GetInstError()) {
- // You're using the wrong instruction set! YOU FOOL!
- cerr << "Cannot load creature from stream:" << endl
- << " Unknown line: " << cur_line << endl;
- }
- }
- return new_genome;
-}
-
-void cInstUtil::SaveGenome(ostream & fp, const cInstSet & inst_set,
- const cGenome & gen)
-{
- for (int i = 0; i < gen.GetSize(); i++) {
- fp << inst_set.GetName(gen[i]) << endl;
- }
-}
-
-void cInstUtil::SaveInternalGenome(ostream & fp, const cInstSet & inst_set,
- const cGenome & gen)
-{
- fp << gen.GetSize() << endl;
- SaveGenome(fp, inst_set, gen);
-}
-
-
-cGenome cInstUtil::RandomGenome(int length, const cInstSet & inst_set)
-{
- cGenome genome(length);
- for (int i = 0; i < length; i++) {
- genome[i] = inst_set.GetRandomInst();
- }
- return genome;
-}
-
Deleted: trunk/source/main/inst_util.hh
===================================================================
--- trunk/source/main/inst_util.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/inst_util.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,39 +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 INST_UTIL_HH
-#define INST_UTIL_HH
-
-#include <iostream>
-
-#ifndef GENOME_HH
-#include "genome.hh"
-#endif
-
-class cInitFile;
-class cInstSet;
-class cString;
-class cInstUtil {
-public:
-
- // ========= Genome-File Interaction =========
- // Saving and loading of files. These functions assume that the genome is
- // the only thing in the file unless 'Internal' is in the function name
- // (Internal genomes must begin with a number that indicates genome length)
-
- static cGenome LoadGenome(const cString &filename, const cInstSet &inst_set);
- static cGenome LoadInternalGenome(std::istream & fp, const cInstSet &inst_set);
- static void SaveGenome(std::ostream &fp, const cInstSet & inst_set,
- const cGenome &gen);
- static void SaveInternalGenome(std::ostream &fp, const cInstSet &inst_set,
- const cGenome &gen);
-
- // ========= Genome Construction =========
- static cGenome RandomGenome(int length, const cInstSet & inst_set);
-};
-
-#endif
Deleted: trunk/source/main/instruction.cc
===================================================================
--- trunk/source/main/instruction.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/instruction.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,27 +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 "instruction.hh"
-
-
-char cInstruction::GetSymbol() const
-{
- if (operand < 26) return operand + 'a';
- if (operand < 52) return operand - 26 + 'A';
- if (operand < 62) return operand - 52 + '0';
- if (operand == 255) return '_';
- return '?';
-}
-
-void cInstruction::SetSymbol(char symbol)
-{
- if (symbol >= 'a' && symbol <= 'z') operand = symbol - 'a';
- else if (symbol >= 'A' && symbol <= 'Z') operand = symbol - 'A' + 26;
- else if (symbol >= '0' && symbol <= '9') operand = symbol - '0' + 52;
- else operand = 254;
-}
-
Deleted: trunk/source/main/instruction.hh
===================================================================
--- trunk/source/main/instruction.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/instruction.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,45 +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 INSTRUCTION_HH
-#define INSTRUCTION_HH
-
-#include <assert.h>
-
-#ifndef DEFS_HH
-#include "defs.hh"
-#endif
-
-class cInstruction {
-private:
- UCHAR operand;
-
-public:
- // Accessors...
- int GetOp() const { return (int) operand; }
- void SetOp(int in_op) { assert(in_op < 256); operand = in_op; }
-
- // Operators...
- void operator=(const cInstruction & inst)
- { if (this != &inst) operand = inst.operand; }
- bool operator==(const cInstruction & inst) const
- { return (operand == inst.operand); }
- bool operator!=(const cInstruction & inst) const
- { return !(operator==(inst)); }
-
- // Constructors and Destructor...
- cInstruction() { operand = 0; }
- cInstruction(const cInstruction & _inst) { *this = _inst; }
- explicit cInstruction(int in_op) { SetOp(in_op); }
- ~cInstruction() { ; }
-
- // Some extra methods to convert too and from alpha-numeric symbols...
- char GetSymbol() const;
- void SetSymbol(char symbol);
-};
-
-#endif
Modified: trunk/source/main/landscape.cc
===================================================================
--- trunk/source/main/landscape.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/landscape.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -9,7 +9,7 @@
#include "cCPUMemory.h"
#include "cEnvironment.h"
-#include "inst_set.hh"
+#include "cInstSet.h"
#include "organism.hh"
#include "phenotype.hh"
#include "stats.hh" // For GetUpdate in outputs...
Modified: trunk/source/main/landscape.hh
===================================================================
--- trunk/source/main/landscape.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/landscape.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -12,7 +12,7 @@
#include "cCPUTestInfo.h"
#endif
#ifndef GENOME_HH
-#include "genome.hh"
+#include "cGenome.h"
#endif
#ifndef STRING_HH
#include "string.hh"
Modified: trunk/source/main/lineage.cc
===================================================================
--- trunk/source/main/lineage.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/lineage.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -9,7 +9,7 @@
#include "lineage.hh"
#endif
#ifndef GENOTYPE_HH
-#include "genotype.hh"
+#include "cGenotype.h"
#endif
using namespace std;
Modified: trunk/source/main/lineage_control.cc
===================================================================
--- trunk/source/main/lineage_control.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/lineage_control.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -12,8 +12,8 @@
#include "lineage.hh"
#include "stats.hh"
#include "cConfig.h"
-#include "genebank.hh"
-#include "genotype.hh"
+#include "cGenebank.h"
+#include "cGenotype.h"
#include "organism.hh"
#include "nHardware.h" // for macro nHardware::FITNESS_NEUTRAL_MAX
Modified: trunk/source/main/main_sub.pri
===================================================================
--- trunk/source/main/main_sub.pri 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/main_sub.pri 2005-09-16 22:19:23 UTC (rev 317)
@@ -8,17 +8,17 @@
$$MAIN_HH/cCallbackUtil.h \
$$MAIN_HH/cConfig.h \
$$MAIN_HH/cEnvironment.h \
- $$MAIN_HH/fitness_matrix.hh \
- $$MAIN_HH/genebank.hh \
- $$MAIN_HH/genome.hh \
- $$MAIN_HH/genome_util.hh \
- $$MAIN_HH/genotype.hh \
- $$MAIN_HH/inject_genotype.hh \
- $$MAIN_HH/inject_genebank.hh \
- $$MAIN_HH/instruction.hh \
- $$MAIN_HH/inst_lib_base.hh \
- $$MAIN_HH/inst_set.hh \
- $$MAIN_HH/inst_util.hh \
+ $$MAIN_HH/cFitnessMatrix.h \
+ $$MAIN_HH/cGenebank.h \
+ $$MAIN_HH/cGenome.h \
+ $$MAIN_HH/cGenomeUtil.h \
+ $$MAIN_HH/cGenotype.h \
+ $$MAIN_HH/cInjectGenotype.h \
+ $$MAIN_HH/cInjectGenebank.h \
+ $$MAIN_HH/cInstruction.h \
+ $$MAIN_HH/cInstLibBase.h \
+ $$MAIN_HH/cInstSet.h \
+ $$MAIN_HH/cInstUtil.h \
$$MAIN_HH/landscape.hh \
$$MAIN_HH/lineage.hh \
$$MAIN_HH/lineage_control.hh \
@@ -47,22 +47,22 @@
$$MAIN_CC/cCallbackUtil.cc \
$$MAIN_CC/cConfig.cc \
$$MAIN_CC/cEnvironment.cc \
- $$MAIN_CC/fitness_matrix.cc \
- $$MAIN_CC/genebank.cc \
- $$MAIN_CC/genome.cc \
- $$MAIN_CC/genome_util.cc \
- $$MAIN_CC/genotype.cc \
- $$MAIN_CC/genotype_birth_data.cc \
- $$MAIN_CC/genotype_control.cc \
- $$MAIN_CC/genotype_test_data.cc \
- $$MAIN_CC/instruction.cc \
- $$MAIN_CC/inst_set.cc \
- $$MAIN_CC/inst_util.cc \
- $$MAIN_CC/inject_genebank.cc \
- $$MAIN_CC/inject_genotype.cc \
- $$MAIN_CC/inject_genotype_birth_data.cc \
- $$MAIN_CC/inject_genotype_control.cc \
- $$MAIN_CC/inject_genotype_queue.cc \
+ $$MAIN_CC/cFitnessMatrix.cc \
+ $$MAIN_CC/cGenebank.cc \
+ $$MAIN_CC/cGenome.cc \
+ $$MAIN_CC/cGenomeUtil.cc \
+ $$MAIN_CC/cGenotype.cc \
+ $$MAIN_CC/cGenotype_BirthData.cc \
+ $$MAIN_CC/cGenotypeControl.cc \
+ $$MAIN_CC/cGenotype_TestData.cc \
+ $$MAIN_CC/cInstruction.cc \
+ $$MAIN_CC/cInstSet.cc \
+ $$MAIN_CC/cInstUtil.cc \
+ $$MAIN_CC/cInjectGenebank.cc \
+ $$MAIN_CC/cInjectGenotype.cc \
+ $$MAIN_CC/cInjectGenotype_BirthData.cc \
+ $$MAIN_CC/cInjectGenotypeControl.cc \
+ $$MAIN_CC/cInjectGenotypeQueue.cc \
$$MAIN_CC/landscape.cc \
$$MAIN_CC/lineage.cc \
$$MAIN_CC/lineage_control.cc \
Modified: trunk/source/main/mx_code_array.cc
===================================================================
--- trunk/source/main/mx_code_array.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/mx_code_array.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -16,10 +16,10 @@
#include "cCPUTestInfo.h"
#endif
#ifndef GENOME_HH
-#include "genome.hh"
+#include "cGenome.h"
#endif
#ifndef INST_SET_HH
-#include "inst_set.hh"
+#include "cInstSet.h"
#endif
#ifndef MY_CODE_ARRAY_LESS_THAN_HH
#include "my_code_array_less_than.hh"
Modified: trunk/source/main/mx_code_array.hh
===================================================================
--- trunk/source/main/mx_code_array.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/mx_code_array.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -14,7 +14,7 @@
#include <set>
#ifndef INSTRUCTION_HH
-#include "instruction.hh"
+#include "cInstruction.h"
#endif
#ifndef STRING_HH
#include "string.hh"
Modified: trunk/source/main/organism.cc
===================================================================
--- trunk/source/main/organism.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/organism.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -11,12 +11,12 @@
#include "nHardware.h"
#include "cEnvironment.h"
#include "functions.hh"
-#include "genome.hh"
-#include "genome_util.hh"
+#include "cGenome.h"
+#include "cGenomeUtil.h"
#include "cHardwareBase.h"
-#include "inject_genotype.hh"
-#include "inst_set.hh"
-#include "inst_util.hh"
+#include "cInjectGenotype.h"
+#include "cInstSet.h"
+#include "cInstUtil.h"
#include "org_message.hh"
#include "string_util.hh"
#include "tArray.hh"
Modified: trunk/source/main/organism.hh
===================================================================
--- trunk/source/main/organism.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/organism.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -18,7 +18,7 @@
#include "sCPUStats.h"
#endif
#ifndef GENOME_HH
-#include "genome.hh"
+#include "cGenome.h"
#endif
#ifndef LOCAL_MUTATIONS_HH
#include "local_mutations.hh"
Modified: trunk/source/main/population.cc
===================================================================
--- trunk/source/main/population.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/population.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -13,17 +13,17 @@
#include "data_file.hh"
#include "cEnvironment.h"
#include "functions.hh"
-#include "genebank.hh"
-#include "genome_util.hh"
-#include "genotype.hh"
+#include "cGenebank.h"
+#include "cGenomeUtil.h"
+#include "cGenotype.h"
#include "cHardwareBase.h"
#include "cHardwareFactory.h"
#include "cHardware4Stack.h"
#include "cHardwareUtil.h"
#include "init_file.hh"
-#include "inject_genebank.hh"
-#include "inject_genotype.hh"
-#include "inst_util.hh"
+#include "cInjectGenebank.h"
+#include "cInjectGenotype.h"
+#include "cInstUtil.h"
#include "integrated_schedule.hh"
#include "lineage.hh"
#include "lineage_control.hh"
Modified: trunk/source/main/species.cc
===================================================================
--- trunk/source/main/species.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/species.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -16,10 +16,10 @@
#include "functions.hh"
#endif
#ifndef GENOTYPE_HH
-#include "genotype.hh"
+#include "cGenotype.h"
#endif
#ifndef GENOME_UTIL_HH
-#include "genome_util.hh"
+#include "cGenomeUtil.h"
#endif
#ifndef TEST_CPU_HH
#include "cTestCPU.h"
Modified: trunk/source/main/species.hh
===================================================================
--- trunk/source/main/species.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/species.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -11,7 +11,7 @@
#include <fstream>
#ifndef GENOME_HH
-#include "genome.hh"
+#include "cGenome.h"
#endif
#define SPECIES_QUEUE_NONE 0
Modified: trunk/source/main/species_control.cc
===================================================================
--- trunk/source/main/species_control.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/main/species_control.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -16,7 +16,7 @@
#include "defs.hh"
#endif
#ifndef GENOTYPE_HH
-#include "genotype.hh"
+#include "cGenotype.h"
#endif
#ifndef GENOTYPE_MACROS_HH
#include "genotype_macros.hh"
Modified: trunk/source/testsuites/unit_testsuites/fitness_matrix.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/fitness_matrix.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/fitness_matrix.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef FITNESS_MATRIX_HH
-#include "fitness_matrix.hh"
+#include "cFitnessMatrix.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/genebank.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/genebank.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/genebank.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef GENEBANK_HH
-#include "genebank.hh"
+#include "cGenebank.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/genome.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/genome.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/genome.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef GENOME_HH
-#include "genome.hh"
+#include "cGenome.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/genome_util.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/genome_util.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/genome_util.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef GENOME_UTIL_HH
-#include "genome_util.hh"
+#include "cGenomeUtil.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/genotype.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/genotype.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/genotype.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef GENOTYPE_HH
-#include "genotype.hh"
+#include "cGenotype.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/genotype_batch.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/genotype_batch.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/genotype_batch.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef GENOTYPE_BATCH_HH
-#include "genotype_batch.hh"
+#include "cGenotypeBatch.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/genotype_birth_data.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/genotype_birth_data.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/genotype_birth_data.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef GENOTYPE_BIRTH_DATA_HH
-#include "genotype_birth_data.hh"
+#include "cGenotype_BirthData.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/genotype_control.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/genotype_control.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/genotype_control.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef GENOTYPE_CONTROL_HH
-#include "genotype_control.hh"
+#include "cGenotypeControl.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/inject_genebank.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/inject_genebank.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/inject_genebank.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef INJECT_GENEBANK_HH
-#include "inject_genebank.hh"
+#include "cInjectGenebank.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/inject_genotype.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/inject_genotype.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/inject_genotype.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef INJECT_GENOTYPE_HH
-#include "inject_genotype.hh"
+#include "cInjectGenotype.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/inject_genotype_birth_data.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/inject_genotype_birth_data.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/inject_genotype_birth_data.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef INJECT_GENOTYPE_BIRTH_DATA_HH
-#include "inject_genotype_birth_data.hh"
+#include "cInjectGenotype_BirthData.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/inject_genotype_control.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/inject_genotype_control.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/inject_genotype_control.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef INJECT_GENOTYPE_CONTROL_HH
-#include "inject_genotype_control.hh"
+#include "cInjectGenotypeControl.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/inject_genotype_element.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/inject_genotype_element.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/inject_genotype_element.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef INJECT_GENOTYPE_ELEMENT_HH
-#include "inject_genotype_element.hh"
+#include "cInjectGenotypeElement.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/inject_genotype_queue.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/inject_genotype_queue.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/inject_genotype_queue.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef INJECT_GENOTYPE_QUEUE_HH
-#include "inject_genotype_queue.hh"
+#include "cInjectGenotypeQueue.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/inst_lib_base.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/inst_lib_base.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/inst_lib_base.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef INST_LIB_BASE_HH
-#include "inst_lib_base.hh"
+#include "cInstLibBase.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/inst_set.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/inst_set.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/inst_set.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef INST_SET_HH
-#include "inst_set.hh"
+#include "cInstSet.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/inst_util.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/inst_util.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/inst_util.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef INST_UTIL_HH
-#include "inst_util.hh"
+#include "cInstUtil.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/level_0/genotype_test_data.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/level_0/genotype_test_data.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/level_0/genotype_test_data.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,5 +1,5 @@
#ifndef GENOTYPE_TEST_DATA_HH
-#include "genotype_test_data.hh"
+#include "cGenotype_TestData.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/level_1/instruction.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/level_1/instruction.t.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/testsuites/unit_testsuites/level_1/instruction.t.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef INSTRUCTION_HH
-#include "main/instruction.hh"
+#include "main/cInstruction.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/viewers/environment_screen.cc
===================================================================
--- trunk/source/viewers/environment_screen.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/viewers/environment_screen.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -7,8 +7,8 @@
#include "cConfig.h"
#include "cEnvironment.h"
-#include "genebank.hh"
-#include "genotype.hh"
+#include "cGenebank.h"
+#include "cGenotype.h"
#include "population.hh"
#ifndef REACTION_HH
#include "reaction.hh"
Modified: trunk/source/viewers/hist_screen.cc
===================================================================
--- trunk/source/viewers/hist_screen.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/viewers/hist_screen.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -7,8 +7,8 @@
#include <fstream>
-#include "genebank.hh"
-#include "genotype.hh"
+#include "cGenebank.h"
+#include "cGenotype.h"
#include "species.hh"
#include "hist_screen.hh"
Modified: trunk/source/viewers/map_screen.cc
===================================================================
--- trunk/source/viewers/map_screen.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/viewers/map_screen.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -7,7 +7,7 @@
#include <fstream>
-#include "genotype.hh"
+#include "cGenotype.h"
#include "population.hh"
#include "population_cell.hh"
Modified: trunk/source/viewers/stats_screen.cc
===================================================================
--- trunk/source/viewers/stats_screen.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/viewers/stats_screen.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -7,8 +7,8 @@
#include "cConfig.h"
#include "cEnvironment.h"
-#include "genebank.hh"
-#include "genotype.hh"
+#include "cGenebank.h"
+#include "cGenotype.h"
#include "population.hh"
#include "species.hh"
#include "stats.hh"
Modified: trunk/source/viewers/symbol_util.cc
===================================================================
--- trunk/source/viewers/symbol_util.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/viewers/symbol_util.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -9,7 +9,7 @@
#include "symbol_util.hh"
-#include "genotype.hh"
+#include "cGenotype.h"
#include "organism.hh"
#include "population_cell.hh"
#include "species.hh"
Modified: trunk/source/viewers/text_screen.cc
===================================================================
--- trunk/source/viewers/text_screen.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/viewers/text_screen.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -8,10 +8,10 @@
#include <fstream>
#include "species.hh"
-#include "genotype.hh"
-#include "genebank.hh"
-#include "inject_genotype.hh"
-#include "inject_genebank.hh"
+#include "cGenotype.h"
+#include "cGenebank.h"
+#include "cInjectGenotype.h"
+#include "cInjectGenebank.h"
#include "population.hh"
#include "population_cell.hh"
#include "organism.hh"
Modified: trunk/source/viewers/text_screen.hh
===================================================================
--- trunk/source/viewers/text_screen.hh 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/viewers/text_screen.hh 2005-09-16 22:19:23 UTC (rev 317)
@@ -10,7 +10,7 @@
#include "merit.hh"
-#include "inst_set.hh"
+#include "cInstSet.h"
#include "defs.hh"
#include "ncurses.hh"
Modified: trunk/source/viewers/view.cc
===================================================================
--- trunk/source/viewers/view.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/viewers/view.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -10,7 +10,7 @@
#ifndef ENVIRONMENT_HH
#include "cEnvironment.h"
#endif
-#include "genotype.hh"
+#include "cGenotype.h"
#include "organism.hh"
#include "phenotype.hh"
#include "population.hh"
Modified: trunk/source/viewers/zoom_screen.cc
===================================================================
--- trunk/source/viewers/zoom_screen.cc 2005-09-16 14:10:13 UTC (rev 316)
+++ trunk/source/viewers/zoom_screen.cc 2005-09-16 22:19:23 UTC (rev 317)
@@ -11,8 +11,8 @@
#include "functions.hh"
#include "cConfig.h"
-#include "genebank.hh"
-#include "genotype.hh"
+#include "cGenebank.h"
+#include "cGenotype.h"
#include "organism.hh"
#include "phenotype.hh"
#include "population.hh"
More information about the Avida-cvs
mailing list