[Avida-cvs] [Avida2-svn] r330 - in trunk: Avida2.xcodeproj source/bindings/Boost.Python source/cpu source/event source/main source/testsuites/unit_testsuites
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Wed Oct 5 16:42:13 PDT 2005
Author: brysonda
Date: 2005-10-05 19:24:09 -0400 (Wed, 05 Oct 2005)
New Revision: 330
Added:
trunk/source/main/MyCodeArrayLessThan.h
trunk/source/main/cLandscape.cc
trunk/source/main/cLandscape.h
trunk/source/main/cLineage.cc
trunk/source/main/cLineage.h
trunk/source/main/cLineageControl.cc
trunk/source/main/cLineageControl.h
trunk/source/main/cLocalMutations.cc
trunk/source/main/cLocalMutations.h
trunk/source/main/cMutation.cc
trunk/source/main/cMutation.h
trunk/source/main/cMutationLib.cc
trunk/source/main/cMutationLib.h
trunk/source/main/cMutationRates.cc
trunk/source/main/cMutationRates.h
trunk/source/main/cMxCodeArray.cc
trunk/source/main/cMxCodeArray.h
trunk/source/main/nGenotype.h
trunk/source/main/nInjectGenotype.h
trunk/source/main/nMutation.h
trunk/source/main/nSpecies.h
Removed:
trunk/source/main/genotype_macros.hh
trunk/source/main/inject_genebank_macros.hh
trunk/source/main/landscape.cc
trunk/source/main/landscape.hh
trunk/source/main/lineage.cc
trunk/source/main/lineage.hh
trunk/source/main/lineage_control.cc
trunk/source/main/lineage_control.hh
trunk/source/main/local_mutations.cc
trunk/source/main/local_mutations.hh
trunk/source/main/mutation.cc
trunk/source/main/mutation.hh
trunk/source/main/mutation_lib.cc
trunk/source/main/mutation_lib.hh
trunk/source/main/mutation_macros.hh
trunk/source/main/mutation_rates.cc
trunk/source/main/mutation_rates.hh
trunk/source/main/mx_code_array.cc
trunk/source/main/mx_code_array.hh
trunk/source/main/my_code_array_less_than.hh
Modified:
trunk/Avida2.xcodeproj/project.pbxproj
trunk/source/bindings/Boost.Python/hardware_4stack.pyste
trunk/source/bindings/Boost.Python/hardware_cpu.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/local_mutations.pyste
trunk/source/bindings/Boost.Python/mutation.pyste
trunk/source/bindings/Boost.Python/mutation_lib.pyste
trunk/source/bindings/Boost.Python/mutation_rates.pyste
trunk/source/bindings/Boost.Python/mx_code_array.pyste
trunk/source/bindings/Boost.Python/my_code_array_less_than.pyste
trunk/source/bindings/Boost.Python/organism.pyste
trunk/source/bindings/Boost.Python/population.pyste
trunk/source/bindings/Boost.Python/tArray_instantiations.hh
trunk/source/bindings/Boost.Python/tList_instantiations.hh
trunk/source/cpu/cHardware4Stack.cc
trunk/source/cpu/cHardwareCPU.cc
trunk/source/cpu/cHardwareSMT.cc
trunk/source/event/cPopulationEventFactory.cc
trunk/source/main/CMakeLists.txt
trunk/source/main/cAnalyze.cc
trunk/source/main/cAnalyzeGenotype.cc
trunk/source/main/cAnalyzeUtil.cc
trunk/source/main/cEnvironment.cc
trunk/source/main/cEnvironment.h
trunk/source/main/cFitnessMatrix.h
trunk/source/main/cGenebank.cc
trunk/source/main/cGenebank.h
trunk/source/main/cGenotypeControl.cc
trunk/source/main/cGenotypeControl.h
trunk/source/main/cInjectGenebank.cc
trunk/source/main/cInjectGenebank.h
trunk/source/main/cInjectGenotypeControl.cc
trunk/source/main/cInjectGenotypeControl.h
trunk/source/main/main_sub.pri
trunk/source/main/organism.hh
trunk/source/main/population.cc
trunk/source/main/population_cell.hh
trunk/source/main/species_control.cc
trunk/source/testsuites/unit_testsuites/landscape.t.cc
trunk/source/testsuites/unit_testsuites/lineage.t.cc
trunk/source/testsuites/unit_testsuites/lineage_control.t.cc
trunk/source/testsuites/unit_testsuites/local_mutations.t.cc
trunk/source/testsuites/unit_testsuites/mutation.t.cc
trunk/source/testsuites/unit_testsuites/mutation_lib.t.cc
trunk/source/testsuites/unit_testsuites/mutation_rates.t.cc
trunk/source/testsuites/unit_testsuites/mx_code_array.t.cc
trunk/source/testsuites/unit_testsuites/my_code_array_less_than.t.cc
Log:
Continue renaming main/*
Modified: trunk/Avida2.xcodeproj/project.pbxproj
===================================================================
--- trunk/Avida2.xcodeproj/project.pbxproj 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/Avida2.xcodeproj/project.pbxproj 2005-10-05 23:24:09 UTC (rev 330)
@@ -9,14 +9,6 @@
/* Begin PBXBuildFile section */
700E2996085A1F6000CF158A /* primitive in CopyFiles */ = {isa = PBXBuildFile; fileRef = DCC3164D07626CF3008F7A48 /* primitive */; };
700E2AF8085DE50C00CF158A /* avida.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC3109C0762539E008F7A48 /* avida.cc */; };
- 700E2B11085DE50C00CF158A /* landscape.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310E80762539E008F7A48 /* landscape.cc */; };
- 700E2B12085DE50C00CF158A /* lineage.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310EA0762539E008F7A48 /* lineage.cc */; };
- 700E2B13085DE50C00CF158A /* lineage_control.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310EC0762539E008F7A48 /* lineage_control.cc */; };
- 700E2B14085DE50C00CF158A /* local_mutations.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310EE0762539E008F7A48 /* local_mutations.cc */; };
- 700E2B15085DE50C00CF158A /* mutation.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310F30762539E008F7A48 /* mutation.cc */; };
- 700E2B16085DE50C00CF158A /* mutation_lib.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310F50762539E008F7A48 /* mutation_lib.cc */; };
- 700E2B17085DE50C00CF158A /* mutation_rates.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310F80762539E008F7A48 /* mutation_rates.cc */; };
- 700E2B18085DE50C00CF158A /* mx_code_array.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310FA0762539E008F7A48 /* mx_code_array.cc */; };
700E2B19085DE50C00CF158A /* org_message.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310FD0762539E008F7A48 /* org_message.cc */; };
700E2B1A085DE50C00CF158A /* organism.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310FF0762539E008F7A48 /* organism.cc */; };
700E2B1B085DE50C00CF158A /* phenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC311010762539E008F7A48 /* phenotype.cc */; };
@@ -142,6 +134,22 @@
706D330F0854A7B900D7DC8F /* organism.smt in CopyFiles */ = {isa = PBXBuildFile; fileRef = 706D330E0854A7B900D7DC8F /* organism.smt */; };
706D33110854A7D700D7DC8F /* genesis.smt in CopyFiles */ = {isa = PBXBuildFile; fileRef = 706D33100854A7D700D7DC8F /* genesis.smt */; };
706D33280854A90D00D7DC8F /* inst_set.smt in CopyFiles */ = {isa = PBXBuildFile; fileRef = 706D33270854A90D00D7DC8F /* inst_set.smt */; };
+ 70B0865908F4974300FC65FE /* cLandscape.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865108F4974300FC65FE /* cLandscape.cc */; };
+ 70B0865A08F4974300FC65FE /* cLineage.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865208F4974300FC65FE /* cLineage.cc */; };
+ 70B0865B08F4974300FC65FE /* cLineageControl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865308F4974300FC65FE /* cLineageControl.cc */; };
+ 70B0865C08F4974300FC65FE /* cLocalMutations.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865408F4974300FC65FE /* cLocalMutations.cc */; };
+ 70B0865D08F4974300FC65FE /* cMutation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865508F4974300FC65FE /* cMutation.cc */; };
+ 70B0865E08F4974300FC65FE /* cMutationLib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865608F4974300FC65FE /* cMutationLib.cc */; };
+ 70B0865F08F4974300FC65FE /* cMutationRates.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865708F4974300FC65FE /* cMutationRates.cc */; };
+ 70B0866008F4974300FC65FE /* cMxCodeArray.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865808F4974300FC65FE /* cMxCodeArray.cc */; };
+ 70B0866108F4974300FC65FE /* cLandscape.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865108F4974300FC65FE /* cLandscape.cc */; };
+ 70B0866208F4974300FC65FE /* cLineage.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865208F4974300FC65FE /* cLineage.cc */; };
+ 70B0866308F4974300FC65FE /* cLineageControl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865308F4974300FC65FE /* cLineageControl.cc */; };
+ 70B0866408F4974300FC65FE /* cLocalMutations.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865408F4974300FC65FE /* cLocalMutations.cc */; };
+ 70B0866508F4974300FC65FE /* cMutation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865508F4974300FC65FE /* cMutation.cc */; };
+ 70B0866608F4974300FC65FE /* cMutationLib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865608F4974300FC65FE /* cMutationLib.cc */; };
+ 70B0866708F4974300FC65FE /* cMutationRates.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865708F4974300FC65FE /* cMutationRates.cc */; };
+ 70B0866808F4974300FC65FE /* cMxCodeArray.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865808F4974300FC65FE /* cMxCodeArray.cc */; };
70C1EF4808C393BA00F50912 /* cCodeLabel.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1EF4608C393BA00F50912 /* cCodeLabel.cc */; };
70C1EF4A08C393BA00F50912 /* cCodeLabel.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1EF4608C393BA00F50912 /* cCodeLabel.cc */; };
70C1EF5908C3948C00F50912 /* cCPUMemory.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1EF5808C3948C00F50912 /* cCPUMemory.cc */; };
@@ -225,14 +233,6 @@
70D46935085F61DD004C8409 /* trionan.c in Sources */ = {isa = PBXBuildFile; fileRef = DCC31471076253A1008F7A48 /* trionan.c */; };
70D46936085F61DF004C8409 /* triostr.c in Sources */ = {isa = PBXBuildFile; fileRef = DCC31474076253A1008F7A48 /* triostr.c */; };
DCC3166107628531008F7A48 /* avida.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC3109C0762539E008F7A48 /* avida.cc */; };
- DCC3167A07628567008F7A48 /* landscape.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310E80762539E008F7A48 /* landscape.cc */; };
- DCC3167B07628568008F7A48 /* lineage.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310EA0762539E008F7A48 /* lineage.cc */; };
- DCC3167C07628569008F7A48 /* lineage_control.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310EC0762539E008F7A48 /* lineage_control.cc */; };
- DCC3167D07628569008F7A48 /* local_mutations.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310EE0762539E008F7A48 /* local_mutations.cc */; };
- DCC3167E0762856C008F7A48 /* mutation.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310F30762539E008F7A48 /* mutation.cc */; };
- DCC3167F0762856C008F7A48 /* mutation_lib.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310F50762539E008F7A48 /* mutation_lib.cc */; };
- DCC316800762856D008F7A48 /* mutation_rates.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310F80762539E008F7A48 /* mutation_rates.cc */; };
- DCC316810762856E008F7A48 /* mx_code_array.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310FA0762539E008F7A48 /* mx_code_array.cc */; };
DCC316820762856F008F7A48 /* org_message.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310FD0762539E008F7A48 /* org_message.cc */; };
DCC3168307628570008F7A48 /* organism.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC310FF0762539E008F7A48 /* organism.cc */; };
DCC3168407628571008F7A48 /* phenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC311010762539E008F7A48 /* phenotype.cc */; };
@@ -410,6 +410,27 @@
706D33270854A90D00D7DC8F /* inst_set.smt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = inst_set.smt; sourceTree = "<group>"; };
707A687408E3750300576968 /* cHardwareTracer_SMT.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHardwareTracer_SMT.h; sourceTree = "<group>"; };
707A68B808E37D5900576968 /* hardware_tracer_smt.pyste */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = hardware_tracer_smt.pyste; sourceTree = "<group>"; };
+ 70B085D108F48C9400FC65FE /* nSpecies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nSpecies.h; sourceTree = "<group>"; };
+ 70B0861508F48E8900FC65FE /* nGenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = nGenotype.h; sourceTree = "<group>"; };
+ 70B0861608F48E8900FC65FE /* nInjectGenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = nInjectGenotype.h; sourceTree = "<group>"; };
+ 70B0864808F4972600FC65FE /* cLandscape.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cLandscape.h; sourceTree = "<group>"; };
+ 70B0864908F4972600FC65FE /* cLineage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cLineage.h; sourceTree = "<group>"; };
+ 70B0864A08F4972600FC65FE /* cLineageControl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cLineageControl.h; sourceTree = "<group>"; };
+ 70B0864B08F4972600FC65FE /* cLocalMutations.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cLocalMutations.h; sourceTree = "<group>"; };
+ 70B0864C08F4972600FC65FE /* cMutation.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMutation.h; sourceTree = "<group>"; };
+ 70B0864D08F4972600FC65FE /* cMutationLib.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMutationLib.h; sourceTree = "<group>"; };
+ 70B0864E08F4972600FC65FE /* cMutationRates.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMutationRates.h; sourceTree = "<group>"; };
+ 70B0864F08F4972600FC65FE /* cMxCodeArray.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMxCodeArray.h; sourceTree = "<group>"; };
+ 70B0865008F4972600FC65FE /* MyCodeArrayLessThan.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MyCodeArrayLessThan.h; sourceTree = "<group>"; };
+ 70B0865108F4974300FC65FE /* cLandscape.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cLandscape.cc; sourceTree = "<group>"; };
+ 70B0865208F4974300FC65FE /* cLineage.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cLineage.cc; sourceTree = "<group>"; };
+ 70B0865308F4974300FC65FE /* cLineageControl.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cLineageControl.cc; sourceTree = "<group>"; };
+ 70B0865408F4974300FC65FE /* cLocalMutations.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cLocalMutations.cc; sourceTree = "<group>"; };
+ 70B0865508F4974300FC65FE /* cMutation.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cMutation.cc; sourceTree = "<group>"; };
+ 70B0865608F4974300FC65FE /* cMutationLib.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cMutationLib.cc; sourceTree = "<group>"; };
+ 70B0865708F4974300FC65FE /* cMutationRates.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cMutationRates.cc; sourceTree = "<group>"; };
+ 70B0865808F4974300FC65FE /* cMxCodeArray.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cMxCodeArray.cc; sourceTree = "<group>"; };
+ 70B0867208F499C100FC65FE /* nMutation.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = nMutation.h; sourceTree = "<group>"; };
70C1EF4608C393BA00F50912 /* cCodeLabel.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCodeLabel.cc; sourceTree = "<group>"; };
70C1EF4708C393BA00F50912 /* cCodeLabel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cCodeLabel.h; sourceTree = "<group>"; };
70C1EF5808C3948C00F50912 /* cCPUMemory.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCPUMemory.cc; sourceTree = "<group>"; };
@@ -921,28 +942,8 @@
DCC3109C0762539E008F7A48 /* avida.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = avida.cc; sourceTree = "<group>"; };
DCC3109D0762539E008F7A48 /* avida.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = avida.hh; sourceTree = "<group>"; };
DCC310A90762539E008F7A48 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
- DCC310D20762539E008F7A48 /* genotype_macros.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = genotype_macros.hh; sourceTree = "<group>"; };
- DCC310D70762539E008F7A48 /* inject_genebank_macros.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = inject_genebank_macros.hh; sourceTree = "<group>"; };
- DCC310E80762539E008F7A48 /* landscape.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = landscape.cc; sourceTree = "<group>"; };
- DCC310E90762539E008F7A48 /* landscape.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = landscape.hh; sourceTree = "<group>"; };
- DCC310EA0762539E008F7A48 /* lineage.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = lineage.cc; sourceTree = "<group>"; };
- DCC310EB0762539E008F7A48 /* lineage.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = lineage.hh; sourceTree = "<group>"; };
- DCC310EC0762539E008F7A48 /* lineage_control.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = lineage_control.cc; sourceTree = "<group>"; };
- DCC310ED0762539E008F7A48 /* lineage_control.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = lineage_control.hh; sourceTree = "<group>"; };
- DCC310EE0762539E008F7A48 /* local_mutations.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = local_mutations.cc; sourceTree = "<group>"; };
- DCC310EF0762539E008F7A48 /* local_mutations.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = local_mutations.hh; sourceTree = "<group>"; };
DCC310F00762539E008F7A48 /* main.pro */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = main.pro; sourceTree = "<group>"; };
DCC310F10762539E008F7A48 /* main_sub.pri */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = main_sub.pri; sourceTree = "<group>"; };
- DCC310F30762539E008F7A48 /* mutation.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = mutation.cc; sourceTree = "<group>"; };
- DCC310F40762539E008F7A48 /* mutation.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = mutation.hh; sourceTree = "<group>"; };
- DCC310F50762539E008F7A48 /* mutation_lib.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = mutation_lib.cc; sourceTree = "<group>"; };
- DCC310F60762539E008F7A48 /* mutation_lib.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = mutation_lib.hh; sourceTree = "<group>"; };
- DCC310F70762539E008F7A48 /* mutation_macros.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = mutation_macros.hh; sourceTree = "<group>"; };
- DCC310F80762539E008F7A48 /* mutation_rates.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = mutation_rates.cc; sourceTree = "<group>"; };
- DCC310F90762539E008F7A48 /* mutation_rates.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = mutation_rates.hh; sourceTree = "<group>"; };
- DCC310FA0762539E008F7A48 /* mx_code_array.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = mx_code_array.cc; sourceTree = "<group>"; };
- DCC310FB0762539E008F7A48 /* mx_code_array.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = mx_code_array.hh; sourceTree = "<group>"; };
- DCC310FC0762539E008F7A48 /* my_code_array_less_than.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = my_code_array_less_than.hh; sourceTree = "<group>"; };
DCC310FD0762539E008F7A48 /* org_message.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = org_message.cc; sourceTree = "<group>"; };
DCC310FE0762539E008F7A48 /* org_message.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = org_message.hh; sourceTree = "<group>"; };
DCC310FF0762539E008F7A48 /* organism.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = organism.cc; sourceTree = "<group>"; };
@@ -2037,6 +2038,26 @@
DCC310040762539D008F7A48 /* main */ = {
isa = PBXGroup;
children = (
+ 70B0867208F499C100FC65FE /* nMutation.h */,
+ 70B0865108F4974300FC65FE /* cLandscape.cc */,
+ 70B0865208F4974300FC65FE /* cLineage.cc */,
+ 70B0865308F4974300FC65FE /* cLineageControl.cc */,
+ 70B0865408F4974300FC65FE /* cLocalMutations.cc */,
+ 70B0865508F4974300FC65FE /* cMutation.cc */,
+ 70B0865608F4974300FC65FE /* cMutationLib.cc */,
+ 70B0865708F4974300FC65FE /* cMutationRates.cc */,
+ 70B0865808F4974300FC65FE /* cMxCodeArray.cc */,
+ 70B0864808F4972600FC65FE /* cLandscape.h */,
+ 70B0864908F4972600FC65FE /* cLineage.h */,
+ 70B0864A08F4972600FC65FE /* cLineageControl.h */,
+ 70B0864B08F4972600FC65FE /* cLocalMutations.h */,
+ 70B0864C08F4972600FC65FE /* cMutation.h */,
+ 70B0864D08F4972600FC65FE /* cMutationLib.h */,
+ 70B0864E08F4972600FC65FE /* cMutationRates.h */,
+ 70B0864F08F4972600FC65FE /* cMxCodeArray.h */,
+ 70B0865008F4972600FC65FE /* MyCodeArrayLessThan.h */,
+ 70B0861508F48E8900FC65FE /* nGenotype.h */,
+ 70B0861608F48E8900FC65FE /* nInjectGenotype.h */,
70CA6EF508DB806200068AC2 /* cGenotypeBatch.h */,
70CA6EE208DB7F9E00068AC2 /* cFitnessMatrix.h */,
70CA6EE308DB7F9E00068AC2 /* cGenebank.h */,
@@ -2105,28 +2126,8 @@
DCC3109D0762539E008F7A48 /* avida.hh */,
DCC310A90762539E008F7A48 /* CMakeLists.txt */,
DCC310B00762539E008F7A48 /* functional_testsuites */,
- DCC310D20762539E008F7A48 /* genotype_macros.hh */,
- DCC310D70762539E008F7A48 /* inject_genebank_macros.hh */,
- DCC310E80762539E008F7A48 /* landscape.cc */,
- DCC310E90762539E008F7A48 /* landscape.hh */,
- DCC310EA0762539E008F7A48 /* lineage.cc */,
- DCC310EB0762539E008F7A48 /* lineage.hh */,
- DCC310EC0762539E008F7A48 /* lineage_control.cc */,
- DCC310ED0762539E008F7A48 /* lineage_control.hh */,
- DCC310EE0762539E008F7A48 /* local_mutations.cc */,
- DCC310EF0762539E008F7A48 /* local_mutations.hh */,
DCC310F00762539E008F7A48 /* main.pro */,
DCC310F10762539E008F7A48 /* main_sub.pri */,
- DCC310F30762539E008F7A48 /* mutation.cc */,
- DCC310F40762539E008F7A48 /* mutation.hh */,
- DCC310F50762539E008F7A48 /* mutation_lib.cc */,
- DCC310F60762539E008F7A48 /* mutation_lib.hh */,
- DCC310F70762539E008F7A48 /* mutation_macros.hh */,
- DCC310F80762539E008F7A48 /* mutation_rates.cc */,
- DCC310F90762539E008F7A48 /* mutation_rates.hh */,
- DCC310FA0762539E008F7A48 /* mx_code_array.cc */,
- DCC310FB0762539E008F7A48 /* mx_code_array.hh */,
- DCC310FC0762539E008F7A48 /* my_code_array_less_than.hh */,
DCC310FD0762539E008F7A48 /* org_message.cc */,
DCC310FE0762539E008F7A48 /* org_message.hh */,
DCC310FF0762539E008F7A48 /* organism.cc */,
@@ -2175,6 +2176,7 @@
DCC3112C0762539E008F7A48 /* task_lib.cc */,
DCC3112D0762539E008F7A48 /* task_lib.hh */,
DCC3112E0762539E008F7A48 /* unit_testsuites */,
+ 70B085D108F48C9400FC65FE /* nSpecies.h */,
);
path = main;
sourceTree = "<group>";
@@ -3034,14 +3036,6 @@
buildActionMask = 2147483647;
files = (
700E2AF8085DE50C00CF158A /* avida.cc in Sources */,
- 700E2B11085DE50C00CF158A /* landscape.cc in Sources */,
- 700E2B12085DE50C00CF158A /* lineage.cc in Sources */,
- 700E2B13085DE50C00CF158A /* lineage_control.cc in Sources */,
- 700E2B14085DE50C00CF158A /* local_mutations.cc in Sources */,
- 700E2B15085DE50C00CF158A /* mutation.cc in Sources */,
- 700E2B16085DE50C00CF158A /* mutation_lib.cc in Sources */,
- 700E2B17085DE50C00CF158A /* mutation_rates.cc in Sources */,
- 700E2B18085DE50C00CF158A /* mx_code_array.cc in Sources */,
700E2B19085DE50C00CF158A /* org_message.cc in Sources */,
700E2B1A085DE50C00CF158A /* organism.cc in Sources */,
700E2B1B085DE50C00CF158A /* phenotype.cc in Sources */,
@@ -3164,6 +3158,14 @@
70CA6EDF08DB7F8200068AC2 /* cInstruction.cc in Sources */,
70CA6EE008DB7F8200068AC2 /* cInstSet.cc in Sources */,
70CA6EE108DB7F8200068AC2 /* cInstUtil.cc in Sources */,
+ 70B0866108F4974300FC65FE /* cLandscape.cc in Sources */,
+ 70B0866208F4974300FC65FE /* cLineage.cc in Sources */,
+ 70B0866308F4974300FC65FE /* cLineageControl.cc in Sources */,
+ 70B0866408F4974300FC65FE /* cLocalMutations.cc in Sources */,
+ 70B0866508F4974300FC65FE /* cMutation.cc in Sources */,
+ 70B0866608F4974300FC65FE /* cMutationLib.cc in Sources */,
+ 70B0866708F4974300FC65FE /* cMutationRates.cc in Sources */,
+ 70B0866808F4974300FC65FE /* cMxCodeArray.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -3172,14 +3174,6 @@
buildActionMask = 2147483647;
files = (
DCC3166107628531008F7A48 /* avida.cc in Sources */,
- DCC3167A07628567008F7A48 /* landscape.cc in Sources */,
- DCC3167B07628568008F7A48 /* lineage.cc in Sources */,
- DCC3167C07628569008F7A48 /* lineage_control.cc in Sources */,
- DCC3167D07628569008F7A48 /* local_mutations.cc in Sources */,
- DCC3167E0762856C008F7A48 /* mutation.cc in Sources */,
- DCC3167F0762856C008F7A48 /* mutation_lib.cc in Sources */,
- DCC316800762856D008F7A48 /* mutation_rates.cc in Sources */,
- DCC316810762856E008F7A48 /* mx_code_array.cc in Sources */,
DCC316820762856F008F7A48 /* org_message.cc in Sources */,
DCC3168307628570008F7A48 /* organism.cc in Sources */,
DCC3168407628571008F7A48 /* phenotype.cc in Sources */,
@@ -3292,6 +3286,14 @@
70CA6ECF08DB7F8200068AC2 /* cInstruction.cc in Sources */,
70CA6ED008DB7F8200068AC2 /* cInstSet.cc in Sources */,
70CA6ED108DB7F8200068AC2 /* cInstUtil.cc in Sources */,
+ 70B0865908F4974300FC65FE /* cLandscape.cc in Sources */,
+ 70B0865A08F4974300FC65FE /* cLineage.cc in Sources */,
+ 70B0865B08F4974300FC65FE /* cLineageControl.cc in Sources */,
+ 70B0865C08F4974300FC65FE /* cLocalMutations.cc in Sources */,
+ 70B0865D08F4974300FC65FE /* cMutation.cc in Sources */,
+ 70B0865E08F4974300FC65FE /* cMutationLib.cc in Sources */,
+ 70B0865F08F4974300FC65FE /* cMutationRates.cc in Sources */,
+ 70B0866008F4974300FC65FE /* cMxCodeArray.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/source/bindings/Boost.Python/hardware_4stack.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_4stack.pyste 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/hardware_4stack.pyste 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,5 +1,5 @@
-Include("mutation.hh")
+Include("cMutation.h")
Include("cInjectGenotype.h")
Include("cInstSet.h")
Include("organism.hh")
Modified: trunk/source/bindings/Boost.Python/hardware_cpu.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_cpu.pyste 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/hardware_cpu.pyste 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,5 +1,5 @@
-Include("mutation.hh")
+Include("cMutation.h")
Include("cInstLibCPU.h")
Include("cInstSet.h")
Include("organism.hh")
Modified: trunk/source/bindings/Boost.Python/landscape.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/landscape.pyste 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/landscape.pyste 2005-10-05 23:24:09 UTC (rev 330)
@@ -3,6 +3,6 @@
Include("fstream")
-cLandscape = Class("cLandscape", "landscape.hh")
+cLandscape = Class("cLandscape", "cLandscape.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/lineage.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/lineage.pyste 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/lineage.pyste 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,6 +1,6 @@
Include("cGenotype.h")
-cLineage = Class("cLineage", "lineage.hh")
+cLineage = Class("cLineage", "cLineage.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/lineage_control.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/lineage_control.pyste 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/lineage_control.pyste 2005-10-05 23:24:09 UTC (rev 330)
@@ -3,10 +3,10 @@
Include("stats.hh")
Include("string.hh")
Include("cGenotype.h")
-Include("lineage.hh")
+Include("cLineage.h")
Include("organism.hh")
-cLineageControl = Class("cLineageControl", "lineage_control.hh")
+cLineageControl = Class("cLineageControl", "cLineageControl.h")
set_policy(cLineageControl.AddCreature, return_internal_reference())
set_policy(cLineageControl.FindLineage, return_internal_reference())
set_policy(cLineageControl.GetMaxFitnessLineage, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/local_mutations.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/local_mutations.pyste 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/local_mutations.pyste 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,6 +1,6 @@
-Include("mutation_lib.hh")
+Include("cMutationLib.h")
-cLocalMutations = Class("cLocalMutations", "local_mutations.hh")
+cLocalMutations = Class("cLocalMutations", "cLocalMutations.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/mutation.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/mutation.pyste 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/mutation.pyste 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,4 +1,4 @@
-cMutation = Class("cMutation", "mutation.hh")
+cMutation = Class("cMutation", "cMutation.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/mutation_lib.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/mutation_lib.pyste 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/mutation_lib.pyste 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,8 +1,8 @@
Include("string.hh")
-Include("mutation.hh")
+Include("cMutation.h")
-cMutationLib = Class("cMutationLib", "mutation_lib.hh")
+cMutationLib = Class("cMutationLib", "cMutationLib.h")
set_policy(cMutationLib.AddMutation, return_internal_reference())
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/mutation_rates.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/mutation_rates.pyste 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/mutation_rates.pyste 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,4 +1,4 @@
-cMutationRates = Class("cMutationRates", "mutation_rates.hh")
+cMutationRates = Class("cMutationRates", "cMutationRates.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/mx_code_array.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/mx_code_array.pyste 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/mx_code_array.pyste 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,7 +1,7 @@
-Include("my_code_array_less_than.hh")
+Include("MyCodeArrayLessThan.h")
Include("cGenome.h")
-cMxCodeArray = Class("cMxCodeArray", "mx_code_array.hh")
+cMxCodeArray = Class("cMxCodeArray", "cMxCodeArray.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/my_code_array_less_than.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/my_code_array_less_than.pyste 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/my_code_array_less_than.pyste 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,4 +1,4 @@
-MyCodeArrayLessThan = Class("MyCodeArrayLessThan", "my_code_array_less_than.hh")
+MyCodeArrayLessThan = Class("MyCodeArrayLessThan", "MyCodeArrayLessThan.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/organism.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/organism.pyste 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/organism.pyste 2005-10-05 23:24:09 UTC (rev 330)
@@ -5,7 +5,7 @@
Include("cCodeLabel.h")
Include("org_message.hh")
Include("cGenotype.h")
-Include("lineage.hh")
+Include("cLineage.h")
cOrganism = Class("cOrganism", "organism.hh")
set_policy(cOrganism.GetHardware, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/population.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/population.pyste 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/population.pyste 2005-10-05 23:24:09 UTC (rev 330)
@@ -3,7 +3,7 @@
Include("cEnvironment.h")
Include("cGenebank.h" )
Include("cInjectGenebank.h")
-Include("lineage_control.hh")
+Include("cLineageControl.h")
Include("organism.hh")
Include("population_cell.hh")
Modified: trunk/source/bindings/Boost.Python/tArray_instantiations.hh
===================================================================
--- trunk/source/bindings/Boost.Python/tArray_instantiations.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/tArray_instantiations.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,6 +1,6 @@
#include "organism.hh"
#include "merit.hh"
-#include "mutation.hh"
+#include "cMutation.h"
#include "int_sum.hh"
#include "tArray.hh"
Modified: trunk/source/bindings/Boost.Python/tList_instantiations.hh
===================================================================
--- trunk/source/bindings/Boost.Python/tList_instantiations.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/bindings/Boost.Python/tList_instantiations.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,6 +1,6 @@
#include "cAnalyzeCommand.h"
#include "cAnalyzeGenotype.h"
-#include "mutation.hh"
+#include "cMutation.h"
#include "population_cell.hh"
#include "reaction_process.hh"
#include "reaction_requisite.hh"
Modified: trunk/source/cpu/cHardware4Stack.cc
===================================================================
--- trunk/source/cpu/cHardware4Stack.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/cpu/cHardware4Stack.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -17,9 +17,9 @@
#include "cInstSet.h"
#include "cHardwareTracer.h"
#include "cHardwareTracer_4Stack.h"
-#include "mutation.hh"
-#include "mutation_lib.hh"
-#include "mutation_macros.hh"
+#include "cMutation.h"
+#include "cMutationLib.h"
+#include "nMutation.h"
#include "organism.hh"
#include "phenotype.hh"
#include "random.hh"
@@ -1039,7 +1039,7 @@
bool cHardware4Stack::TriggerMutations(int trigger)
{
// Only update triggers should happen from the outside!
- assert(trigger == MUTATION_TRIGGER_UPDATE);
+ assert(trigger == nMutation::TRIGGER_UPDATE);
// Assume instruction pointer is the intended target (if one is even
// needed!
@@ -1059,7 +1059,7 @@
bool has_mutation = false;
// Determine what memory this mutation will be affecting.
- cCPUMemory & target_mem = (trigger == MUTATION_TRIGGER_DIVIDE)
+ cCPUMemory & target_mem = (trigger == nMutation::TRIGGER_DIVIDE)
? organism->ChildGenome() : GetMemory(0);
// Loop through all mutations associated with this trigger and test them.
@@ -1071,21 +1071,21 @@
const int scope = cur_mut->GetScope();
const double rate = mut_info.GetRate(mut_id);
switch (scope) {
- case MUTATION_SCOPE_GENOME:
+ case nMutation::SCOPE_GENOME:
if (TriggerMutations_ScopeGenome(cur_mut, target_mem, cur_head, rate)) {
has_mutation = true;
mut_info.IncCount(mut_id);
}
break;
- case MUTATION_SCOPE_LOCAL:
- case MUTATION_SCOPE_PROP:
+ case nMutation::SCOPE_LOCAL:
+ case nMutation::SCOPE_PROP:
if (TriggerMutations_ScopeLocal(cur_mut, target_mem, cur_head, rate)) {
has_mutation = true;
mut_info.IncCount(mut_id);
}
break;
- case MUTATION_SCOPE_GLOBAL:
- case MUTATION_SCOPE_SPREAD:
+ case nMutation::SCOPE_GLOBAL:
+ case nMutation::SCOPE_SPREAD:
int num_muts =
TriggerMutations_ScopeGlobal(cur_mut, target_mem, cur_head, rate);
if (num_muts > 0) {
@@ -1156,16 +1156,16 @@
const int pos = cur_head.GetPosition();
switch (type) {
- case MUTATION_TYPE_POINT:
+ case nMutation::TYPE_POINT:
target_memory[pos] = GetRandomInst();
target_memory.FlagMutated(pos) = true;
break;
- case MUTATION_TYPE_INSERT:
- case MUTATION_TYPE_DELETE:
- case MUTATION_TYPE_HEAD_INC:
- case MUTATION_TYPE_HEAD_DEC:
- case MUTATION_TYPE_TEMP:
- case MUTATION_TYPE_KILL:
+ case nMutation::TYPE_INSERT:
+ case nMutation::TYPE_DELETE:
+ case nMutation::TYPE_HEAD_INC:
+ case nMutation::TYPE_HEAD_DEC:
+ case nMutation::TYPE_TEMP:
+ case nMutation::TYPE_KILL:
default:
cout << "Error: Mutation type not implemented!" << endl;
break;
@@ -1993,7 +1993,7 @@
read_head.Adjust();
write_head.Adjust();
- // TriggerMutations(MUTATION_TRIGGER_READ, read_head);
+ // TriggerMutations(nMutation::TRIGGER_READ, read_head);
// Do mutations.
cInstruction read_inst = read_head.GetInst();
@@ -2011,7 +2011,7 @@
write_head.SetInst(read_inst);
write_head.FlagCopied() = true; // Set the copied flag...
- // TriggerMutations(MUTATION_TRIGGER_WRITE, write_head);
+ // TriggerMutations(nMutation::TRIGGER_WRITE, write_head);
read_head.Advance();
write_head.Advance();
Modified: trunk/source/cpu/cHardwareCPU.cc
===================================================================
--- trunk/source/cpu/cHardwareCPU.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/cpu/cHardwareCPU.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -16,9 +16,9 @@
#include "cHardwareTracer_CPU.h"
#include "cInstLibCPU.h"
#include "cInstSet.h"
-#include "mutation.hh"
-#include "mutation_lib.hh"
-#include "mutation_macros.hh"
+#include "cMutation.h"
+#include "cMutationLib.h"
+#include "nMutation.h"
#include "organism.hh"
#include "phenotype.hh"
#include "string_util.hh"
@@ -1097,7 +1097,7 @@
bool cHardwareCPU::TriggerMutations(int trigger)
{
// Only update triggers should happen from the outside!
- assert(trigger == MUTATION_TRIGGER_UPDATE);
+ assert(trigger == nMutation::TRIGGER_UPDATE);
// Assume instruction pointer is the intended target (if one is even
// needed!
@@ -1117,7 +1117,7 @@
bool has_mutation = false;
// Determine what memory this mutation will be affecting.
- cCPUMemory & target_mem = (trigger == MUTATION_TRIGGER_DIVIDE)
+ cCPUMemory & target_mem = (trigger == nMutation::TRIGGER_DIVIDE)
? organism->ChildGenome() : GetMemory();
// Loop through all mutations associated with this trigger and test them.
@@ -1129,21 +1129,21 @@
const int scope = cur_mut->GetScope();
const double rate = mut_info.GetRate(mut_id);
switch (scope) {
- case MUTATION_SCOPE_GENOME:
+ case nMutation::SCOPE_GENOME:
if (TriggerMutations_ScopeGenome(cur_mut, target_mem, cur_head, rate)) {
has_mutation = true;
mut_info.IncCount(mut_id);
}
break;
- case MUTATION_SCOPE_LOCAL:
- case MUTATION_SCOPE_PROP:
+ case nMutation::SCOPE_LOCAL:
+ case nMutation::SCOPE_PROP:
if (TriggerMutations_ScopeLocal(cur_mut, target_mem, cur_head, rate)) {
has_mutation = true;
mut_info.IncCount(mut_id);
}
break;
- case MUTATION_SCOPE_GLOBAL:
- case MUTATION_SCOPE_SPREAD:
+ case nMutation::SCOPE_GLOBAL:
+ case nMutation::SCOPE_SPREAD:
int num_muts =
TriggerMutations_ScopeGlobal(cur_mut, target_mem, cur_head, rate);
if (num_muts > 0) {
@@ -1214,16 +1214,16 @@
const int pos = cur_head.GetPosition();
switch (type) {
- case MUTATION_TYPE_POINT:
+ case nMutation::TYPE_POINT:
target_memory[pos] = GetRandomInst();
target_memory.FlagMutated(pos) = true;
break;
- case MUTATION_TYPE_INSERT:
- case MUTATION_TYPE_DELETE:
- case MUTATION_TYPE_HEAD_INC:
- case MUTATION_TYPE_HEAD_DEC:
- case MUTATION_TYPE_TEMP:
- case MUTATION_TYPE_KILL:
+ case nMutation::TYPE_INSERT:
+ case nMutation::TYPE_DELETE:
+ case nMutation::TYPE_HEAD_INC:
+ case nMutation::TYPE_HEAD_DEC:
+ case nMutation::TYPE_TEMP:
+ case nMutation::TYPE_KILL:
default:
cout << "Error: Mutation type not implemented!" << endl;
break;
@@ -3341,7 +3341,7 @@
read_head.Adjust();
write_head.Adjust();
- // TriggerMutations(MUTATION_TRIGGER_READ, read_head);
+ // TriggerMutations(nMutation::TRIGGER_READ, read_head);
// Do mutations.
cInstruction read_inst = read_head.GetInst();
@@ -3359,7 +3359,7 @@
write_head.SetInst(read_inst);
write_head.FlagCopied() = true; // Set the copied flag...
- // TriggerMutations(MUTATION_TRIGGER_WRITE, write_head);
+ // TriggerMutations(nMutation::TRIGGER_WRITE, write_head);
read_head.Advance();
write_head.Advance();
Modified: trunk/source/cpu/cHardwareSMT.cc
===================================================================
--- trunk/source/cpu/cHardwareSMT.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/cpu/cHardwareSMT.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -17,9 +17,9 @@
#include "cInstSet.h"
#include "cHardwareTracer.h"
#include "cHardwareTracer_SMT.h"
-#include "mutation.hh"
-#include "mutation_lib.hh"
-#include "mutation_macros.hh"
+#include "cMutation.h"
+#include "cMutationLib.h"
+#include "nMutation.h"
#include "organism.hh"
#include "phenotype.hh"
#include "random.hh"
@@ -863,7 +863,7 @@
bool cHardwareSMT::TriggerMutations(int trigger)
{
// Only update triggers should happen from the outside!
- assert(trigger == MUTATION_TRIGGER_UPDATE);
+ assert(trigger == nMutation::TRIGGER_UPDATE);
// Assume instruction pointer is the intended target (if one is even
// needed!
@@ -883,7 +883,7 @@
bool has_mutation = false;
// Determine what memory this mutation will be affecting.
- cCPUMemory & target_mem = (trigger == MUTATION_TRIGGER_DIVIDE)
+ cCPUMemory & target_mem = (trigger == nMutation::TRIGGER_DIVIDE)
? organism->ChildGenome() : m_mem_array[0];
// Loop through all mutations associated with this trigger and test them.
@@ -895,21 +895,21 @@
const int scope = cur_mut->GetScope();
const double rate = mut_info.GetRate(mut_id);
switch (scope) {
- case MUTATION_SCOPE_GENOME:
+ case nMutation::SCOPE_GENOME:
if (TriggerMutations_ScopeGenome(cur_mut, target_mem, cur_head, rate)) {
has_mutation = true;
mut_info.IncCount(mut_id);
}
break;
- case MUTATION_SCOPE_LOCAL:
- case MUTATION_SCOPE_PROP:
+ case nMutation::SCOPE_LOCAL:
+ case nMutation::SCOPE_PROP:
if (TriggerMutations_ScopeLocal(cur_mut, target_mem, cur_head, rate)) {
has_mutation = true;
mut_info.IncCount(mut_id);
}
break;
- case MUTATION_SCOPE_GLOBAL:
- case MUTATION_SCOPE_SPREAD:
+ case nMutation::SCOPE_GLOBAL:
+ case nMutation::SCOPE_SPREAD:
int num_muts =
TriggerMutations_ScopeGlobal(cur_mut, target_mem, cur_head, rate);
if (num_muts > 0) {
@@ -980,16 +980,16 @@
const int pos = cur_head.GetPosition();
switch (type) {
- case MUTATION_TYPE_POINT:
+ case nMutation::TYPE_POINT:
target_memory[pos] = GetRandomInst();
target_memory.FlagMutated(pos) = true;
break;
- case MUTATION_TYPE_INSERT:
- case MUTATION_TYPE_DELETE:
- case MUTATION_TYPE_HEAD_INC:
- case MUTATION_TYPE_HEAD_DEC:
- case MUTATION_TYPE_TEMP:
- case MUTATION_TYPE_KILL:
+ case nMutation::TYPE_INSERT:
+ case nMutation::TYPE_DELETE:
+ case nMutation::TYPE_HEAD_INC:
+ case nMutation::TYPE_HEAD_DEC:
+ case nMutation::TYPE_TEMP:
+ case nMutation::TYPE_KILL:
default:
cout << "Error: Mutation type not implemented!" << endl;
break;
@@ -1753,7 +1753,7 @@
read_head.Adjust();
write_head.Adjust();
- // TriggerMutations(MUTATION_TRIGGER_READ, read_head);
+ // TriggerMutations(nMutation::TRIGGER_READ, read_head);
// Do mutations.
cInstruction read_inst = read_head.GetInst();
@@ -1771,7 +1771,7 @@
write_head.SetInst(read_inst);
write_head.FlagCopied() = true; // Set the copied flag...
- // TriggerMutations(MUTATION_TRIGGER_WRITE, write_head);
+ // TriggerMutations(nMutation::TRIGGER_WRITE, write_head);
read_head.Advance();
write_head.Advance();
Modified: trunk/source/event/cPopulationEventFactory.cc
===================================================================
--- trunk/source/event/cPopulationEventFactory.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/event/cPopulationEventFactory.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -43,10 +43,10 @@
#include "cInstUtil.h"
#endif
#ifndef LANDSCAPE_HH
-#include "landscape.hh"
+#include "cLandscape.h"
#endif
#ifndef LINEAGE_CONTROL_HH
-#include "lineage_control.hh"
+#include "cLineageControl.h"
#endif
#ifndef ORGANISM_HH
#include "organism.hh"
Modified: trunk/source/main/CMakeLists.txt
===================================================================
--- trunk/source/main/CMakeLists.txt 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/CMakeLists.txt 2005-10-05 23:24:09 UTC (rev 330)
@@ -28,14 +28,14 @@
cInstruction.cc
cInstSet.cc
cInstUtil.cc
- landscape.cc
- lineage.cc
- lineage_control.cc
- local_mutations.cc
- mutation_lib.cc
- mutation_rates.cc
- mutation.cc
- mx_code_array.cc
+ cLandscape.cc
+ cLineage.cc
+ cLineageControl.cc
+ cLocalMutations.cc
+ cMutationLib.cc
+ cMutationRates.cc
+ cMutation.cc
+ cMxCodeArray.cc
org_message.cc
organism.cc
phenotype.cc
Copied: trunk/source/main/MyCodeArrayLessThan.h (from rev 329, trunk/source/main/my_code_array_less_than.hh)
===================================================================
--- trunk/source/main/my_code_array_less_than.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/MyCodeArrayLessThan.h 2005-10-05 23:24:09 UTC (rev 330)
@@ -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 MY_CODE_ARRAY_LESS_THAN_HH
+#define MY_CODE_ARRAY_LESS_THAN_HH
+
+#ifndef MX_CODE_ARRAY_HH
+#include "cMxCodeArray.h"
+#endif
+
+class MyCodeArrayLessThan {
+public:
+ bool operator()(const cMxCodeArray &x, const cMxCodeArray &y) const
+ {
+ return x < y;
+ }
+};
+
+#endif
Modified: trunk/source/main/cAnalyze.cc
===================================================================
--- trunk/source/main/cAnalyze.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cAnalyze.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -32,7 +32,7 @@
#include "init_file.hh"
#include "cInstSet.h"
#include "cInstUtil.h"
-#include "landscape.hh"
+#include "cLandscape.h"
#include "phenotype.hh"
#include "species.hh"
#include "tArgDataEntry.hh"
Modified: trunk/source/main/cAnalyzeGenotype.cc
===================================================================
--- trunk/source/main/cAnalyzeGenotype.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cAnalyzeGenotype.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -10,7 +10,7 @@
#include "cConfig.h"
#include "cCPUTestInfo.h"
#include "cInstSet.h"
-#include "landscape.hh"
+#include "cLandscape.h"
#include "organism.hh"
#include "phenotype.hh"
#include "cTestCPU.h"
Modified: trunk/source/main/cAnalyzeUtil.cc
===================================================================
--- trunk/source/main/cAnalyzeUtil.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cAnalyzeUtil.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -43,7 +43,7 @@
#include "cInstUtil.h"
#endif
#ifndef LANDSCAPE_HH
-#include "landscape.hh"
+#include "cLandscape.h"
#endif
#ifndef ORGANISM_HH
#include "organism.hh"
Modified: trunk/source/main/cEnvironment.cc
===================================================================
--- trunk/source/main/cEnvironment.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cEnvironment.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -13,7 +13,7 @@
#include "init_file.hh"
#endif
#ifndef MUTATION_MACROS_HH
-#include "mutation_macros.hh"
+#include "nMutation.h"
#endif
#ifndef RANDOM_HH
#include "random.hh"
@@ -498,72 +498,72 @@
int scope_id = -1;
int type_id = -1;
- if (trigger == "none") trig_id = MUTATION_TRIGGER_NONE;
- else if (trigger == "update") trig_id = MUTATION_TRIGGER_UPDATE;
- else if (trigger == "divide") trig_id = MUTATION_TRIGGER_DIVIDE;
- else if (trigger == "parent") trig_id = MUTATION_TRIGGER_PARENT;
- else if (trigger == "write") trig_id = MUTATION_TRIGGER_WRITE;
- else if (trigger == "read") trig_id = MUTATION_TRIGGER_READ;
- else if (trigger == "exec") trig_id = MUTATION_TRIGGER_EXEC;
+ if (trigger == "none") trig_id = nMutation::TRIGGER_NONE;
+ else if (trigger == "update") trig_id = nMutation::TRIGGER_UPDATE;
+ else if (trigger == "divide") trig_id = nMutation::TRIGGER_DIVIDE;
+ else if (trigger == "parent") trig_id = nMutation::TRIGGER_PARENT;
+ else if (trigger == "write") trig_id = nMutation::TRIGGER_WRITE;
+ else if (trigger == "read") trig_id = nMutation::TRIGGER_READ;
+ else if (trigger == "exec") trig_id = nMutation::TRIGGER_EXEC;
else {
cerr << "Error: Unknown mutation trigger '" << trigger << "'." << endl;
return false;
}
- if (scope == "genome") scope_id = MUTATION_SCOPE_GENOME;
- else if (scope == "local") scope_id = MUTATION_SCOPE_LOCAL;
- else if (scope == "prop") scope_id = MUTATION_SCOPE_PROP;
- else if (scope == "global") scope_id = MUTATION_SCOPE_GLOBAL;
- else if (scope == "spread") scope_id = MUTATION_SCOPE_SPREAD;
+ if (scope == "genome") scope_id = nMutation::SCOPE_GENOME;
+ else if (scope == "local") scope_id = nMutation::SCOPE_LOCAL;
+ else if (scope == "prop") scope_id = nMutation::SCOPE_PROP;
+ else if (scope == "global") scope_id = nMutation::SCOPE_GLOBAL;
+ else if (scope == "spread") scope_id = nMutation::SCOPE_SPREAD;
else {
cerr << "Error: Unknown mutation scope '" << scope << "'." << endl;
return false;
}
- if (type == "point") type_id = MUTATION_TYPE_POINT;
- else if (type == "insert") type_id = MUTATION_TYPE_INSERT;
- else if (type == "delete") type_id = MUTATION_TYPE_DELETE;
- else if (type == "head_inc") type_id = MUTATION_TYPE_HEAD_INC;
- else if (type == "head_dec") type_id = MUTATION_TYPE_HEAD_DEC;
- else if (type == "temp") type_id = MUTATION_TYPE_TEMP;
- else if (type == "kill") type_id = MUTATION_TYPE_KILL;
+ if (type == "point") type_id = nMutation::TYPE_POINT;
+ else if (type == "insert") type_id = nMutation::TYPE_INSERT;
+ else if (type == "delete") type_id = nMutation::TYPE_DELETE;
+ else if (type == "head_inc") type_id = nMutation::TYPE_HEAD_INC;
+ else if (type == "head_dec") type_id = nMutation::TYPE_HEAD_DEC;
+ else if (type == "temp") type_id = nMutation::TYPE_TEMP;
+ else if (type == "kill") type_id = nMutation::TYPE_KILL;
else {
cerr << "Error: Unknown mutation type '" << type << "'." << endl;
return false;
}
// Lets do a few checks for legal combinations...
- if (trig_id == MUTATION_TRIGGER_NONE) {
+ if (trig_id == nMutation::TRIGGER_NONE) {
cerr << "Warning: Mutations with trigger 'none' will never occur." << endl;
}
- if (scope_id == MUTATION_SCOPE_LOCAL || scope_id == MUTATION_SCOPE_PROP) {
- if (trig_id == MUTATION_TRIGGER_DIVIDE) {
+ if (scope_id == nMutation::SCOPE_LOCAL || scope_id == nMutation::SCOPE_PROP) {
+ if (trig_id == nMutation::TRIGGER_DIVIDE) {
cerr << "Error: Offspring after divide have no " << scope
<< " for mutations." << endl;
return false;
}
- if (trig_id == MUTATION_TRIGGER_UPDATE ||
- trig_id == MUTATION_TRIGGER_PARENT) {
+ if (trig_id == nMutation::TRIGGER_UPDATE ||
+ trig_id == nMutation::TRIGGER_PARENT) {
cerr << "Warning: Mutation trigger " << trigger
<< "has no natural positions; IP used." << endl;
}
}
else { // Genome-wide scope
- if (type_id == MUTATION_TYPE_HEAD_INC ||
- type_id == MUTATION_TYPE_HEAD_DEC ||
- type_id == MUTATION_TYPE_TEMP) {
+ if (type_id == nMutation::TYPE_HEAD_INC ||
+ type_id == nMutation::TYPE_HEAD_DEC ||
+ type_id == nMutation::TYPE_TEMP) {
cerr << "Error: " << scope << " scope not compatible with type "
<< type << "." << endl;
return false;
}
}
- if (type_id == MUTATION_TYPE_TEMP) {
- if (trig_id == MUTATION_TRIGGER_UPDATE ||
- trig_id == MUTATION_TRIGGER_DIVIDE ||
- trig_id == MUTATION_TRIGGER_PARENT ||
- trig_id == MUTATION_TRIGGER_WRITE) {
+ if (type_id == nMutation::TYPE_TEMP) {
+ if (trig_id == nMutation::TRIGGER_UPDATE ||
+ trig_id == nMutation::TRIGGER_DIVIDE ||
+ trig_id == nMutation::TRIGGER_PARENT ||
+ trig_id == nMutation::TRIGGER_WRITE) {
cerr << "Error: " << trigger << " trigger not meaningful with type "
<< type << "." << endl;
return false;
Modified: trunk/source/main/cEnvironment.h
===================================================================
--- trunk/source/main/cEnvironment.h 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cEnvironment.h 2005-10-05 23:24:09 UTC (rev 330)
@@ -12,10 +12,10 @@
#include "cInstSet.h"
#endif
#ifndef MUTATION_LIB_HH
-#include "mutation_lib.hh"
+#include "cMutationLib.h"
#endif
#ifndef MUTATION_RATES_HH
-#include "mutation_rates.hh"
+#include "cMutationRates.h"
#endif
#ifndef REACTION_LIB_HH
#include "reaction_lib.hh"
Modified: trunk/source/main/cFitnessMatrix.h
===================================================================
--- trunk/source/main/cFitnessMatrix.h 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cFitnessMatrix.h 2005-10-05 23:24:09 UTC (rev 330)
@@ -21,10 +21,10 @@
#include "defs.hh"
#endif
#ifndef MX_CODE_ARRAY_HH
-#include "mx_code_array.hh"
+#include "cMxCodeArray.h"
#endif
#ifndef MY_CODE_ARRAY_LESS_THAN_HH
-#include "my_code_array_less_than.hh"
+#include "MyCodeArrayLessThan.h"
#endif
#ifndef ORGANISM_HH
#include "organism.hh"
Modified: trunk/source/main/cGenebank.cc
===================================================================
--- trunk/source/main/cGenebank.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cGenebank.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -77,7 +77,7 @@
// hist_array.SetAll(0);
// int total_gens = 0;
-// for (int i = 0; i < GENOTYPE_HASH_SIZE; i++) {
+// for (int i = 0; i < nGenotype::HASH_SIZE; i++) {
// int cur_val = active_genotypes[i].GetSize();
// total_gens += cur_val;
// if (cur_val < 15) hist_array[cur_val]++;
@@ -901,7 +901,7 @@
total += (in_genome[i].GetOp() + 3) * i;
}
- return total % GENOTYPE_HASH_SIZE;
+ return total % nGenotype::HASH_SIZE;
}
void cGenebank::SpeciesTest(char * message, cGenotype & genotype)
Modified: trunk/source/main/cGenebank.h
===================================================================
--- trunk/source/main/cGenebank.h 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cGenebank.h 2005-10-05 23:24:09 UTC (rev 330)
@@ -37,7 +37,7 @@
class cGenebank {
private:
unsigned int genotype_count[MAX_CREATURE_SIZE];
- tList<cGenotype> active_genotypes[GENOTYPE_HASH_SIZE];
+ tList<cGenotype> active_genotypes[nGenotype::HASH_SIZE];
cGenotypeControl * genotype_control;
cSpeciesControl * species_control;
cStats & stats;
Modified: trunk/source/main/cGenotypeControl.cc
===================================================================
--- trunk/source/main/cGenotypeControl.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cGenotypeControl.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -28,7 +28,7 @@
size = 0;
best = NULL;
coalescent = NULL;
- for (int i = 0; i < GENOTYPE_THREADS; i++) threads[i] = NULL;
+ for (int i = 0; i < nGenotype::THREADS; i++) threads[i] = NULL;
historic_list = NULL;
historic_count = 0;
Modified: trunk/source/main/cGenotypeControl.h
===================================================================
--- trunk/source/main/cGenotypeControl.h 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cGenotypeControl.h 2005-10-05 23:24:09 UTC (rev 330)
@@ -8,8 +8,8 @@
#ifndef GENOTYPE_CONTROL_HH
#define GENOTYPE_CONTROL_HH
-#ifndef GENOTYPE_MACROS_HH
-#include "genotype_macros.hh"
+#ifndef nGenotype_h
+#include "nGenotype.h"
#endif
class cGenebank;
@@ -20,7 +20,7 @@
int size;
cGenotype * best;
cGenotype * coalescent;
- cGenotype * threads[GENOTYPE_THREADS];
+ cGenotype * threads[nGenotype::THREADS];
cGenebank & genebank;
cGenotype * historic_list;
Modified: trunk/source/main/cInjectGenebank.cc
===================================================================
--- trunk/source/main/cInjectGenebank.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cInjectGenebank.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -94,7 +94,7 @@
assert( in_inject_genotype != 0 );
if ( in_list_num < 0 )
- in_list_num = FindCRC(in_inject_genotype->GetGenome()) % INJECTGENOTYPE_HASH_SIZE;
+ in_list_num = FindCRC(in_inject_genotype->GetGenome()) % nInjectGenotype::HASH_SIZE;
active_inject_genotypes[in_list_num].Insert(*in_inject_genotype);
inject_genotype_control->Insert(*in_inject_genotype);
@@ -105,7 +105,7 @@
cInjectGenotype * cInjectGenebank::AddInjectGenotype(const cGenome & in_genome,
cInjectGenotype * parent_genotype)
{
- int list_num = FindCRC(in_genome) % INJECTGENOTYPE_HASH_SIZE;
+ int list_num = FindCRC(in_genome) % nInjectGenotype::HASH_SIZE;
cInjectGenotype * found_genotype;
found_genotype = active_inject_genotypes[list_num].Find(in_genome);
@@ -125,7 +125,7 @@
cInjectGenotype * cInjectGenebank::FindInjectGenotype(const cGenome & in_genome) const
{
- int list_num = FindCRC(in_genome) % INJECTGENOTYPE_HASH_SIZE;
+ int list_num = FindCRC(in_genome) % nInjectGenotype::HASH_SIZE;
return active_inject_genotypes[list_num].Find(in_genome);
}
@@ -136,7 +136,7 @@
// assigned to it.
if (in_inject_genotype.GetActive() == true) {
- int list_num = FindCRC(in_inject_genotype.GetGenome()) % INJECTGENOTYPE_HASH_SIZE;
+ int list_num = FindCRC(in_inject_genotype.GetGenome()) % nInjectGenotype::HASH_SIZE;
active_inject_genotypes[list_num].Remove(in_inject_genotype);
inject_genotype_control->Remove(in_inject_genotype);
//in_inject_genotype.Deactivate(stats.GetUpdate());
@@ -316,7 +316,7 @@
// Loop through all of the reference lists for matching genotypes...
- for (i = 0; i < INJECTGENOTYPE_HASH_SIZE; i++) {
+ for (i = 0; i < nInjectGenotype::HASH_SIZE; i++) {
assert (active_inject_genotypes[i].OK());
}
Modified: trunk/source/main/cInjectGenebank.h
===================================================================
--- trunk/source/main/cInjectGenebank.h 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cInjectGenebank.h 2005-10-05 23:24:09 UTC (rev 330)
@@ -13,8 +13,8 @@
#ifndef DEFS_HH
#include "defs.hh"
#endif
-#ifndef INJECT_GENEBANK_MACROS_HH
-#include "inject_genebank_macros.hh"
+#ifndef nInjectGenotype_h
+#include "nInjectGenotype.h"
#endif
#ifndef INJECT_GENOTYPE_CONTROL_HH
#include "cInjectGenotypeControl.h"
@@ -39,7 +39,7 @@
class cInjectGenebank {
private:
unsigned int inject_genotype_count[MAX_CREATURE_SIZE];
- cInjectGenotypeQueue active_inject_genotypes[INJECTGENOTYPE_HASH_SIZE];
+ cInjectGenotypeQueue active_inject_genotypes[nInjectGenotype::HASH_SIZE];
cInjectGenotypeControl * inject_genotype_control;
cStats & stats;
Modified: trunk/source/main/cInjectGenotypeControl.cc
===================================================================
--- trunk/source/main/cInjectGenotypeControl.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cInjectGenotypeControl.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -28,7 +28,7 @@
size = 0;
best = NULL;
coalescent = NULL;
- for (int i = 0; i < INJECTGENOTYPE_THREADS; i++) threads[i] = NULL;
+ for (int i = 0; i < nInjectGenotype::THREADS; i++) threads[i] = NULL;
historic_list = NULL;
historic_count = 0;
Modified: trunk/source/main/cInjectGenotypeControl.h
===================================================================
--- trunk/source/main/cInjectGenotypeControl.h 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cInjectGenotypeControl.h 2005-10-05 23:24:09 UTC (rev 330)
@@ -8,8 +8,8 @@
#ifndef INJECT_GENOTYPE_CONTROL_HH
#define INJECT_GENOTYPE_CONTROL_HH
-#ifndef INJECT_GENEBANK_MACROS_HH
-#include "inject_genebank_macros.hh"
+#ifndef nInjectGenotype_h
+#include "nInjectGenotype.h"
#endif
class cGenome;
@@ -20,7 +20,7 @@
int size;
cInjectGenotype * best;
cInjectGenotype * coalescent;
- cInjectGenotype * threads[INJECTGENOTYPE_THREADS];
+ cInjectGenotype * threads[nInjectGenotype::THREADS];
cInjectGenebank & genebank;
cInjectGenotype * historic_list;
Copied: trunk/source/main/cLandscape.cc (from rev 329, trunk/source/main/landscape.cc)
===================================================================
--- trunk/source/main/landscape.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cLandscape.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -0,0 +1,863 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 "cLandscape.h"
+
+#include "cCPUMemory.h"
+#include "cEnvironment.h"
+#include "cInstSet.h"
+#include "organism.hh"
+#include "phenotype.hh"
+#include "stats.hh" // For GetUpdate in outputs...
+#include "cTestCPU.h"
+#include "cTestUtil.h"
+#include "tools.hh"
+
+using namespace std;
+
+
+////////////////
+// cLandscape
+////////////////
+
+cLandscape::cLandscape(const cGenome & in_genome, const cInstSet & in_inst_set)
+ : inst_set(in_inst_set), base_genome(1), peak_genome(1)
+{
+ site_count = NULL;
+ Reset(in_genome);
+}
+
+cLandscape::~cLandscape()
+{
+ if (site_count != NULL) delete [] site_count;
+}
+
+void cLandscape::Reset(const cGenome & in_genome)
+{
+ base_genome = in_genome;
+ peak_genome = in_genome;
+ base_fitness = 0.0;
+ base_merit = 0.0;
+ base_gestation = 0;
+ peak_fitness = 0.0;
+ total_fitness = 0.0;
+ total_sqr_fitness = 0.0;
+ distance = 0;
+ del_distance = 0;
+ ins_distance = 0;
+ trials = 0;
+
+ total_count = 0;
+ dead_count = 0;
+ neg_count = 0;
+ neut_count = 0;
+ pos_count = 0;
+
+ pos_size = 0;
+ neg_size = 0;
+
+ total_epi_count = 0;
+ pos_epi_count = 0;
+ neg_epi_count = 0;
+ no_epi_count = 0;
+ dead_epi_count= 0;
+
+ pos_epi_size = 0;
+ neg_epi_size = 0;
+ no_epi_size = 0;
+
+ if (site_count != NULL) delete [] site_count;
+ site_count = new int[base_genome.GetSize() + 1];
+ for (int i = 0; i <= base_genome.GetSize(); i++) site_count[i] = 0;
+
+ total_entropy = 0.0;
+ complexity = 0.0;
+ neut_min = 0.0;
+ neut_max = 0.0;
+}
+
+void cLandscape::ProcessGenome(cGenome & in_genome)
+{
+ cTestCPU::TestGenome(test_info, in_genome);
+
+ test_fitness = test_info.GetColonyFitness();
+
+ total_fitness += test_fitness;
+ total_sqr_fitness += test_fitness * test_fitness;
+ total_count++;
+ if (test_fitness == 0) {
+ dead_count++;
+ } else if (test_fitness < neut_min) {
+ neg_count++;
+ neg_size = neg_size + test_fitness ;
+ } else if (test_fitness <= neut_max) {
+ neut_count++;
+ } else {
+ pos_count++;
+ pos_size = pos_size + test_fitness ;
+ if (test_fitness > peak_fitness) {
+ peak_fitness = test_fitness;
+ peak_genome = in_genome;
+ }
+ }
+}
+
+void cLandscape::ProcessBase()
+{
+ // Collect info on base creature.
+
+ cTestCPU::TestGenome(test_info, base_genome);
+
+ cPhenotype & phenotype = test_info.GetColonyOrganism()->GetPhenotype();
+ base_fitness = phenotype.GetFitness();
+ base_merit = phenotype.GetMerit().GetDouble();
+ base_gestation = phenotype.GetGestationTime();
+
+ peak_fitness = base_fitness;
+ peak_genome = base_genome;
+
+ neut_min = base_fitness * nHardware::FITNESS_NEUTRAL_MIN;
+ neut_max = base_fitness * nHardware::FITNESS_NEUTRAL_MAX;
+
+}
+
+void cLandscape::Process(int in_distance)
+{
+ distance = in_distance;
+
+ // Get the info about the base creature.
+ ProcessBase();
+
+ // Now Process the new creature at the proper distance.
+ Process_Body(base_genome, distance, 0);
+
+ // Calculate the complexity...
+
+ double max_ent = log((double) inst_set.GetSize());
+ for (int i = 0; i < base_genome.GetSize(); i++) {
+ total_entropy += (log((double) site_count[i] + 1) / max_ent);
+ }
+ complexity = base_genome.GetSize() - total_entropy;
+}
+
+
+// For distances greater than one, this needs to be called recursively.
+
+void cLandscape::Process_Body(cGenome & cur_genome, int cur_distance,
+ int start_line)
+{
+ const int max_line = base_genome.GetSize() - cur_distance + 1;
+ const int inst_size = inst_set.GetSize();
+
+ cGenome mod_genome(cur_genome);
+
+ // Loop through all the lines of genome, testing trying all combinations.
+ for (int line_num = start_line; line_num < max_line; line_num++) {
+ int cur_inst = base_genome[line_num].GetOp();
+
+ // Loop through all instructions...
+ for (int inst_num = 0; inst_num < inst_size; inst_num++) {
+ if (cur_inst == inst_num) continue;
+
+ mod_genome[line_num].SetOp(inst_num);
+ if (cur_distance <= 1) {
+ ProcessGenome(mod_genome);
+ if (test_info.GetColonyFitness() >= neut_min) site_count[line_num]++;
+ } else {
+ Process_Body(mod_genome, cur_distance - 1, line_num + 1);
+ }
+ }
+
+ mod_genome[line_num].SetOp(cur_inst);
+ }
+
+}
+
+void cLandscape::ProcessDelete()
+{
+ // Get the info about the base creature.
+ ProcessBase();
+
+ const int max_line = base_genome.GetSize();
+ cCPUMemory mod_genome(base_genome);
+
+ // Loop through all the lines of genome, testing all deletions.
+ for (int line_num = 0; line_num < max_line; line_num++) {
+ int cur_inst = base_genome[line_num].GetOp();
+ mod_genome.Remove(line_num);
+ ProcessGenome(mod_genome);
+ if (test_info.GetColonyFitness() >= neut_min) site_count[line_num]++;
+ mod_genome.Insert(line_num, cInstruction(cur_inst));
+ }
+
+}
+
+void cLandscape::ProcessInsert()
+{
+ // Get the info about the base creature.
+ ProcessBase();
+
+ const int max_line = base_genome.GetSize();
+ const int inst_size = inst_set.GetSize();
+
+ cCPUMemory mod_genome(base_genome);
+
+ // Loop through all the lines of genome, testing all insertions.
+ for (int line_num = 0; line_num <= max_line; line_num++) {
+ // Loop through all instructions...
+ for (int inst_num = 0; inst_num < inst_size; inst_num++) {
+ mod_genome.Insert(line_num, cInstruction(inst_num));
+ ProcessGenome(mod_genome);
+ if (test_info.GetColonyFitness() >= neut_min) site_count[line_num]++;
+ mod_genome.Remove(line_num);
+ }
+ }
+
+}
+
+// Prediction for a landscape where n sites are _randomized_.
+void cLandscape::PredictWProcess(ostream & fp, int update)
+{
+ distance = 1;
+
+ // Get the info about the base creature.
+ ProcessBase();
+ if (base_fitness == 0.0) return;
+
+ BuildFitnessChart();
+ const int genome_size = fitness_chart.GetNumRows();
+ const int inst_size = fitness_chart.GetNumCols();
+ const double min_neut_fitness = 0.99;
+ const double max_neut_fitness = 1.01;
+
+ // Loop through the entries printing them and doing additional
+ // calculations.
+ int total_pos_found = 0;
+ int total_neut_found = 0;
+ int total_neg_found = 0;
+ int total_dead_found = 0;
+ double max_fitness = 1.0;
+ double total_fitness = 0.0;
+ double total_sqr_fitness = 0.0;
+
+ for (int row = 0; row < genome_size; row++) {
+ double max_line_fitness = 1.0;
+ for (int col = 0; col < inst_size; col++) {
+ double & cur_fitness = fitness_chart(row, col);
+ cur_fitness /= base_fitness;
+ total_fitness += cur_fitness;
+ total_sqr_fitness += cur_fitness * cur_fitness;
+ if (cur_fitness > max_neut_fitness) total_pos_found++;
+ else if (cur_fitness > min_neut_fitness) total_neut_found++;
+ else if (cur_fitness > 0.0) total_neg_found++;
+
+ if (cur_fitness > max_line_fitness) max_line_fitness = cur_fitness;
+ }
+ max_fitness *= max_line_fitness;
+ }
+
+ const int total_tests = genome_size * inst_size;
+ total_dead_found = total_tests - total_pos_found - total_neut_found - total_neg_found;
+ fp << update << " "
+ << "1 "
+ << ((double) total_dead_found / (double) total_tests) << " "
+ << ((double) total_neg_found / (double) total_tests) << " "
+ << ((double) total_neut_found / (double) total_tests) << " "
+ << ((double) total_pos_found / (double) total_tests) << " "
+ << total_tests << " "
+ << total_neut_found + total_pos_found << " "
+ << total_fitness / (double) total_tests << " "
+ << total_sqr_fitness / (double) total_tests << " "
+ << endl;
+ fp.flush();
+
+ // Sample the table out to 10 mutations
+ const int max_muts = 10;
+ const int min_found = 100;
+ const int min_tests = 10000;
+ const int max_tests = 1000000000;
+
+ double test_fitness;
+ for (int num_muts = 2; num_muts <= max_muts; num_muts++) {
+ total_pos_found = 0;
+ total_neut_found = 0;
+ total_neg_found = 0;
+ total_fitness = 0.0;
+ total_sqr_fitness = 0.0;
+ tArray<int> mut_lines(num_muts);
+
+ int test_id = 0;
+ while ((test_id < min_tests) ||
+ (test_id < max_tests && (total_neut_found + total_pos_found) < min_found)) {
+ g_random.Choose(genome_size, mut_lines);
+ test_fitness = 1.0;
+ for (int j = 0; j < num_muts && test_fitness != 0.0; j++) {
+ test_fitness *=
+ fitness_chart(mut_lines[j], g_random.GetUInt(inst_size));
+ }
+ total_fitness += test_fitness;
+ total_sqr_fitness += test_fitness * test_fitness;
+ if (test_fitness > max_neut_fitness) total_pos_found++;
+ else if (test_fitness > min_neut_fitness) total_neut_found++;
+ else if (test_fitness > 0.0) total_neg_found++;
+
+ test_id++;
+ }
+
+ total_dead_found = test_id - total_pos_found - total_neut_found - total_neg_found;
+ fp << update << " " // 1
+ << num_muts << " " // 2
+ << ((double) total_dead_found / (double) test_id) << " " // 3
+ << ((double) total_neg_found / (double) test_id) << " " // 4
+ << ((double) total_neut_found / (double) test_id) << " " // 5
+ << ((double) total_pos_found / (double) test_id) << " " // 6
+ << test_id << " " // 7
+ << total_neut_found + total_pos_found << " " // 8
+ << total_fitness / (double) test_id << " " // 9
+ << total_sqr_fitness / (double) test_id << " " // 10
+ << endl;
+ fp.flush();
+
+ if (total_pos_found + total_neut_found < min_found / 2) break;
+ }
+
+ // Calculate the complexity...
+
+ double max_ent = log((double) inst_set.GetSize());
+ for (int i = 0; i < base_genome.GetSize(); i++) {
+ total_entropy += (log((double) site_count[i] + 1) / max_ent);
+ }
+ complexity = base_genome.GetSize() - total_entropy;
+}
+
+
+// Prediction for a landscape where n sites are _mutated_.
+void cLandscape::PredictNuProcess(ostream & fp, int update)
+{
+ distance = 1;
+
+ // Get the info about the base creature.
+ ProcessBase();
+ if (base_fitness == 0.0) return;
+
+ BuildFitnessChart();
+ const int genome_size = fitness_chart.GetNumRows();
+ const int inst_size = fitness_chart.GetNumCols();
+ const double min_neut_fitness = 0.99;
+ const double max_neut_fitness = 1.01;
+
+ // Loop through the entries printing them and doing additional
+ // calculations.
+ int total_pos_found = 0;
+ int total_neut_found = 0;
+ int total_neg_found = 0;
+ int total_dead_found = 0;
+ int total_live_found = 0;
+ double max_fitness = 1.0;
+ double max_found_fitness = 0.0;
+ double total_fitness = 0.0;
+ double total_sqr_fitness = 0.0;
+
+ for (int row = 0; row < genome_size; row++) {
+ double max_line_fitness = 1.0;
+ int base_inst = base_genome[row].GetOp();
+ for (int col = 0; col < inst_size; col++) {
+ if (col == base_inst) continue; // Only consider changes to line!
+ double & cur_fitness = fitness_chart(row, col);
+ cur_fitness /= base_fitness;
+ total_fitness += cur_fitness;
+ total_sqr_fitness += cur_fitness * cur_fitness;
+ if (cur_fitness > max_neut_fitness) total_pos_found++;
+ else if (cur_fitness > min_neut_fitness) total_neut_found++;
+ else if (cur_fitness > 0.0) total_neg_found++;
+
+ if (cur_fitness > max_line_fitness) max_line_fitness = cur_fitness;
+ }
+ max_fitness *= max_line_fitness;
+ if (max_line_fitness > max_found_fitness) max_found_fitness = max_line_fitness;
+ }
+
+ const int total_tests = genome_size * inst_size;
+ total_live_found = total_pos_found + total_neut_found + total_neg_found;
+ total_dead_found = total_tests - total_live_found;
+ fp << update << " "
+ << "1 "
+ << ((double) total_dead_found / (double) total_tests) << " "
+ << ((double) total_neg_found / (double) total_tests) << " "
+ << ((double) total_neut_found / (double) total_tests) << " "
+ << ((double) total_pos_found / (double) total_tests) << " "
+ << total_tests << " "
+ << total_live_found << " "
+ << total_fitness / (double) total_tests << " "
+ << total_sqr_fitness / (double) total_tests << " "
+ << max_found_fitness << " "
+ << endl;
+ fp.flush();
+
+ // Sample the table out to 10 mutations
+ const int max_muts = 10;
+ const int min_found = 100;
+ const int min_tests = 10000;
+ const int max_tests = 1000000000;
+
+ double test_fitness;
+ for (int num_muts = 2; num_muts <= max_muts; num_muts++) {
+ total_pos_found = 0;
+ total_neut_found = 0;
+ total_neg_found = 0;
+ total_fitness = 0.0;
+ total_sqr_fitness = 0.0;
+ max_found_fitness = 0.0;
+ tArray<int> mut_lines(num_muts);
+
+ int test_id = 0;
+ while ((test_id < min_tests) ||
+ (test_id < max_tests && (total_neg_found + total_neut_found + total_pos_found) < min_found)) {
+ g_random.Choose(genome_size, mut_lines);
+ test_fitness = 1.0;
+ for (int j = 0; j < num_muts && test_fitness != 0.0; j++) {
+ int base_inst = base_genome[ mut_lines[j] ].GetOp();
+ int mut_inst = g_random.GetUInt(inst_size);
+ while (mut_inst == base_inst) mut_inst = g_random.GetUInt(inst_size);
+ test_fitness *= fitness_chart(mut_lines[j], mut_inst);
+ if (test_fitness == 0.0) break;
+ }
+ total_fitness += test_fitness;
+ total_sqr_fitness += test_fitness * test_fitness;
+ if (test_fitness > max_found_fitness) max_found_fitness = test_fitness;
+
+ if (test_fitness > max_neut_fitness) total_pos_found++;
+ else if (test_fitness > min_neut_fitness) total_neut_found++;
+ else if (test_fitness > 0.0) total_neg_found++;
+
+ test_id++;
+ }
+
+ total_live_found = total_neg_found + total_neut_found + total_pos_found;
+ total_dead_found = test_id - total_live_found;
+
+
+ fp << update << " " // 1
+ << num_muts << " " // 2
+ << ((double) total_dead_found / (double) test_id) << " " // 3
+ << ((double) total_neg_found / (double) test_id) << " " // 4
+ << ((double) total_neut_found / (double) test_id) << " " // 5
+ << ((double) total_pos_found / (double) test_id) << " " // 6
+ << test_id << " " // 7
+ << total_live_found << " " // 8
+ << total_fitness / (double) test_id << " " // 9
+ << total_sqr_fitness / (double) test_id << " " // 10
+ << max_found_fitness << " " // 11
+ << endl;
+ fp.flush();
+
+ if (total_live_found < min_found / 2) break;
+ }
+
+ // Calculate the complexity...
+
+ double max_ent = log((double) inst_set.GetSize());
+ for (int i = 0; i < base_genome.GetSize(); i++) {
+ total_entropy += (log((double) site_count[i] + 1) / max_ent);
+ }
+ complexity = base_genome.GetSize() - total_entropy;
+}
+
+
+void cLandscape::SampleProcess(int in_trials)
+{
+ trials = in_trials; // Trials _per line_
+ distance = 1;
+
+ cGenome mod_genome(base_genome);
+ int genome_size = base_genome.GetSize();
+
+ ProcessBase();
+
+ // Loop through all the lines of genome, testing each line.
+ for (int line_num = 0; line_num < genome_size; line_num++) {
+ cInstruction cur_inst( base_genome[line_num] );
+
+ for (int i = 0; i < trials; i++) {
+ // Choose the new instruction for that line...
+ cInstruction new_inst( inst_set.GetRandomInst() );
+ if (cur_inst == new_inst) { i--; continue; }
+
+ // Make the change, and test it!
+ mod_genome[line_num] = new_inst;
+ ProcessGenome(mod_genome);
+ }
+
+ mod_genome[line_num] = cur_inst;
+ }
+}
+
+
+int cLandscape::RandomProcess(int in_trials, int in_distance, int min_found,
+ int max_trials, bool print_if_found)
+{
+ distance = in_distance;
+
+ cGenome mod_genome(base_genome);
+ int genome_size = base_genome.GetSize();
+
+ ProcessBase();
+
+ int mut_num;
+ tArray<int> mut_lines(distance);
+
+ // Loop through all the lines of genome, testing many combinations.
+ int cur_trial = 0;
+ int total_found = 0;
+
+// for (cur_trial = 0;
+// (cur_trial < in_trials) ||
+// (total_found < min_found && cur_trial < max_trials);
+// cur_trial++) {
+// Way too confusing and not being used, commented it out DM
+
+ for (cur_trial = 0; cur_trial < in_trials; cur_trial++) {
+
+ // Choose the lines to mutate...
+ g_random.Choose(genome_size, mut_lines);
+
+ // Choose the new instructions for those lines...
+ for (mut_num = 0; mut_num < distance; mut_num++) {
+ const cInstruction new_inst( inst_set.GetRandomInst() );
+ const cInstruction & cur_inst = base_genome[ mut_lines[mut_num] ];
+ if (cur_inst == new_inst) {
+ mut_num--;
+ continue;
+ }
+
+ mod_genome[ mut_lines[mut_num] ] = new_inst;
+ }
+
+ // And test it!
+
+ ProcessGenome(mod_genome);
+
+ // if (test_info.IsViable()) {
+ //if (test_fitness >= neut_min) {
+ // total_found++;
+ // If we are supposed to print those found, do so!
+ // if (print_if_found) {
+ // cString filename;
+ // filename.Set("creature.land.%d.%d", distance, cur_trial);
+ // cTestUtil::PrintGenome(mod_genome, filename);
+ // }
+ //}
+
+
+ // And reset the genome.
+ for (mut_num = 0; mut_num < distance; mut_num++) {
+ mod_genome[ mut_lines[mut_num] ] = base_genome[ mut_lines[mut_num] ];
+ }
+ }
+
+ trials = cur_trial;
+
+ return total_found;
+}
+
+void cLandscape::BuildFitnessChart()
+{
+ // First, resize the fitness_chart.
+ const int max_line = base_genome.GetSize();
+ const int inst_size = inst_set.GetSize();
+ fitness_chart.ResizeClear(max_line, inst_size);
+
+ cGenome mod_genome(base_genome);
+
+ // Loop through all the lines of genome, testing trying all combinations.
+ for (int line_num = 0; line_num < max_line; line_num++) {
+ int cur_inst = base_genome[line_num].GetOp();
+
+ // Loop through all instructions...
+ for (int inst_num = 0; inst_num < inst_size; inst_num++) {
+ if (cur_inst == inst_num) {
+ fitness_chart(line_num, inst_num) = base_fitness;
+ continue;
+ }
+
+ mod_genome[line_num].SetOp(inst_num);
+ ProcessGenome(mod_genome);
+ fitness_chart(line_num, inst_num) = test_info.GetColonyFitness();
+ }
+
+ mod_genome[line_num].SetOp(cur_inst);
+ }
+
+}
+
+void cLandscape::TestPairs(int in_trials, ostream & fp)
+{
+ trials = in_trials;
+
+ ProcessBase();
+ if (base_fitness == 0.0) return;
+
+ BuildFitnessChart();
+
+ cGenome mod_genome(base_genome);
+ const int genome_size = base_genome.GetSize();
+
+ tArray<int> mut_lines(2);
+ tArray<cInstruction> mut_insts(2);
+
+ // Loop through all the lines of genome, testing many combinations.
+ for (int i = 0; i < trials; i++) {
+ // Choose the lines to mutate...
+ g_random.Choose(genome_size, mut_lines);
+
+ // Choose the new instructions for those lines...
+ for (int mut_num = 0; mut_num < 2; mut_num++) {
+ const cInstruction new_inst( inst_set.GetRandomInst() );
+ const cInstruction & cur_inst = base_genome[ mut_lines[mut_num] ];
+ if (cur_inst == new_inst) {
+ mut_num--;
+ continue;
+ }
+
+ mut_insts[mut_num] = new_inst;
+ }
+
+ TestMutPair(mod_genome, mut_lines[0], mut_lines[1], mut_insts[0],
+ mut_insts[1], fp);
+
+ }
+
+}
+
+
+void cLandscape::TestAllPairs(ostream & fp)
+{
+ ProcessBase();
+ if (base_fitness == 0.0) return;
+
+ BuildFitnessChart();
+
+ const int max_line = base_genome.GetSize();
+ const int inst_size = inst_set.GetSize();
+ cGenome mod_genome(base_genome);
+ cInstruction inst1, inst2;
+
+ // Loop through all the lines of genome, testing trying all combinations.
+ for (int line1_num = 0; line1_num < max_line - 1; line1_num++) {
+ for (int line2_num = line1_num + 1; line2_num < max_line; line2_num++) {
+
+ // Loop through all instructions...
+ for (int inst1_num = 0; inst1_num < inst_size; inst1_num++) {
+ inst1.SetOp(inst1_num);
+ if (inst1 == base_genome[line1_num]) continue;
+ for (int inst2_num = 0; inst2_num < inst_size; inst2_num++) {
+ inst2.SetOp(inst2_num);
+ if (inst2 == base_genome[line2_num]) continue;
+ TestMutPair(mod_genome, line1_num, line2_num, inst1, inst2, fp);
+ } // inst2_num loop
+ } //inst1_num loop;
+
+ } // line2_num loop
+ } // line1_num loop.
+
+}
+
+
+void cLandscape::HillClimb(ofstream & fp)
+{
+ cGenome cur_genome(base_genome);
+ int gen = 0;
+ HillClimb_Body(fp, cur_genome, gen);
+}
+
+void cLandscape::HillClimb_Body(ofstream & fp, cGenome & cur_genome,
+ int & gen)
+{
+ cCPUMemory mod_genome(base_genome);
+
+ const int inst_size = inst_set.GetSize();
+
+ double pos_frac = 1.0;
+
+ bool finished = false;
+ while (finished == false) {
+ if (pos_frac == 0.0) finished = true;
+
+ // Search the landscape for the next best.
+ Reset(cur_genome);
+ const int max_line = cur_genome.GetSize();
+
+ // Try all Mutations...
+ Process(1);
+
+ // Try Insertion Mutations.
+
+ mod_genome = cur_genome;
+ for (int line_num = 0; line_num <= max_line; line_num++) {
+ // Loop through all instructions...
+ for (int inst_num = 0; inst_num < inst_size; inst_num++) {
+ mod_genome.Insert(line_num, cInstruction(inst_num));
+ ProcessGenome(mod_genome);
+ mod_genome.Remove(line_num);
+ }
+ }
+
+ // Try all deletion mutations.
+
+ for (int line_num = 0; line_num < max_line; line_num++) {
+ int cur_inst = cur_genome[line_num].GetOp();
+ mod_genome.Remove(line_num);
+ ProcessGenome(mod_genome);
+ mod_genome.Insert(line_num, cInstruction(cur_inst));
+ }
+
+ pos_frac = GetProbPos();
+
+ // Print the information on the current best.
+ HillClimb_Print(fp, cur_genome, gen);
+
+ // Move on to the peak genome found.
+ cur_genome = GetPeakGenome();
+ gen++;
+ }
+}
+
+void cLandscape::HillClimb_Neut(ofstream & fp)
+{
+}
+
+void cLandscape::HillClimb_Rand(ofstream & fp)
+{
+}
+
+void cLandscape::HillClimb_Print(ofstream & fp, const cGenome & _genome, const int gen) const
+{
+ cCPUTestInfo test_info;
+ cTestCPU::TestGenome(test_info, _genome);
+ cPhenotype &colony_phenotype = test_info.GetColonyOrganism()->GetPhenotype();
+ fp << gen << " "
+ << colony_phenotype.GetMerit().GetDouble() << " "
+ << colony_phenotype.GetGestationTime() << " "
+ << colony_phenotype.GetFitness() << " "
+ << _genome.GetSize() << " "
+ << GetProbDead() << " "
+ << GetProbNeg() << " "
+ << GetProbNeut() << " "
+ << GetProbPos() << " "
+ << endl;
+}
+
+double cLandscape::TestMutPair(cGenome & mod_genome, int line1, int line2,
+ const cInstruction & mut1, const cInstruction & mut2, ostream & fp)
+{
+ mod_genome[line1] = mut1;
+ mod_genome[line2] = mut2;
+ cTestCPU::TestGenome(test_info, mod_genome);
+ double combo_fitness = test_info.GetColonyFitness() / base_fitness;
+
+ mod_genome[line1] = base_genome[line1];
+ mod_genome[line2] = base_genome[line2];
+
+ double mut1_fitness = fitness_chart(line1, mut1.GetOp()) / base_fitness;
+ double mut2_fitness = fitness_chart(line2, mut2.GetOp()) / base_fitness;
+ double mult_combo = mut1_fitness * mut2_fitness;
+
+ /*
+ fp << line1 << " "
+ << line2 << " "
+ << ( (int) mut1.GetOp() ) << " "
+ << ( (int) mut2.GetOp() ) << " ";
+
+ fp << ( fitness_chart(line1, mut1.GetOp()) / base_fitness ) << " "
+ << ( fitness_chart(line2, mut2.GetOp()) / base_fitness ) << " "
+ << combo_fitness << endl;
+ */
+
+ total_epi_count++;
+ if ((mut1_fitness==0 || mut2_fitness==0)&&(combo_fitness==0)) {
+ dead_epi_count++;
+ } else if (combo_fitness < mult_combo) {
+ neg_epi_count++;
+ neg_epi_size = neg_epi_size + combo_fitness;
+ } else if (combo_fitness > mult_combo) {
+ pos_epi_count++;
+ pos_epi_size = pos_epi_size + combo_fitness;
+ } else {
+ no_epi_count++;
+ no_epi_size = no_epi_size + combo_fitness;
+ }
+
+ return combo_fitness;
+}
+
+
+void cLandscape::PrintStats(ofstream & fp, int update)
+{
+ fp << update << " " // 1
+ << GetProbDead() << " " // 2
+ << GetProbNeg() << " " // 3
+ << GetProbNeut() << " " // 4
+ << GetProbPos() << " " // 5
+// << pos_size << " " // 6
+// << pos_count << " " // 6
+ << GetAvPosSize() << " " // 6
+ << GetAvNegSize() << " " // 7
+ << total_count << " " // 8
+ << distance << " " // 9
+// << neut_min << " " // 10
+// << neut_max << " " // 10
+// << nHardware::FITNESS_NEUTRAL_MIN << " " // 10
+// << nHardware::FITNESS_NEUTRAL_MAX << " " // 10
+ << base_fitness << " " // 10
+ << base_merit << " " // 11
+ << base_gestation << " " // 12
+ << peak_fitness << " " // 13
+ << GetAveFitness() << " " // 14
+ << GetAveSqrFitness() << " " // 15
+ << total_entropy << " " // 16
+ << complexity << " " // 17
+ << GetProbEpiDead() << " " // 18
+ << GetProbEpiPos() << " " // 19
+ << GetProbEpiNeg() << " " // 20
+ << GetProbNoEpi() << " " // 21
+ << GetAvPosEpiSize() << " " // 22
+ << GetAvNegEpiSize() << " " // 23
+ << GetAvNoEpiSize() << " " // 24
+ << total_epi_count << endl; // 25
+ fp.flush();
+}
+
+void cLandscape::PrintEntropy(ofstream & fp)
+{
+ double max_ent = log((double) inst_set.GetSize());
+ for (int j = 0; j < base_genome.GetSize(); j++) {
+ fp << (log((double) site_count[j] + 1) / max_ent) << " ";
+ }
+ fp << endl;
+ fp.flush();
+}
+
+void cLandscape::PrintSiteCount(ofstream & fp)
+{
+ for (int j = 0; j < base_genome.GetSize(); j++) {
+ fp << site_count[j] << " ";
+ }
+ fp << endl;
+ fp.flush();
+}
+
+
+void cLandscape::PrintBase(cString filename)
+{
+ cTestUtil::PrintGenome(base_genome, filename);
+}
+
+void cLandscape::PrintPeak(cString filename)
+{
+ cTestUtil::PrintGenome(peak_genome, filename);
+}
+
Copied: trunk/source/main/cLandscape.h (from rev 329, trunk/source/main/landscape.hh)
Copied: trunk/source/main/cLineage.cc (from rev 329, trunk/source/main/lineage.cc)
===================================================================
--- trunk/source/main/lineage.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cLineage.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -0,0 +1,155 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 LINEAGE_HH
+#include "cLineage.h"
+#endif
+#ifndef GENOTYPE_HH
+#include "cGenotype.h"
+#endif
+
+using namespace std;
+
+
+bool gt_gentype::operator()(const cGenotype * g1, const cGenotype * g2) const
+{
+ return g1->GetID() > g2->GetID();
+}
+
+int cLineage::m_max_id = 0;
+
+cLineage::cLineage(double start_fitness, int parent_id, int id, int update,
+ double generation, double lineage_stat1, double lineage_stat2)
+ : m_parent_id(parent_id)
+ , m_update_born(update)
+ , m_num_CPUs(0)
+ , m_total_CPUs(0)
+ , m_total_genotypes(0)
+ , m_generation_born(generation)
+ , m_lineage_stat1(lineage_stat1)
+ , m_lineage_stat2(lineage_stat2)
+{
+ if ( id < 0 )
+ m_id = m_max_id++;
+ else{
+ m_id = id;
+ if ( id >= m_max_id )
+ m_max_id = id + 1;
+ }
+ m_start_fitness = m_max_fitness = m_max_fitness_ever = start_fitness;
+ m_ave_fitness = 0;
+ m_ave_fitness_changed = true;
+ m_threshold = false;
+}
+
+cLineage::~cLineage()
+{
+}
+
+void cLineage::AddCreature(cGenotype * genotype)
+{
+ // add the new genotype to the map if necessary, otherwise
+ // find its position
+ pair<map<const cGenotype *, int, gt_gentype>::iterator, bool> p =
+ m_genotype_map.insert( pair<const cGenotype*, int>( genotype, 0 ) );
+
+ // did we add a new genotype?
+ if ( ( p.second ) == true )
+ m_total_genotypes += 1;
+
+ // increase the count for the given genotype by one.
+ (*(p.first)).second += 1;
+
+ // The above lines could be written like that:
+ // m_genotype_map[ genotype ] += 1;
+ // if we didn't want to count how often we add a new genotype
+
+ double fitness = genotype->GetTestColonyFitness();
+
+ // adjust the current maximum fitness
+ if ( fitness > m_max_fitness )
+ m_max_fitness = fitness;
+ // adjust overall maxiumum fitness
+ if ( fitness> m_max_fitness_ever )
+ m_max_fitness_ever = fitness;
+ // the average fitness has changed as well
+ m_ave_fitness_changed = true;
+
+ m_num_CPUs++;
+ m_total_CPUs++;
+}
+
+bool cLineage::RemoveCreature(cGenotype * genotype)
+{
+ // we return true if the removal of this creature triggers a
+ // recalculation of the best lineage
+ bool result = false;
+
+ map<const cGenotype *, int, gt_gentype>::iterator cur = m_genotype_map.find( genotype );
+
+ // is the genotype part of the map?
+ if ( cur == m_genotype_map.end() ){
+ cerr << "Removing creature from lineage whose genotype is not part of the lineage!" << endl;
+ cerr << " " << genotype->GetName()() << " " << GetID() << endl;
+ return false;
+ }
+
+ // yes, decrease the count
+ (*cur).second -= 1;
+ // and adjust the average fitness
+ m_ave_fitness_changed = true;
+
+ double fitness = genotype->GetTestColonyFitness();
+
+ // did we reach zero?
+ if ( (*cur).second == 0 ){
+ // yes, remove the entry
+ m_genotype_map.erase( cur );
+ // make sure that the maximum fitness is correct
+ if (fitness == m_max_fitness) CalcCurrentFitness();
+ // adjust the return value
+ result = true;
+ }
+
+ // and now the total cpu count
+ m_num_CPUs--;
+
+ return result;
+}
+
+int cLineage::CountNumCreatures() const
+{
+ int creature_count = 0;
+
+ map<const cGenotype *, int, gt_gentype>::const_iterator it =
+ m_genotype_map.begin();
+
+ for ( ; it!=m_genotype_map.end(); it++ )
+ creature_count += (*it).second;
+
+ return creature_count;
+}
+
+void cLineage::CalcCurrentFitness() const
+{
+ m_max_fitness = 0.0;
+ map<const cGenotype *, int, gt_gentype>::const_iterator it =
+ m_genotype_map.begin();
+
+ // we calculate the average fitness as well, since it is so easy.
+ m_ave_fitness = 0;
+ for ( ; it!=m_genotype_map.end(); it++ ){
+ double fitness = (*it).first->GetTestColonyFitness();
+ if (fitness > m_max_fitness) m_max_fitness = fitness;
+ if (fitness > m_max_fitness_ever) m_max_fitness_ever = fitness;
+ m_ave_fitness += fitness * (*it).second;
+ }
+ m_ave_fitness /= (double) m_num_CPUs;
+ m_ave_fitness_changed = false;
+}
+
+
Copied: trunk/source/main/cLineage.h (from rev 329, trunk/source/main/lineage.hh)
Copied: trunk/source/main/cLineageControl.cc (from rev 329, trunk/source/main/lineage_control.cc)
===================================================================
--- trunk/source/main/lineage_control.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cLineageControl.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -0,0 +1,391 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 "cLineageControl.h"
+
+#include "string.hh"
+
+#include "cLineage.h"
+#include "stats.hh"
+#include "cConfig.h"
+#include "cGenebank.h"
+#include "cGenotype.h"
+#include "organism.hh"
+
+#include "nHardware.h" // for macro nHardware::FITNESS_NEUTRAL_MAX
+
+
+using namespace std;
+
+
+/////////////////////
+// cLineageControl
+/////////////////////
+
+cLineageControl::cLineageControl( cGenebank & genebank, cStats & stats )
+ : m_best_lineage(NULL)
+ , m_max_fitness_lineage(NULL)
+ , m_dominant_lineage(NULL)
+ , m_genebank( genebank )
+ , m_stats( stats )
+{
+}
+
+cLineageControl::~cLineageControl()
+{
+}
+
+
+cLineage *
+cLineageControl::AddLineage( double start_fitness, int parent_lin_id, int id, double lineage_stat1, double lineage_stat2 )
+{
+ cLineage * new_lineage = new cLineage( start_fitness, parent_lin_id, id,
+ m_stats.GetUpdate(), m_stats.GetGeneration(), lineage_stat1, lineage_stat2 );
+
+ // the best/ dominant lineage are automatically corrected
+ // when a creature is added to this lineage
+ m_lineage_list.push_back(new_lineage);
+
+ m_stats.AddLineage();
+
+ return new_lineage;
+}
+
+
+void
+cLineageControl::AddCreaturePrivate( cGenotype *genotype,
+ cLineage * lineage )
+{
+ assert( lineage != 0 );
+
+ // add to the lineage
+ lineage->AddCreature( genotype );
+
+ // This would be nice, but the current Avida code doesn't allow for it.
+ // Try to implement it in a new version...
+ // update the cpu
+ // cpu->SetLineage( lineage );
+ // cpu->SetLineageLabel( lineage->GetID() );
+
+ // test whether this makes the new lineage the best
+ if ( !m_best_lineage ||
+ lineage->GetAveFitness() > m_best_lineage->GetAveFitness() )
+ m_best_lineage = lineage;
+
+ // test whether this makes the new lineage the dominant
+ if ( !m_dominant_lineage ||
+ lineage->GetNumCreatures() > m_dominant_lineage->GetNumCreatures() )
+ m_dominant_lineage = lineage;
+
+ // test whether thiw makes the new lineage the one with the maximum fitness
+ if ( !m_max_fitness_lineage ||
+ lineage->GetMaxFitness() > m_max_fitness_lineage->GetMaxFitness() )
+ m_max_fitness_lineage = lineage;
+
+}
+
+void cLineageControl::UpdateLineages()
+{
+ m_best_lineage = NULL;
+ m_dominant_lineage = NULL;
+ m_max_fitness_lineage = NULL;
+
+ list<cLineage *>::iterator it = m_lineage_list.begin();
+ list<cLineage *>::iterator del_it;
+
+ while( it != m_lineage_list.end() ){
+ bool del = false;
+
+ // mark the lineage for removal if empty
+ if ( (*it)->GetNumCreatures() == 0 ){
+ del_it = it;
+ del = true;
+ }
+ else { // otherwise it is a candidate for the best/ dominant/... lineage
+ if ( !m_best_lineage ||
+ (*it)->GetAveFitness() > m_best_lineage->GetAveFitness() )
+ m_best_lineage = (*it);
+
+ if ( !m_dominant_lineage ||
+ (*it)->GetNumCreatures() > m_dominant_lineage->GetNumCreatures() )
+ m_dominant_lineage = (*it);
+
+ if ( !m_max_fitness_lineage ||
+ (*it)->GetMaxFitness() > m_max_fitness_lineage->GetMaxFitness() )
+ m_max_fitness_lineage = (*it);
+
+ }
+ // proceed to the next lineage
+ it++;
+
+ // now do the removal if necessary
+ if ( del ){
+ delete (*del_it); // delete the lineage
+ m_lineage_list.erase( del_it ); // and remove its reference
+ }
+ }
+
+#ifdef DEBUG
+ if ( !m_lineage_list.empty() ){
+ assert( m_dominant_lineage != 0 );
+ assert( m_best_lineage != 0 );
+ assert( m_max_fitness_lineage != 0 );
+ }
+#endif
+
+}
+
+
+cLineage*
+cLineageControl::AddCreature( cGenotype * child_genotype, cGenotype *parent_genotype, cLineage * parent_lineage, int parent_lin_id )
+{
+ // Collect any information we can about the parent.
+ double parent_fitness = 0.0;
+ // int parent_lin_id = 0;
+
+ // at this point, the cpu has still the lineage from the
+ // parent
+ // cLineage * parent_lineage = cpu->GetLineage();
+
+#ifdef DEBUG
+ if (parent_lineage != NULL){
+ assert( parent_lin_id == parent_lineage->GetID() );
+ }
+#endif
+
+ if (parent_genotype != NULL) {
+ assert( parent_genotype->GetNumOrganisms() > 0 );
+ parent_fitness = parent_genotype->GetTestColonyFitness();
+ }
+ //cGenotype * child_genotype = cpu->GetActiveGenotype();
+ double child_fitness = child_genotype->GetTestColonyFitness();
+ cLineage * child_lineage = parent_lineage;
+ bool create_lineage = false;
+ double lineage_stat1 = child_fitness;
+ double lineage_stat2 = child_fitness;
+
+ // if we don't have a child lineage, we are probably dealing
+ // with manual assignement of the lineage label
+ if ( child_lineage == NULL ){
+ child_lineage = FindLineage( parent_lin_id );
+ // lineage doesn't exist...
+ if ( child_lineage == NULL ){
+ // create it
+ cout << "Creating new lineage 'by hand'!\nRequested lineage label: " << parent_lin_id;
+ child_lineage = AddLineage(child_fitness, -1, parent_lin_id, 0, 0);
+ cout << ", actual lineage label: " << child_lineage->GetID() << endl;
+
+ }
+ }
+ // otherwise, check for conditions that cause the creation of a new lineage
+ else {
+ switch ( cConfig::GetLineageCreationMethod() ) {
+ case 0: // manual creation only
+ break;
+ case 1: // new lineage whenever a parent has offspring of greater fitness
+ if ( child_fitness > parent_fitness ){
+ create_lineage = true;
+ lineage_stat1 = parent_fitness;
+ lineage_stat2 = 0;
+ }
+ break;
+ case 2: // new lineage whenever a new child exceeds the
+ // currently highest fitness in the population
+ if ( child_fitness > m_max_fitness_lineage->GetMaxFitness() ){
+ create_lineage = true;
+ lineage_stat1 = m_max_fitness_lineage->GetMaxFitness();
+ lineage_stat2 = 0;
+ }
+ break;
+ case 3: // new lineage whenever a new child exceeds the
+ // highest fitness, or when it is a child of the
+ // of the dominant lineage and exceeds that highest fitness
+ if ( child_fitness > m_max_fitness_lineage->GetMaxFitness() ||
+ ( parent_lineage == m_dominant_lineage
+ && child_fitness > m_dominant_lineage->GetMaxFitness() ) ){
+ create_lineage = true;
+ lineage_stat1 = m_max_fitness_lineage->GetMaxFitness();
+ lineage_stat2 = m_dominant_lineage->GetMaxFitness();
+ }
+ break;
+ case 4: // new lineage whenever a new child exceeds the
+ // fitness of the dominant creature (and the fitness of its own lineage)
+ if (child_fitness > m_genebank.GetBestGenotype()->GetTestColonyFitness()
+ && child_fitness > parent_lineage->GetMaxFitness() ){
+ create_lineage = true;
+ lineage_stat1=m_genebank.GetBestGenotype()->GetTestColonyFitness();
+ lineage_stat2=parent_lineage->GetMaxFitness();
+ }
+ break;
+ case 5: // new lineage whenever a new child exceeds the
+ // fitness of the dominant lineage (and the fitness of its own lineage)
+ if ( child_fitness > m_dominant_lineage->GetMaxFitness()
+ && child_fitness > parent_lineage->GetMaxFitness() ){
+ create_lineage = true;
+ lineage_stat1=m_dominant_lineage->GetMaxFitness();
+ lineage_stat2=parent_lineage->GetMaxFitness();
+ }
+ break;
+ case 6: // new lineage whenever a new child exceeds the
+ // fitness of its own lineage
+ if ( child_fitness > parent_lineage->GetMaxFitness() ){
+ create_lineage = true;
+ lineage_stat1=parent_lineage->GetMaxFitness();
+ lineage_stat2 = 0;
+ }
+ break;
+ case 7: // new lineage whenever a new child exceeds the
+ // maximum fitness ever attained by its parent lineage
+ if (child_fitness > parent_lineage->GetMaxFitnessEver() ) {
+ create_lineage = true;
+ lineage_stat1 = parent_lineage->GetMaxFitnessEver();
+ lineage_stat2 = 0;
+ }
+ break;
+ }
+ }
+ if ( create_lineage ){
+ child_lineage = AddLineage(child_fitness, parent_lin_id, -1, lineage_stat1, lineage_stat2);
+ // cout << "Lineage " << child_lineage->GetID() << " created."
+ // << " Genotype: " << child_genotype->GetName()() << endl;
+ }
+
+ AddCreaturePrivate( child_genotype, child_lineage );
+
+ return child_lineage;
+}
+
+
+void
+cLineageControl::RemoveCreature( cOrganism * cpu )
+{
+ cLineage * cur_lineage = cpu->GetLineage();
+
+ if (cur_lineage) {
+ // remove the creature
+ if ( cur_lineage->RemoveCreature( cpu->GetGenotype() )
+ || cur_lineage == m_dominant_lineage
+ || cur_lineage == m_best_lineage )
+ // If this lineage no longer exists, tell stats...
+ if (cur_lineage->GetNumCreatures() == 0) {
+ m_stats.RemoveLineage( cur_lineage->GetID(),
+ cur_lineage->GetParentID(),
+ cur_lineage->GetUpdateBorn(),
+ cur_lineage->GetGenerationBorn(),
+ cur_lineage->GetTotalCreatures(),
+ cur_lineage->GetTotalGenotypes(),
+ cur_lineage->GetStartFitness(),
+ cur_lineage->GetLineageStat1(),
+ cur_lineage->GetLineageStat2() );
+ }
+
+ // recalc the best/dominant lineage if necessary
+ UpdateLineages();
+ cpu->SetLineage( 0 );
+ cpu->SetLineageLabel( -1 );
+ }
+
+}
+
+
+cLineage *
+cLineageControl::FindLineage( int lineage_id ) const
+{
+ list<cLineage *>::const_iterator it = m_lineage_list.begin();
+
+ for ( ; it != m_lineage_list.end(); it++ )
+ if ( (*it)->GetID() == lineage_id )
+ break;
+
+ if ( it == m_lineage_list.end() ){
+ cout << "Lineage " << lineage_id << " not found." << endl;
+ return 0;
+ }
+ else
+ return ( *it );
+}
+
+
+void cLineageControl::PrintLineageTotals(const cString &filename, bool verbose)
+{
+ ofstream & fp = m_stats.GetDataFileOFStream(filename);
+ assert(fp.good());
+
+ fp << m_stats.GetUpdate();
+ const list<cLineage *> & lineage_list = GetLineageList();
+
+ if ( verbose ){ // in verbose format, we print only those
+ // lineages that are actually present, but
+ // we print much more info
+ fp << ": " << m_stats.SumGeneration().Average() << "\n";
+
+ // let's calculate the average fitness in the population also
+ double fitness_sum = 0;
+ double fitness = 0;
+ int total_num_organisms = 0;
+ int num_organisms = 0;
+
+
+ list<cLineage *>::const_iterator it = lineage_list.begin();
+ for ( ; it != lineage_list.end(); it++ ){
+ num_organisms = (*it)->GetNumCreatures();
+ fitness = (*it)->GetAveFitness();
+ fitness_sum += fitness * num_organisms;
+ total_num_organisms += num_organisms;
+ fp << " "
+ << (*it)->GetID() << " "
+ << (*it)->GetParentID() << " "
+ << (*it)->GetStartFitness() << " "
+ << (*it)->GetMaxFitness() << " "
+ << fitness << " "
+ << num_organisms << " "
+ << (*it)->GetTotalCreatures() << "\n";
+ }
+ fp << "#Dom: " << GetDominantLineage()->GetID()
+ << ", Max: " << GetMaxFitnessLineage()->GetID()
+ << ", Best: " << GetBestLineage()->GetID()
+ << "\n#Pop. fitness: " << fitness_sum / (double) total_num_organisms
+ << "\n" << endl;
+ }
+ else {
+ fp << " ";
+ int cur_id = 0;
+
+ list<cLineage *>::const_iterator it = lineage_list.begin();
+ for ( ; it != lineage_list.end(); it++ ){
+ int next_id = (*it)->GetID();
+ // wind up the current id to the next id
+ for ( ; cur_id < next_id; cur_id++ )
+ fp << "-1 "; // output -1 when we don't have the data
+ fp << (*it)->GetTotalCreatures() << " ";
+ cur_id += 1;
+ }
+ fp << endl;
+ }
+}
+
+
+void cLineageControl::PrintLineageCurCounts(const cString & filename)
+{
+ ofstream & fp = m_stats.GetDataFileOFStream(filename);
+ assert(fp.good());
+
+ fp << m_stats.GetUpdate() << " ";
+ const list<cLineage *> & lineage_list = GetLineageList();
+
+ list<cLineage *>::const_iterator it = lineage_list.begin();
+ int cur_id = 0;
+ for ( ; it != lineage_list.end(); it++ ){
+ int next_id = (*it)->GetID();
+ // wind up the current id to the next id
+ for ( ; cur_id < next_id; cur_id++ )
+ fp << "0 ";
+ fp << (*it)->GetNumCreatures() << " ";
+ cur_id += 1;
+ }
+ fp << endl;
+}
Copied: trunk/source/main/cLineageControl.h (from rev 329, trunk/source/main/lineage_control.hh)
Copied: trunk/source/main/cLocalMutations.cc (from rev 329, trunk/source/main/local_mutations.cc)
===================================================================
--- trunk/source/main/local_mutations.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cLocalMutations.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 LOCAL_MUTATIONS_HH
+#include "cLocalMutations.h"
+#endif
+
+#ifndef MUTATION_HH
+#include "cMutation.h"
+#endif
+#ifndef MUTATION_LIB_HH
+#include "cMutationLib.h"
+#endif
+#ifndef MUTATION_MACROS_HH
+#include "nMutation.h"
+#endif
+
+/////////////////////
+// cLocalMutations
+/////////////////////
+
+cLocalMutations::cLocalMutations(const cMutationLib & _lib, int genome_length)
+ : mut_lib(_lib)
+ , rates(_lib.GetSize())
+{
+ // Setup the rates for this specifc organism.
+ const tArray<cMutation *> & mut_array = mut_lib.GetMutationArray();
+ for (int i = 0; i < rates.GetSize(); i++) {
+ if (mut_array[i]->GetScope() == nMutation::SCOPE_PROP ||
+ mut_array[i]->GetScope() == nMutation::SCOPE_SPREAD) {
+ rates[i] = mut_array[i]->GetRate() / (double) genome_length;
+ }
+ else {
+ rates[i] = mut_array[i]->GetRate();
+ }
+ }
+
+ // Setup the mutation count array.
+ counts.Resize(mut_lib.GetSize(), 0);
+}
+
+cLocalMutations::~cLocalMutations()
+{
+}
Copied: trunk/source/main/cLocalMutations.h (from rev 329, trunk/source/main/local_mutations.hh)
Copied: trunk/source/main/cMutation.cc (from rev 329, trunk/source/main/mutation.cc)
===================================================================
--- trunk/source/main/mutation.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cMutation.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -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 MUTATION_HH
+#include "cMutation.h"
+#endif
+
+
+///////////////
+// cMutation
+///////////////
+
+cMutation::cMutation(const cString & _name, int _id, int _trigger,
+ int _scope, int _type, double _rate)
+ : name(_name)
+ , id(_id)
+ , trigger(_trigger)
+ , scope(_scope)
+ , type(_type)
+ , rate(_rate)
+{
+}
+
+cMutation::~cMutation()
+{
+}
Copied: trunk/source/main/cMutation.h (from rev 329, trunk/source/main/mutation.hh)
Copied: trunk/source/main/cMutationLib.cc (from rev 329, trunk/source/main/mutation_lib.cc)
===================================================================
--- trunk/source/main/mutation_lib.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cMutationLib.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -0,0 +1,51 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 MUTATION_LIB_HH
+#include "cMutationLib.h"
+#endif
+
+#ifndef MUTATION_HH
+#include "cMutation.h"
+#endif
+#ifndef MUTATION_MACROS_HH
+#include "nMutation.h"
+#endif
+
+//////////////////
+// cMutationLib
+//////////////////
+
+cMutationLib::cMutationLib()
+ : trigger_list_array(nMutation::NUM_TRIGGERS)
+{
+}
+
+cMutationLib::~cMutationLib()
+{
+ // Get rid of the trigger lists... This is not required, but since we
+ // are deleting the mutations after this, we should first remove all
+ // references to them.
+ trigger_list_array.Resize(0);
+
+ // Now delete the actual mutations.
+ for (int i = 0; i < mutation_array.GetSize(); i++) {
+ delete mutation_array[i];
+ }
+}
+
+cMutation * cMutationLib::AddMutation(const cString & name, int trigger,
+ int scope, int type, double rate)
+{
+ // Build the new mutation and drop it in the proper trigger list.
+ const int id = GetSize();
+ mutation_array.Resize(id+1);
+ mutation_array[id] = new cMutation(name, id, trigger, scope, type, rate);
+ trigger_list_array[trigger].Push(mutation_array[id]);
+
+ return mutation_array[id];
+}
Copied: trunk/source/main/cMutationLib.h (from rev 329, trunk/source/main/mutation_lib.hh)
Copied: trunk/source/main/cMutationRates.cc (from rev 329, trunk/source/main/mutation_rates.cc)
===================================================================
--- trunk/source/main/mutation_rates.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cMutationRates.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -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 MUTATION_RATES_HH
+#include "cMutationRates.h"
+#endif
+
+#ifndef TOOLS_HH
+#include "tools.hh"
+#endif
+
+////////////////////
+// cMutationRates
+////////////////////
+
+cMutationRates::cMutationRates()
+{
+ Clear();
+}
+
+cMutationRates::cMutationRates(const cMutationRates & in_muts)
+{
+ Copy(in_muts);
+}
+
+cMutationRates::~cMutationRates()
+{
+}
+
+void cMutationRates::Clear()
+{
+ exec.point_mut_prob = 0.0;
+ copy.copy_mut_prob = 0.0;
+ divide.ins_mut_prob = 0.0;
+ divide.del_mut_prob = 0.0;
+ divide.div_mut_prob = 0.0;
+ divide.divide_mut_prob = 0.0;
+ divide.divide_ins_prob = 0.0;
+ divide.divide_del_prob = 0.0;
+ divide.parent_mut_prob = 0.0;
+ divide.crossover_prob = 0.0;
+ divide.aligned_cross_prob = 0.0;
+}
+
+void cMutationRates::Copy(const cMutationRates & in_muts)
+{
+ exec.point_mut_prob = in_muts.exec.point_mut_prob;
+ copy.copy_mut_prob = in_muts.copy.copy_mut_prob;
+ divide.ins_mut_prob = in_muts.divide.ins_mut_prob;
+ divide.del_mut_prob = in_muts.divide.del_mut_prob;
+ divide.div_mut_prob = in_muts.divide.div_mut_prob;
+ divide.divide_mut_prob = in_muts.divide.divide_mut_prob;
+ divide.divide_ins_prob = in_muts.divide.divide_ins_prob;
+ divide.divide_del_prob = in_muts.divide.divide_del_prob;
+ divide.parent_mut_prob = in_muts.divide.parent_mut_prob;
+ divide.crossover_prob = in_muts.divide.crossover_prob;
+ divide.aligned_cross_prob = in_muts.divide.aligned_cross_prob;
+
+ // if (copy.copy_mut_prob != 0) cerr << "Copying non-zero copy mut rate!" << endl;
+}
+
+bool cMutationRates::TestPointMut() const
+{
+ return g_random.P(exec.point_mut_prob);
+}
+
+bool cMutationRates::TestCopyMut() const
+{
+ return g_random.P(copy.copy_mut_prob);
+}
+
+bool cMutationRates::TestDivideMut() const
+{
+ return g_random.P(divide.divide_mut_prob);
+}
+
+bool cMutationRates::TestDivideIns() const
+{
+ return g_random.P(divide.divide_ins_prob);
+}
+
+bool cMutationRates::TestDivideDel() const
+{
+ return g_random.P(divide.divide_del_prob);
+}
+
+bool cMutationRates::TestParentMut() const
+{
+ return g_random.P(divide.parent_mut_prob);
+}
+
+bool cMutationRates::TestCrossover() const
+{
+ return g_random.P(divide.crossover_prob);
+}
+
+bool cMutationRates::TestAlignedCrossover() const
+{
+ return g_random.P(divide.aligned_cross_prob);
+}
Copied: trunk/source/main/cMutationRates.h (from rev 329, trunk/source/main/mutation_rates.hh)
Copied: trunk/source/main/cMxCodeArray.cc (from rev 329, trunk/source/main/mx_code_array.cc)
===================================================================
--- trunk/source/main/mx_code_array.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/cMxCodeArray.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -0,0 +1,482 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 MX_CODE_ARRAY_HH
+#include "cMxCodeArray.h"
+#endif
+
+#ifndef CONFIG_HH
+#include "cConfig.h"
+#endif
+#ifndef CPU_TEST_INFO_HH
+#include "cCPUTestInfo.h"
+#endif
+#ifndef GENOME_HH
+#include "cGenome.h"
+#endif
+#ifndef INST_SET_HH
+#include "cInstSet.h"
+#endif
+#ifndef MY_CODE_ARRAY_LESS_THAN_HH
+#include "MyCodeArrayLessThan.h"
+#endif
+#ifndef ORGANISM_HH
+#include "organism.hh"
+#endif
+#ifndef TEST_CPU_HH
+#include "cTestCPU.h"
+#endif
+#ifndef TOOLS_HH
+#include "tools.hh"
+#endif
+
+#include <iomanip>
+
+using namespace std;
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+// cMxCodeArray
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+const int cMxCodeArray::m_max_gestation_time = 1000000000;
+
+
+cMxCodeArray::cMxCodeArray()
+{
+ // Initialize the code array as empty.
+ size = 0;
+ max_size = 0;
+ data = NULL;
+ m_merit = 0;
+ m_gestation_time = m_max_gestation_time;
+ m_num_instructions = 0;
+}
+
+cMxCodeArray::cMxCodeArray(int n_inst, int in_size, int in_max_size) :m_merit(0), m_gestation_time(m_max_gestation_time), m_num_instructions(n_inst)
+{
+ assert (in_max_size == 0 || in_max_size >= in_size);
+
+ // Initialize the code array randomly.
+ size = in_size;
+ if (in_max_size != 0) max_size = in_max_size;
+ else max_size = size;
+
+ data = new cInstruction[max_size];
+
+ for (int i = 0; i < size; i++)
+ {
+ data[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
+ }
+
+}
+
+cMxCodeArray::cMxCodeArray(const cMxCodeArray &in_code)
+{
+
+ size = in_code.size;
+ max_size = in_code.max_size;
+ m_merit = in_code.m_merit;
+ m_gestation_time = in_code.m_gestation_time;
+ m_num_instructions = in_code.m_num_instructions;
+ m_trans_probs = in_code.m_trans_probs;
+
+ data = new cInstruction[max_size];
+
+ for (int i = 0; i < size; i++)
+ {
+ data[i] = in_code.data[i];
+ }
+
+}
+
+
+cMxCodeArray::cMxCodeArray(const cGenome &in_code, int in_max_size) :m_merit(0), m_gestation_time(m_max_gestation_time), m_num_instructions(0)
+{
+ assert (in_max_size == 0 || in_max_size >= in_code.GetSize());
+
+ size = in_code.GetSize();
+ if (in_max_size != 0) max_size = in_max_size;
+ else max_size = size;
+
+ data = new cInstruction[max_size];
+
+ for (int i = 0; i < size; i++) {
+ data[i] = in_code[i];
+ }
+}
+
+
+cMxCodeArray::~cMxCodeArray()
+{
+ // TODO - what is this?
+ // g_memory.Remove(C_CODE_ARRAY);
+
+ if (data) delete [] data;
+}
+
+void cMxCodeArray::Resize(int new_size)
+{
+ assert (new_size <= MAX_CREATURE_SIZE);
+
+ // If we are not changing the size, just return.
+ if (new_size == size) return;
+
+ // Re-construct the arrays only if we have to...
+ if (new_size > max_size || new_size * 4 < max_size) {
+ cInstruction * new_data = new cInstruction[new_size];
+
+ for (int i = 0; i < size && i < new_size; i++) {
+ new_data[i] = data[i];
+ }
+
+ if (data) delete [] data;
+
+ data = new_data;
+ max_size = new_size;
+ }
+
+ // Fill in the un-filled-in bits...
+ for (int i = size; i < new_size; i++) {
+ data[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
+ }
+
+ size = new_size;
+}
+
+// Resize the arrays, and leave memeory uninitializes! (private method)
+void cMxCodeArray::ResetSize(int new_size, int new_max)
+{
+ assert (new_size >= 0);
+ assert (new_max == 0 || new_max >= new_size);
+
+ // If we are clearing it totally, do so.
+ if (!new_size) {
+ if (data) delete [] data;
+ data = NULL;
+ size = 0;
+ max_size = 0;
+ return;
+ }
+
+ // If a new max is _not_ being set, see if one needs to be.
+ if (new_max == 0 &&
+ (max_size < new_size) || (max_size > new_size * 2)) {
+ new_max = new_size;
+ }
+
+ // If the arrays need to be rebuilt, do so.
+ if (new_max != 0 && new_max != max_size) {
+ cInstruction * new_data = new cInstruction[new_max];
+
+ if (data) delete [] data;
+ data = new_data;
+ max_size = new_max;
+ }
+
+ // Reset the array size.
+ size = new_size;
+}
+
+/**
+ * Resizes and reinitializes the genome. The previous data is lost.
+ **/
+void cMxCodeArray::Reset()
+{
+ // Initialze the array
+ if( cConfig::GetAllocMethod() == ALLOC_METHOD_RANDOM ){
+ // Randomize the initial contents of the new array.
+ Randomize();
+ }else{
+ // Assume default instuction initialization
+ Clear();
+ }
+}
+
+/**
+ * Sets all instructions to @ref cInstruction::GetInstDefault().
+ **/
+void cMxCodeArray::Clear()
+{
+ int i;
+ for (i = 0; i < size; i++)
+ {
+ data[i] = cInstSet::GetInstDefault();
+ }
+}
+
+/**
+ * Replaces all instructions in the genome with a sequence of random
+ * instructions.
+ **/
+
+void cMxCodeArray::Randomize()
+{
+ int i;
+ for (i = 0; i < size; i++)
+ {
+ data[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
+ }
+}
+
+void cMxCodeArray::operator=(const cMxCodeArray & other_code)
+{
+ // If we need to resize, do so...
+
+ ResetSize(other_code.size);
+
+ // Now that both code arrays are the same size, copy the other one over.
+
+ for (int i = 0; i < size; i++)
+ {
+ data[i] = other_code.data[i];
+ }
+
+ m_merit = other_code.m_merit;
+ m_gestation_time = other_code.m_gestation_time;
+ m_num_instructions = other_code.m_num_instructions;
+ m_trans_probs = other_code.m_trans_probs;
+}
+
+
+/*
+ * Let the 0th instruction be the least significant,
+ * so longer codes are always greater.
+ */
+bool cMxCodeArray::operator<(const cMxCodeArray &other_code) const
+{
+
+ if (size < other_code.size)
+ return true;
+ else if (size > other_code.size)
+ return false;
+
+ bool result = false;
+
+ for (int i = size-1; i >= 0; i-- )
+ {
+ if (data[i].GetOp() < other_code.data[i].GetOp())
+ {
+ result = true;
+ break;
+ }
+ else if (other_code.data[i].GetOp() < data[i].GetOp())
+ {
+ result = false;
+ break;
+ }
+ }
+
+ return result;
+}
+
+
+void cMxCodeArray::CopyDataTo(cGenome & other_code) const
+{
+ // @CAO this is ugly, but the only option I see...
+ other_code = cGenome(size);
+
+ for (int i = 0; i < size; i++) {
+ other_code[i] = data[i];
+ }
+}
+
+bool cMxCodeArray::OK() const
+{
+ bool result = true;
+
+ assert (size >= 0 && size <= max_size && max_size <= MAX_CREATURE_SIZE);
+
+ return result;
+}
+
+
+int cMxCodeArray::FindInstruction(const cInstruction & inst, int start_index)
+{
+ assert(start_index < GetSize());
+ for(int i=0; i<GetSize(); ++i ){
+ if( Get(i) == inst ){
+ return i;
+ }
+ }
+ return -1;
+}
+
+cString cMxCodeArray::AsString() const
+{
+ cString out_string(size);
+ for (int i = 0; i < size; i++) {
+ int cur_char = data[i].GetOp();
+ if (cur_char < 26) {
+ out_string[i] = cur_char + 'a';
+ } else if (cur_char < 52) {
+ out_string[i] = cur_char - 26 + 'A';
+ } else if (cur_char < 62) {
+ out_string[i] = cur_char - 52 + '1';
+ } else {
+ out_string[i] = '*';
+ }
+ }
+
+ return out_string;
+}
+
+
+void cMxCodeArray::Get1Mutants(list<cMxCodeArray>& mutants) const
+{
+ for (int line_num = 0; line_num < size; line_num++)
+ {
+ int cur_inst = data[line_num].GetOp();
+
+ for (int inst_num = 0; inst_num < m_num_instructions; inst_num++)
+ {
+ if (cur_inst == inst_num) continue;
+
+ cMxCodeArray newMutant(*this);
+ newMutant[line_num].SetOp(inst_num);
+ mutants.push_back(newMutant);
+ }
+ }
+}
+
+
+/*
+ Make a list of the transition probabilities only to those other
+ genotypes that are within the given hamming distance of this
+ genotype.
+
+ The list is actually implemented as a map from indexes to
+ probabilities, where the index is the place of the genotype in
+ the complete ordered set of genotypes.
+
+ TODO this seems kind of inefficient that you have to calculate the
+ hamming distance twice - maybe I should pass it as a parameter to
+ the TransitionProbability function after it is first calculated? Or
+ maybe the threshold should be in the transition probability?
+*/
+
+ /* dropped const for win32 -- kgn */
+//int cMxCodeArray::MakeTransitionList(const set<cMxCodeArray, MyCodeArrayLessThan > &data_set, int hamDistThresh, double errorRate) const
+int cMxCodeArray::MakeTransitionList(set<cMxCodeArray, MyCodeArrayLessThan > &data_set, int hamDistThresh, double errorRate) const
+{
+ set<cMxCodeArray, MyCodeArrayLessThan >::iterator set_iter;
+ int index = 0;
+ double totalProb = 0.0;
+ int num = 0;
+
+ for (set_iter = data_set.begin(); set_iter != data_set.end(); set_iter++, index++)
+ {
+ if (HammingDistance(*set_iter) <= hamDistThresh)
+ {
+ double transProb = TransitionProbability(*set_iter, errorRate);
+ m_trans_probs[index] = transProb * GetFitness();
+ totalProb += transProb;
+ num += 1;
+ }
+ else
+ {
+ m_trans_probs[index]= 0.0;
+ }
+ }
+
+ /* The transition probability for "other"
+ index got incremented at the very end of the loop so its pointing
+ to the next element now */
+
+ m_trans_probs[index] = (1.0 - totalProb) * GetFitness();
+
+ return num;
+
+}
+
+
+const map<int, double, less<int> >& cMxCodeArray::GetTransitionList() const
+{
+ return m_trans_probs;
+}
+
+
+int cMxCodeArray::HammingDistance(const cMxCodeArray &other_gene) const
+{
+ int distance = 0;
+
+ assert (size == other_gene.GetSize());
+
+ for (int i = 0; i < size; i++)
+ {
+ if (this->Get(i) != other_gene.Get(i))
+ distance++;
+ }
+
+ return distance;
+}
+
+
+double cMxCodeArray::TransitionProbability(const cMxCodeArray &other_gene, double errorRate) const
+{
+ double Q = 0.0;
+ assert (size == other_gene.GetSize());
+
+ if ( (*this) == other_gene)
+ {
+ Q = pow((1-errorRate), size);
+ }
+ else
+ {
+ int distance = HammingDistance(other_gene);
+ Q = pow((1.0-errorRate), (size -distance)) * pow((errorRate/m_num_instructions),distance);
+ }
+
+ return Q;
+}
+
+/*
+ Used in testing the diagonalization.
+*/
+
+void cMxCodeArray::PrintTransitionList(ostream &fp, int size) const
+{
+
+ fp.setf(ios::fixed);
+
+ fp << "{" ;
+
+ for (int index=0 ; index < size; index++)
+ {
+ map<int, double, less<int> >::const_iterator find_results = m_trans_probs.find(index);
+ if (find_results == m_trans_probs.end())
+ {
+ fp << 0.0 ;
+ }
+ else
+ {
+ fp << setprecision(10) << (*find_results).second ;
+ }
+
+ if (index < size-1)
+ fp << " , " ;
+
+ }
+
+ fp << "}" ;
+}
+
+
+void cMxCodeArray::CalcFitness()
+{
+ cGenome temp(1);
+ cCPUTestInfo test_info;
+ CopyDataTo(temp);
+ cTestCPU::TestGenome(test_info, temp);
+ if ( test_info.IsViable() )
+ m_gestation_time =
+ test_info.GetTestOrganism()->GetPhenotype().GetGestationTime();
+ else // if not viable, set a really high gestation time
+ m_gestation_time = m_max_gestation_time;
+ m_merit = test_info.GetTestOrganism()->GetPhenotype().GetMerit().GetDouble();
+}
Copied: trunk/source/main/cMxCodeArray.h (from rev 329, trunk/source/main/mx_code_array.hh)
Deleted: trunk/source/main/genotype_macros.hh
===================================================================
--- trunk/source/main/genotype_macros.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/genotype_macros.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,19 +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_MACROS_HH
-#define GENOTYPE_MACROS_HH
-
-#define GENOTYPE_HASH_SIZE 3203 // @CAO Is this an optimal number?
-#define SPECIES_HASH_SIZE 101
-#define GENOTYPE_THREADS 2
-
-#define SPECIES_RECORD_OFF 0
-#define SPECIES_RECORD_FULL 1
-#define SPECIES_RECORD_LIMITED 2
-
-#endif
Deleted: trunk/source/main/inject_genebank_macros.hh
===================================================================
--- trunk/source/main/inject_genebank_macros.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/inject_genebank_macros.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,19 +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_MACROS_HH
-#define INJECT_GENEBANK_MACROS_HH
-
-#define INJECTGENOTYPE_HASH_SIZE 307 // @CAO Is this an optimal number?
-#define SPECIES_HASH_SIZE 101
-#define INJECTGENOTYPE_THREADS 2
-
-#define SPECIES_RECORD_OFF 0
-#define SPECIES_RECORD_FULL 1
-#define SPECIES_RECORD_LIMITED 2
-
-#endif
Deleted: trunk/source/main/landscape.cc
===================================================================
--- trunk/source/main/landscape.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/landscape.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,863 +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 "landscape.hh"
-
-#include "cCPUMemory.h"
-#include "cEnvironment.h"
-#include "cInstSet.h"
-#include "organism.hh"
-#include "phenotype.hh"
-#include "stats.hh" // For GetUpdate in outputs...
-#include "cTestCPU.h"
-#include "cTestUtil.h"
-#include "tools.hh"
-
-using namespace std;
-
-
-////////////////
-// cLandscape
-////////////////
-
-cLandscape::cLandscape(const cGenome & in_genome, const cInstSet & in_inst_set)
- : inst_set(in_inst_set), base_genome(1), peak_genome(1)
-{
- site_count = NULL;
- Reset(in_genome);
-}
-
-cLandscape::~cLandscape()
-{
- if (site_count != NULL) delete [] site_count;
-}
-
-void cLandscape::Reset(const cGenome & in_genome)
-{
- base_genome = in_genome;
- peak_genome = in_genome;
- base_fitness = 0.0;
- base_merit = 0.0;
- base_gestation = 0;
- peak_fitness = 0.0;
- total_fitness = 0.0;
- total_sqr_fitness = 0.0;
- distance = 0;
- del_distance = 0;
- ins_distance = 0;
- trials = 0;
-
- total_count = 0;
- dead_count = 0;
- neg_count = 0;
- neut_count = 0;
- pos_count = 0;
-
- pos_size = 0;
- neg_size = 0;
-
- total_epi_count = 0;
- pos_epi_count = 0;
- neg_epi_count = 0;
- no_epi_count = 0;
- dead_epi_count= 0;
-
- pos_epi_size = 0;
- neg_epi_size = 0;
- no_epi_size = 0;
-
- if (site_count != NULL) delete [] site_count;
- site_count = new int[base_genome.GetSize() + 1];
- for (int i = 0; i <= base_genome.GetSize(); i++) site_count[i] = 0;
-
- total_entropy = 0.0;
- complexity = 0.0;
- neut_min = 0.0;
- neut_max = 0.0;
-}
-
-void cLandscape::ProcessGenome(cGenome & in_genome)
-{
- cTestCPU::TestGenome(test_info, in_genome);
-
- test_fitness = test_info.GetColonyFitness();
-
- total_fitness += test_fitness;
- total_sqr_fitness += test_fitness * test_fitness;
- total_count++;
- if (test_fitness == 0) {
- dead_count++;
- } else if (test_fitness < neut_min) {
- neg_count++;
- neg_size = neg_size + test_fitness ;
- } else if (test_fitness <= neut_max) {
- neut_count++;
- } else {
- pos_count++;
- pos_size = pos_size + test_fitness ;
- if (test_fitness > peak_fitness) {
- peak_fitness = test_fitness;
- peak_genome = in_genome;
- }
- }
-}
-
-void cLandscape::ProcessBase()
-{
- // Collect info on base creature.
-
- cTestCPU::TestGenome(test_info, base_genome);
-
- cPhenotype & phenotype = test_info.GetColonyOrganism()->GetPhenotype();
- base_fitness = phenotype.GetFitness();
- base_merit = phenotype.GetMerit().GetDouble();
- base_gestation = phenotype.GetGestationTime();
-
- peak_fitness = base_fitness;
- peak_genome = base_genome;
-
- neut_min = base_fitness * nHardware::FITNESS_NEUTRAL_MIN;
- neut_max = base_fitness * nHardware::FITNESS_NEUTRAL_MAX;
-
-}
-
-void cLandscape::Process(int in_distance)
-{
- distance = in_distance;
-
- // Get the info about the base creature.
- ProcessBase();
-
- // Now Process the new creature at the proper distance.
- Process_Body(base_genome, distance, 0);
-
- // Calculate the complexity...
-
- double max_ent = log((double) inst_set.GetSize());
- for (int i = 0; i < base_genome.GetSize(); i++) {
- total_entropy += (log((double) site_count[i] + 1) / max_ent);
- }
- complexity = base_genome.GetSize() - total_entropy;
-}
-
-
-// For distances greater than one, this needs to be called recursively.
-
-void cLandscape::Process_Body(cGenome & cur_genome, int cur_distance,
- int start_line)
-{
- const int max_line = base_genome.GetSize() - cur_distance + 1;
- const int inst_size = inst_set.GetSize();
-
- cGenome mod_genome(cur_genome);
-
- // Loop through all the lines of genome, testing trying all combinations.
- for (int line_num = start_line; line_num < max_line; line_num++) {
- int cur_inst = base_genome[line_num].GetOp();
-
- // Loop through all instructions...
- for (int inst_num = 0; inst_num < inst_size; inst_num++) {
- if (cur_inst == inst_num) continue;
-
- mod_genome[line_num].SetOp(inst_num);
- if (cur_distance <= 1) {
- ProcessGenome(mod_genome);
- if (test_info.GetColonyFitness() >= neut_min) site_count[line_num]++;
- } else {
- Process_Body(mod_genome, cur_distance - 1, line_num + 1);
- }
- }
-
- mod_genome[line_num].SetOp(cur_inst);
- }
-
-}
-
-void cLandscape::ProcessDelete()
-{
- // Get the info about the base creature.
- ProcessBase();
-
- const int max_line = base_genome.GetSize();
- cCPUMemory mod_genome(base_genome);
-
- // Loop through all the lines of genome, testing all deletions.
- for (int line_num = 0; line_num < max_line; line_num++) {
- int cur_inst = base_genome[line_num].GetOp();
- mod_genome.Remove(line_num);
- ProcessGenome(mod_genome);
- if (test_info.GetColonyFitness() >= neut_min) site_count[line_num]++;
- mod_genome.Insert(line_num, cInstruction(cur_inst));
- }
-
-}
-
-void cLandscape::ProcessInsert()
-{
- // Get the info about the base creature.
- ProcessBase();
-
- const int max_line = base_genome.GetSize();
- const int inst_size = inst_set.GetSize();
-
- cCPUMemory mod_genome(base_genome);
-
- // Loop through all the lines of genome, testing all insertions.
- for (int line_num = 0; line_num <= max_line; line_num++) {
- // Loop through all instructions...
- for (int inst_num = 0; inst_num < inst_size; inst_num++) {
- mod_genome.Insert(line_num, cInstruction(inst_num));
- ProcessGenome(mod_genome);
- if (test_info.GetColonyFitness() >= neut_min) site_count[line_num]++;
- mod_genome.Remove(line_num);
- }
- }
-
-}
-
-// Prediction for a landscape where n sites are _randomized_.
-void cLandscape::PredictWProcess(ostream & fp, int update)
-{
- distance = 1;
-
- // Get the info about the base creature.
- ProcessBase();
- if (base_fitness == 0.0) return;
-
- BuildFitnessChart();
- const int genome_size = fitness_chart.GetNumRows();
- const int inst_size = fitness_chart.GetNumCols();
- const double min_neut_fitness = 0.99;
- const double max_neut_fitness = 1.01;
-
- // Loop through the entries printing them and doing additional
- // calculations.
- int total_pos_found = 0;
- int total_neut_found = 0;
- int total_neg_found = 0;
- int total_dead_found = 0;
- double max_fitness = 1.0;
- double total_fitness = 0.0;
- double total_sqr_fitness = 0.0;
-
- for (int row = 0; row < genome_size; row++) {
- double max_line_fitness = 1.0;
- for (int col = 0; col < inst_size; col++) {
- double & cur_fitness = fitness_chart(row, col);
- cur_fitness /= base_fitness;
- total_fitness += cur_fitness;
- total_sqr_fitness += cur_fitness * cur_fitness;
- if (cur_fitness > max_neut_fitness) total_pos_found++;
- else if (cur_fitness > min_neut_fitness) total_neut_found++;
- else if (cur_fitness > 0.0) total_neg_found++;
-
- if (cur_fitness > max_line_fitness) max_line_fitness = cur_fitness;
- }
- max_fitness *= max_line_fitness;
- }
-
- const int total_tests = genome_size * inst_size;
- total_dead_found = total_tests - total_pos_found - total_neut_found - total_neg_found;
- fp << update << " "
- << "1 "
- << ((double) total_dead_found / (double) total_tests) << " "
- << ((double) total_neg_found / (double) total_tests) << " "
- << ((double) total_neut_found / (double) total_tests) << " "
- << ((double) total_pos_found / (double) total_tests) << " "
- << total_tests << " "
- << total_neut_found + total_pos_found << " "
- << total_fitness / (double) total_tests << " "
- << total_sqr_fitness / (double) total_tests << " "
- << endl;
- fp.flush();
-
- // Sample the table out to 10 mutations
- const int max_muts = 10;
- const int min_found = 100;
- const int min_tests = 10000;
- const int max_tests = 1000000000;
-
- double test_fitness;
- for (int num_muts = 2; num_muts <= max_muts; num_muts++) {
- total_pos_found = 0;
- total_neut_found = 0;
- total_neg_found = 0;
- total_fitness = 0.0;
- total_sqr_fitness = 0.0;
- tArray<int> mut_lines(num_muts);
-
- int test_id = 0;
- while ((test_id < min_tests) ||
- (test_id < max_tests && (total_neut_found + total_pos_found) < min_found)) {
- g_random.Choose(genome_size, mut_lines);
- test_fitness = 1.0;
- for (int j = 0; j < num_muts && test_fitness != 0.0; j++) {
- test_fitness *=
- fitness_chart(mut_lines[j], g_random.GetUInt(inst_size));
- }
- total_fitness += test_fitness;
- total_sqr_fitness += test_fitness * test_fitness;
- if (test_fitness > max_neut_fitness) total_pos_found++;
- else if (test_fitness > min_neut_fitness) total_neut_found++;
- else if (test_fitness > 0.0) total_neg_found++;
-
- test_id++;
- }
-
- total_dead_found = test_id - total_pos_found - total_neut_found - total_neg_found;
- fp << update << " " // 1
- << num_muts << " " // 2
- << ((double) total_dead_found / (double) test_id) << " " // 3
- << ((double) total_neg_found / (double) test_id) << " " // 4
- << ((double) total_neut_found / (double) test_id) << " " // 5
- << ((double) total_pos_found / (double) test_id) << " " // 6
- << test_id << " " // 7
- << total_neut_found + total_pos_found << " " // 8
- << total_fitness / (double) test_id << " " // 9
- << total_sqr_fitness / (double) test_id << " " // 10
- << endl;
- fp.flush();
-
- if (total_pos_found + total_neut_found < min_found / 2) break;
- }
-
- // Calculate the complexity...
-
- double max_ent = log((double) inst_set.GetSize());
- for (int i = 0; i < base_genome.GetSize(); i++) {
- total_entropy += (log((double) site_count[i] + 1) / max_ent);
- }
- complexity = base_genome.GetSize() - total_entropy;
-}
-
-
-// Prediction for a landscape where n sites are _mutated_.
-void cLandscape::PredictNuProcess(ostream & fp, int update)
-{
- distance = 1;
-
- // Get the info about the base creature.
- ProcessBase();
- if (base_fitness == 0.0) return;
-
- BuildFitnessChart();
- const int genome_size = fitness_chart.GetNumRows();
- const int inst_size = fitness_chart.GetNumCols();
- const double min_neut_fitness = 0.99;
- const double max_neut_fitness = 1.01;
-
- // Loop through the entries printing them and doing additional
- // calculations.
- int total_pos_found = 0;
- int total_neut_found = 0;
- int total_neg_found = 0;
- int total_dead_found = 0;
- int total_live_found = 0;
- double max_fitness = 1.0;
- double max_found_fitness = 0.0;
- double total_fitness = 0.0;
- double total_sqr_fitness = 0.0;
-
- for (int row = 0; row < genome_size; row++) {
- double max_line_fitness = 1.0;
- int base_inst = base_genome[row].GetOp();
- for (int col = 0; col < inst_size; col++) {
- if (col == base_inst) continue; // Only consider changes to line!
- double & cur_fitness = fitness_chart(row, col);
- cur_fitness /= base_fitness;
- total_fitness += cur_fitness;
- total_sqr_fitness += cur_fitness * cur_fitness;
- if (cur_fitness > max_neut_fitness) total_pos_found++;
- else if (cur_fitness > min_neut_fitness) total_neut_found++;
- else if (cur_fitness > 0.0) total_neg_found++;
-
- if (cur_fitness > max_line_fitness) max_line_fitness = cur_fitness;
- }
- max_fitness *= max_line_fitness;
- if (max_line_fitness > max_found_fitness) max_found_fitness = max_line_fitness;
- }
-
- const int total_tests = genome_size * inst_size;
- total_live_found = total_pos_found + total_neut_found + total_neg_found;
- total_dead_found = total_tests - total_live_found;
- fp << update << " "
- << "1 "
- << ((double) total_dead_found / (double) total_tests) << " "
- << ((double) total_neg_found / (double) total_tests) << " "
- << ((double) total_neut_found / (double) total_tests) << " "
- << ((double) total_pos_found / (double) total_tests) << " "
- << total_tests << " "
- << total_live_found << " "
- << total_fitness / (double) total_tests << " "
- << total_sqr_fitness / (double) total_tests << " "
- << max_found_fitness << " "
- << endl;
- fp.flush();
-
- // Sample the table out to 10 mutations
- const int max_muts = 10;
- const int min_found = 100;
- const int min_tests = 10000;
- const int max_tests = 1000000000;
-
- double test_fitness;
- for (int num_muts = 2; num_muts <= max_muts; num_muts++) {
- total_pos_found = 0;
- total_neut_found = 0;
- total_neg_found = 0;
- total_fitness = 0.0;
- total_sqr_fitness = 0.0;
- max_found_fitness = 0.0;
- tArray<int> mut_lines(num_muts);
-
- int test_id = 0;
- while ((test_id < min_tests) ||
- (test_id < max_tests && (total_neg_found + total_neut_found + total_pos_found) < min_found)) {
- g_random.Choose(genome_size, mut_lines);
- test_fitness = 1.0;
- for (int j = 0; j < num_muts && test_fitness != 0.0; j++) {
- int base_inst = base_genome[ mut_lines[j] ].GetOp();
- int mut_inst = g_random.GetUInt(inst_size);
- while (mut_inst == base_inst) mut_inst = g_random.GetUInt(inst_size);
- test_fitness *= fitness_chart(mut_lines[j], mut_inst);
- if (test_fitness == 0.0) break;
- }
- total_fitness += test_fitness;
- total_sqr_fitness += test_fitness * test_fitness;
- if (test_fitness > max_found_fitness) max_found_fitness = test_fitness;
-
- if (test_fitness > max_neut_fitness) total_pos_found++;
- else if (test_fitness > min_neut_fitness) total_neut_found++;
- else if (test_fitness > 0.0) total_neg_found++;
-
- test_id++;
- }
-
- total_live_found = total_neg_found + total_neut_found + total_pos_found;
- total_dead_found = test_id - total_live_found;
-
-
- fp << update << " " // 1
- << num_muts << " " // 2
- << ((double) total_dead_found / (double) test_id) << " " // 3
- << ((double) total_neg_found / (double) test_id) << " " // 4
- << ((double) total_neut_found / (double) test_id) << " " // 5
- << ((double) total_pos_found / (double) test_id) << " " // 6
- << test_id << " " // 7
- << total_live_found << " " // 8
- << total_fitness / (double) test_id << " " // 9
- << total_sqr_fitness / (double) test_id << " " // 10
- << max_found_fitness << " " // 11
- << endl;
- fp.flush();
-
- if (total_live_found < min_found / 2) break;
- }
-
- // Calculate the complexity...
-
- double max_ent = log((double) inst_set.GetSize());
- for (int i = 0; i < base_genome.GetSize(); i++) {
- total_entropy += (log((double) site_count[i] + 1) / max_ent);
- }
- complexity = base_genome.GetSize() - total_entropy;
-}
-
-
-void cLandscape::SampleProcess(int in_trials)
-{
- trials = in_trials; // Trials _per line_
- distance = 1;
-
- cGenome mod_genome(base_genome);
- int genome_size = base_genome.GetSize();
-
- ProcessBase();
-
- // Loop through all the lines of genome, testing each line.
- for (int line_num = 0; line_num < genome_size; line_num++) {
- cInstruction cur_inst( base_genome[line_num] );
-
- for (int i = 0; i < trials; i++) {
- // Choose the new instruction for that line...
- cInstruction new_inst( inst_set.GetRandomInst() );
- if (cur_inst == new_inst) { i--; continue; }
-
- // Make the change, and test it!
- mod_genome[line_num] = new_inst;
- ProcessGenome(mod_genome);
- }
-
- mod_genome[line_num] = cur_inst;
- }
-}
-
-
-int cLandscape::RandomProcess(int in_trials, int in_distance, int min_found,
- int max_trials, bool print_if_found)
-{
- distance = in_distance;
-
- cGenome mod_genome(base_genome);
- int genome_size = base_genome.GetSize();
-
- ProcessBase();
-
- int mut_num;
- tArray<int> mut_lines(distance);
-
- // Loop through all the lines of genome, testing many combinations.
- int cur_trial = 0;
- int total_found = 0;
-
-// for (cur_trial = 0;
-// (cur_trial < in_trials) ||
-// (total_found < min_found && cur_trial < max_trials);
-// cur_trial++) {
-// Way too confusing and not being used, commented it out DM
-
- for (cur_trial = 0; cur_trial < in_trials; cur_trial++) {
-
- // Choose the lines to mutate...
- g_random.Choose(genome_size, mut_lines);
-
- // Choose the new instructions for those lines...
- for (mut_num = 0; mut_num < distance; mut_num++) {
- const cInstruction new_inst( inst_set.GetRandomInst() );
- const cInstruction & cur_inst = base_genome[ mut_lines[mut_num] ];
- if (cur_inst == new_inst) {
- mut_num--;
- continue;
- }
-
- mod_genome[ mut_lines[mut_num] ] = new_inst;
- }
-
- // And test it!
-
- ProcessGenome(mod_genome);
-
- // if (test_info.IsViable()) {
- //if (test_fitness >= neut_min) {
- // total_found++;
- // If we are supposed to print those found, do so!
- // if (print_if_found) {
- // cString filename;
- // filename.Set("creature.land.%d.%d", distance, cur_trial);
- // cTestUtil::PrintGenome(mod_genome, filename);
- // }
- //}
-
-
- // And reset the genome.
- for (mut_num = 0; mut_num < distance; mut_num++) {
- mod_genome[ mut_lines[mut_num] ] = base_genome[ mut_lines[mut_num] ];
- }
- }
-
- trials = cur_trial;
-
- return total_found;
-}
-
-void cLandscape::BuildFitnessChart()
-{
- // First, resize the fitness_chart.
- const int max_line = base_genome.GetSize();
- const int inst_size = inst_set.GetSize();
- fitness_chart.ResizeClear(max_line, inst_size);
-
- cGenome mod_genome(base_genome);
-
- // Loop through all the lines of genome, testing trying all combinations.
- for (int line_num = 0; line_num < max_line; line_num++) {
- int cur_inst = base_genome[line_num].GetOp();
-
- // Loop through all instructions...
- for (int inst_num = 0; inst_num < inst_size; inst_num++) {
- if (cur_inst == inst_num) {
- fitness_chart(line_num, inst_num) = base_fitness;
- continue;
- }
-
- mod_genome[line_num].SetOp(inst_num);
- ProcessGenome(mod_genome);
- fitness_chart(line_num, inst_num) = test_info.GetColonyFitness();
- }
-
- mod_genome[line_num].SetOp(cur_inst);
- }
-
-}
-
-void cLandscape::TestPairs(int in_trials, ostream & fp)
-{
- trials = in_trials;
-
- ProcessBase();
- if (base_fitness == 0.0) return;
-
- BuildFitnessChart();
-
- cGenome mod_genome(base_genome);
- const int genome_size = base_genome.GetSize();
-
- tArray<int> mut_lines(2);
- tArray<cInstruction> mut_insts(2);
-
- // Loop through all the lines of genome, testing many combinations.
- for (int i = 0; i < trials; i++) {
- // Choose the lines to mutate...
- g_random.Choose(genome_size, mut_lines);
-
- // Choose the new instructions for those lines...
- for (int mut_num = 0; mut_num < 2; mut_num++) {
- const cInstruction new_inst( inst_set.GetRandomInst() );
- const cInstruction & cur_inst = base_genome[ mut_lines[mut_num] ];
- if (cur_inst == new_inst) {
- mut_num--;
- continue;
- }
-
- mut_insts[mut_num] = new_inst;
- }
-
- TestMutPair(mod_genome, mut_lines[0], mut_lines[1], mut_insts[0],
- mut_insts[1], fp);
-
- }
-
-}
-
-
-void cLandscape::TestAllPairs(ostream & fp)
-{
- ProcessBase();
- if (base_fitness == 0.0) return;
-
- BuildFitnessChart();
-
- const int max_line = base_genome.GetSize();
- const int inst_size = inst_set.GetSize();
- cGenome mod_genome(base_genome);
- cInstruction inst1, inst2;
-
- // Loop through all the lines of genome, testing trying all combinations.
- for (int line1_num = 0; line1_num < max_line - 1; line1_num++) {
- for (int line2_num = line1_num + 1; line2_num < max_line; line2_num++) {
-
- // Loop through all instructions...
- for (int inst1_num = 0; inst1_num < inst_size; inst1_num++) {
- inst1.SetOp(inst1_num);
- if (inst1 == base_genome[line1_num]) continue;
- for (int inst2_num = 0; inst2_num < inst_size; inst2_num++) {
- inst2.SetOp(inst2_num);
- if (inst2 == base_genome[line2_num]) continue;
- TestMutPair(mod_genome, line1_num, line2_num, inst1, inst2, fp);
- } // inst2_num loop
- } //inst1_num loop;
-
- } // line2_num loop
- } // line1_num loop.
-
-}
-
-
-void cLandscape::HillClimb(ofstream & fp)
-{
- cGenome cur_genome(base_genome);
- int gen = 0;
- HillClimb_Body(fp, cur_genome, gen);
-}
-
-void cLandscape::HillClimb_Body(ofstream & fp, cGenome & cur_genome,
- int & gen)
-{
- cCPUMemory mod_genome(base_genome);
-
- const int inst_size = inst_set.GetSize();
-
- double pos_frac = 1.0;
-
- bool finished = false;
- while (finished == false) {
- if (pos_frac == 0.0) finished = true;
-
- // Search the landscape for the next best.
- Reset(cur_genome);
- const int max_line = cur_genome.GetSize();
-
- // Try all Mutations...
- Process(1);
-
- // Try Insertion Mutations.
-
- mod_genome = cur_genome;
- for (int line_num = 0; line_num <= max_line; line_num++) {
- // Loop through all instructions...
- for (int inst_num = 0; inst_num < inst_size; inst_num++) {
- mod_genome.Insert(line_num, cInstruction(inst_num));
- ProcessGenome(mod_genome);
- mod_genome.Remove(line_num);
- }
- }
-
- // Try all deletion mutations.
-
- for (int line_num = 0; line_num < max_line; line_num++) {
- int cur_inst = cur_genome[line_num].GetOp();
- mod_genome.Remove(line_num);
- ProcessGenome(mod_genome);
- mod_genome.Insert(line_num, cInstruction(cur_inst));
- }
-
- pos_frac = GetProbPos();
-
- // Print the information on the current best.
- HillClimb_Print(fp, cur_genome, gen);
-
- // Move on to the peak genome found.
- cur_genome = GetPeakGenome();
- gen++;
- }
-}
-
-void cLandscape::HillClimb_Neut(ofstream & fp)
-{
-}
-
-void cLandscape::HillClimb_Rand(ofstream & fp)
-{
-}
-
-void cLandscape::HillClimb_Print(ofstream & fp, const cGenome & _genome, const int gen) const
-{
- cCPUTestInfo test_info;
- cTestCPU::TestGenome(test_info, _genome);
- cPhenotype &colony_phenotype = test_info.GetColonyOrganism()->GetPhenotype();
- fp << gen << " "
- << colony_phenotype.GetMerit().GetDouble() << " "
- << colony_phenotype.GetGestationTime() << " "
- << colony_phenotype.GetFitness() << " "
- << _genome.GetSize() << " "
- << GetProbDead() << " "
- << GetProbNeg() << " "
- << GetProbNeut() << " "
- << GetProbPos() << " "
- << endl;
-}
-
-double cLandscape::TestMutPair(cGenome & mod_genome, int line1, int line2,
- const cInstruction & mut1, const cInstruction & mut2, ostream & fp)
-{
- mod_genome[line1] = mut1;
- mod_genome[line2] = mut2;
- cTestCPU::TestGenome(test_info, mod_genome);
- double combo_fitness = test_info.GetColonyFitness() / base_fitness;
-
- mod_genome[line1] = base_genome[line1];
- mod_genome[line2] = base_genome[line2];
-
- double mut1_fitness = fitness_chart(line1, mut1.GetOp()) / base_fitness;
- double mut2_fitness = fitness_chart(line2, mut2.GetOp()) / base_fitness;
- double mult_combo = mut1_fitness * mut2_fitness;
-
- /*
- fp << line1 << " "
- << line2 << " "
- << ( (int) mut1.GetOp() ) << " "
- << ( (int) mut2.GetOp() ) << " ";
-
- fp << ( fitness_chart(line1, mut1.GetOp()) / base_fitness ) << " "
- << ( fitness_chart(line2, mut2.GetOp()) / base_fitness ) << " "
- << combo_fitness << endl;
- */
-
- total_epi_count++;
- if ((mut1_fitness==0 || mut2_fitness==0)&&(combo_fitness==0)) {
- dead_epi_count++;
- } else if (combo_fitness < mult_combo) {
- neg_epi_count++;
- neg_epi_size = neg_epi_size + combo_fitness;
- } else if (combo_fitness > mult_combo) {
- pos_epi_count++;
- pos_epi_size = pos_epi_size + combo_fitness;
- } else {
- no_epi_count++;
- no_epi_size = no_epi_size + combo_fitness;
- }
-
- return combo_fitness;
-}
-
-
-void cLandscape::PrintStats(ofstream & fp, int update)
-{
- fp << update << " " // 1
- << GetProbDead() << " " // 2
- << GetProbNeg() << " " // 3
- << GetProbNeut() << " " // 4
- << GetProbPos() << " " // 5
-// << pos_size << " " // 6
-// << pos_count << " " // 6
- << GetAvPosSize() << " " // 6
- << GetAvNegSize() << " " // 7
- << total_count << " " // 8
- << distance << " " // 9
-// << neut_min << " " // 10
-// << neut_max << " " // 10
-// << nHardware::FITNESS_NEUTRAL_MIN << " " // 10
-// << nHardware::FITNESS_NEUTRAL_MAX << " " // 10
- << base_fitness << " " // 10
- << base_merit << " " // 11
- << base_gestation << " " // 12
- << peak_fitness << " " // 13
- << GetAveFitness() << " " // 14
- << GetAveSqrFitness() << " " // 15
- << total_entropy << " " // 16
- << complexity << " " // 17
- << GetProbEpiDead() << " " // 18
- << GetProbEpiPos() << " " // 19
- << GetProbEpiNeg() << " " // 20
- << GetProbNoEpi() << " " // 21
- << GetAvPosEpiSize() << " " // 22
- << GetAvNegEpiSize() << " " // 23
- << GetAvNoEpiSize() << " " // 24
- << total_epi_count << endl; // 25
- fp.flush();
-}
-
-void cLandscape::PrintEntropy(ofstream & fp)
-{
- double max_ent = log((double) inst_set.GetSize());
- for (int j = 0; j < base_genome.GetSize(); j++) {
- fp << (log((double) site_count[j] + 1) / max_ent) << " ";
- }
- fp << endl;
- fp.flush();
-}
-
-void cLandscape::PrintSiteCount(ofstream & fp)
-{
- for (int j = 0; j < base_genome.GetSize(); j++) {
- fp << site_count[j] << " ";
- }
- fp << endl;
- fp.flush();
-}
-
-
-void cLandscape::PrintBase(cString filename)
-{
- cTestUtil::PrintGenome(base_genome, filename);
-}
-
-void cLandscape::PrintPeak(cString filename)
-{
- cTestUtil::PrintGenome(peak_genome, filename);
-}
-
Deleted: trunk/source/main/landscape.hh
===================================================================
--- trunk/source/main/landscape.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/landscape.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,169 +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 LANDSCAPE_HH
-#define LANDSCAPE_HH
-
-#ifndef CPU_TEST_INFO_HH
-#include "cCPUTestInfo.h"
-#endif
-#ifndef GENOME_HH
-#include "cGenome.h"
-#endif
-#ifndef STRING_HH
-#include "string.hh"
-#endif
-#ifndef TMATRIX_HH
-#include "tMatrix.hh"
-#endif
-
-#include <fstream>
-
-class cInstSet;
-class cGenome; // aggregate
-class cCPUTestInfo; // aggregate
-template <class T> class tMatrix; // aggregate
-class cInstruction;
-class cString; // aggregate
-
-struct cLandscape {
-private:
- const cInstSet & inst_set;
- cGenome base_genome;
- cGenome peak_genome;
- double base_fitness;
- double base_merit;
- double base_gestation;
- double peak_fitness;
- double total_fitness;
- double total_sqr_fitness;
-
- int distance;
- int del_distance;
- int ins_distance;
-
- int trials;
-
- int total_count;
-
- int dead_count;
- int neg_count;
- int neut_count;
- int pos_count;
-
- double pos_size;
- double neg_size;
-
- int total_epi_count;
- int pos_epi_count;
- int neg_epi_count;
- int no_epi_count;
- int dead_epi_count;
-
- double pos_epi_size;
- double neg_epi_size;
- double no_epi_size;
-
-
- double test_fitness;
-
- int * site_count;
-
- double total_entropy;
- double complexity;
-
- cCPUTestInfo test_info; // Info used for all cpu calculations.
- double neut_min; // These two variables are a range around the base
- double neut_max; // fitness to be counted as neutral mutations.
- tMatrix<double> fitness_chart; // Chart of all one-step mutations.
-
-private:
- void BuildFitnessChart();
- void ProcessGenome(cGenome & in_genome);
- void ProcessBase();
- void Process_Body(cGenome & cur_genome, int cur_distance, int start_line);
-
- void HillClimb_Body(std::ofstream & fp, cGenome & cur_genome, int & gen);
- void HillClimb_Print(std::ofstream & fp, const cGenome & _genome,
- const int gen) const;
-
- double TestMutPair(cGenome & mod_genome, int line1, int line2,
- const cInstruction & mut1, const cInstruction & mut2, std::ostream & fp);
-private:
- // disabled copy constructor.
- cLandscape(const cLandscape &);
-public:
- cLandscape(const cGenome & in_genome, const cInstSet & in_inst_set);
- ~cLandscape();
-
- void Reset(const cGenome & in_genome);
-
- void Process(int in_distance=1);
- void ProcessDelete();
- void ProcessInsert();
- void PredictWProcess(std::ostream & fp, int update=-1);
- void PredictNuProcess(std::ostream & fp, int update=-1);
-
- void SampleProcess(int in_trials);
- int RandomProcess(int in_trials, int in_distance=1, int min_found=0,
- int max_trials=0, bool print_if_found=false);
-
- void TestPairs(int in_trials, std::ostream & fp);
- void TestAllPairs(std::ostream & fp);
-
- void HillClimb(std::ofstream & fp);
- void HillClimb_Neut(std::ofstream & fp);
- void HillClimb_Rand(std::ofstream & fp);
-
- void PrintStats(std::ofstream & fp, int update=-1);
- void PrintEntropy(std::ofstream & fp);
- void PrintSiteCount(std::ofstream & fp);
- void PrintBase(cString filename);
- void PrintPeak(cString filename);
-
- inline const cGenome & GetPeakGenome() { return peak_genome; }
- inline double GetAveFitness() { return total_fitness / total_count; }
- inline double GetAveSqrFitness() { return total_sqr_fitness / total_count; }
- inline double GetPeakFitness() { return peak_fitness; }
-
- inline double GetProbDead() const { return ((double)dead_count)/total_count;}
- inline double GetProbNeg() const { return ((double)neg_count) /total_count;}
- inline double GetProbNeut() const { return ((double)neut_count)/total_count;}
- inline double GetProbPos() const { return ((double)pos_count) /total_count;}
- inline double GetAvPosSize() const {
- if (pos_count == 0) return 0;
- else return pos_size/pos_count;}
- inline double GetAvNegSize() const {
- if (neg_count == 0) return 0;
- else return neg_size/neg_count;}
-
- inline double GetProbEpiDead() const {
- if (total_epi_count == 0) return 0;
- else return ((double)dead_epi_count)/total_epi_count;}
- inline double GetProbEpiPos() const {
- if (total_epi_count == 0) return 0;
- else return ((double)pos_epi_count) /total_epi_count;}
- inline double GetProbEpiNeg() const {
- if (total_epi_count == 0) return 0;
- else return ((double)neg_epi_count) /total_epi_count;}
- inline double GetProbNoEpi() const {
- if (total_epi_count == 0) return 0;
- else return ((double)no_epi_count)/total_epi_count;}
- inline double GetAvPosEpiSize() const {
- if (pos_epi_count == 0) return 0;
- else return pos_epi_size/pos_epi_count;}
- inline double GetAvNegEpiSize() const {
- if (neg_epi_count == 0) return 0;
- else return neg_epi_size/neg_epi_count;}
- inline double GetAvNoEpiSize() const {
- if (no_epi_count == 0) return 0;
- else return no_epi_size/no_epi_count;}
-
- inline int GetNumTrials() const { return trials; }
-};
-
-#endif
Deleted: trunk/source/main/lineage.cc
===================================================================
--- trunk/source/main/lineage.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/lineage.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,155 +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 LINEAGE_HH
-#include "lineage.hh"
-#endif
-#ifndef GENOTYPE_HH
-#include "cGenotype.h"
-#endif
-
-using namespace std;
-
-
-bool gt_gentype::operator()(const cGenotype * g1, const cGenotype * g2) const
-{
- return g1->GetID() > g2->GetID();
-}
-
-int cLineage::m_max_id = 0;
-
-cLineage::cLineage(double start_fitness, int parent_id, int id, int update,
- double generation, double lineage_stat1, double lineage_stat2)
- : m_parent_id(parent_id)
- , m_update_born(update)
- , m_num_CPUs(0)
- , m_total_CPUs(0)
- , m_total_genotypes(0)
- , m_generation_born(generation)
- , m_lineage_stat1(lineage_stat1)
- , m_lineage_stat2(lineage_stat2)
-{
- if ( id < 0 )
- m_id = m_max_id++;
- else{
- m_id = id;
- if ( id >= m_max_id )
- m_max_id = id + 1;
- }
- m_start_fitness = m_max_fitness = m_max_fitness_ever = start_fitness;
- m_ave_fitness = 0;
- m_ave_fitness_changed = true;
- m_threshold = false;
-}
-
-cLineage::~cLineage()
-{
-}
-
-void cLineage::AddCreature(cGenotype * genotype)
-{
- // add the new genotype to the map if necessary, otherwise
- // find its position
- pair<map<const cGenotype *, int, gt_gentype>::iterator, bool> p =
- m_genotype_map.insert( pair<const cGenotype*, int>( genotype, 0 ) );
-
- // did we add a new genotype?
- if ( ( p.second ) == true )
- m_total_genotypes += 1;
-
- // increase the count for the given genotype by one.
- (*(p.first)).second += 1;
-
- // The above lines could be written like that:
- // m_genotype_map[ genotype ] += 1;
- // if we didn't want to count how often we add a new genotype
-
- double fitness = genotype->GetTestColonyFitness();
-
- // adjust the current maximum fitness
- if ( fitness > m_max_fitness )
- m_max_fitness = fitness;
- // adjust overall maxiumum fitness
- if ( fitness> m_max_fitness_ever )
- m_max_fitness_ever = fitness;
- // the average fitness has changed as well
- m_ave_fitness_changed = true;
-
- m_num_CPUs++;
- m_total_CPUs++;
-}
-
-bool cLineage::RemoveCreature(cGenotype * genotype)
-{
- // we return true if the removal of this creature triggers a
- // recalculation of the best lineage
- bool result = false;
-
- map<const cGenotype *, int, gt_gentype>::iterator cur = m_genotype_map.find( genotype );
-
- // is the genotype part of the map?
- if ( cur == m_genotype_map.end() ){
- cerr << "Removing creature from lineage whose genotype is not part of the lineage!" << endl;
- cerr << " " << genotype->GetName()() << " " << GetID() << endl;
- return false;
- }
-
- // yes, decrease the count
- (*cur).second -= 1;
- // and adjust the average fitness
- m_ave_fitness_changed = true;
-
- double fitness = genotype->GetTestColonyFitness();
-
- // did we reach zero?
- if ( (*cur).second == 0 ){
- // yes, remove the entry
- m_genotype_map.erase( cur );
- // make sure that the maximum fitness is correct
- if (fitness == m_max_fitness) CalcCurrentFitness();
- // adjust the return value
- result = true;
- }
-
- // and now the total cpu count
- m_num_CPUs--;
-
- return result;
-}
-
-int cLineage::CountNumCreatures() const
-{
- int creature_count = 0;
-
- map<const cGenotype *, int, gt_gentype>::const_iterator it =
- m_genotype_map.begin();
-
- for ( ; it!=m_genotype_map.end(); it++ )
- creature_count += (*it).second;
-
- return creature_count;
-}
-
-void cLineage::CalcCurrentFitness() const
-{
- m_max_fitness = 0.0;
- map<const cGenotype *, int, gt_gentype>::const_iterator it =
- m_genotype_map.begin();
-
- // we calculate the average fitness as well, since it is so easy.
- m_ave_fitness = 0;
- for ( ; it!=m_genotype_map.end(); it++ ){
- double fitness = (*it).first->GetTestColonyFitness();
- if (fitness > m_max_fitness) m_max_fitness = fitness;
- if (fitness > m_max_fitness_ever) m_max_fitness_ever = fitness;
- m_ave_fitness += fitness * (*it).second;
- }
- m_ave_fitness /= (double) m_num_CPUs;
- m_ave_fitness_changed = false;
-}
-
-
Deleted: trunk/source/main/lineage.hh
===================================================================
--- trunk/source/main/lineage.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/lineage.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,168 +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 LINEAGE_HH
-#define LINEAGE_HH
-
-#include <map>
-
-class cGenotype;
-
-// struct to compare to genotypes
-struct gt_gentype
-{
- bool operator()(const cGenotype * g1, const cGenotype * g2) const;
-};
-
-class cLineage {
-private:
- static int m_max_id;
- int m_id;
- int m_parent_id;
- int m_update_born;
- int m_num_CPUs;
- int m_total_CPUs;
- int m_total_genotypes;
- double m_start_fitness;
- mutable double m_max_fitness;
- mutable double m_ave_fitness;
- double m_generation_born;
-
- std::map<const cGenotype *, int, gt_gentype> m_genotype_map;
- bool m_threshold;
- mutable bool m_ave_fitness_changed;
- mutable double m_max_fitness_ever;
- double m_lineage_stat1;
- double m_lineage_stat2;
-
- void CalcCurrentFitness() const;
-public:
- /**
- * Creates a new lineage with a given start fitness and parent id.
- * The first genotype has to be added with AddGenotype later.
- *
- * @param start_fitness The initial fitness of the lineage.
- * @param parent_id The id of the parent's lineage.
- * @param id The requested id for this lineage. If negative, a generated
- * value is used. Attention: if you request lineage id's, it is your
- * responsibility not to request two identical ones for different lineages
- * (the class @ref cLineageControl does that correctly).
- **/
- cLineage(double start_fitness, int parent_id, int id,
- int update, double generation,
- double lineage_stat1 = 0.0, double lineage_stat2 = 0.0);
- ~cLineage();
-
- /**
- * Adds one instance of the given genotype to the lineage.
- **/
- void AddCreature( cGenotype * genotype );
-
- /**
- * Removes on instance of the given genotype from the lineage.
- *
- * @return True if the removal of this creature potentially creates a new
- * best lineage, otherwise false.
- **/
- bool RemoveCreature( cGenotype * genotype );
- void SetThreshold() { m_threshold = true; }
-
- /**
- * @return The id of the lineage.
- **/
- int GetID() const { return m_id; }
-
- /**
- * @return The id of the parent lineage.
- **/
- int GetParentID() const { return m_parent_id; }
-
- /**
- * @return An integer that is one larger than the maximum id used so far.
- **/
- int GetMaxID() const { return m_max_id; }
-
- /**
- * @return The update at which the lineage was created.
- **/
- int GetUpdateBorn() const { return m_update_born; }
-
- /**
- * @return The generation at which the lineage was created.
- **/
- double GetGenerationBorn() const { return m_generation_born; }
-
- /**
- * @return The initial fitness of the lineage.
- **/
- double GetStartFitness() const { return m_start_fitness; }
-
- /**
- * @return The current maximum fitness of the lineage.
- **/
- double GetMaxFitness() const { return m_max_fitness; }
-
- /**
- * @return The average fitness of the lineage.
- **/
- double GetAveFitness() const {
- if ( m_ave_fitness_changed )
- CalcCurrentFitness();
- return m_ave_fitness; }
-
- /**
- * @return The current number of genotypes in the lineage.
- **/
- int GetNumGenotypes() const { return m_genotype_map.size(); }
-
- /**
- * @return The current number of creatures in the lineage.
- **/
- int GetNumCreatures() const { return m_num_CPUs; }
-
- /**
- * Counts the number of creatures in the lineage.
- *
- * Should always equal GetNumCreatures(), otherwise something
- * is wrong.
- **/
- int CountNumCreatures() const;
-
- /**
- * @return The total number of creatures that have ever existed
- * in this lineage.
- **/
- int GetTotalCreatures() const { return m_total_CPUs; }
-
- /**
- * @return The total number of genotypes that have ever been part
- * of this lineage.
- **/
- int GetTotalGenotypes() const { return m_total_genotypes; }
-
- bool GetThreshold() const { return m_threshold; }
-
- /**
- * @return The maximum fitness ever attained by this lineage
- **/
- double GetMaxFitnessEver() const { return m_max_fitness_ever; }
-
- /**
- * @return The value of the first fitness criteria for
- * the creation of this lineage
- **/
- double GetLineageStat1 () const { return m_lineage_stat1; }
-
- /**
- * @return The value of the second fitness criteria for
- * the creation of this lineage
- **/
- double GetLineageStat2 () const { return m_lineage_stat2; }
-
-};
-
-#endif
Deleted: trunk/source/main/lineage_control.cc
===================================================================
--- trunk/source/main/lineage_control.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/lineage_control.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,391 +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 "lineage_control.hh"
-
-#include "string.hh"
-
-#include "lineage.hh"
-#include "stats.hh"
-#include "cConfig.h"
-#include "cGenebank.h"
-#include "cGenotype.h"
-#include "organism.hh"
-
-#include "nHardware.h" // for macro nHardware::FITNESS_NEUTRAL_MAX
-
-
-using namespace std;
-
-
-/////////////////////
-// cLineageControl
-/////////////////////
-
-cLineageControl::cLineageControl( cGenebank & genebank, cStats & stats )
- : m_best_lineage(NULL)
- , m_max_fitness_lineage(NULL)
- , m_dominant_lineage(NULL)
- , m_genebank( genebank )
- , m_stats( stats )
-{
-}
-
-cLineageControl::~cLineageControl()
-{
-}
-
-
-cLineage *
-cLineageControl::AddLineage( double start_fitness, int parent_lin_id, int id, double lineage_stat1, double lineage_stat2 )
-{
- cLineage * new_lineage = new cLineage( start_fitness, parent_lin_id, id,
- m_stats.GetUpdate(), m_stats.GetGeneration(), lineage_stat1, lineage_stat2 );
-
- // the best/ dominant lineage are automatically corrected
- // when a creature is added to this lineage
- m_lineage_list.push_back(new_lineage);
-
- m_stats.AddLineage();
-
- return new_lineage;
-}
-
-
-void
-cLineageControl::AddCreaturePrivate( cGenotype *genotype,
- cLineage * lineage )
-{
- assert( lineage != 0 );
-
- // add to the lineage
- lineage->AddCreature( genotype );
-
- // This would be nice, but the current Avida code doesn't allow for it.
- // Try to implement it in a new version...
- // update the cpu
- // cpu->SetLineage( lineage );
- // cpu->SetLineageLabel( lineage->GetID() );
-
- // test whether this makes the new lineage the best
- if ( !m_best_lineage ||
- lineage->GetAveFitness() > m_best_lineage->GetAveFitness() )
- m_best_lineage = lineage;
-
- // test whether this makes the new lineage the dominant
- if ( !m_dominant_lineage ||
- lineage->GetNumCreatures() > m_dominant_lineage->GetNumCreatures() )
- m_dominant_lineage = lineage;
-
- // test whether thiw makes the new lineage the one with the maximum fitness
- if ( !m_max_fitness_lineage ||
- lineage->GetMaxFitness() > m_max_fitness_lineage->GetMaxFitness() )
- m_max_fitness_lineage = lineage;
-
-}
-
-void cLineageControl::UpdateLineages()
-{
- m_best_lineage = NULL;
- m_dominant_lineage = NULL;
- m_max_fitness_lineage = NULL;
-
- list<cLineage *>::iterator it = m_lineage_list.begin();
- list<cLineage *>::iterator del_it;
-
- while( it != m_lineage_list.end() ){
- bool del = false;
-
- // mark the lineage for removal if empty
- if ( (*it)->GetNumCreatures() == 0 ){
- del_it = it;
- del = true;
- }
- else { // otherwise it is a candidate for the best/ dominant/... lineage
- if ( !m_best_lineage ||
- (*it)->GetAveFitness() > m_best_lineage->GetAveFitness() )
- m_best_lineage = (*it);
-
- if ( !m_dominant_lineage ||
- (*it)->GetNumCreatures() > m_dominant_lineage->GetNumCreatures() )
- m_dominant_lineage = (*it);
-
- if ( !m_max_fitness_lineage ||
- (*it)->GetMaxFitness() > m_max_fitness_lineage->GetMaxFitness() )
- m_max_fitness_lineage = (*it);
-
- }
- // proceed to the next lineage
- it++;
-
- // now do the removal if necessary
- if ( del ){
- delete (*del_it); // delete the lineage
- m_lineage_list.erase( del_it ); // and remove its reference
- }
- }
-
-#ifdef DEBUG
- if ( !m_lineage_list.empty() ){
- assert( m_dominant_lineage != 0 );
- assert( m_best_lineage != 0 );
- assert( m_max_fitness_lineage != 0 );
- }
-#endif
-
-}
-
-
-cLineage*
-cLineageControl::AddCreature( cGenotype * child_genotype, cGenotype *parent_genotype, cLineage * parent_lineage, int parent_lin_id )
-{
- // Collect any information we can about the parent.
- double parent_fitness = 0.0;
- // int parent_lin_id = 0;
-
- // at this point, the cpu has still the lineage from the
- // parent
- // cLineage * parent_lineage = cpu->GetLineage();
-
-#ifdef DEBUG
- if (parent_lineage != NULL){
- assert( parent_lin_id == parent_lineage->GetID() );
- }
-#endif
-
- if (parent_genotype != NULL) {
- assert( parent_genotype->GetNumOrganisms() > 0 );
- parent_fitness = parent_genotype->GetTestColonyFitness();
- }
- //cGenotype * child_genotype = cpu->GetActiveGenotype();
- double child_fitness = child_genotype->GetTestColonyFitness();
- cLineage * child_lineage = parent_lineage;
- bool create_lineage = false;
- double lineage_stat1 = child_fitness;
- double lineage_stat2 = child_fitness;
-
- // if we don't have a child lineage, we are probably dealing
- // with manual assignement of the lineage label
- if ( child_lineage == NULL ){
- child_lineage = FindLineage( parent_lin_id );
- // lineage doesn't exist...
- if ( child_lineage == NULL ){
- // create it
- cout << "Creating new lineage 'by hand'!\nRequested lineage label: " << parent_lin_id;
- child_lineage = AddLineage(child_fitness, -1, parent_lin_id, 0, 0);
- cout << ", actual lineage label: " << child_lineage->GetID() << endl;
-
- }
- }
- // otherwise, check for conditions that cause the creation of a new lineage
- else {
- switch ( cConfig::GetLineageCreationMethod() ) {
- case 0: // manual creation only
- break;
- case 1: // new lineage whenever a parent has offspring of greater fitness
- if ( child_fitness > parent_fitness ){
- create_lineage = true;
- lineage_stat1 = parent_fitness;
- lineage_stat2 = 0;
- }
- break;
- case 2: // new lineage whenever a new child exceeds the
- // currently highest fitness in the population
- if ( child_fitness > m_max_fitness_lineage->GetMaxFitness() ){
- create_lineage = true;
- lineage_stat1 = m_max_fitness_lineage->GetMaxFitness();
- lineage_stat2 = 0;
- }
- break;
- case 3: // new lineage whenever a new child exceeds the
- // highest fitness, or when it is a child of the
- // of the dominant lineage and exceeds that highest fitness
- if ( child_fitness > m_max_fitness_lineage->GetMaxFitness() ||
- ( parent_lineage == m_dominant_lineage
- && child_fitness > m_dominant_lineage->GetMaxFitness() ) ){
- create_lineage = true;
- lineage_stat1 = m_max_fitness_lineage->GetMaxFitness();
- lineage_stat2 = m_dominant_lineage->GetMaxFitness();
- }
- break;
- case 4: // new lineage whenever a new child exceeds the
- // fitness of the dominant creature (and the fitness of its own lineage)
- if (child_fitness > m_genebank.GetBestGenotype()->GetTestColonyFitness()
- && child_fitness > parent_lineage->GetMaxFitness() ){
- create_lineage = true;
- lineage_stat1=m_genebank.GetBestGenotype()->GetTestColonyFitness();
- lineage_stat2=parent_lineage->GetMaxFitness();
- }
- break;
- case 5: // new lineage whenever a new child exceeds the
- // fitness of the dominant lineage (and the fitness of its own lineage)
- if ( child_fitness > m_dominant_lineage->GetMaxFitness()
- && child_fitness > parent_lineage->GetMaxFitness() ){
- create_lineage = true;
- lineage_stat1=m_dominant_lineage->GetMaxFitness();
- lineage_stat2=parent_lineage->GetMaxFitness();
- }
- break;
- case 6: // new lineage whenever a new child exceeds the
- // fitness of its own lineage
- if ( child_fitness > parent_lineage->GetMaxFitness() ){
- create_lineage = true;
- lineage_stat1=parent_lineage->GetMaxFitness();
- lineage_stat2 = 0;
- }
- break;
- case 7: // new lineage whenever a new child exceeds the
- // maximum fitness ever attained by its parent lineage
- if (child_fitness > parent_lineage->GetMaxFitnessEver() ) {
- create_lineage = true;
- lineage_stat1 = parent_lineage->GetMaxFitnessEver();
- lineage_stat2 = 0;
- }
- break;
- }
- }
- if ( create_lineage ){
- child_lineage = AddLineage(child_fitness, parent_lin_id, -1, lineage_stat1, lineage_stat2);
- // cout << "Lineage " << child_lineage->GetID() << " created."
- // << " Genotype: " << child_genotype->GetName()() << endl;
- }
-
- AddCreaturePrivate( child_genotype, child_lineage );
-
- return child_lineage;
-}
-
-
-void
-cLineageControl::RemoveCreature( cOrganism * cpu )
-{
- cLineage * cur_lineage = cpu->GetLineage();
-
- if (cur_lineage) {
- // remove the creature
- if ( cur_lineage->RemoveCreature( cpu->GetGenotype() )
- || cur_lineage == m_dominant_lineage
- || cur_lineage == m_best_lineage )
- // If this lineage no longer exists, tell stats...
- if (cur_lineage->GetNumCreatures() == 0) {
- m_stats.RemoveLineage( cur_lineage->GetID(),
- cur_lineage->GetParentID(),
- cur_lineage->GetUpdateBorn(),
- cur_lineage->GetGenerationBorn(),
- cur_lineage->GetTotalCreatures(),
- cur_lineage->GetTotalGenotypes(),
- cur_lineage->GetStartFitness(),
- cur_lineage->GetLineageStat1(),
- cur_lineage->GetLineageStat2() );
- }
-
- // recalc the best/dominant lineage if necessary
- UpdateLineages();
- cpu->SetLineage( 0 );
- cpu->SetLineageLabel( -1 );
- }
-
-}
-
-
-cLineage *
-cLineageControl::FindLineage( int lineage_id ) const
-{
- list<cLineage *>::const_iterator it = m_lineage_list.begin();
-
- for ( ; it != m_lineage_list.end(); it++ )
- if ( (*it)->GetID() == lineage_id )
- break;
-
- if ( it == m_lineage_list.end() ){
- cout << "Lineage " << lineage_id << " not found." << endl;
- return 0;
- }
- else
- return ( *it );
-}
-
-
-void cLineageControl::PrintLineageTotals(const cString &filename, bool verbose)
-{
- ofstream & fp = m_stats.GetDataFileOFStream(filename);
- assert(fp.good());
-
- fp << m_stats.GetUpdate();
- const list<cLineage *> & lineage_list = GetLineageList();
-
- if ( verbose ){ // in verbose format, we print only those
- // lineages that are actually present, but
- // we print much more info
- fp << ": " << m_stats.SumGeneration().Average() << "\n";
-
- // let's calculate the average fitness in the population also
- double fitness_sum = 0;
- double fitness = 0;
- int total_num_organisms = 0;
- int num_organisms = 0;
-
-
- list<cLineage *>::const_iterator it = lineage_list.begin();
- for ( ; it != lineage_list.end(); it++ ){
- num_organisms = (*it)->GetNumCreatures();
- fitness = (*it)->GetAveFitness();
- fitness_sum += fitness * num_organisms;
- total_num_organisms += num_organisms;
- fp << " "
- << (*it)->GetID() << " "
- << (*it)->GetParentID() << " "
- << (*it)->GetStartFitness() << " "
- << (*it)->GetMaxFitness() << " "
- << fitness << " "
- << num_organisms << " "
- << (*it)->GetTotalCreatures() << "\n";
- }
- fp << "#Dom: " << GetDominantLineage()->GetID()
- << ", Max: " << GetMaxFitnessLineage()->GetID()
- << ", Best: " << GetBestLineage()->GetID()
- << "\n#Pop. fitness: " << fitness_sum / (double) total_num_organisms
- << "\n" << endl;
- }
- else {
- fp << " ";
- int cur_id = 0;
-
- list<cLineage *>::const_iterator it = lineage_list.begin();
- for ( ; it != lineage_list.end(); it++ ){
- int next_id = (*it)->GetID();
- // wind up the current id to the next id
- for ( ; cur_id < next_id; cur_id++ )
- fp << "-1 "; // output -1 when we don't have the data
- fp << (*it)->GetTotalCreatures() << " ";
- cur_id += 1;
- }
- fp << endl;
- }
-}
-
-
-void cLineageControl::PrintLineageCurCounts(const cString & filename)
-{
- ofstream & fp = m_stats.GetDataFileOFStream(filename);
- assert(fp.good());
-
- fp << m_stats.GetUpdate() << " ";
- const list<cLineage *> & lineage_list = GetLineageList();
-
- list<cLineage *>::const_iterator it = lineage_list.begin();
- int cur_id = 0;
- for ( ; it != lineage_list.end(); it++ ){
- int next_id = (*it)->GetID();
- // wind up the current id to the next id
- for ( ; cur_id < next_id; cur_id++ )
- fp << "0 ";
- fp << (*it)->GetNumCreatures() << " ";
- cur_id += 1;
- }
- fp << endl;
-}
Deleted: trunk/source/main/lineage_control.hh
===================================================================
--- trunk/source/main/lineage_control.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/lineage_control.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,108 +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 LINEAGE_CONTROL_HH
-#define LINEAGE_CONTROL_HH
-
-#include <list>
-
-class cLineage;
-class cGenebank;
-class cStats;
-class cGenotype;
-class cOrganism;
-class cString;
-
-class cLineageControl {
-private:
- std::list<cLineage *> m_lineage_list;
- cLineage * m_best_lineage; // the lineage with the highest average fitness
- cLineage * m_max_fitness_lineage; // lineage with the single highest fitness
- cLineage * m_dominant_lineage; // the lineage with the largest number of creatures.
-
- // references to the genebank and stats used by Avida
- cGenebank & m_genebank;
- cStats & m_stats;
-
- /**
- * Adds a new lineage to the control.
- **/
- cLineage * AddLineage( double start_fitness, int parent_lin_id, int id = -1,
- double lineage_stat1 = 0.0, double lineage_stat2 = 0.0 );
-
- /**
- * Determines the best lineage (lineage with the highest fitness),
- * the dominant lineage, and removes empty lineages.
- **/
- void UpdateLineages();
-
- /**
- * Does the actual adding of a creature to the lineage, after AddCreature
- * has done all the preliminary work.
- **/
- void AddCreaturePrivate( cGenotype *genotype, cLineage * lineage );
-
- cLineageControl();
- cLineageControl( const cLineageControl & );
- cLineageControl & operator=( const cLineageControl & );
-public:
- cLineageControl( cGenebank & genebank, cStats & stats );
- ~cLineageControl();
-
-
- // manipulators
- /**
- * Adds a creature to the correct lineage. The parent genotype is necessary
- * to determine when a new lineage should be created.
- *
- * Attention: the creature is not updated, this has to happen somewhere else!
- **/
- cLineage* AddCreature( cGenotype * child_genotype, cGenotype *parent_genotype, cLineage * parent_lineage, int parent_lin_id );
-
- /**
- * Removes a creature from the corresponding lineage.
- **/
- void RemoveCreature( cOrganism * cpu );
-
- // accessors
- /**
- * Finds the lineage with the given id.
- * Returns 0 if the lineage does not exist.
- **/
- cLineage * FindLineage( int lineage_id ) const;
-
- /**
- * @return The lineage with the fastest replicating genotype.
- **/
- cLineage * GetMaxFitnessLineage() const { return m_max_fitness_lineage; }
-
- /**
- * @return The lineage with the highest average fitness.
- **/
- cLineage * GetBestLineage() const { return m_best_lineage; }
-
- /**
- * @return The most abundant lineage.
- **/
- cLineage * GetDominantLineage() const { return m_dominant_lineage; }
-
- /**
- * @return The current number of lineages.
- **/
- int GetSize() const { return m_lineage_list.size(); }
-
- /**
- * @return A list of the single lineages.
- **/
- const std::list<cLineage *> & GetLineageList() const { return m_lineage_list; }
-
-
- void PrintLineageTotals(const cString & filename, bool verbose=false);
- void PrintLineageCurCounts(const cString & filename);
-};
-
-#endif
Deleted: trunk/source/main/local_mutations.cc
===================================================================
--- trunk/source/main/local_mutations.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/local_mutations.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,48 +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 LOCAL_MUTATIONS_HH
-#include "local_mutations.hh"
-#endif
-
-#ifndef MUTATION_HH
-#include "mutation.hh"
-#endif
-#ifndef MUTATION_LIB_HH
-#include "mutation_lib.hh"
-#endif
-#ifndef MUTATION_MACROS_HH
-#include "mutation_macros.hh"
-#endif
-
-/////////////////////
-// cLocalMutations
-/////////////////////
-
-cLocalMutations::cLocalMutations(const cMutationLib & _lib, int genome_length)
- : mut_lib(_lib)
- , rates(_lib.GetSize())
-{
- // Setup the rates for this specifc organism.
- const tArray<cMutation *> & mut_array = mut_lib.GetMutationArray();
- for (int i = 0; i < rates.GetSize(); i++) {
- if (mut_array[i]->GetScope() == MUTATION_SCOPE_PROP ||
- mut_array[i]->GetScope() == MUTATION_SCOPE_SPREAD) {
- rates[i] = mut_array[i]->GetRate() / (double) genome_length;
- }
- else {
- rates[i] = mut_array[i]->GetRate();
- }
- }
-
- // Setup the mutation count array.
- counts.Resize(mut_lib.GetSize(), 0);
-}
-
-cLocalMutations::~cLocalMutations()
-{
-}
Deleted: trunk/source/main/local_mutations.hh
===================================================================
--- trunk/source/main/local_mutations.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/local_mutations.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,33 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef LOCAL_MUTATIONS_HH
-#define LOCAL_MUTATIONS_HH
-
-#ifndef TARRAY_HH
-#include "tArray.hh"
-#endif
-
-class cMutationLib;
-class cLocalMutations {
-private:
- const cMutationLib & mut_lib;
- tArray<double> rates;
- tArray<int> counts;
-public:
- cLocalMutations(const cMutationLib & _lib, int genome_length);
- ~cLocalMutations();
-
- const cMutationLib & GetMutationLib() const { return mut_lib; }
- double GetRate(int id) const { return rates[id]; }
- int GetCount(int id) const { return counts[id]; }
-
- void IncCount(int id) { counts[id]++; }
- void IncCount(int id, int num_mut) { counts[id] += num_mut; }
-};
-
-#endif
Modified: trunk/source/main/main_sub.pri
===================================================================
--- trunk/source/main/main_sub.pri 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/main_sub.pri 2005-10-05 23:24:09 UTC (rev 330)
@@ -19,9 +19,9 @@
$$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 \
+ $$MAIN_HH/cLandscape.h \
+ $$MAIN_HH/cLineage.h \
+ $$MAIN_HH/cLineageControl.h \
$$MAIN_HH/organism.hh \
$$MAIN_HH/phenotype.hh \
$$MAIN_HH/cPopulationInterface.h \
@@ -63,14 +63,14 @@
$$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 \
- $$MAIN_CC/local_mutations.cc \
- $$MAIN_CC/mutation_lib.cc \
- $$MAIN_CC/mutation_rates.cc \
- $$MAIN_CC/mutation.cc \
- $$MAIN_CC/mx_code_array.cc \
+ $$MAIN_CC/cLandscape.cc \
+ $$MAIN_CC/cLineage.cc \
+ $$MAIN_CC/cLineageControl.cc \
+ $$MAIN_CC/cLocalMutations.cc \
+ $$MAIN_CC/cMutationLib.cc \
+ $$MAIN_CC/cMutationRates.cc \
+ $$MAIN_CC/cMutation.cc \
+ $$MAIN_CC/cMxCodeArray.cc \
$$MAIN_CC/organism.cc \
$$MAIN_CC/phenotype.cc \
$$MAIN_CC/cPopulationInterface.cc \
Deleted: trunk/source/main/mutation.cc
===================================================================
--- trunk/source/main/mutation.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/mutation.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -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 MUTATION_HH
-#include "mutation.hh"
-#endif
-
-
-///////////////
-// cMutation
-///////////////
-
-cMutation::cMutation(const cString & _name, int _id, int _trigger,
- int _scope, int _type, double _rate)
- : name(_name)
- , id(_id)
- , trigger(_trigger)
- , scope(_scope)
- , type(_type)
- , rate(_rate)
-{
-}
-
-cMutation::~cMutation()
-{
-}
Deleted: trunk/source/main/mutation.hh
===================================================================
--- trunk/source/main/mutation.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/mutation.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,42 +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 MUTATION_HH
-#define MUTATION_HH
-
-#ifndef STRING_HH
-#include "string.hh"
-#endif
-
-class cMutation {
-private:
- cString name;
- int id;
- int trigger;
- int scope;
- int type;
- double rate;
-public:
- cMutation(const cString & _name, int _id, int _trigger, int _scope,
- int _type, double _rate);
- ~cMutation();
-
- const cString & GetName() const { return name; }
- int GetID() const { return id; }
- int GetTrigger() const { return trigger; }
- int GetScope() const { return scope; }
- int GetType() const { return type; }
- double GetRate() const { return rate; }
-
- /*
- added to satisfy Boost.Python; the semantics are fairly useless --
- equality of two references means that they refer to the same object.
- */
- bool operator==(const cMutation &in) const { return &in == this; }
-};
-
-#endif
Deleted: trunk/source/main/mutation_lib.cc
===================================================================
--- trunk/source/main/mutation_lib.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/mutation_lib.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,51 +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 MUTATION_LIB_HH
-#include "mutation_lib.hh"
-#endif
-
-#ifndef MUTATION_HH
-#include "mutation.hh"
-#endif
-#ifndef MUTATION_MACROS_HH
-#include "mutation_macros.hh"
-#endif
-
-//////////////////
-// cMutationLib
-//////////////////
-
-cMutationLib::cMutationLib()
- : trigger_list_array(NUM_MUTATION_TRIGGERS)
-{
-}
-
-cMutationLib::~cMutationLib()
-{
- // Get rid of the trigger lists... This is not required, but since we
- // are deleting the mutations after this, we should first remove all
- // references to them.
- trigger_list_array.Resize(0);
-
- // Now delete the actual mutations.
- for (int i = 0; i < mutation_array.GetSize(); i++) {
- delete mutation_array[i];
- }
-}
-
-cMutation * cMutationLib::AddMutation(const cString & name, int trigger,
- int scope, int type, double rate)
-{
- // Build the new mutation and drop it in the proper trigger list.
- const int id = GetSize();
- mutation_array.Resize(id+1);
- mutation_array[id] = new cMutation(name, id, trigger, scope, type, rate);
- trigger_list_array[trigger].Push(mutation_array[id]);
-
- return mutation_array[id];
-}
Deleted: trunk/source/main/mutation_lib.hh
===================================================================
--- trunk/source/main/mutation_lib.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/mutation_lib.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -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 MUTATION_LIB_HH
-#define MUTATION_LIB_HH
-
-#ifndef TARRAY_HH
-#include "tArray.hh"
-#endif
-#ifndef TLIST_HH
-#include "tList.hh"
-#endif
-
-class cMutation;
-class cString;
-class cMutationLib {
-private:
- tArray<cMutation *> mutation_array;
- tArray< tList<cMutation> > trigger_list_array;
-public:
- cMutationLib();
- ~cMutationLib();
-
- int GetSize() const { return mutation_array.GetSize(); }
-
- cMutation * AddMutation(const cString & name, int trigger, int scope,
- int type, double rate);
-
- const tArray<cMutation *> & GetMutationArray() const
- { return mutation_array; }
- const tList<cMutation> & GetMutationList(int trigger) const
- { return trigger_list_array[trigger]; }
-};
-
-#endif
Deleted: trunk/source/main/mutation_macros.hh
===================================================================
--- trunk/source/main/mutation_macros.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/mutation_macros.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -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 MUTATION_MACROS_HH
-#define MUTATION_MACROS_HH
-
-#define MUTATION_TRIGGER_NONE 0
-#define MUTATION_TRIGGER_UPDATE 1
-#define MUTATION_TRIGGER_DIVIDE 2
-#define MUTATION_TRIGGER_PARENT 3
-#define MUTATION_TRIGGER_WRITE 4
-#define MUTATION_TRIGGER_READ 5
-#define MUTATION_TRIGGER_EXEC 6
-#define NUM_MUTATION_TRIGGERS 7
-
-#define MUTATION_SCOPE_GENOME 0
-#define MUTATION_SCOPE_LOCAL 1
-#define MUTATION_SCOPE_GLOBAL 2
-#define MUTATION_SCOPE_PROP 3
-#define MUTATION_SCOPE_SPREAD 4
-
-#define MUTATION_TYPE_POINT 0
-#define MUTATION_TYPE_INSERT 1
-#define MUTATION_TYPE_DELETE 2
-#define MUTATION_TYPE_HEAD_INC 3
-#define MUTATION_TYPE_HEAD_DEC 4
-#define MUTATION_TYPE_TEMP 5
-#define MUTATION_TYPE_KILL 6
-
-#endif
Deleted: trunk/source/main/mutation_rates.cc
===================================================================
--- trunk/source/main/mutation_rates.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/mutation_rates.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -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 MUTATION_RATES_HH
-#include "mutation_rates.hh"
-#endif
-
-#ifndef TOOLS_HH
-#include "tools.hh"
-#endif
-
-////////////////////
-// cMutationRates
-////////////////////
-
-cMutationRates::cMutationRates()
-{
- Clear();
-}
-
-cMutationRates::cMutationRates(const cMutationRates & in_muts)
-{
- Copy(in_muts);
-}
-
-cMutationRates::~cMutationRates()
-{
-}
-
-void cMutationRates::Clear()
-{
- exec.point_mut_prob = 0.0;
- copy.copy_mut_prob = 0.0;
- divide.ins_mut_prob = 0.0;
- divide.del_mut_prob = 0.0;
- divide.div_mut_prob = 0.0;
- divide.divide_mut_prob = 0.0;
- divide.divide_ins_prob = 0.0;
- divide.divide_del_prob = 0.0;
- divide.parent_mut_prob = 0.0;
- divide.crossover_prob = 0.0;
- divide.aligned_cross_prob = 0.0;
-}
-
-void cMutationRates::Copy(const cMutationRates & in_muts)
-{
- exec.point_mut_prob = in_muts.exec.point_mut_prob;
- copy.copy_mut_prob = in_muts.copy.copy_mut_prob;
- divide.ins_mut_prob = in_muts.divide.ins_mut_prob;
- divide.del_mut_prob = in_muts.divide.del_mut_prob;
- divide.div_mut_prob = in_muts.divide.div_mut_prob;
- divide.divide_mut_prob = in_muts.divide.divide_mut_prob;
- divide.divide_ins_prob = in_muts.divide.divide_ins_prob;
- divide.divide_del_prob = in_muts.divide.divide_del_prob;
- divide.parent_mut_prob = in_muts.divide.parent_mut_prob;
- divide.crossover_prob = in_muts.divide.crossover_prob;
- divide.aligned_cross_prob = in_muts.divide.aligned_cross_prob;
-
- // if (copy.copy_mut_prob != 0) cerr << "Copying non-zero copy mut rate!" << endl;
-}
-
-bool cMutationRates::TestPointMut() const
-{
- return g_random.P(exec.point_mut_prob);
-}
-
-bool cMutationRates::TestCopyMut() const
-{
- return g_random.P(copy.copy_mut_prob);
-}
-
-bool cMutationRates::TestDivideMut() const
-{
- return g_random.P(divide.divide_mut_prob);
-}
-
-bool cMutationRates::TestDivideIns() const
-{
- return g_random.P(divide.divide_ins_prob);
-}
-
-bool cMutationRates::TestDivideDel() const
-{
- return g_random.P(divide.divide_del_prob);
-}
-
-bool cMutationRates::TestParentMut() const
-{
- return g_random.P(divide.parent_mut_prob);
-}
-
-bool cMutationRates::TestCrossover() const
-{
- return g_random.P(divide.crossover_prob);
-}
-
-bool cMutationRates::TestAlignedCrossover() const
-{
- return g_random.P(divide.aligned_cross_prob);
-}
Deleted: trunk/source/main/mutation_rates.hh
===================================================================
--- trunk/source/main/mutation_rates.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/mutation_rates.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,85 +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 MUTATION_RATES_HH
-#define MUTATION_RATES_HH
-
-class cMutationRates {
-private:
- // Mutations are divided up by when they occur...
-
- // ...anytime during execution...
- struct sExecMuts {
- double point_mut_prob;
- };
- sExecMuts exec;
-
- // ...during an instruction copy...
- struct sCopyMuts {
- double copy_mut_prob;
- };
- sCopyMuts copy;
-
- // ...at the divide...
- struct sDivideMuts {
- double ins_mut_prob; // Per site
- double del_mut_prob; // Per site
- double div_mut_prob; // Per site
- double divide_mut_prob; // Max one per divide
- double divide_ins_prob; // Max one per divide
- double divide_del_prob; // Max one per divide
- double crossover_prob;
- double aligned_cross_prob;
- double parent_mut_prob;
- };
- sDivideMuts divide;
-
- void operator=(const cMutationRates & in_muts)
- { (void) in_muts; } // Disable operator=
-public:
- cMutationRates();
- cMutationRates(const cMutationRates & in_muts);
- ~cMutationRates();
-
- void Clear();
- void Copy(const cMutationRates & in_muts);
-
- bool TestPointMut() const;
- bool TestCopyMut() const;
- bool TestDivideMut() const;
- bool TestDivideIns() const;
- bool TestDivideDel() const;
- bool TestParentMut() const;
- bool TestCrossover() const;
- bool TestAlignedCrossover() const;
-
- double GetPointMutProb() const { return exec.point_mut_prob; }
- double GetCopyMutProb() const { return copy.copy_mut_prob; }
- double GetInsMutProb() const { return divide.ins_mut_prob; }
- double GetDelMutProb() const { return divide.del_mut_prob; }
- double GetDivMutProb() const { return divide.div_mut_prob; }
- double GetDivideMutProb() const { return divide.divide_mut_prob; }
- double GetDivideInsProb() const { return divide.divide_ins_prob; }
- double GetDivideDelProb() const { return divide.divide_del_prob; }
- double GetParentMutProb() const { return divide.parent_mut_prob; }
- double GetCrossoverProb() const { return divide.crossover_prob; }
- double GetAlignedCrossProb() const { return divide.aligned_cross_prob; }
-
- void SetPointMutProb(double in_prob) { exec.point_mut_prob = in_prob; }
- void SetCopyMutProb(double in_prob) { copy.copy_mut_prob = in_prob; }
- void SetInsMutProb(double in_prob) { divide.ins_mut_prob = in_prob; }
- void SetDelMutProb(double in_prob) { divide.del_mut_prob = in_prob; }
- void SetDivMutProb(double in_prob) { divide.div_mut_prob = in_prob; }
- void SetDivideMutProb(double in_prob) { divide.divide_mut_prob = in_prob; }
- void SetDivideInsProb(double in_prob) { divide.divide_ins_prob = in_prob; }
- void SetDivideDelProb(double in_prob) { divide.divide_del_prob = in_prob; }
- void SetParentMutProb(double in_prob) { divide.parent_mut_prob = in_prob; }
- void SetCrossoverProb(double in_prob) { divide.crossover_prob = in_prob; }
- void SetAlignedCrossProb(double in) { divide.aligned_cross_prob = in; }
-};
-
-#endif
Deleted: trunk/source/main/mx_code_array.cc
===================================================================
--- trunk/source/main/mx_code_array.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/mx_code_array.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,482 +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 MX_CODE_ARRAY_HH
-#include "mx_code_array.hh"
-#endif
-
-#ifndef CONFIG_HH
-#include "cConfig.h"
-#endif
-#ifndef CPU_TEST_INFO_HH
-#include "cCPUTestInfo.h"
-#endif
-#ifndef GENOME_HH
-#include "cGenome.h"
-#endif
-#ifndef INST_SET_HH
-#include "cInstSet.h"
-#endif
-#ifndef MY_CODE_ARRAY_LESS_THAN_HH
-#include "my_code_array_less_than.hh"
-#endif
-#ifndef ORGANISM_HH
-#include "organism.hh"
-#endif
-#ifndef TEST_CPU_HH
-#include "cTestCPU.h"
-#endif
-#ifndef TOOLS_HH
-#include "tools.hh"
-#endif
-
-#include <iomanip>
-
-using namespace std;
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-// cMxCodeArray
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-const int cMxCodeArray::m_max_gestation_time = 1000000000;
-
-
-cMxCodeArray::cMxCodeArray()
-{
- // Initialize the code array as empty.
- size = 0;
- max_size = 0;
- data = NULL;
- m_merit = 0;
- m_gestation_time = m_max_gestation_time;
- m_num_instructions = 0;
-}
-
-cMxCodeArray::cMxCodeArray(int n_inst, int in_size, int in_max_size) :m_merit(0), m_gestation_time(m_max_gestation_time), m_num_instructions(n_inst)
-{
- assert (in_max_size == 0 || in_max_size >= in_size);
-
- // Initialize the code array randomly.
- size = in_size;
- if (in_max_size != 0) max_size = in_max_size;
- else max_size = size;
-
- data = new cInstruction[max_size];
-
- for (int i = 0; i < size; i++)
- {
- data[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
- }
-
-}
-
-cMxCodeArray::cMxCodeArray(const cMxCodeArray &in_code)
-{
-
- size = in_code.size;
- max_size = in_code.max_size;
- m_merit = in_code.m_merit;
- m_gestation_time = in_code.m_gestation_time;
- m_num_instructions = in_code.m_num_instructions;
- m_trans_probs = in_code.m_trans_probs;
-
- data = new cInstruction[max_size];
-
- for (int i = 0; i < size; i++)
- {
- data[i] = in_code.data[i];
- }
-
-}
-
-
-cMxCodeArray::cMxCodeArray(const cGenome &in_code, int in_max_size) :m_merit(0), m_gestation_time(m_max_gestation_time), m_num_instructions(0)
-{
- assert (in_max_size == 0 || in_max_size >= in_code.GetSize());
-
- size = in_code.GetSize();
- if (in_max_size != 0) max_size = in_max_size;
- else max_size = size;
-
- data = new cInstruction[max_size];
-
- for (int i = 0; i < size; i++) {
- data[i] = in_code[i];
- }
-}
-
-
-cMxCodeArray::~cMxCodeArray()
-{
- // TODO - what is this?
- // g_memory.Remove(C_CODE_ARRAY);
-
- if (data) delete [] data;
-}
-
-void cMxCodeArray::Resize(int new_size)
-{
- assert (new_size <= MAX_CREATURE_SIZE);
-
- // If we are not changing the size, just return.
- if (new_size == size) return;
-
- // Re-construct the arrays only if we have to...
- if (new_size > max_size || new_size * 4 < max_size) {
- cInstruction * new_data = new cInstruction[new_size];
-
- for (int i = 0; i < size && i < new_size; i++) {
- new_data[i] = data[i];
- }
-
- if (data) delete [] data;
-
- data = new_data;
- max_size = new_size;
- }
-
- // Fill in the un-filled-in bits...
- for (int i = size; i < new_size; i++) {
- data[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
- }
-
- size = new_size;
-}
-
-// Resize the arrays, and leave memeory uninitializes! (private method)
-void cMxCodeArray::ResetSize(int new_size, int new_max)
-{
- assert (new_size >= 0);
- assert (new_max == 0 || new_max >= new_size);
-
- // If we are clearing it totally, do so.
- if (!new_size) {
- if (data) delete [] data;
- data = NULL;
- size = 0;
- max_size = 0;
- return;
- }
-
- // If a new max is _not_ being set, see if one needs to be.
- if (new_max == 0 &&
- (max_size < new_size) || (max_size > new_size * 2)) {
- new_max = new_size;
- }
-
- // If the arrays need to be rebuilt, do so.
- if (new_max != 0 && new_max != max_size) {
- cInstruction * new_data = new cInstruction[new_max];
-
- if (data) delete [] data;
- data = new_data;
- max_size = new_max;
- }
-
- // Reset the array size.
- size = new_size;
-}
-
-/**
- * Resizes and reinitializes the genome. The previous data is lost.
- **/
-void cMxCodeArray::Reset()
-{
- // Initialze the array
- if( cConfig::GetAllocMethod() == ALLOC_METHOD_RANDOM ){
- // Randomize the initial contents of the new array.
- Randomize();
- }else{
- // Assume default instuction initialization
- Clear();
- }
-}
-
-/**
- * Sets all instructions to @ref cInstruction::GetInstDefault().
- **/
-void cMxCodeArray::Clear()
-{
- int i;
- for (i = 0; i < size; i++)
- {
- data[i] = cInstSet::GetInstDefault();
- }
-}
-
-/**
- * Replaces all instructions in the genome with a sequence of random
- * instructions.
- **/
-
-void cMxCodeArray::Randomize()
-{
- int i;
- for (i = 0; i < size; i++)
- {
- data[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
- }
-}
-
-void cMxCodeArray::operator=(const cMxCodeArray & other_code)
-{
- // If we need to resize, do so...
-
- ResetSize(other_code.size);
-
- // Now that both code arrays are the same size, copy the other one over.
-
- for (int i = 0; i < size; i++)
- {
- data[i] = other_code.data[i];
- }
-
- m_merit = other_code.m_merit;
- m_gestation_time = other_code.m_gestation_time;
- m_num_instructions = other_code.m_num_instructions;
- m_trans_probs = other_code.m_trans_probs;
-}
-
-
-/*
- * Let the 0th instruction be the least significant,
- * so longer codes are always greater.
- */
-bool cMxCodeArray::operator<(const cMxCodeArray &other_code) const
-{
-
- if (size < other_code.size)
- return true;
- else if (size > other_code.size)
- return false;
-
- bool result = false;
-
- for (int i = size-1; i >= 0; i-- )
- {
- if (data[i].GetOp() < other_code.data[i].GetOp())
- {
- result = true;
- break;
- }
- else if (other_code.data[i].GetOp() < data[i].GetOp())
- {
- result = false;
- break;
- }
- }
-
- return result;
-}
-
-
-void cMxCodeArray::CopyDataTo(cGenome & other_code) const
-{
- // @CAO this is ugly, but the only option I see...
- other_code = cGenome(size);
-
- for (int i = 0; i < size; i++) {
- other_code[i] = data[i];
- }
-}
-
-bool cMxCodeArray::OK() const
-{
- bool result = true;
-
- assert (size >= 0 && size <= max_size && max_size <= MAX_CREATURE_SIZE);
-
- return result;
-}
-
-
-int cMxCodeArray::FindInstruction(const cInstruction & inst, int start_index)
-{
- assert(start_index < GetSize());
- for(int i=0; i<GetSize(); ++i ){
- if( Get(i) == inst ){
- return i;
- }
- }
- return -1;
-}
-
-cString cMxCodeArray::AsString() const
-{
- cString out_string(size);
- for (int i = 0; i < size; i++) {
- int cur_char = data[i].GetOp();
- if (cur_char < 26) {
- out_string[i] = cur_char + 'a';
- } else if (cur_char < 52) {
- out_string[i] = cur_char - 26 + 'A';
- } else if (cur_char < 62) {
- out_string[i] = cur_char - 52 + '1';
- } else {
- out_string[i] = '*';
- }
- }
-
- return out_string;
-}
-
-
-void cMxCodeArray::Get1Mutants(list<cMxCodeArray>& mutants) const
-{
- for (int line_num = 0; line_num < size; line_num++)
- {
- int cur_inst = data[line_num].GetOp();
-
- for (int inst_num = 0; inst_num < m_num_instructions; inst_num++)
- {
- if (cur_inst == inst_num) continue;
-
- cMxCodeArray newMutant(*this);
- newMutant[line_num].SetOp(inst_num);
- mutants.push_back(newMutant);
- }
- }
-}
-
-
-/*
- Make a list of the transition probabilities only to those other
- genotypes that are within the given hamming distance of this
- genotype.
-
- The list is actually implemented as a map from indexes to
- probabilities, where the index is the place of the genotype in
- the complete ordered set of genotypes.
-
- TODO this seems kind of inefficient that you have to calculate the
- hamming distance twice - maybe I should pass it as a parameter to
- the TransitionProbability function after it is first calculated? Or
- maybe the threshold should be in the transition probability?
-*/
-
- /* dropped const for win32 -- kgn */
-//int cMxCodeArray::MakeTransitionList(const set<cMxCodeArray, MyCodeArrayLessThan > &data_set, int hamDistThresh, double errorRate) const
-int cMxCodeArray::MakeTransitionList(set<cMxCodeArray, MyCodeArrayLessThan > &data_set, int hamDistThresh, double errorRate) const
-{
- set<cMxCodeArray, MyCodeArrayLessThan >::iterator set_iter;
- int index = 0;
- double totalProb = 0.0;
- int num = 0;
-
- for (set_iter = data_set.begin(); set_iter != data_set.end(); set_iter++, index++)
- {
- if (HammingDistance(*set_iter) <= hamDistThresh)
- {
- double transProb = TransitionProbability(*set_iter, errorRate);
- m_trans_probs[index] = transProb * GetFitness();
- totalProb += transProb;
- num += 1;
- }
- else
- {
- m_trans_probs[index]= 0.0;
- }
- }
-
- /* The transition probability for "other"
- index got incremented at the very end of the loop so its pointing
- to the next element now */
-
- m_trans_probs[index] = (1.0 - totalProb) * GetFitness();
-
- return num;
-
-}
-
-
-const map<int, double, less<int> >& cMxCodeArray::GetTransitionList() const
-{
- return m_trans_probs;
-}
-
-
-int cMxCodeArray::HammingDistance(const cMxCodeArray &other_gene) const
-{
- int distance = 0;
-
- assert (size == other_gene.GetSize());
-
- for (int i = 0; i < size; i++)
- {
- if (this->Get(i) != other_gene.Get(i))
- distance++;
- }
-
- return distance;
-}
-
-
-double cMxCodeArray::TransitionProbability(const cMxCodeArray &other_gene, double errorRate) const
-{
- double Q = 0.0;
- assert (size == other_gene.GetSize());
-
- if ( (*this) == other_gene)
- {
- Q = pow((1-errorRate), size);
- }
- else
- {
- int distance = HammingDistance(other_gene);
- Q = pow((1.0-errorRate), (size -distance)) * pow((errorRate/m_num_instructions),distance);
- }
-
- return Q;
-}
-
-/*
- Used in testing the diagonalization.
-*/
-
-void cMxCodeArray::PrintTransitionList(ostream &fp, int size) const
-{
-
- fp.setf(ios::fixed);
-
- fp << "{" ;
-
- for (int index=0 ; index < size; index++)
- {
- map<int, double, less<int> >::const_iterator find_results = m_trans_probs.find(index);
- if (find_results == m_trans_probs.end())
- {
- fp << 0.0 ;
- }
- else
- {
- fp << setprecision(10) << (*find_results).second ;
- }
-
- if (index < size-1)
- fp << " , " ;
-
- }
-
- fp << "}" ;
-}
-
-
-void cMxCodeArray::CalcFitness()
-{
- cGenome temp(1);
- cCPUTestInfo test_info;
- CopyDataTo(temp);
- cTestCPU::TestGenome(test_info, temp);
- if ( test_info.IsViable() )
- m_gestation_time =
- test_info.GetTestOrganism()->GetPhenotype().GetGestationTime();
- else // if not viable, set a really high gestation time
- m_gestation_time = m_max_gestation_time;
- m_merit = test_info.GetTestOrganism()->GetPhenotype().GetMerit().GetDouble();
-}
Deleted: trunk/source/main/mx_code_array.hh
===================================================================
--- trunk/source/main/mx_code_array.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/mx_code_array.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,134 +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 MX_CODE_ARRAY_HH
-#define MX_CODE_ARRAY_HH
-
-#include <iostream>
-#include <list>
-#include <map>
-#include <set>
-
-#ifndef INSTRUCTION_HH
-#include "cInstruction.h"
-#endif
-#ifndef STRING_HH
-#include "string.hh"
-#endif
-#ifndef STRING_UTIL_HH
-#include "string_util.hh"
-#endif
-
-/**
- * This class stores the genome of an Avida organism only.
- * Cannot be run in a simulation.
- **/
-
-class cGenome;
-class MyCodeArrayLessThan;
-class cMxCodeArray {
-private:
- int size;
- int max_size;
- cInstruction * data;
- double m_merit;
- int m_gestation_time;
- static const int m_max_gestation_time;
- int m_num_instructions;
- mutable std::map<int, double, std::less<int> > m_trans_probs;
-
-
-public:
- cMxCodeArray();
- explicit cMxCodeArray(int ninst, int in_size=0, int in_max_size=0);
- cMxCodeArray(const cMxCodeArray &in_code);
- cMxCodeArray(const cGenome & in_code, int in_max_size=0);
- virtual ~cMxCodeArray();
-
- void operator=(const cMxCodeArray &other_code);
- bool operator==(const cMxCodeArray &other_code) const;
- inline cInstruction & operator[](int index);
- bool operator<(const cMxCodeArray &other_code) const;
-
- void CopyDataTo(cGenome & other_code) const;
- void Resize(int new_size);
- void ResetSize(int new_size, int new_max=0);
- inline int GetSize() const { return size; }
- inline double GetFitness() const {
- if ( m_gestation_time == m_max_gestation_time )
- return 0;
- else return m_merit/m_gestation_time;}
- double GetMerit() const { return m_merit; }
- double GetGestationTime() const { return m_gestation_time; }
- void CalcFitness();
-
- inline const cInstruction & Get(int index) const {
- assert(index < size);
- return data[index];
- }
-
- int FindInstruction(const cInstruction & inst, int start_index=0);
- inline bool HasInstruction(const cInstruction & inst){
- return ( FindInstruction(inst) >= 0 ) ? true : false; }
-
- inline void Set(int index, const cInstruction & value);
-
- void Reset();
- void Clear();
- void Randomize();
- bool OK() const;
- cString AsString() const;
-
- cString DebugType() { return "cMxCodeArray"; }
- cString DebugInfo() { return cStringUtil::Stringf("size = %d", size); }
- int DebugSize() { return max_size; }
-
-
-
- /* For Depth Limited Search */
- void Get1Mutants(std::list<cMxCodeArray>& mutants) const;
- void SetNumInstructions(int ninst) {m_num_instructions = ninst;}
-
-
- /* For Transition Matrix */
- //int MakeTransitionList(const std::set<cMxCodeArray, MyCodeArrayLessThan >& m_data_set,
- /* dropped const for win32 -- kgn */
- int MakeTransitionList(std::set<cMxCodeArray, MyCodeArrayLessThan >& m_data_set,
- int hamDistThresh, double errorRate) const;
- const std::map<int, double, std::less<int> >& GetTransitionList() const;
- int HammingDistance(const cMxCodeArray &other_gene) const;
- double TransitionProbability(const cMxCodeArray &other_gene, double errorRate) const;
- void PrintTransitionList(std::ostream &fp, int size) const;
-};
-
-cInstruction & cMxCodeArray::operator[](int index)
-{
-#ifdef DEBUG
- assert(index < size);
- assert(index >= 0);
-#endif
- return data[index];
-}
-
-inline bool cMxCodeArray::operator==(const cMxCodeArray &other_code) const
-{
- // Make sure the sizes are the same.
- if (size != other_code.size) return false;
-
- // Then go through line by line.
- for (int i = 0; i < size; i++)
- if (data[i].GetOp() != other_code.data[i].GetOp()) return false;
-
- return true;
-}
-
-inline void cMxCodeArray::Set(int index, const cInstruction & value)
-{
- operator[](index) = value;
-}
-
-#endif
Deleted: trunk/source/main/my_code_array_less_than.hh
===================================================================
--- trunk/source/main/my_code_array_less_than.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/my_code_array_less_than.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -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 MY_CODE_ARRAY_LESS_THAN_HH
-#define MY_CODE_ARRAY_LESS_THAN_HH
-
-#ifndef MX_CODE_ARRAY_HH
-#include "mx_code_array.hh"
-#endif
-
-class MyCodeArrayLessThan{
-public:
- bool operator()(const cMxCodeArray &x, const cMxCodeArray &y) const
- {
- return x < y;
- }
-};
-
-#endif
Copied: trunk/source/main/nGenotype.h (from rev 329, trunk/source/main/genotype_macros.hh)
===================================================================
--- trunk/source/main/genotype_macros.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/nGenotype.h 2005-10-05 23:24:09 UTC (rev 330)
@@ -0,0 +1,18 @@
+/*
+ * nGenotype.h
+ * Avida2
+ *
+ * Created by David on 10/5/05.
+ * Copyright 2005 Michigan State University. All rights reserved.
+ *
+ */
+
+#ifndef nGenotype_h
+#define nGenotype_h
+
+namespace nGenotype {
+ const int HASH_SIZE = 3203; // @CAO Is this an optimal number?
+ const int THREADS = 2;
+}
+
+#endif
Copied: trunk/source/main/nInjectGenotype.h (from rev 329, trunk/source/main/inject_genebank_macros.hh)
===================================================================
--- trunk/source/main/inject_genebank_macros.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/nInjectGenotype.h 2005-10-05 23:24:09 UTC (rev 330)
@@ -0,0 +1,18 @@
+/*
+ * nInjectGenotype.h
+ * Avida2
+ *
+ * Created by David on 10/5/05.
+ * Copyright 2005 Michigan State University. All rights reserved.
+ *
+ */
+
+#ifndef nInjectGenotype_h
+#define nInjectGenotype_h
+
+namespace nInjectGenotype {
+ const int HASH_SIZE = 307; // @CAO Is this an optimal number?
+ const int THREADS = 2;
+}
+
+#endif
Copied: trunk/source/main/nMutation.h (from rev 329, trunk/source/main/mutation_macros.hh)
===================================================================
--- trunk/source/main/mutation_macros.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/nMutation.h 2005-10-05 23:24:09 UTC (rev 330)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////////
+// 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 MUTATION_MACROS_HH
+#define MUTATION_MACROS_HH
+
+namespace nMutation {
+ enum {
+ TRIGGER_NONE = 0,
+ TRIGGER_UPDATE,
+ TRIGGER_DIVIDE,
+ TRIGGER_PARENT,
+ TRIGGER_WRITE,
+ TRIGGER_READ,
+ TRIGGER_EXEC,
+ NUM_TRIGGERS
+ };
+
+ enum {
+ SCOPE_GENOME = 0,
+ SCOPE_LOCAL,
+ SCOPE_GLOBAL,
+ SCOPE_PROP,
+ SCOPE_SPREAD
+ };
+
+ enum {
+ TYPE_POINT = 0,
+ TYPE_INSERT,
+ TYPE_DELETE,
+ TYPE_HEAD_INC,
+ TYPE_HEAD_DEC,
+ TYPE_TEMP,
+ TYPE_KILL
+ };
+}
+
+#endif
Added: trunk/source/main/nSpecies.h
===================================================================
--- trunk/source/main/nSpecies.h 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/nSpecies.h 2005-10-05 23:24:09 UTC (rev 330)
@@ -0,0 +1,17 @@
+/*
+ * nSpecies.h
+ * Avida2
+ *
+ * Created by David on 10/5/05.
+ * Copyright 2005 Michigan State University. All rights reserved.
+ *
+ */
+
+#ifndef nSpecies_h
+#define nSpecies_h
+
+namespace nSpecies {
+ enum tRecording { RECORD_OFF = 0, RECORD_FULL = 1, RECORD_LIMITED = 2 };
+}
+
+#endif
Modified: trunk/source/main/organism.hh
===================================================================
--- trunk/source/main/organism.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/organism.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -21,10 +21,10 @@
#include "cGenome.h"
#endif
#ifndef LOCAL_MUTATIONS_HH
-#include "local_mutations.hh"
+#include "cLocalMutations.h"
#endif
#ifndef MUTATION_RATES_HH
-#include "mutation_rates.hh"
+#include "cMutationRates.h"
#endif
#ifndef PHENOTYPE_HH
#include "phenotype.hh"
Modified: trunk/source/main/population.cc
===================================================================
--- trunk/source/main/population.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/population.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -25,8 +25,8 @@
#include "cInjectGenotype.h"
#include "cInstUtil.h"
#include "integrated_schedule.hh"
-#include "lineage.hh"
-#include "lineage_control.hh"
+#include "cLineage.h"
+#include "cLineageControl.h"
#include "organism.hh"
#include "phenotype.hh"
#include "population_cell.hh"
Modified: trunk/source/main/population_cell.hh
===================================================================
--- trunk/source/main/population_cell.hh 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/population_cell.hh 2005-10-05 23:24:09 UTC (rev 330)
@@ -11,7 +11,7 @@
#include <fstream>
#ifndef MUTATION_RATES_HH
-#include "mutation_rates.hh"
+#include "cMutationRates.h"
#endif
#ifndef TARRAY_HH
#include "tArray.hh"
Modified: trunk/source/main/species_control.cc
===================================================================
--- trunk/source/main/species_control.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/main/species_control.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -18,8 +18,8 @@
#ifndef GENOTYPE_HH
#include "cGenotype.h"
#endif
-#ifndef GENOTYPE_MACROS_HH
-#include "genotype_macros.hh"
+#ifndef nSpecies_h
+#include "nSpecies.h"
#endif
#ifndef SPECIES_HH
#include "species.hh"
@@ -125,7 +125,7 @@
int cur_count, best_count = MAX_CREATURE_SIZE;
cSpecies * cur_species;
- if (record_level == SPECIES_RECORD_FULL) {
+ if (record_level == nSpecies::RECORD_FULL) {
cur_species = active_queue.GetFirst();
int size = active_queue.GetSize();
for (int i = 0; i < size; i++) {
@@ -140,7 +140,7 @@
}
}
- if (record_level == SPECIES_RECORD_LIMITED) {
+ if (record_level == nSpecies::RECORD_LIMITED) {
cur_species = in_genotype.GetSpecies();
if (cur_species) {
Modified: trunk/source/testsuites/unit_testsuites/landscape.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/landscape.t.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/testsuites/unit_testsuites/landscape.t.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,5 +1,5 @@
#ifndef LANDSCAPE_HH
-#include "landscape.hh"
+#include "cLandscape.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/lineage.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/lineage.t.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/testsuites/unit_testsuites/lineage.t.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,5 +1,5 @@
#ifndef LINEAGE_HH
-#include "lineage.hh"
+#include "cLineage.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/lineage_control.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/lineage_control.t.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/testsuites/unit_testsuites/lineage_control.t.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,5 +1,5 @@
#ifndef LINEAGE_CONTROL_HH
-#include "lineage_control.hh"
+#include "cLineageControl.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/local_mutations.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/local_mutations.t.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/testsuites/unit_testsuites/local_mutations.t.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,5 +1,5 @@
#ifndef LOCAL_MUTATIONS_HH
-#include "local_mutations.hh"
+#include "cLocalMutations.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/mutation.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/mutation.t.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/testsuites/unit_testsuites/mutation.t.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,5 +1,5 @@
#ifndef MUTATION_HH
-#include "mutation.hh"
+#include "cMutation.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/mutation_lib.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/mutation_lib.t.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/testsuites/unit_testsuites/mutation_lib.t.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,5 +1,5 @@
#ifndef MUTATION_LIB_HH
-#include "mutation_lib.hh"
+#include "cMutationLib.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/mutation_rates.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/mutation_rates.t.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/testsuites/unit_testsuites/mutation_rates.t.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,5 +1,5 @@
#ifndef MUTATION_RATES_HH
-#include "mutation_rates.hh"
+#include "cMutationRates.h"
#endif
#ifndef TEST_CASE_H
Modified: trunk/source/testsuites/unit_testsuites/mx_code_array.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/mx_code_array.t.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/testsuites/unit_testsuites/mx_code_array.t.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef MX_CODE_ARRAY_HH
-#include "mx_code_array.hh"
+#include "cMxCodeArray.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/my_code_array_less_than.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/my_code_array_less_than.t.cc 2005-10-04 02:37:32 UTC (rev 329)
+++ trunk/source/testsuites/unit_testsuites/my_code_array_less_than.t.cc 2005-10-05 23:24:09 UTC (rev 330)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef MY_CODE_ARRAY_LESS_THAN_HH
-#include "my_code_array_less_than.hh"
+#include "MyCodeArrayLessThan.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
More information about the Avida-cvs
mailing list