[Avida-cvs] [Avida2-svn] r297 - in trunk: . CMakeModules CMakeModules/Templates documentation/content/using documentation/content/using/glossary source source/bindings source/bindings/Boost.Python source/bindings/Boost.Python/AvidaGui source/cpu source/event source/main source/main/functional_testsuites source/main/functional_testsuites/config source/main/functional_testsuites/default.md5sum source/main/functional_testsuites/default.tail source/main/functional_testsuites/demo.md5sum source/main/functional_testsuites/demo.tail source/main/functional_testsuites/tedious.tail source/main/unit_testsuites source/main/unit_testsuites/config source/main/unit_testsuites/demo.hello source/python/AvidaGui2 source/qt-viewer source/qt-viewer/exp source/qt-viewer/exp/exp_cleanup source/qt-viewer/exp/exp_cleanup/analyzer source/qt-viewer/exp/exp_cleanup/analyzer_o source/qt-viewer/exp/exp_cleanup/containers source/qt-viewer/exp/exp_cleanup/dumb_gui source/qt-viewer/exp/exp_cleanup/exp_gui sou! rce/qt-viewer/exp/exp_cleanup/gui_factory source/qt-viewer/exp/exp_cleanup/map_gui source/qt-viewer/exp/exp_cleanup/mc source/qt-viewer/exp/exp_cleanup/mc/attributes source/qt-viewer/exp/exp_cleanup/memory_mgt source/qt-viewer/exp/exp_cleanup/menubar source/qt-viewer/exp/exp_cleanup/preferences source/qt-viewer/exp/exp_cleanup/prefs_gui_factory source/qt-viewer/exp/exp_cleanup/threaded_driver source/qt-viewer/exp/exp_cleanup/user_msg source/qt-viewer/exp/exp_cleanup2 source/qt-viewer/exp/share source/support source/support/config source/support/preset_organisms source/testsuites source/testsuites/functional_testsuites source/testsuites/functional_testsuites/config source/testsuites/functional_testsuites/default.md5sum source/testsuites/functional_testsuites/default.tail source/testsuites/functional_testsuites/default.tail.disabled source/testsuites/functional_testsuites/demo.md5sum source/testsuites/functional_testsuites/demo.tail.disabled source/testsuites/functional_tests! uites/tedious.tail.disabled source/testsuites/qt_viewer_unit_t! estsuite
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Sun Aug 28 15:25:36 PDT 2005
Author: brysonda
Date: 2005-08-28 18:25:35 -0400 (Sun, 28 Aug 2005)
New Revision: 297
Added:
trunk/Avida2.xcodeproj/
trunk/source/LEVELS.txt
trunk/source/MAP.txt
trunk/source/cpu/hardware_smt.cc
trunk/source/cpu/hardware_smt.h
trunk/source/cpu/hardware_smt_constants.h
trunk/source/cpu/hardware_smt_thread.cc
trunk/source/cpu/hardware_smt_thread.h
trunk/source/cpu/head_cpu.cc
trunk/source/cpu/head_cpu.hh
trunk/source/cpu/head_multi_mem.cc
trunk/source/cpu/head_multi_mem.hh
trunk/source/cpu/tInstLib.h
trunk/source/support/genesis.smt
trunk/source/support/inst_set.smt
trunk/source/support/organism.smt
trunk/source/tools/tObjectFactory.h
Removed:
trunk/Avida2.xcode/
trunk/CMakeModules/CVS/
trunk/CMakeModules/Templates/CVS/
trunk/CVS/
trunk/documentation/content/using/CVS/
trunk/documentation/content/using/glossary/CVS/
trunk/source/CVS/
trunk/source/LEVELS
trunk/source/MAP.renamed_to_avoid_naming_conflict_with_stl
trunk/source/bindings/Boost.Python/AvidaGui/CVS/
trunk/source/bindings/Boost.Python/CVS/
trunk/source/bindings/Boost.Python/event_factory.pyste
trunk/source/bindings/CVS/
trunk/source/cpu/4stack_head.cc
trunk/source/cpu/4stack_head.hh
trunk/source/cpu/CVS/
trunk/source/cpu/cpu_head.cc
trunk/source/cpu/cpu_head.hh
trunk/source/event/CVS/
trunk/source/event/cPopulation.events
trunk/source/event/cPopulation_event_list
trunk/source/event/event.cc
trunk/source/event/event_factory.cc
trunk/source/event/event_factory.hh
trunk/source/event/event_list_entry.cc
trunk/source/event/make_events.pl
trunk/source/event/population_event.cc
trunk/source/main/CVS/
trunk/source/main/functional_testsuites/CVS/
trunk/source/main/functional_testsuites/config/CVS/
trunk/source/main/functional_testsuites/default.md5sum/CVS/
trunk/source/main/functional_testsuites/default.tail/CVS/
trunk/source/main/functional_testsuites/demo.md5sum/CVS/
trunk/source/main/functional_testsuites/demo.tail/CVS/
trunk/source/main/functional_testsuites/tedious.tail/CVS/
trunk/source/main/unit_testsuites/CVS/
trunk/source/main/unit_testsuites/config/CVS/
trunk/source/main/unit_testsuites/demo.hello/CVS/
trunk/source/qt-viewer/CVS/
trunk/source/qt-viewer/exp/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/analyzer/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/analyzer_o/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/containers/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/dumb_gui/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/exp_gui/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/gui_factory/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/map_gui/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/mc/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/mc/attributes/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/memory_mgt/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/menubar/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/preferences/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/prefs_gui_factory/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/threaded_driver/CVS/
trunk/source/qt-viewer/exp/exp_cleanup/user_msg/CVS/
trunk/source/qt-viewer/exp/exp_cleanup2/CVS/
trunk/source/qt-viewer/exp/share/CVS/
trunk/source/support/CVS/
trunk/source/support/config/CVS/
trunk/source/support/preset_organisms/CVS/
trunk/source/testsuites/CVS/
trunk/source/testsuites/functional_testsuites/CVS/
trunk/source/testsuites/functional_testsuites/config/CVS/
trunk/source/testsuites/functional_testsuites/default.md5sum/CVS/
trunk/source/testsuites/functional_testsuites/default.tail.disabled/CVS/
trunk/source/testsuites/functional_testsuites/default.tail/CVS/
trunk/source/testsuites/functional_testsuites/demo.md5sum/CVS/
trunk/source/testsuites/functional_testsuites/demo.tail.disabled/CVS/
trunk/source/testsuites/functional_testsuites/tedious.tail.disabled/CVS/
trunk/source/testsuites/qt_viewer_unit_testsuites/CVS/
trunk/source/testsuites/unit_testsuites/CVS/
trunk/source/testsuites/unit_testsuites/level_0/CVS/
trunk/source/testsuites/unit_testsuites/level_1/CVS/
trunk/source/testsuites/unit_testsuites/ncurses_viewer/CVS/
trunk/source/third-party/CVS/
trunk/source/third-party/Loki/Borland/CVS/
trunk/source/third-party/Loki/CVS/
trunk/source/third-party/Loki/MSVC/1200/CVS/
trunk/source/third-party/Loki/MSVC/1300/CVS/
trunk/source/third-party/Loki/MSVC/CVS/
trunk/source/third-party/Loki/Reference/CVS/
trunk/source/third-party/Loki/tools/CVS/
trunk/source/third-party/Loki/tools/HeaderGen/CVS/
trunk/source/third-party/Loki/tools/RegressionTest/AllTest/CVS/
trunk/source/third-party/Loki/tools/RegressionTest/CVS/
trunk/source/third-party/Loki/tools/RegressionTest2/CVS/
trunk/source/third-party/PDCurses-2.6/CVS/
trunk/source/third-party/mockpp/
trunk/source/third-party/pdcurses/CVS/
trunk/source/third-party/trio-1.9/
trunk/source/third-party/trio/CVS/
trunk/source/third-party/trio/doc/CVS/
trunk/source/third-party/trio/html/CVS/
trunk/source/third-party/yaktest/CVS/
trunk/source/third-party/yaktest/example/CVS/
trunk/source/tools/CVS/
trunk/source/utils/CVS/
trunk/source/utils/hist_map/CVS/
trunk/source/utils/task_events/CVS/
trunk/source/viewers/CVS/
trunk/source/vista/CVS/
Modified:
trunk/CMakeLists.txt
trunk/CMakeModules/AddPysteModule.cmake
trunk/source/bindings/Boost.Python/4stack_head.pyste
trunk/source/bindings/Boost.Python/AvidaGui/py_avida_core_data.py
trunk/source/bindings/Boost.Python/CMakeLists.txt
trunk/source/bindings/Boost.Python/cpu_head-fixups.cc
trunk/source/bindings/Boost.Python/cpu_head-fixups.hh
trunk/source/bindings/Boost.Python/cpu_head.pyste
trunk/source/bindings/Boost.Python/event_factory_manager.pyste
trunk/source/bindings/Boost.Python/generatePysteFiles.py
trunk/source/bindings/Boost.Python/phenotype.pyste
trunk/source/bindings/Boost.Python/py_avida_driver-fixups.cc
trunk/source/bindings/Boost.Python/tList.pyste
trunk/source/cpu/CMakeLists.txt
trunk/source/cpu/code_label.cc
trunk/source/cpu/code_label.hh
trunk/source/cpu/cpu_defs.hh
trunk/source/cpu/cpu_stack.hh
trunk/source/cpu/hardware_4stack.cc
trunk/source/cpu/hardware_4stack.hh
trunk/source/cpu/hardware_4stack_thread.cc
trunk/source/cpu/hardware_4stack_thread.hh
trunk/source/cpu/hardware_cpu.cc
trunk/source/cpu/hardware_cpu.hh
trunk/source/cpu/hardware_cpu_thread.hh
trunk/source/cpu/hardware_factory.cc
trunk/source/cpu/hardware_status_printer.cc
trunk/source/cpu/hardware_tracer.hh
trunk/source/cpu/hardware_tracer_4stack.hh
trunk/source/cpu/hardware_tracer_cpu.hh
trunk/source/cpu/hardware_tracer_test_cpu.hh
trunk/source/cpu/hardware_util.cc
trunk/source/cpu/hardware_util.hh
trunk/source/defs.hh
trunk/source/event/CMakeLists.txt
trunk/source/event/event.hh
trunk/source/event/event.pri
trunk/source/event/event_factory_manager.cc
trunk/source/event/event_factory_manager.hh
trunk/source/event/event_list.cc
trunk/source/event/event_list_entry.hh
trunk/source/event/event_triggers.hh
trunk/source/event/population_event.hh
trunk/source/event/population_event_factory.cc
trunk/source/event/population_event_factory.hh
trunk/source/main/analyze.cc
trunk/source/main/avida.cc
trunk/source/main/avida_driver_population.cc
trunk/source/main/config.cc
trunk/source/main/config.hh
trunk/source/main/environment.cc
trunk/source/main/genebank.cc
trunk/source/main/genotype.cc
trunk/source/main/inject_genotype.cc
trunk/source/main/inst_lib_base.hh
trunk/source/main/inst_set.hh
trunk/source/main/inst_util.cc
trunk/source/main/phenotype.cc
trunk/source/main/population.cc
trunk/source/main/primitive.cc
trunk/source/main/task_lib.cc
trunk/source/python/AvidaGui2/pyAvida.py
trunk/source/python/AvidaGui2/pyWriteGenesisEvent.py
trunk/source/qt-viewer/event_view_widget.cc
trunk/source/qt-viewer/setup_wizard_config.cc
trunk/source/support/genesis
trunk/source/support/genesis.4stack
trunk/source/testsuites/functional_testsuites/default.md5sum/genesis
trunk/source/testsuites/functional_testsuites/default.tail.disabled/genesis
trunk/source/testsuites/functional_testsuites/default.tail/genesis
trunk/source/testsuites/functional_testsuites/tedious.tail.disabled/genesis
trunk/source/testsuites/unit_testsuites/4stack_head.t.cc
trunk/source/testsuites/unit_testsuites/cpu_head.t.cc
trunk/source/third-party/yaktest/cTestCase.hh
trunk/source/tools/block_struct.cc
trunk/source/tools/functions.hh
trunk/source/tools/histogram.cc
trunk/source/tools/histogram.hh
trunk/source/tools/indexed_block_struct.cc
trunk/source/tools/init_file.cc
trunk/source/tools/message_display.cc
trunk/source/tools/message_display.hh
trunk/source/tools/random.hh
trunk/source/tools/tools.cc
trunk/source/viewers/symbol_util.cc
trunk/source/viewers/viewer.cc
trunk/source/viewers/zoom_screen.cc
Log:
Merge r175:296 from branches/brysonda into trunk
Copied: trunk/Avida2.xcodeproj (from rev 296, branches/brysonda/Avida2.xcodeproj)
Modified: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/CMakeLists.txt 2005-08-28 22:25:35 UTC (rev 297)
@@ -15,7 +15,7 @@
# - release (Release)
# - release with debug info (RelWithDebInfo)
SET(CMAKE_CXX_FLAGS_DEBUG
- "-g ${COMPILER_WARNING_FLAGS} -pedantic -DDEBUG"
+ "-g ${COMPILER_WARNING_FLAGS} -DDEBUG"
CACHE STRING "Flags used by the compiler during debug builds.")
SET(CMAKE_CXX_FLAGS_MINSIZEREL
"-Os -DNDEBUG"
@@ -24,7 +24,7 @@
"-O3 -ffast-math -DNDEBUG"
CACHE STRING "Flags used by the compiler during release builds.")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
- "-O2 -ffast-math -g ${COMPILER_WARNING_FLAGS} -pedantic -DDEBUG"
+ "-O2 -ffast-math -g ${COMPILER_WARNING_FLAGS} -DDEBUG"
CACHE STRING "Flags used by the compiler during release builds.")
# Four types of c compilations:
@@ -33,7 +33,7 @@
# - release (Release)
# - release with debug info (RelWithDebInfo)
SET(CMAKE_C_FLAGS_DEBUG
- "-g ${COMPILER_WARNING_FLAGS} -pedantic -DDEBUG"
+ "-g ${COMPILER_WARNING_FLAGS} -DDEBUG"
CACHE STRING "Flags used by the compiler during debug builds.")
SET(CMAKE_C_FLAGS_MINSIZEREL
"-Os -DNDEBUG"
@@ -42,7 +42,7 @@
"-O3 -ffast-math -DNDEBUG"
CACHE STRING "Flags used by the compiler during release builds.")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO
- "-O2 -ffast-math -g ${COMPILER_WARNING_FLAGS} -pedantic -DDEBUG"
+ "-O2 -ffast-math -g ${COMPILER_WARNING_FLAGS} -DDEBUG"
CACHE STRING "Flags used by the compiler during release builds.")
# By default, show all build commands.
Modified: trunk/CMakeModules/AddPysteModule.cmake
===================================================================
--- trunk/CMakeModules/AddPysteModule.cmake 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/CMakeModules/AddPysteModule.cmake 2005-08-28 22:25:35 UTC (rev 297)
@@ -2,7 +2,6 @@
INCLUDE_DIRECTORIES(${BOOST_INCLUDE_PATH} ${PYTHON_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${ALL_INC_DIRS} ${PROJECT_SOURCE_DIR}/source/third-party/yaktest)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
-#LINK_DIRECTORIES(${PY_BOOST_LIBRARIES})
IF(APPLE)
SET(BOOST_PYTHON_COMPILE_FLAGS "-no-cpp-precomp -ftemplate-depth-120 -fno-inline -fPIC -Wno-long-double -Wno-long-long -DBOOST_PYTHON_DYNAMIC_LIB")
@@ -31,10 +30,7 @@
#XXX
FOREACH(Entry ${${PysteBases}})
STRING(REGEX REPLACE "(.*)::(.*)" "\\1" PysteBase ${Entry})
- #STRING(REGEX REPLACE "(.*)::(.*)" "\\2" DepList ${Entry})
SET(${ModuleName}_CppFiles ${${ModuleName}_CppFiles} ${CMAKE_CURRENT_BINARY_DIR}/${ModuleName}/_${PysteBase}.cpp)
- #FILE(GLOB tmpfile "${PROJECT_SOURCE_DIR}/source/*/${PysteBase}.hh")
- #MESSAGE("found \"${PysteBase}.hh\" at \"${tmpfile}\".")
ENDFOREACH(Entry ${${PysteBases}})
SET(${ModuleName}_CppFiles ${${ModuleName}_CppFiles} ${CMAKE_CURRENT_BINARY_DIR}/${ModuleName}/_main.cpp)
@@ -57,20 +53,6 @@
ENDIF(${ExtraDepends})
#
- # A list of dummy cpp source files used as dependencies for
- # corresponding pyste files. Each of the dummy cpp files includes the
- # headers required by the corresponding pyste files.
- #
- # I couldn't think of any easier ways to trigger dependency tracking
- # for the pyste files.
- #
- #SET(Dummy_${ModuleName}_CppFiles)
- #FOREACH(PysteBase ${${PysteBases}})
- # SET(Dummy_${ModuleName}_CppFiles ${Dummy_${ModuleName}_CppFiles} ${CMAKE_CURRENT_SOURCE_DIR}/dummy_${PysteBase}.cc)
- #ENDFOREACH(PysteBase ${${PysteBases}})
- #ADD_LIBRARY(Dummy_${ModuleName} MODULE ${Dummy_${ModuleName}_CppFiles})
-
- #
# Make a list of pyste source files to parse, and for each such file, add the parsing command that produces the
# corresponding cpp source file.
#
@@ -78,8 +60,6 @@
SET(${ModuleName}_PysteCacheFiles)
#XXX
FOREACH(Entry ${${PysteBases}})
- #STRING(REGEX REPLACE "(.*)::" "\\1" PysteBase ${Entry})
- #STRING(REGEX REPLACE "::(.*)" "\\1" Args ${Entry})
STRING(REGEX REPLACE "(.*)::(.*)" "\\1" PysteBase ${Entry})
STRING(REGEX REPLACE "(.*)::(.*)" "\\2" Args ${Entry})
IF(Args)
@@ -94,12 +74,7 @@
${CMAKE_CURRENT_BINARY_DIR}/${ModuleName}/${PysteBase}.pystec)
FILE(GLOB HeaderFile "${PROJECT_SOURCE_DIR}/source/*/${PysteBase}.hh")
FILE(GLOB ThirdPartyHeaderFile "${PROJECT_SOURCE_DIR}/source/*/*/${PysteBase}.hh")
- #MESSAGE("\"${PysteBase}.hh\" dependencies :")
- #MESSAGE("...\"${HeaderFile}\"")
SET(DepList ${HeaderFile} ${ThirdPartyHeaderFile} ${DepList})
- #FOREACH(Dep ${DepList})
- # MESSAGE(" \"${Dep}\"")
- #ENDFOREACH(Dep ${DepList})
ADD_CUSTOM_COMMAND(COMMENT "${PysteBase} pyste cache file..."
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ModuleName}/${PysteBase}.pystec
@@ -207,12 +182,7 @@
FILE(GLOB HeaderFile "${PROJECT_SOURCE_DIR}/source/*/${PysteBase}.hh")
FILE(GLOB ThirdPartyHeaderFile "${PROJECT_SOURCE_DIR}/source/*/*/${PysteBase}.hh")
- #MESSAGE("\"${PysteBase}.hh\" dependencies :")
- #MESSAGE("...\"${HeaderFile}\"")
SET(DepList ${HeaderFile} ${ThirdPartyHeaderFile} ${DepList})
- #FOREACH(Dep ${DepList})
- # MESSAGE(" \"${Dep}\"")
- #ENDFOREACH(Dep ${DepList})
ADD_CUSTOM_COMMAND(COMMENT "${PysteBase} pyste cache file..."
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PysteBase}.pystec
@@ -256,8 +226,4 @@
INSTALL_TARGETS(${PackageLocation}/${ModuleName} $${ModuleName}/${PysteBase})
FILE(APPEND ${LIBRARY_OUTPUT_PATH}/${ModuleName}/__init__.py "from ${PysteBase} import *\n")
ENDFOREACH(Entry ${${PysteBases}})
- #FOREACH(Entry ${${PysteBases}})
- # STRING(REGEX REPLACE "(.*)::(.*)" "\\1" PysteBase ${Entry})
- # FILE(APPEND ${LIBRARY_OUTPUT_PATH}/${ModuleName}/__init__.py "del(${PysteBase})\n")
- #ENDFOREACH(Entry ${${PysteBases}})
ENDMACRO(ADD_PYSTE_PACKAGE)
Deleted: trunk/source/LEVELS
===================================================================
--- trunk/source/LEVELS 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/LEVELS 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,95 +0,0 @@
-Pure headers:
- defs.hh
- cpu_defs.hh
-
-A '*' indicates dependency is in the header, otherwise body is assumed.
-
---Component-- --Dependencies--
-LEVEL 0
-config [none]
-cpu_stats [none]
-cpu_stack [none]
-inst [none]
-label [none]
-mutations [none]
-pop_interface [none]
-reaction [none]
-reaction_result [none]
-resource [none]
-resource_count [none]
-tasks [none]
-
-LEVEL 1
-genome *inst
-inst_lib *inst
-stats config
-
-LEVEL 2
-environment *reaction *resource *tasks *inst_lib *mutations
- *reaction_result
-cpu_memory *genome
-genome_util genome
-hardware_base *inst inst_lib
-inst_util inst_lib genome
-
-LEVEL 3
-phenotype *environment config
-head *inst inst_lib hardware_base cpu_memory label
-
-LEVEL 4
-organism *mutations *pop_interface *cpu_stats *phenotype
- config inst_lib inst_util genome genome_util hardware_base
-
-LEVEL 5
-population_cell *mutations organism
-test_cpu config hardware_base inst_lib inst_util organism
- phenotype pop_interface resource_count tasks
-
-LEVEL 6
-fitness_matrix *stats *organism test_cpu config inst_lib
-genotype *genome config genome_util organism phenotype stats
- test_cpu
-hardware_cpu *cpu_memory *cpu_stack *label *head
- config inst_lib genome_util organism phenotype test_cpu
-
-LEVEL 7
-hardware_factory hardware_base hardware_cpu
-hardware_util inst_lib inst_util hardware_base hardware_cpu config
-lineage genotype stats
-species *genome stats genotype genome_util test_cpu
-test_util genome genotype inst_util organism phenotype stats
- hardware_base test_cpu
-
-LEVEL 8
-genebank species genotype config stats test_util
-landscape *genome *test_cpu cpu_memory stats inst_lib organism
- phenotype test_util
-
-LEVEL 9
-analyze *genome config species fitness_matrix inst_lib inst_util
- landscape phenotype genome_util test_cpu hardware_util
- test_util environment
-birth_chamber label genome organism genotype genebank
-lineage_control stats config lineage genome genome_util genebank
- genotype organism
-
-LEVEL 10
-population *resource_count *inst_lib *pop_interface *mutations config
- genebank genome_util genotype hardware_base
- hardware_factory hardware_util inst_util lineage
- lineage_control organism phenotype population_cell
- species stats tasks birth_chamber
-
-
-LEVEL 11
-analyze_util config genebank genome genome_util genotype inst_lib
- inst_util landscape organism phenotype population
- population_cell species stats test_cpu test_util
-callback_util avida config genotype organism population population_cell
- pop_interface hardware_base hardware_factory test_cpu
- birth_chamber
-
-LEVEL 12
-avida *stats environment genotype genebank analyze config
- species genome_util test_cpu callback_util population
- {events} {viewers}
Copied: trunk/source/LEVELS.txt (from rev 296, branches/brysonda/source/LEVELS.txt)
Deleted: trunk/source/MAP.renamed_to_avoid_naming_conflict_with_stl
===================================================================
--- trunk/source/MAP.renamed_to_avoid_naming_conflict_with_stl 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/MAP.renamed_to_avoid_naming_conflict_with_stl 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,112 +0,0 @@
-These dependencies do not include built-in libraries, files from the
-tools directory in avida, or defs.hh. It is further assumed that a *.ii
-file has the corresponding *.hh as its first include, and likewise *.cc
-has both *.hh and *.ii. Files with nothing listed have no additional
-dependencies.
-
-There is a seperate tools MAP in the 'source/tools/' directory.
-
-DIRECTORY: source/main/
-
-analyze.hh : data_entry.hh genome.hh
-analyze.cc : config.hh species.hh fitness_matrix.hh
- inst_lib.hh landscape.hh phenotype.hh test_cpu.hh
-
-avida.hh :
-avida.cc : population.hh genotype.hh genebank.hh analyze.hh
- config.hh test_cpu.hh tasks.hh stats.hh
- species.hh
-
-config.hh :
-config.cc :
-
-fitness_matrix.hh : cpu.hh test_cpu.hh stats.hh
-fitness_matrix.cc : config.hh inst_lib.hh
-
-genebank.hh :
-genebank.cc : species.hh population.hh genotype.hh config.hh
- stats.hh test_cpu.hh
-
-genome.hh : inst.hh
-genome.cc :
-
-genome_util.hh :
-genome_util.cc : genome.hh
-
-genotype.hh : genome.hh
-genotype.cc : stats.hh config.hh test_cpu.hh
-
-inst.hh :
-inst.cc :
-
-inst_lib.hh : inst.hh
-inst_lib.cc : cpu.hh
-
-landscape.hh : test_cpu.hh
-landscape.cc : stats.hh inst_lib.hh
-
-lineage.hh :
-lineage.cc : stats.hh genotype.hh
-
-lineage_control.hh :
-lineage_control.cc : lineage.hh stats.hh config.hh genebank.hh
- landscape.hh genotype.hh cpu.hh
-
-phenotype.hh : tasks.hh
-phenotype.cc : config.hh cpu.hh
-
-population.hh : cpu.hh
-population.cc : avida.hh stats.hh genebank.hh inst_lib.hh
- species.hh genotype.hh landscape.hh tasks.hh
- config.hh environment.hh
- phenotype.hh lineage.hh lineage_control.hh
-
-species.hh : genome.hh
-species.cc : stats.hh genotype.hh test_cpu.hh
-
-stats.hh :
-stats.cc : config.hh genotype.hh lineage_control.hh
- lineage.hh test_cpu.hh
-
-task_buffer.hh :
-task_buffer.cc :
-
-tasks.hh : task_buffer.hh
-tasks.cc : stats.hh config.hh
-
-
-DIRECTORY: source/cpu/
-
-cpu.hh : cpu_defs.hh cpu_stats.hh cpu_memory.hh
- head.hh creature.hh hardware.hh
-cpu.cc : environment.hh phenotype.hh inst_lib.hh
- genotype.hh landscape.hh config.hh
- stats.hh genome.hh genome_util.hh
-
-cpu_memory.hh : genome.hh
-cpu_memory.cc :
-
-cpu_defs.hh :
-cpu_stats.hh :
-creature.hh :
-
-environment.hh : head.hh
-environment.cc : population.hh genebank.hh stats.hh genotype.hh
-
-hardware.hh : task_buffer.hh cpu_defs.hh label.hh
- head.hh cpu_memory.hh
-hardware.cc : config.hh phenotype.hh inst_lib.hh
-
-head.hh : inst.hh
-head.cc : environment.hh inst_lib.hh cpu.hh
-
-label.hh : cpu_defs.hh
-label.cc :
-
-test_cpu.hh : cpu.hh
-test_cpu.cc : hardware.hh genotype.hh config.hh
- phenotype.hh stats.hh inst_lib.hh
-
-
-DIRECTORY: source/viewers/
-
Copied: trunk/source/MAP.txt (from rev 296, branches/brysonda/source/MAP.txt)
Modified: trunk/source/bindings/Boost.Python/4stack_head.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/4stack_head.pyste 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/bindings/Boost.Python/4stack_head.pyste 2005-08-28 22:25:35 UTC (rev 297)
@@ -5,12 +5,12 @@
Include("instruction.hh")
Include("hardware_base.hh")
-c4StackHead = Class("c4StackHead", "4stack_head.hh")
-set_policy(c4StackHead.FlagCopied, return_internal_reference())
-set_policy(c4StackHead.FlagMutated, return_internal_reference())
-set_policy(c4StackHead.FlagExecuted, return_internal_reference())
-set_policy(c4StackHead.FlagPointMut, return_internal_reference())
-set_policy(c4StackHead.FlagCopyMut, return_internal_reference())
-set_policy(c4StackHead.FlagBreakpoint, return_internal_reference())
+cHeadMultiMem = Class("cHeadMultiMem", "head_multi_mem.hh")
+set_policy(cHeadMultiMem.FlagCopied, return_internal_reference())
+set_policy(cHeadMultiMem.FlagMutated, return_internal_reference())
+set_policy(cHeadMultiMem.FlagExecuted, return_internal_reference())
+set_policy(cHeadMultiMem.FlagPointMut, return_internal_reference())
+set_policy(cHeadMultiMem.FlagCopyMut, return_internal_reference())
+set_policy(cHeadMultiMem.FlagBreakpoint, return_internal_reference())
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/AvidaGui/py_avida_core_data.py
===================================================================
--- trunk/source/bindings/Boost.Python/AvidaGui/py_avida_core_data.py 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/bindings/Boost.Python/AvidaGui/py_avida_core_data.py 2005-08-28 22:25:35 UTC (rev 297)
@@ -21,7 +21,7 @@
import sys
sys.exit()
self.environment.GetInstSet().SetInstLib(cHardwareCPU.GetInstLib())
- cHardwareUtil.LoadInstSet_CPUOriginal(cConfig.GetInstFilename(), self.environment.GetInstSet())
+ cHardwareUtil.LoadInstSet(cConfig.GetInstFilename(), self.environment.GetInstSet())
cConfig.SetNumInstructions(self.environment.GetInstSet().GetSize())
cConfig.SetNumTasks(self.environment.GetTaskLib().GetSize())
cConfig.SetNumReactions(self.environment.GetReactionLib().GetSize())
Modified: trunk/source/bindings/Boost.Python/CMakeLists.txt
===================================================================
--- trunk/source/bindings/Boost.Python/CMakeLists.txt 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/bindings/Boost.Python/CMakeLists.txt 2005-08-28 22:25:35 UTC (rev 297)
@@ -28,44 +28,14 @@
ENDFOREACH(PY_TEST_SUITE)
#
-# kaben-brainstorms.
-#
-#SET(libkaben_brainstorms_SOURCES kaben_brainstorms.cc)
-#SET_SOURCE_FILES_PROPERTIES(${libkaben_brainstorms_SOURCES} PROPERTIES COMPILE_FLAGS ${BOOST_PYTHON_COMPILE_FLAGS})
-#ADD_LIBRARY(kaben_brainstorms MODULE ${libkaben_brainstorms_SOURCES})
-#SET_TARGET_PROPERTIES(kaben_brainstorms PROPERTIES PREFIX "")
-#TARGET_LINK_LIBRARIES(kaben_brainstorms main cpu event main tools ${BOOST_LIBRARY} ${PYTHON_LIBRARY})
-
-
-#
# A test of python packaging.
#
SET(PyAvida_Pyste_Bases
- #A::${CMAKE_CURRENT_SOURCE_DIR}/A.hh:
- #B::${CMAKE_CURRENT_SOURCE_DIR}/B.hh:
- # XXX : cCallbackUtil is used by taking pointers to its member functions. Doesn't play well with Python; don't wrap it.
- #callback_util::
- # XXX : cBlockStruct is designed for use with raw pointers, and won't play well with Python. Hence, don't wrap it.
- #block_struct::
- # XXX : cScaledBlock is designed for use with raw pointers, and won't play well with Python. Hence, don't wrap it.
- #scaled_block::
-
# XXX I can't figure out how it works.
tArray::${CMAKE_CURRENT_SOURCE_DIR}/organism.pyste:${CMAKE_CURRENT_SOURCE_DIR}/merit.pyste:${CMAKE_CURRENT_SOURCE_DIR}/mutation.pyste:${CMAKE_CURRENT_SOURCE_DIR}/int_sum.pyste:
- # XXX Boost doesn't like that tMatrix returns refs to doubles.
- #tMatrix::
cpu_head::
- ###4stack_head::${CMAKE_CURRENT_SOURCE_DIR}/cpu_head.pyste:
- ###event::
- ###population_event::${CMAKE_CURRENT_SOURCE_DIR}/event.pyste:
- ###analyze_command_def::${CMAKE_CURRENT_SOURCE_DIR}/analyze_command_def_base.pyste:
- ###analyze_flow_command_def::${CMAKE_CURRENT_SOURCE_DIR}/analyze_command_def_base.pyste:
- ###random::
- ###tools::
- ###event_list_entry::
- ###analyze_command::
phenotype::
population_cell::
merit::
@@ -99,12 +69,9 @@
lineage_control::
mutation_lib::
organism::
- ###event_factory::
- ###population_event_factory::${CMAKE_CURRENT_SOURCE_DIR}/event_factory.pyste:
cpu_test_info::
hardware_factory::
event_factory_manager::
- #analyze_flow_command::${CMAKE_CURRENT_SOURCE_DIR}/analyze_command.pyste:
analyze_function::
genotype_batch::
inject_genotype::
@@ -183,7 +150,6 @@
file::${CMAKE_CURRENT_SOURCE_DIR}/file-fixups.hh # XXX XXX XXX
init_file::${CMAKE_CURRENT_SOURCE_DIR}/file.pyste # XXX XXX XXX
genesis::${CMAKE_CURRENT_SOURCE_DIR}/init_file.pyste:${CMAKE_CURRENT_SOURCE_DIR}/genesis-fixups.hh # XXX XXX XXX
- #hardware_base::${CPU_SRC_DIR}/hardware_base.hh # XXX XXX XXX
hardware_base::
hardware_4stack::${CMAKE_CURRENT_SOURCE_DIR}/hardware_base.pyste # XXX XXX XXX
hardware_cpu::${CMAKE_CURRENT_SOURCE_DIR}/hardware_base.pyste:${CMAKE_CURRENT_SOURCE_DIR}/hardware_cpu-fixups.hh # XXX XXX XXX
Modified: trunk/source/bindings/Boost.Python/cpu_head-fixups.cc
===================================================================
--- trunk/source/bindings/Boost.Python/cpu_head-fixups.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/bindings/Boost.Python/cpu_head-fixups.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,40 +1,40 @@
#include "cpu_head-fixups.hh"
-bool cCPUHead_GetFlagCopied(cCPUHead &cpu_head){
+bool cHeadCPU_GetFlagCopied(cHeadCPU &cpu_head){
return cpu_head.FlagCopied();
}
-bool cCPUHead_GetFlagMutated(cCPUHead &cpu_head){
+bool cHeadCPU_GetFlagMutated(cHeadCPU &cpu_head){
return cpu_head.FlagMutated();
}
-bool cCPUHead_GetFlagExecuted(cCPUHead &cpu_head){
+bool cHeadCPU_GetFlagExecuted(cHeadCPU &cpu_head){
return cpu_head.FlagExecuted();
}
-bool cCPUHead_GetFlagBreakpoint(cCPUHead &cpu_head){
+bool cHeadCPU_GetFlagBreakpoint(cHeadCPU &cpu_head){
return cpu_head.FlagBreakpoint();
}
-bool cCPUHead_GetFlagPointMut(cCPUHead &cpu_head){
+bool cHeadCPU_GetFlagPointMut(cHeadCPU &cpu_head){
return cpu_head.FlagPointMut();
}
-bool cCPUHead_GetFlagCopyMut(cCPUHead &cpu_head){
+bool cHeadCPU_GetFlagCopyMut(cHeadCPU &cpu_head){
return cpu_head.FlagCopyMut();
}
-void cCPUHead_SetFlagCopied(cCPUHead &cpu_head, bool flag){
+void cHeadCPU_SetFlagCopied(cHeadCPU &cpu_head, bool flag){
cpu_head.FlagCopied() = flag;
}
-void cCPUHead_SetFlagMutated(cCPUHead &cpu_head, bool flag){
+void cHeadCPU_SetFlagMutated(cHeadCPU &cpu_head, bool flag){
cpu_head.FlagMutated() = flag;
}
-void cCPUHead_SetFlagExecuted(cCPUHead &cpu_head, bool flag){
+void cHeadCPU_SetFlagExecuted(cHeadCPU &cpu_head, bool flag){
cpu_head.FlagExecuted() = flag;
}
-void cCPUHead_SetFlagBreakpoint(cCPUHead &cpu_head, bool flag){
+void cHeadCPU_SetFlagBreakpoint(cHeadCPU &cpu_head, bool flag){
cpu_head.FlagBreakpoint() = flag;
}
-void cCPUHead_SetFlagPointMut(cCPUHead &cpu_head, bool flag){
+void cHeadCPU_SetFlagPointMut(cHeadCPU &cpu_head, bool flag){
cpu_head.FlagPointMut() = flag;
}
-void cCPUHead_SetFlagCopyMut(cCPUHead &cpu_head, bool flag){
+void cHeadCPU_SetFlagCopyMut(cHeadCPU &cpu_head, bool flag){
cpu_head.FlagCopyMut() = flag;
}
Modified: trunk/source/bindings/Boost.Python/cpu_head-fixups.hh
===================================================================
--- trunk/source/bindings/Boost.Python/cpu_head-fixups.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/bindings/Boost.Python/cpu_head-fixups.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,22 +1,22 @@
#ifndef CPU_HEAD_FIXUPS_HH
#define CPU_HEAD_FIXUPS_HH
-#ifndef CPU_HEAD_HH
-#include "cpu_head.hh"
+#ifndef HEAD_CPU_HH
+#include "head_cpu.hh"
#endif
-bool cCPUHead_GetFlagCopied(cCPUHead &);
-bool cCPUHead_GetFlagMutated(cCPUHead &);
-bool cCPUHead_GetFlagExecuted(cCPUHead &);
-bool cCPUHead_GetFlagBreakpoint(cCPUHead &);
-bool cCPUHead_GetFlagPointMut(cCPUHead &);
-bool cCPUHead_GetFlagCopyMut(cCPUHead &);
+bool cHeadCPU_GetFlagCopied(cHeadCPU &);
+bool cHeadCPU_GetFlagMutated(cHeadCPU &);
+bool cHeadCPU_GetFlagExecuted(cHeadCPU &);
+bool cHeadCPU_GetFlagBreakpoint(cHeadCPU &);
+bool cHeadCPU_GetFlagPointMut(cHeadCPU &);
+bool cHeadCPU_GetFlagCopyMut(cHeadCPU &);
-void cCPUHead_SetFlagCopied(cCPUHead &, bool);
-void cCPUHead_SetFlagMutated(cCPUHead &, bool);
-void cCPUHead_SetFlagExecuted(cCPUHead &, bool);
-void cCPUHead_SetFlagBreakpoint(cCPUHead &, bool);
-void cCPUHead_SetFlagPointMut(cCPUHead &, bool);
-void cCPUHead_SetFlagCopyMut(cCPUHead &, bool);
+void cHeadCPU_SetFlagCopied(cHeadCPU &, bool);
+void cHeadCPU_SetFlagMutated(cHeadCPU &, bool);
+void cHeadCPU_SetFlagExecuted(cHeadCPU &, bool);
+void cHeadCPU_SetFlagBreakpoint(cHeadCPU &, bool);
+void cHeadCPU_SetFlagPointMut(cHeadCPU &, bool);
+void cHeadCPU_SetFlagCopyMut(cHeadCPU &, bool);
#endif
Modified: trunk/source/bindings/Boost.Python/cpu_head.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/cpu_head.pyste 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/bindings/Boost.Python/cpu_head.pyste 2005-08-28 22:25:35 UTC (rev 297)
@@ -4,44 +4,44 @@
Include("hardware_base.hh")
Include("code_label.hh")
-cCPUHead = Class("cCPUHead", "cpu_head-fixups.hh")
-set_policy(cCPUHead.GetCurHardware, return_internal_reference())
-set_policy(cCPUHead.GetMainHardware, return_internal_reference())
+cHeadCPU = Class("cHeadCPU", "cpu_head-fixups.hh")
+set_policy(cHeadCPU.GetCurHardware, return_internal_reference())
+set_policy(cHeadCPU.GetMainHardware, return_internal_reference())
-exclude(cCPUHead.FlagCopied)
-exclude(cCPUHead.FlagMutated)
-exclude(cCPUHead.FlagExecuted)
-exclude(cCPUHead.FlagPointMut)
-exclude(cCPUHead.FlagCopyMut)
-exclude(cCPUHead.FlagBreakpoint)
+exclude(cHeadCPU.FlagCopied)
+exclude(cHeadCPU.FlagMutated)
+exclude(cHeadCPU.FlagExecuted)
+exclude(cHeadCPU.FlagPointMut)
+exclude(cHeadCPU.FlagCopyMut)
+exclude(cHeadCPU.FlagBreakpoint)
-add_method(cCPUHead, "cCPUHead_GetFlagCopied")
-add_method(cCPUHead, "cCPUHead_GetFlagMutated")
-add_method(cCPUHead, "cCPUHead_GetFlagExecuted")
-add_method(cCPUHead, "cCPUHead_GetFlagPointMut")
-add_method(cCPUHead, "cCPUHead_GetFlagCopyMut")
-add_method(cCPUHead, "cCPUHead_GetFlagBreakpoint")
+add_method(cHeadCPU, "cHeadCPU_GetFlagCopied")
+add_method(cHeadCPU, "cHeadCPU_GetFlagMutated")
+add_method(cHeadCPU, "cHeadCPU_GetFlagExecuted")
+add_method(cHeadCPU, "cHeadCPU_GetFlagPointMut")
+add_method(cHeadCPU, "cHeadCPU_GetFlagCopyMut")
+add_method(cHeadCPU, "cHeadCPU_GetFlagBreakpoint")
-add_method(cCPUHead, "cCPUHead_SetFlagCopied")
-add_method(cCPUHead, "cCPUHead_SetFlagMutated")
-add_method(cCPUHead, "cCPUHead_SetFlagExecuted")
-add_method(cCPUHead, "cCPUHead_SetFlagPointMut")
-add_method(cCPUHead, "cCPUHead_SetFlagCopyMut")
-add_method(cCPUHead, "cCPUHead_SetFlagBreakpoint")
+add_method(cHeadCPU, "cHeadCPU_SetFlagCopied")
+add_method(cHeadCPU, "cHeadCPU_SetFlagMutated")
+add_method(cHeadCPU, "cHeadCPU_SetFlagExecuted")
+add_method(cHeadCPU, "cHeadCPU_SetFlagPointMut")
+add_method(cHeadCPU, "cHeadCPU_SetFlagCopyMut")
+add_method(cHeadCPU, "cHeadCPU_SetFlagBreakpoint")
-rename(cCPUHead.cCPUHead_GetFlagCopied, "GetFlagCopied");
-rename(cCPUHead.cCPUHead_GetFlagMutated, "GetFlagMutated");
-rename(cCPUHead.cCPUHead_GetFlagExecuted, "GetFlagExecuted");
-rename(cCPUHead.cCPUHead_GetFlagPointMut, "GetFlagPointMut");
-rename(cCPUHead.cCPUHead_GetFlagCopyMut, "GetFlagCopyMut");
-rename(cCPUHead.cCPUHead_GetFlagBreakpoint, "GetFlagBreakpoint");
+rename(cHeadCPU.cHeadCPU_GetFlagCopied, "GetFlagCopied");
+rename(cHeadCPU.cHeadCPU_GetFlagMutated, "GetFlagMutated");
+rename(cHeadCPU.cHeadCPU_GetFlagExecuted, "GetFlagExecuted");
+rename(cHeadCPU.cHeadCPU_GetFlagPointMut, "GetFlagPointMut");
+rename(cHeadCPU.cHeadCPU_GetFlagCopyMut, "GetFlagCopyMut");
+rename(cHeadCPU.cHeadCPU_GetFlagBreakpoint, "GetFlagBreakpoint");
-rename(cCPUHead.cCPUHead_SetFlagCopied, "SetFlagCopied");
-rename(cCPUHead.cCPUHead_SetFlagMutated, "SetFlagMutated");
-rename(cCPUHead.cCPUHead_SetFlagExecuted, "SetFlagExecuted");
-rename(cCPUHead.cCPUHead_SetFlagPointMut, "SetFlagPointMut");
-rename(cCPUHead.cCPUHead_SetFlagCopyMut, "SetFlagCopyMut");
-rename(cCPUHead.cCPUHead_SetFlagBreakpoint, "SetFlagBreakpoint");
+rename(cHeadCPU.cHeadCPU_SetFlagCopied, "SetFlagCopied");
+rename(cHeadCPU.cHeadCPU_SetFlagMutated, "SetFlagMutated");
+rename(cHeadCPU.cHeadCPU_SetFlagExecuted, "SetFlagExecuted");
+rename(cHeadCPU.cHeadCPU_SetFlagPointMut, "SetFlagPointMut");
+rename(cHeadCPU.cHeadCPU_SetFlagCopyMut, "SetFlagCopyMut");
+rename(cHeadCPU.cHeadCPU_SetFlagBreakpoint, "SetFlagBreakpoint");
# vim: set ft=python:
Deleted: trunk/source/bindings/Boost.Python/event_factory.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/event_factory.pyste 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/bindings/Boost.Python/event_factory.pyste 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,8 +0,0 @@
-
-Include("event.hh")
-Include("string.hh")
-
-cEventFactory = Class("cEventFactory", "event_factory.hh")
-set_policy(cEventFactory.ConstructEvent, return_internal_reference())
-
-# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/event_factory_manager.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/event_factory_manager.pyste 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/bindings/Boost.Python/event_factory_manager.pyste 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,5 +1,4 @@
-Include("event_factory.hh")
Include("event.hh")
cEventFactoryManager = Class("cEventFactoryManager", "event_factory_manager.hh")
Modified: trunk/source/bindings/Boost.Python/generatePysteFiles.py
===================================================================
--- trunk/source/bindings/Boost.Python/generatePysteFiles.py 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/bindings/Boost.Python/generatePysteFiles.py 2005-08-28 22:25:35 UTC (rev 297)
@@ -4,10 +4,10 @@
classes_table = [
#["cCLASSNAMEBLAHBLAHBLAHBLAHBLAH", "defs", [],],
# cpu/
- ["c4StackHead", "4stack_head", ["cpu_head"],],
+ ["cHeadMultiMem", "4stack_head", ["cpu_head"],],
["cCodeLabel", "code_label", [],],
#["cCLASSNAMEBLAHBLAHBLAHBLAHBLAH", "cpu_defs", [],],
- ["cCPUHead", "cpu_head", [],],
+ ["cHeadCPU", "cpu_head", [],],
["cCPUMemory", "cpu_memory", ["genome"],],
["cCPUStack", "cpu_stack", [],],
["sCPUStats", "cpu_stats", [],],
Modified: trunk/source/bindings/Boost.Python/phenotype.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/phenotype.pyste 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/bindings/Boost.Python/phenotype.pyste 2005-08-28 22:25:35 UTC (rev 297)
@@ -29,6 +29,7 @@
exclude(cPhenotype.ParentCrossNum)
exclude(cPhenotype.CopyTrue)
exclude(cPhenotype.DivideSex)
+exclude(cPhenotype.MateSelectID)
exclude(cPhenotype.CrossNum)
exclude(cPhenotype.ChildFertile)
exclude(cPhenotype.IsMultiThread)
Modified: trunk/source/bindings/Boost.Python/py_avida_driver-fixups.cc
===================================================================
--- trunk/source/bindings/Boost.Python/py_avida_driver-fixups.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/bindings/Boost.Python/py_avida_driver-fixups.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -16,26 +16,28 @@
#include <iostream>
-bool pyAvidaDriver::preUpdate(const unsigned int){
- //if (cChangeList *change_list = population->GetChangeList()) {
- // change_list->Reset();
- //}
+bool pyAvidaDriver::preUpdate(const unsigned int)
+{
GetEvents();
- if(true == done_flag){ return false; }
+
+ if(true == done_flag) { return false; }
+
// Increment the Update.
cStats &stats = population->GetStats();
stats.IncCurrentUpdate();
+
// Handle all data collection for previous update.
- if(stats.GetUpdate() > 0){
+ if(stats.GetUpdate() > 0) {
// Tell the stats object to do update calculations and printing.
stats.ProcessUpdate();
+
// Update all the genotypes for the end of this update.
cGenebank &genebank = population->GetGenebank();
for(
- cGenotype *cur_genotype = genebank.ResetThread(0);
- cur_genotype != 0 && cur_genotype->GetThreshold();
- cur_genotype = genebank.NextGenotype(0)
- ){
+ cGenotype *cur_genotype = genebank.ResetThread(0);
+ cur_genotype != 0 && cur_genotype->GetThreshold();
+ cur_genotype = genebank.NextGenotype(0)
+ ) {
cur_genotype->UpdateReset();
}
}
@@ -44,13 +46,16 @@
m_update_size = cConfig::GetAveTimeslice() * population->GetNumOrganisms();
m_step_size = 1. / m_update_size;
m_update_progress = 0;
+
// Enter next stage of update.
m_update_stage_function = m_update_mode_function;
return true;
}
-bool pyAvidaDriver::fastUpdate(const unsigned int bite_size){
- for(unsigned int i = 0; i < bite_size; i++){
- if(m_update_progress < m_update_size){
+
+bool pyAvidaDriver::fastUpdate(const unsigned int bite_size)
+{
+ for(unsigned int i = 0; i < bite_size; i++) {
+ if(m_update_progress < m_update_size) {
m_current_cell_id = population->ScheduleOrganism();
population->ProcessStep(m_step_size, m_current_cell_id);
m_update_progress++;
@@ -62,9 +67,11 @@
}
return true;
}
-bool pyAvidaDriver::stepUpdate(const unsigned int bite_size){
- for(unsigned int i = 0; i < bite_size; i++){
- if(m_update_progress < m_update_size){
+
+bool pyAvidaDriver::stepUpdate(const unsigned int bite_size)
+{
+ for(unsigned int i = 0; i < bite_size; i++) {
+ if(m_update_progress < m_update_size) {
m_update_progress++;
m_current_cell_id = population->ScheduleOrganism();
population->ProcessStep(m_step_size, m_current_cell_id);
@@ -77,20 +84,16 @@
}
return true;
}
-bool pyAvidaDriver::postUpdate(const unsigned int){
+
+bool pyAvidaDriver::postUpdate(const unsigned int)
+{
// End-of-update stats...
population->CalcUpdateStats();
- // Print out status for this update.
- //cStats &stats = population->GetStats();
- //std::cout
- //<< "UD: " << stats.GetUpdate() << "\t"
- //<< "Gen: " << stats.SumGeneration().Average() << "\t"
- //<< "Fit: " << stats.GetAveFitness() << "\t"
- //<< "Size: " << population->GetNumOrganisms() << "\t"
- //<< std::endl;
+
// Check whether to do point mutations.
if(cConfig::GetPointMutProb() > 0.){
m_mutations_progress = 0;
+
// Enter next stage of update.
m_update_stage_function = &pyAvidaDriver::ptMutations;
} else {
@@ -99,11 +102,13 @@
}
return true;
}
-bool pyAvidaDriver::ptMutations(const unsigned int){
- if(m_mutations_progress < population->GetSize()){
+
+bool pyAvidaDriver::ptMutations(const unsigned int)
+{
+ if(m_mutations_progress < population->GetSize()) {
cPopulationCell &cell = population->GetCell(m_mutations_progress);
if(cell.IsOccupied())
- cell.GetOrganism()->GetHardware().PointMutate(cConfig::GetPointMutProb());
+ cell.GetOrganism()->GetHardware().PointMutate(cConfig::GetPointMutProb());
m_mutations_progress++;
} else {
// Enter next stage of update.
@@ -111,19 +116,23 @@
}
return true;
}
-bool pyAvidaDriver::postPtMutations(const unsigned int){
+
+bool pyAvidaDriver::postPtMutations(const unsigned int) {
// Do any cleanup in the hardware factory...
cHardwareFactory::Update();
+
// Exit conditions...
- if(0 == population->GetNumOrganisms()){
+ if(0 == population->GetNumOrganisms()) {
done_flag = true;
}
+
// Prepare for first stage of new update.
m_update_stage_function = &pyAvidaDriver::preUpdate;
return false;
}
-cChangeList *pyAvidaDriver::GetChangeList(){
+cChangeList *pyAvidaDriver::GetChangeList()
+{
return population->GetChangeList();
}
@@ -137,6 +146,7 @@
{
}
-pyAvidaDriver::~pyAvidaDriver(){
+pyAvidaDriver::~pyAvidaDriver()
+{
delete m_change_list;
}
Modified: trunk/source/bindings/Boost.Python/tList.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/tList.pyste 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/bindings/Boost.Python/tList.pyste 2005-08-28 22:25:35 UTC (rev 297)
@@ -44,6 +44,7 @@
set_policy(list_iterator_type.NextConst , return_value_policy(reference_existing_object))
set_policy(list_iterator_type.PrevConst , return_value_policy(reference_existing_object))
set_policy(list_iterator_type.Get , return_value_policy(reference_existing_object))
+ set_policy(list_iterator_type.GetPos , return_value_policy(reference_existing_object))
set_policy(list_iterator_type.Next , return_value_policy(reference_existing_object))
set_policy(list_iterator_type.Prev , return_value_policy(reference_existing_object))
set_policy(list_iterator_type.Remove , return_value_policy(reference_existing_object))
Deleted: trunk/source/cpu/4stack_head.cc
===================================================================
--- trunk/source/cpu/4stack_head.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/4stack_head.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,224 +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 FOURSTACK_HEAD_HH
-#include "4stack_head.hh"
-#endif
-
-#ifndef CPU_MEMORY_HH
-#include "cpu_memory.hh"
-#endif
-#ifndef HARDWARE_BASE_HH
-#include "hardware_base.hh"
-#endif
-#ifndef INST_SET_HH
-#include "inst_set.hh"
-#endif
-#ifndef INSTRUCTION_HH
-#include "instruction.hh"
-#endif
-
-#include <assert.h>
-
-c4StackHead::c4StackHead() : cCPUHead() { mem_space=0; }
-
-c4StackHead::c4StackHead(cHardwareBase * in_hardware, int in_pos, int in_mem_space)
- : cCPUHead(in_hardware, in_pos) { mem_space = in_mem_space; }
-
-c4StackHead::c4StackHead(const c4StackHead & in_head) : cCPUHead(in_head)
-{
- mem_space = in_head.mem_space;
-}
-
-void c4StackHead::Adjust()
-{
- assert(cur_hardware != NULL);
- assert(main_hardware != NULL);
-
- const int mem_size = GetMemory().GetSize();
-
- // If we are still in range, stop here!
- if (position >= 0 && position < mem_size) return;
-
- // If the memory is gone, just stick it at the begining of its parent.
- if (mem_size == 0) {
- cur_hardware = main_hardware;
- position = 0;
- }
- else if (position <= 0) { position = 0; }
- else if (position >= mem_size) {
- // Always loop into the begining of the owner hardware.
- cur_hardware = main_hardware;
- position -= mem_size;
- while (position >= GetMemory().GetSize()) {
- // position back at the begining of the creature.
- position %= GetMemory().GetSize();
- }
- }
-}
-
-void c4StackHead::Reset(int in_mem_space, cHardwareBase * new_hardware)
-{
- if (new_hardware) main_hardware = new_hardware;
- cur_hardware = new_hardware;
- position = 0;
- mem_space = in_mem_space;
-}
-
-void c4StackHead::Set(int new_pos, int in_mem_space, cHardwareBase * in_hardware)
-{
- position = new_pos;
- if (in_hardware) cur_hardware = in_hardware;
- mem_space = in_mem_space;
- Adjust();
-}
-
-void c4StackHead::Set(const c4StackHead & in_head)
-{
- position = in_head.position;
- cur_hardware = in_head.cur_hardware;
- mem_space = in_head.mem_space;
- Adjust();
-}
-
-void c4StackHead::LoopJump(int jump)
-{
- position += jump;
-
- // If we are out of range, bring back in.
- if (position < 0 || position >= GetMemory().GetSize()) {
- position %= GetMemory().GetSize();
- if (position <= 0) position += GetMemory().GetSize();
- }
-}
-
-const cCPUMemory & c4StackHead::GetMemory() const
-{
- assert(cur_hardware != NULL);
- return cur_hardware->GetMemory(mem_space);
-}
-
-cCPUMemory & c4StackHead::GetMemory()
-{
- assert(cur_hardware != NULL);
- return cur_hardware->GetMemory(mem_space);
-}
-
-const cInstruction & c4StackHead::GetInst() const
-{
- assert(position >= 0);
- assert(position < GetMemory().GetSize());
- return GetMemory()[position];
-}
-
-const cInstruction & c4StackHead::GetInst(int offset) const
-{
- int new_pos = position + offset;
- return GetMemory()[new_pos];
-}
-
-
-void c4StackHead::SetInst(const cInstruction & value)
-{
- assert(cur_hardware != NULL);
-#ifdef WRITE_PROTECTION
- if (main_hardware == cur_hardware) GetMemory()[position] = value;
-#else
- GetMemory()[position] = value;
- if (main_hardware != cur_hardware) cur_hardware->SetModified();
-#endif
-}
-
-void c4StackHead::InsertInst(const cInstruction & value)
-{
- assert(cur_hardware != NULL);
-#ifdef WRITE_PROTECTION
- if (main_hardware == cur_hardware) GetMemory().Insert(position, value);
-#else
- GetMemory().Insert(position, value);
- if (main_hardware != cur_hardware) cur_hardware->SetModified();
-#endif
-}
-
-void c4StackHead::RemoveInst()
-{
- assert(cur_hardware != NULL);
-#ifdef WRITE_PROTECTION
- if (main_hardware == cur_hardware) GetMemory().Remove(position);
-#else
- GetMemory().Remove(position);
- if (main_hardware != cur_hardware) cur_hardware->SetModified();
-#endif
-}
-
-const cInstruction & c4StackHead::GetNextInst()
-{
- return (AtEnd()) ? cInstSet::GetInstError() : GetMemory()[position+1];
-}
-
-bool & c4StackHead::FlagCopied()
-{
- assert(cur_hardware != NULL);
- return GetMemory().FlagCopied(position);
-}
-
-bool & c4StackHead::FlagMutated()
-{
- assert(cur_hardware != NULL);
- return GetMemory().FlagMutated(position);
-}
-
-bool & c4StackHead::FlagExecuted()
-{
- assert(cur_hardware != NULL);
- return GetMemory().FlagExecuted(position);
-}
-
-bool & c4StackHead::FlagBreakpoint()
-{
- assert(cur_hardware != NULL);
- return GetMemory().FlagBreakpoint(position);
-}
-
-bool & c4StackHead::FlagPointMut()
-{
- assert(cur_hardware != NULL);
- return GetMemory().FlagPointMut(position);
-}
-
-bool & c4StackHead::FlagCopyMut()
-{
- assert(cur_hardware != NULL);
- return GetMemory().FlagCopyMut(position);
-}
-
-c4StackHead & c4StackHead::operator=(const c4StackHead & in_cpu_head)
-{
- main_hardware = in_cpu_head.main_hardware;
- cur_hardware = in_cpu_head.cur_hardware;
- position = in_cpu_head.position;
- mem_space = in_cpu_head.mem_space;
- return *this;
-}
-
-bool c4StackHead::operator==(const c4StackHead & in_cpu_head) const
-{
- return (cur_hardware == in_cpu_head.cur_hardware) &&
- (position == in_cpu_head.position) &&
- (mem_space == in_cpu_head.mem_space);
-}
-
-bool c4StackHead::AtEnd() const
-{
- return (position + 1 == GetMemory().GetSize());
-}
-
-bool c4StackHead::InMemory() const
-{
- return (position >= 0 && position < GetMemory().GetSize());
-}
-
Deleted: trunk/source/cpu/4stack_head.hh
===================================================================
--- trunk/source/cpu/4stack_head.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/4stack_head.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,65 +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 FOURSTACK_HEAD_HH
-#define FOURSTACK_HEAD_HH
-
-#ifndef CPU_HEAD_HH
-#include "cpu_head.hh"
-#endif
-#ifndef DEFS_HH
-#include "defs.hh"
-#endif
-
-class cCodeLabel;
-class cCPUMemory;
-class cGenome;
-class cHardwareBase;
-class cInstruction;
-
-class c4StackHead : public cCPUHead {
-private:
- int mem_space;
-
-public:
-
- c4StackHead();
- c4StackHead(cHardwareBase * in_hardware, int in_pos = 0, int mem_space = 0);
- c4StackHead(const c4StackHead & in_cpu_head);
-
- void Adjust();
- void Reset(int in_mem_space=0, cHardwareBase * new_hardware = NULL);
- void Set(int new_pos, int in_mem_space = 0, cHardwareBase * in_hardware = NULL);
- void Set(const c4StackHead & in_head);
- void LoopJump(int jump);
- const cCPUMemory & GetMemory() const;
- cCPUMemory & GetMemory();
- const cInstruction & GetInst() const;
- const cInstruction & GetInst(int offset) const;
-
- int GetMemSpace() const { return mem_space; }
-
- void SetInst(const cInstruction & value);
- void InsertInst(const cInstruction & in_char);
- void RemoveInst();
- const cInstruction & GetNextInst();
-
- bool & FlagCopied();
- bool & FlagMutated();
- bool & FlagExecuted();
- bool & FlagBreakpoint();
- bool & FlagPointMut();
- bool & FlagCopyMut();
-
- // Operator Overloading...
- c4StackHead & operator=(const c4StackHead & in_cpu_head);
- bool operator==(const c4StackHead & in_cpu_head) const;
- bool AtEnd() const;
- bool InMemory() const;
-};
-
-#endif
Modified: trunk/source/cpu/CMakeLists.txt
===================================================================
--- trunk/source/cpu/CMakeLists.txt 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/CMakeLists.txt 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,7 +1,5 @@
SET(libcpu_a_SOURCES
- 4stack_head.cc
code_label.cc
- cpu_head.cc
cpu_memory.cc
cpu_stack.cc
cpu_test_info.cc
@@ -11,8 +9,12 @@
hardware_cpu.cc
hardware_cpu_thread.cc
hardware_factory.cc
+ hardware_smt.cc
+ hardware_smt_thread.cc
+ hardware_status_printer.cc
hardware_util.cc
- hardware_status_printer.cc
+ head_cpu.cc
+ head_multi_mem.cc
memory_flags.cc
test_cpu.cc
test_util.cc
Modified: trunk/source/cpu/code_label.cc
===================================================================
--- trunk/source/cpu/code_label.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/code_label.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -24,21 +24,6 @@
// cCodeLabel stuff...
////////////////////////////////
-cCodeLabel::cCodeLabel()
- : size(0)
-{
-}
-
-cCodeLabel::cCodeLabel(const cCodeLabel &in_label)
- : nop_sequence(in_label.nop_sequence)
- , size(in_label.size)
-{
-}
-
-cCodeLabel::~cCodeLabel()
-{
-}
-
bool cCodeLabel::OK()
{
bool result = true;
Modified: trunk/source/cpu/code_label.hh
===================================================================
--- trunk/source/cpu/code_label.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/code_label.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -35,9 +35,9 @@
int size;
//const int base;
public:
- cCodeLabel();//int in_base=MAX_NOPS);
- cCodeLabel(const cCodeLabel &in_label);
- ~cCodeLabel();
+ cCodeLabel() : size(0) { ; }
+ cCodeLabel(const cCodeLabel& in_label) : nop_sequence(in_label.nop_sequence), size(in_label.size) { ; }
+ ~cCodeLabel() { ; }
bool OK();
bool operator==(const cCodeLabel & other_label) const;
@@ -77,14 +77,8 @@
void cCodeLabel::Rotate(const int rot, const int base)
{
- //for (int i = 0; i < size; i++) {
- // nop_sequence[i] += rot;
- // if (nop_sequence[i] == 3) nop_sequence[i]++; //IGNORING NOP-D FOR NOW!
- // if (nop_sequence[i] >= base) nop_sequence[i] -= base;
- //}
for (int i = 0; i < size; i++) {
nop_sequence[i] += rot;
- //if (nop_sequence[i] == 3) nop_sequence[i]++; //IGNORING NOP-D FOR NOW!
if (nop_sequence[i] >= base) nop_sequence[i] -= base;
}
}
Modified: trunk/source/cpu/cpu_defs.hh
===================================================================
--- trunk/source/cpu/cpu_defs.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/cpu_defs.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -23,7 +23,7 @@
// (especially the number of registers) could have effects in other parts
// of the code!
-#define NUM_NOPS 3
+static const int NUM_NOPS = 3;
#define MAX_NOPS 6
#define MAX_LABEL_SIZE 10
#define REG_AX 0
Deleted: trunk/source/cpu/cpu_head.cc
===================================================================
--- trunk/source/cpu/cpu_head.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/cpu_head.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,489 +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 CPU_HEAD_HH
-#include "cpu_head.hh"
-#endif
-
-#ifndef CPU_MEMORY_HH
-#include "cpu_memory.hh"
-#endif
-#ifndef CODE_LABEL_HH
-#include "code_label.hh"
-#endif
-#ifndef GENOME_HH
-#include "genome.hh"
-#endif
-#ifndef HARDWARE_BASE_HH
-#include "hardware_base.hh"
-#endif
-#ifndef INST_SET_HH
-#include "inst_set.hh"
-#endif
-#ifndef INSTRUCTION_HH
-#include "instruction.hh"
-#endif
-
-#include <assert.h>
-
-class cHardwareBase; // access
-class cCPUMemory; // access
-class cCodeLabel; // access
-class cInstSet; // access
-
-cCPUHead::cCPUHead() {
- main_hardware = NULL;
- cur_hardware = NULL;
- position = 0;
-}
-
-cCPUHead::cCPUHead(cHardwareBase * in_hardware, int in_pos) {
- main_hardware = in_hardware;
- cur_hardware = in_hardware;
-
- position = in_pos;
- if (in_pos) Adjust();
-}
-
-cCPUHead::cCPUHead(const cCPUHead & in_cpu_head) {
- main_hardware = in_cpu_head.main_hardware;
- cur_hardware = in_cpu_head.cur_hardware;
- position = in_cpu_head.position;
-}
-
-
-
-void cCPUHead::Adjust()
-{
- assert(cur_hardware != NULL);
- assert(main_hardware != NULL);
-
- const int mem_size = cur_hardware->GetMemory().GetSize();
-
- // If we are still in range, stop here!
- if (position >= 0 && position < mem_size) return;
-
- // If the memory is gone, just stick it at the begining of its parent.
- if (mem_size == 0) {
- cur_hardware = main_hardware;
- position = 0;
- }
- else if (position <= 0) { position = 0; }
- else if (position >= mem_size) {
- // Always loop into the begining of the owner hardware.
- cur_hardware = main_hardware;
- position -= mem_size;
- while (position >= GetMemory().GetSize()) {
- // position back at the begining of the creature.
- position %= GetMemory().GetSize();
- }
- }
-
-}
-
-
-
-/////////////////////////////////////////////////////////////////////////
-// Method: cCPUHead::FindLabel(direction)
-//
-// Search in 'direction' (+ or - 1) from this head for the compliment of
-// the label in 'next_label' and return a head to the resulting pos.
-//
-/////////////////////////////////////////////////////////////////////////
-
-cCPUHead cCPUHead::FindLabel(const cCodeLabel & label, int direction)
-{
- // Make sure the label is of size > 0.
- if (label.GetSize() == 0) {
- return *this;
- }
-
- int found_pos = -1;
-
- // Call special functions depending on if jump is forwards or backwards.
- if( direction < 0 ) {
- found_pos =
- FindLabel_Backward(label, GetMemory(), GetPosition() - label.GetSize());
- }
-
- // Jump forwards.
- else {
- found_pos = FindLabel_Forward(label, GetMemory(), GetPosition());
- }
-
- if (found_pos >= 0) {
- // Return the last line of the found label, or the starting point.
- cCPUHead search_head(*this);
- search_head.Set(found_pos - 1);
- return search_head;
- }
-
- // It wasn't found; return the starting position of the instruction pointer.
- return *this;
-}
-
-void cCPUHead::Reset(cHardwareBase * new_hardware) {
- if (new_hardware) main_hardware = new_hardware;
- cur_hardware = new_hardware;
- position = 0;
-}
-
-void cCPUHead::Set(int new_pos, cHardwareBase * in_hardware)
-{
- position = new_pos;
- if (in_hardware) cur_hardware = in_hardware;
- Adjust();
-}
-
-
-void cCPUHead::Jump(int jump)
-{
- position += jump;
- Adjust();
-}
-
-void cCPUHead::LoopJump(int jump)
-{
- position += jump;
-
- // If we are out of range, bring back in.
- if (position < 0 || position >= GetMemory().GetSize()) {
- position %= GetMemory().GetSize();
- if (position <= 0) position += GetMemory().GetSize();
- }
-}
-
-void cCPUHead::AbsJump(int jump)
-{
- position += jump;
-}
-
-void cCPUHead::Advance()
-{
- position++;
- Adjust();
-}
-
-void cCPUHead::Retreat()
-{
- position--;
- Adjust();
-}
-
-
-const cCPUMemory & cCPUHead::GetMemory() const
-{
- assert(cur_hardware != NULL);
- return cur_hardware->GetMemory();
-}
-
-
-const cInstruction & cCPUHead::GetInst() const
-{
- assert(position >= 0);
- assert(position < GetMemory().GetSize());
- return GetMemory()[position];
-}
-
-const cInstruction & cCPUHead::GetInst(int offset) const {
- int new_pos = position + offset;
-
- return GetMemory()[new_pos];
-}
-
-
-void cCPUHead::SetInst(const cInstruction & value)
-{
- assert(cur_hardware != NULL);
-#ifdef WRITE_PROTECTION
- if (main_hardware == cur_hardware) cur_hardware->GetMemory()[position] = value;
-#else
- cur_hardware->GetMemory()[position] = value;
- if (main_hardware != cur_hardware) cur_hardware->SetModified();
-#endif
-}
-
-
-void cCPUHead::InsertInst(const cInstruction & value)
-{
- assert(cur_hardware != NULL);
-#ifdef WRITE_PROTECTION
- if (main_hardware == cur_hardware) cur_hardware->GetMemory().Insert(position, value);
-#else
- cur_hardware->GetMemory().Insert(position, value);
- if (main_hardware != cur_hardware) cur_hardware->SetModified();
-#endif
-}
-
-void cCPUHead::RemoveInst()
-{
- assert(cur_hardware != NULL);
-#ifdef WRITE_PROTECTION
- if (main_hardware == cur_hardware) cur_hardware->GetMemory().Remove(position);
-#else
- cur_hardware->GetMemory().Remove(position);
- if (main_hardware != cur_hardware) cur_hardware->SetModified();
-#endif
-}
-
-const cInstruction & cCPUHead::GetNextInst()
-{
- return (AtEnd()) ? cInstSet::GetInstError() : GetMemory()[position+1];
-}
-
-
-
-bool & cCPUHead::FlagCopied()
-{
- assert(cur_hardware != NULL);
- return cur_hardware->GetMemory().FlagCopied(position);
-}
-
-bool & cCPUHead::FlagMutated()
-{
- assert(cur_hardware != NULL);
- return cur_hardware->GetMemory().FlagMutated(position);
-}
-
-bool & cCPUHead::FlagExecuted()
-{
- assert(cur_hardware != NULL);
- return cur_hardware->GetMemory().FlagExecuted(position);
-}
-
-bool & cCPUHead::FlagBreakpoint()
-{
- assert(cur_hardware != NULL);
- return cur_hardware->GetMemory().FlagBreakpoint(position);
-}
-
-bool & cCPUHead::FlagPointMut()
-{
- assert(cur_hardware != NULL);
- return cur_hardware->GetMemory().FlagPointMut(position);
-}
-
-bool & cCPUHead::FlagCopyMut()
-{
- assert(cur_hardware != NULL);
- return cur_hardware->GetMemory().FlagCopyMut(position);
-}
-
-cCPUHead & cCPUHead::operator=(const cCPUHead & in_cpu_head)
-{
- main_hardware = in_cpu_head.main_hardware;
- cur_hardware = in_cpu_head.cur_hardware;
- position = in_cpu_head.position;
- return *this;
-}
-
-
-cCPUHead & cCPUHead::operator++()
-{
- position++;
- Adjust();
- return *this;
-}
-
-cCPUHead & cCPUHead::operator--()
-{
- position--;
- Adjust();
- return *this;
-}
-
-cCPUHead & cCPUHead::operator++(int)
-{
- return operator++();
-}
-
-cCPUHead & cCPUHead::operator--(int)
-{
- return operator--();
-}
-
-
-// Search forwards for search_label from _after_ position pos in the
-// memory. Return the first line _after_ the the found label. It is okay
-// to find search label's match inside another label.
-
-int cCPUHead::FindLabel_Forward(const cCodeLabel & search_label,
- const cGenome & search_mem, int pos)
-{
- assert (pos < search_mem.GetSize() && pos >= 0);
-
- int search_start = pos;
- int label_size = search_label.GetSize();
- bool found_label = false;
- const cInstSet & inst_set = main_hardware->GetInstSet();
-
- // Move off the template we are on.
- pos += label_size;
-
- // Search until we find the complement or exit the memory.
- while (pos < search_mem.GetSize()) {
-
- // If we are within a label, rewind to the beginning of it and see if
- // it has the proper sub-label that we're looking for.
-
- if (inst_set.IsNop(search_mem[pos])) {
- // Find the start and end of the label we're in the middle of.
-
- int start_pos = pos;
- int end_pos = pos + 1;
- while (start_pos > search_start &&
- inst_set.IsNop( search_mem[start_pos - 1] )) {
- start_pos--;
- }
- while (end_pos < search_mem.GetSize() &&
- inst_set.IsNop( search_mem[end_pos] )) {
- end_pos++;
- }
- int test_size = end_pos - start_pos;
-
- // See if this label has the proper sub-label within it.
- int max_offset = test_size - label_size + 1;
- for (int offset = start_pos; offset < start_pos + max_offset; offset++) {
-
- // Test the number of matches for this offset.
- int matches;
- for (matches = 0; matches < label_size; matches++) {
- if (search_label[matches] !=
- inst_set.GetNopMod( search_mem[offset + matches] )) {
- break;
- }
- }
-
- // If we have found it, break out of this loop!
- if (matches == label_size) {
- found_label = true;
- break;
- }
- }
-
- // If we've found the complement label, set the position to the end of
- // the label we found it in, and break out.
-
- if (found_label == true) {
- pos = end_pos;
- break;
- }
-
- // We haven't found it; jump pos to just after the current label being
- // checked.
- pos = end_pos;
- }
-
- // Jump up a block to the next possible point to find a label,
- pos += label_size;
- }
-
- // If the label was not found return a -1.
- if (found_label == false) pos = -1;
-
- return pos;
-}
-
-// Search backwards for search_label from _before_ position pos in the
-// memory. Return the first line _after_ the the found label. It is okay
-// to find search label's match inside another label.
-
-int cCPUHead::FindLabel_Backward(const cCodeLabel & search_label,
- const cGenome & search_mem, int pos)
-{
- assert (pos < search_mem.GetSize());
-
- int search_start = pos;
- int label_size = search_label.GetSize();
- bool found_label = false;
- const cInstSet & inst_set = main_hardware->GetInstSet();
-
- // Move off the template we are on.
- pos -= label_size;
-
- // Search until we find the complement or exit the memory.
- while (pos >= 0) {
- // If we are within a label, rewind to the beginning of it and see if
- // it has the proper sub-label that we're looking for.
-
- if (inst_set.IsNop( search_mem[pos] )) {
- // Find the start and end of the label we're in the middle of.
-
- int start_pos = pos;
- int end_pos = pos + 1;
- while (start_pos > 0 && inst_set.IsNop(search_mem[start_pos - 1])) {
- start_pos--;
- }
- while (end_pos < search_start &&
- inst_set.IsNop( search_mem[end_pos] )) {
- end_pos++;
- }
- int test_size = end_pos - start_pos;
-
- // See if this label has the proper sub-label within it.
- int max_offset = test_size - label_size + 1;
- for (int offset = start_pos; offset < start_pos + max_offset; offset++) {
-
- // Test the number of matches for this offset.
- int matches;
- for (matches = 0; matches < label_size; matches++) {
- if (search_label[matches] !=
- inst_set.GetNopMod( search_mem[offset + matches] )) {
- break;
- }
- }
-
- // If we have found it, break out of this loop!
- if (matches == label_size) {
- found_label = true;
- break;
- }
- }
-
- // If we've found the complement label, set the position to the end of
- // the label we found it in, and break out.
-
- if (found_label == true) {
- pos = end_pos;
- break;
- }
-
- // We haven't found it; jump pos to just before the current label
- // being checked.
- pos = start_pos - 1;
- }
-
- // Jump up a block to the next possible point to find a label,
- pos -= label_size;
- }
-
- // If the label was not found return a -1.
- if (found_label == false) pos = -1;
-
- return pos;
-}
-
-bool cCPUHead::operator==(const cCPUHead & in_cpu_head) const {
- return (cur_hardware == in_cpu_head.cur_hardware) &&
- (position == in_cpu_head.position);
-}
-
-bool cCPUHead::AtEnd() const
-{
- return (position + 1 == GetMemory().GetSize());
-}
-
-bool cCPUHead::InMemory() const
-{
- return (position >= 0 && position < GetMemory().GetSize());
-}
-
-int cCPUHead::TestParasite() const
-{
- // If CPU has a head in another creature, mark it as a parasite.
- return (cur_hardware != main_hardware);
-}
Deleted: trunk/source/cpu/cpu_head.hh
===================================================================
--- trunk/source/cpu/cpu_head.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/cpu_head.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,121 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef CPU_HEAD_HH
-#define CPU_HEAD_HH
-
-#ifndef DEFS_HH
-#include "defs.hh"
-#endif
-
-class cHardwareBase;
-class cCodeLabel;
-class cGenome;
-class cCPUMemory;
-
-/**
- * The cCPUHead class contains a pointer to locations in memory for a CPU.
- **/
-
-class cHardwareBase;
-class cCodeLabel;
-class cGenome;
-class cInstruction;
-
-class cCPUHead {
-protected:
- cHardwareBase * main_hardware;
- cHardwareBase * cur_hardware;
- int position;
-
- int FindLabel_Forward(const cCodeLabel & search_label,
- const cGenome & search_mem, int pos);
- int FindLabel_Backward(const cCodeLabel & search_label,
- const cGenome & search_mem, int pos);
-public:
- cCPUHead();
- cCPUHead(cHardwareBase * in_hardware, int in_pos = 0);
- cCPUHead(const cCPUHead & in_cpu_head);
- virtual ~cCPUHead() { ; }
-
- /**
- * This function keeps the position within the range of the current memory.
- **/
- virtual void Adjust();
-
- virtual void Reset(cHardwareBase * new_hardware = NULL);
-
- /**
- * Set the new position of the head (and adjust it into range in Set()).
- **/
-
- virtual void Set(int new_pos, cHardwareBase * in_hardware = NULL);
-
- void AbsSet(int new_pos) { position = new_pos; }
-
- virtual void Set(const cCPUHead & in_head) {
- position = in_head.position;
- cur_hardware = in_head.cur_hardware;
- }
-
- /**
- * Increment the new position of the head by 'jump'.
- **/
-
- void Jump(int jump);
- virtual void LoopJump(int jump);
- void AbsJump(int jump);
-
- // Other manipulation functions.
- void Advance();
- void Retreat();
- cCPUHead FindLabel(const cCodeLabel & label, int direction=1);
-
- // Accessors.
- int GetPosition() const { return position; }
- virtual const cCPUMemory & GetMemory() const;
- cHardwareBase * GetCurHardware() const { return cur_hardware; }
- cHardwareBase * GetMainHardware() const { return main_hardware; }
- virtual const cInstruction & GetInst() const;
- virtual const cInstruction & GetInst(int offset) const;
- // int GetFlag(int id) const;
-
- virtual void SetInst(const cInstruction & value);
- virtual void InsertInst(const cInstruction & in_char);
- virtual void RemoveInst();
- virtual const cInstruction & GetNextInst();
-
- virtual bool & FlagCopied();
- virtual bool & FlagMutated();
- virtual bool & FlagExecuted();
- virtual bool & FlagBreakpoint();
- virtual bool & FlagPointMut();
- virtual bool & FlagCopyMut();
-
- // Operator Overloading...
- virtual cCPUHead & operator=(const cCPUHead & in_cpu_head);
- cCPUHead & operator++();
- cCPUHead & operator--();
- cCPUHead & operator++(int);
- cCPUHead & operator--(int);
-
- inline int operator-(const cCPUHead & in_cpu_head) {
- if (cur_hardware != in_cpu_head.cur_hardware) return 0;
- else return position - in_cpu_head.position;
- }
- virtual bool operator==(const cCPUHead & in_cpu_head) const;
-
- // Bool Tests...
- inline bool AtFront() const { return (position == 0); }
- virtual bool AtEnd() const;
- virtual bool InMemory() const;
-
- // Test functions...
- int TestParasite() const;
-};
-
-#endif
Modified: trunk/source/cpu/cpu_stack.hh
===================================================================
--- trunk/source/cpu/cpu_stack.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/cpu_stack.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -17,7 +17,7 @@
/**
* A CPU stack, used by various hardware components.
*
- * @see cCPUThread, cCPUHead, cHardware
+ * @see cCPUThread, cHeadCPU, cHardware
**/
class cCPUStack {
Modified: trunk/source/cpu/hardware_4stack.cc
===================================================================
--- trunk/source/cpu/hardware_4stack.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_4stack.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -203,8 +203,6 @@
const int n_size = sizeof(s_n_array)/sizeof(cNOPEntry4Stack);
- cout << "Instruction Library has " << n_size << " instructions." << endl;
-
static cString n_names[n_size];
static int nop_mods[n_size];
for (int i = 0; i < n_size; i++){
@@ -229,14 +227,6 @@
functions
);
- cout <<
- "<cHardware4Stack::initInstLib> debug: important post-init values:" <<endl<<
- " --- GetSize(): " << inst_lib->GetSize() <<endl<<
- " --- GetNumNops(): " << inst_lib->GetNumNops() <<endl<<
- " --- GetName(last): " <<
- inst_lib->GetName(inst_lib->GetSize() - 1) <<endl<<
- endl;
-
return inst_lib;
}
@@ -583,12 +573,12 @@
//
/////////////////////////////////////////////////////////////////////////
-c4StackHead cHardware4Stack::FindLabel(int direction)
+cHeadMultiMem cHardware4Stack::FindLabel(int direction)
{
- c4StackHead & inst_ptr = IP();
+ cHeadMultiMem & inst_ptr = IP();
// Start up a search head at the position of the instruction pointer.
- c4StackHead search_head(inst_ptr);
+ cHeadMultiMem search_head(inst_ptr);
cCodeLabel & search_label = GetLabel();
// Make sure the label is of size > 0.
@@ -785,7 +775,7 @@
}
// Search for 'in_label' anywhere in the hardware.
-c4StackHead cHardware4Stack::FindLabel(const cCodeLabel & in_label, int direction)
+cHeadMultiMem cHardware4Stack::FindLabel(const cCodeLabel & in_label, int direction)
{
assert (in_label.GetSize() > 0);
@@ -796,7 +786,7 @@
// FOR NOW:
// Get something which works, no matter how inefficient!!!
- c4StackHead temp_head(this);
+ cHeadMultiMem temp_head(this);
while (temp_head.InMemory()) {
// IDEALY: Analyze the label we are in; see if the one we are looking
@@ -823,14 +813,14 @@
// @CAO: direction is not currently used; should be used to indicate the
// direction which the heads[HEAD_IP] should progress through a creature.
-c4StackHead cHardware4Stack::FindFullLabel(const cCodeLabel & in_label)
+cHeadMultiMem cHardware4Stack::FindFullLabel(const cCodeLabel & in_label)
{
// cout << "Running FindFullLabel with " << in_label.AsString() <<
// endl;
assert(in_label.GetSize() > 0); // Trying to find label of 0 size!
- c4StackHead temp_head(this);
+ cHeadMultiMem temp_head(this);
while (temp_head.InMemory()) {
// If we are not in a label, jump to the next checkpoint...
@@ -1057,7 +1047,7 @@
return TriggerMutations(trigger, IP());
}
-bool cHardware4Stack::TriggerMutations(int trigger, c4StackHead & cur_head)
+bool cHardware4Stack::TriggerMutations(int trigger, cHeadMultiMem & cur_head)
{
// Collect information about mutations from the organism.
cLocalMutations & mut_info = organism->GetLocalMutations();
@@ -1110,7 +1100,7 @@
}
bool cHardware4Stack::TriggerMutations_ScopeGenome(const cMutation * cur_mut,
- cCPUMemory & target_memory, c4StackHead & cur_head, const double rate)
+ cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate)
{
// The rate we have stored indicates the probability that a single
// mutation will occur anywhere in the genome.
@@ -1118,7 +1108,7 @@
if (g_random.P(rate) == true) {
// We must create a temporary head and use it to randomly determine the
// position in the genome to be mutated.
- c4StackHead tmp_head(cur_head);
+ cHeadMultiMem tmp_head(cur_head);
tmp_head.AbsSet(g_random.GetUInt(target_memory.GetSize()));
TriggerMutations_Body(cur_mut->GetType(), target_memory, tmp_head);
return true;
@@ -1127,7 +1117,7 @@
}
bool cHardware4Stack::TriggerMutations_ScopeLocal(const cMutation * cur_mut,
- cCPUMemory & target_memory, c4StackHead & cur_head, const double rate)
+ cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate)
{
// The rate we have stored is the probability for a mutation at this single
// position in the genome.
@@ -1140,7 +1130,7 @@
}
int cHardware4Stack::TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
- cCPUMemory & target_memory, c4StackHead & cur_head, const double rate)
+ cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate)
{
// The probability we have stored is per-site, so we can pull a random
// number from a binomial distribution to determine the number of mutations
@@ -1151,7 +1141,7 @@
if (num_mut > 0) {
for (int i = 0; i < num_mut; i++) {
- c4StackHead tmp_head(cur_head);
+ cHeadMultiMem tmp_head(cur_head);
tmp_head.AbsSet(g_random.GetUInt(target_memory.GetSize()));
TriggerMutations_Body(cur_mut->GetType(), target_memory, tmp_head);
}
@@ -1161,7 +1151,7 @@
}
void cHardware4Stack::TriggerMutations_Body(int type, cCPUMemory & target_memory,
- c4StackHead & cur_head)
+ cHeadMultiMem & cur_head)
{
const int pos = cur_head.GetPosition();
@@ -1210,7 +1200,7 @@
void cHardware4Stack::ReadLabel(int max_size)
{
int count = 0;
- c4StackHead * inst_ptr = &( IP() );
+ cHeadMultiMem * inst_ptr = &( IP() );
GetLabel().Clear();
@@ -1969,7 +1959,7 @@
bool cHardware4Stack::Inst_HeadWrite()
{
const int head_id = FindModifiedHead(HEAD_WRITE);
- c4StackHead & active_head = GetHead(head_id);
+ cHeadMultiMem & active_head = GetHead(head_id);
int mem_space_used = active_head.GetMemSpace();
//commented out for right now...
@@ -1996,8 +1986,8 @@
bool cHardware4Stack::Inst_HeadCopy()
{
// For the moment, this cannot be nop-modified.
- c4StackHead & read_head = GetHead(HEAD_READ);
- c4StackHead & write_head = GetHead(HEAD_WRITE);
+ cHeadMultiMem & read_head = GetHead(HEAD_READ);
+ cHeadMultiMem & write_head = GetHead(HEAD_WRITE);
sCPUStats & cpu_stats = organism->CPUStats();
read_head.Adjust();
@@ -2106,7 +2096,7 @@
{
ReadLabel();
GetLabel().Rotate(2, NUM_NOPS_4STACK);
- c4StackHead found_pos = FindLabel(0);
+ cHeadMultiMem found_pos = FindLabel(0);
if(found_pos.GetPosition()-IP().GetPosition()==0)
{
GetHead(HEAD_FLOW).Set(IP().GetPosition()+1, IP().GetMemSpace(), this);
Modified: trunk/source/cpu/hardware_4stack.hh
===================================================================
--- trunk/source/cpu/hardware_4stack.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_4stack.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -19,8 +19,8 @@
#ifndef DEFS_HH
#include "defs.hh"
#endif
-#ifndef FOURSTACK_HEAD_HH
-#include "4stack_head.hh"
+#ifndef HEAD_MULTI_MEM_HH
+#include "head_multi_mem.hh"
#endif
#ifndef HARDWARE_BASE_HH
#include "hardware_base.hh"
@@ -60,7 +60,7 @@
class cCodeLabel;
class cCPUMemory;
class cCPUStack; // aggregate
-class c4StackHead; // access
+class cHeadMultiMem; // access
class cGenome;
class cHardware4Stack_Thread; // access
class cInjectGenotype;
@@ -149,28 +149,28 @@
int GetCurHead() const { return threads[cur_thread].cur_head; }
- const c4StackHead & GetHead(int head_id) const
+ const cHeadMultiMem & GetHead(int head_id) const
{ return threads[cur_thread].heads[head_id]; }
- c4StackHead & GetHead(int head_id)
+ cHeadMultiMem & GetHead(int head_id)
{ return threads[cur_thread].heads[head_id];}
- const c4StackHead & GetHead(int head_id, int thread) const
+ const cHeadMultiMem & GetHead(int head_id, int thread) const
{ return threads[thread].heads[head_id]; }
- c4StackHead & GetHead(int head_id, int thread)
+ cHeadMultiMem & GetHead(int head_id, int thread)
{ return threads[thread].heads[head_id];}
- const c4StackHead & GetActiveHead() const { return GetHead(GetCurHead()); }
- c4StackHead & GetActiveHead() { return GetHead(GetCurHead()); }
+ const cHeadMultiMem & GetActiveHead() const { return GetHead(GetCurHead()); }
+ cHeadMultiMem & GetActiveHead() { return GetHead(GetCurHead()); }
void AdjustHeads();
- inline const c4StackHead & IP() const
+ inline const cHeadMultiMem & IP() const
{ return threads[cur_thread].heads[HEAD_IP]; }
- inline c4StackHead & IP() { return threads[cur_thread].heads[HEAD_IP]; }
+ inline cHeadMultiMem & IP() { return threads[cur_thread].heads[HEAD_IP]; }
- inline const c4StackHead & IP(int thread) const
+ inline const cHeadMultiMem & IP(int thread) const
{ return threads[thread].heads[HEAD_IP]; }
- inline c4StackHead & IP(int thread)
+ inline cHeadMultiMem & IP(int thread)
{ return threads[thread].heads[HEAD_IP]; }
@@ -225,13 +225,13 @@
}
// Complex label manipulation...
- c4StackHead FindLabel(int direction);
+ cHeadMultiMem FindLabel(int direction);
int FindLabel_Forward(const cCodeLabel & search_label,
const cGenome & search_genome, int pos);
int FindLabel_Backward(const cCodeLabel & search_label,
const cGenome & search_genome, int pos);
- c4StackHead FindLabel(const cCodeLabel & in_label, int direction);
- c4StackHead FindFullLabel(const cCodeLabel & in_label);
+ cHeadMultiMem FindLabel(const cCodeLabel & in_label, int direction);
+ cHeadMultiMem FindFullLabel(const cCodeLabel & in_label);
int GetType() const { return HARDWARE_TYPE_CPU_4STACK; }
bool InjectParasite(double mut_multiplier);
@@ -243,15 +243,15 @@
bool isEmpty(int mem_space_used);
bool TriggerMutations(int trigger);
- bool TriggerMutations(int trigger, c4StackHead & cur_head);
+ bool TriggerMutations(int trigger, cHeadMultiMem & cur_head);
bool TriggerMutations_ScopeGenome(const cMutation * cur_mut,
- cCPUMemory & target_memory, c4StackHead & cur_head, const double rate);
+ cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate);
bool TriggerMutations_ScopeLocal(const cMutation * cur_mut,
- cCPUMemory & target_memory, c4StackHead & cur_head, const double rate);
+ cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate);
int TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
- cCPUMemory & target_memory, c4StackHead & cur_head, const double rate);
+ cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate);
void TriggerMutations_Body(int type, cCPUMemory & target_memory,
- c4StackHead & cur_head);
+ cHeadMultiMem & cur_head);
void ReadInst(const int in_inst);
Modified: trunk/source/cpu/hardware_4stack_thread.cc
===================================================================
--- trunk/source/cpu/hardware_4stack_thread.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_4stack_thread.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -101,9 +101,8 @@
heads[i].AbsSet(pos);
}
- char marker; fp>>marker; assert( marker == '|' );
+ char marker; fp >> marker; assert( marker == '|' );
/* YIKES! data loss below: */
- char the_cur_head = cur_head;
// Code labels
read_label.LoadState(fp);
Modified: trunk/source/cpu/hardware_4stack_thread.hh
===================================================================
--- trunk/source/cpu/hardware_4stack_thread.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_4stack_thread.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -16,8 +16,8 @@
#ifndef CPU_STACK_HH
#include "cpu_stack.hh"
#endif
-#ifndef FOURSTACK_HEAD_HH
-#include "4stack_head.hh"
+#ifndef HEAD_MULTI_MEM_HH
+#include "head_multi_mem.hh"
#endif
#ifndef HARDWARE_4STACK_CONSTANTS_HH
#include "hardware_4stack_constants.hh"
@@ -29,10 +29,10 @@
/**
* This class is needed to run several threads on a single genome.
*
- * @see cCPUStack, c4StackHead, cHardware4Stack
+ * @see cCPUStack, cHeadMultiMem, cHardware4Stack
**/
-class c4StackHead; // aggregate
+class cHeadMultiMem; // aggregate
class cCodeLabel; // aggregate
class cCPUStack; // aggregate
class cHardwareBase;
@@ -43,7 +43,7 @@
private:
int id;
public:
- c4StackHead heads[NUM_HEADS];
+ cHeadMultiMem heads[NUM_HEADS];
UCHAR cur_head;
cCPUStack local_stacks[NUM_LOCAL_STACKS];
Modified: trunk/source/cpu/hardware_cpu.cc
===================================================================
--- trunk/source/cpu/hardware_cpu.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_cpu.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -336,10 +336,6 @@
const int n_size = sizeof(s_n_array)/sizeof(cNOPEntryCPU);
- cout << "<cHardwareCPU::initInstLib> Instruction Library has "
- << n_size << " instructions." << endl;
-
-
static cString n_names[n_size];
static int nop_mods[n_size];
for (int i = 0; i < n_size; i++){
@@ -364,14 +360,6 @@
functions
);
- cout <<
- "<cHardwareCPU::initInstLib> debug: important post-init values:" <<endl<<
- " --- GetSize(): " << inst_lib->GetSize() <<endl<<
- " --- GetNumNops(): " << inst_lib->GetNumNops() <<endl<<
- " --- GetName(last): " <<
- inst_lib->GetName(inst_lib->GetSize() - 1) <<endl<<
- endl;
-
return inst_lib;
}
@@ -668,12 +656,12 @@
//
/////////////////////////////////////////////////////////////////////////
-cCPUHead cHardwareCPU::FindLabel(int direction)
+cHeadCPU cHardwareCPU::FindLabel(int direction)
{
- cCPUHead & inst_ptr = IP();
+ cHeadCPU & inst_ptr = IP();
// Start up a search head at the position of the instruction pointer.
- cCPUHead search_head(inst_ptr);
+ cHeadCPU search_head(inst_ptr);
cCodeLabel & search_label = GetLabel();
// Make sure the label is of size > 0.
@@ -869,7 +857,7 @@
}
// Search for 'in_label' anywhere in the hardware.
-cCPUHead cHardwareCPU::FindLabel(const cCodeLabel & in_label, int direction)
+cHeadCPU cHardwareCPU::FindLabel(const cCodeLabel & in_label, int direction)
{
assert (in_label.GetSize() > 0);
@@ -880,7 +868,7 @@
// FOR NOW:
// Get something which works, no matter how inefficient!!!
- cCPUHead temp_head(this);
+ cHeadCPU temp_head(this);
while (temp_head.InMemory()) {
// IDEALY: Analyze the label we are in; see if the one we are looking
@@ -907,14 +895,14 @@
// @CAO: direction is not currently used; should be used to indicate the
// direction which the heads[HEAD_IP] should progress through a creature.
-cCPUHead cHardwareCPU::FindFullLabel(const cCodeLabel & in_label)
+cHeadCPU cHardwareCPU::FindFullLabel(const cCodeLabel & in_label)
{
// cout << "Running FindFullLabel with " << in_label.AsString() <<
// endl;
assert(in_label.GetSize() > 0); // Trying to find label of 0 size!
- cCPUHead temp_head(this);
+ cHeadCPU temp_head(this);
while (temp_head.InMemory()) {
// If we are not in a label, jump to the next checkpoint...
@@ -1117,7 +1105,7 @@
return TriggerMutations(trigger, IP());
}
-bool cHardwareCPU::TriggerMutations(int trigger, cCPUHead & cur_head)
+bool cHardwareCPU::TriggerMutations(int trigger, cHeadCPU & cur_head)
{
// Collect information about mutations from the organism.
cLocalMutations & mut_info = organism->GetLocalMutations();
@@ -1170,7 +1158,7 @@
}
bool cHardwareCPU::TriggerMutations_ScopeGenome(const cMutation * cur_mut,
- cCPUMemory & target_memory, cCPUHead & cur_head, const double rate)
+ cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate)
{
// The rate we have stored indicates the probability that a single
// mutation will occur anywhere in the genome.
@@ -1178,7 +1166,7 @@
if (g_random.P(rate) == true) {
// We must create a temporary head and use it to randomly determine the
// position in the genome to be mutated.
- cCPUHead tmp_head(cur_head);
+ cHeadCPU tmp_head(cur_head);
tmp_head.AbsSet(g_random.GetUInt(target_memory.GetSize()));
TriggerMutations_Body(cur_mut->GetType(), target_memory, tmp_head);
return true;
@@ -1187,7 +1175,7 @@
}
bool cHardwareCPU::TriggerMutations_ScopeLocal(const cMutation * cur_mut,
- cCPUMemory & target_memory, cCPUHead & cur_head, const double rate)
+ cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate)
{
// The rate we have stored is the probability for a mutation at this single
// position in the genome.
@@ -1200,7 +1188,7 @@
}
int cHardwareCPU::TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
- cCPUMemory & target_memory, cCPUHead & cur_head, const double rate)
+ cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate)
{
// The probability we have stored is per-site, so we can pull a random
// number from a binomial distribution to determine the number of mutations
@@ -1211,7 +1199,7 @@
if (num_mut > 0) {
for (int i = 0; i < num_mut; i++) {
- cCPUHead tmp_head(cur_head);
+ cHeadCPU tmp_head(cur_head);
tmp_head.AbsSet(g_random.GetUInt(target_memory.GetSize()));
TriggerMutations_Body(cur_mut->GetType(), target_memory, tmp_head);
}
@@ -1221,7 +1209,7 @@
}
void cHardwareCPU::TriggerMutations_Body(int type, cCPUMemory & target_memory,
- cCPUHead & cur_head)
+ cHeadCPU & cur_head)
{
const int pos = cur_head.GetPosition();
@@ -1270,7 +1258,7 @@
void cHardwareCPU::ReadLabel(int max_size)
{
int count = 0;
- cCPUHead * inst_ptr = &( IP() );
+ cHeadCPU * inst_ptr = &( IP() );
GetLabel().Clear();
@@ -1975,7 +1963,7 @@
}
// Otherwise, try to jump to the complement label.
- const cCPUHead jump_location(FindLabel(1));
+ const cHeadCPU jump_location(FindLabel(1));
if ( jump_location.GetPosition() != -1 ) {
GetActiveHead().Set(jump_location);
return true;
@@ -2000,7 +1988,7 @@
}
// otherwise jump to the complement label.
- const cCPUHead jump_location(FindLabel(-1));
+ const cHeadCPU jump_location(FindLabel(-1));
if ( jump_location.GetPosition() != -1 ) {
GetActiveHead().Set(jump_location);
return true;
@@ -2042,7 +2030,7 @@
}
// otherwise jump to the complement label.
- const cCPUHead jump_location(other_hardware.FindFullLabel(GetLabel()));
+ const cHeadCPU jump_location(other_hardware.FindFullLabel(GetLabel()));
if (jump_location.GetPosition() != -1) {
IP().Set(jump_location);
organism->GetPhenotype().IsParasite() = true;
@@ -2069,7 +2057,7 @@
}
// otherwise jump to the complement label.
- const cCPUHead jump_location( FindFullLabel(GetLabel()) );
+ const cHeadCPU jump_location( FindFullLabel(GetLabel()) );
if ( jump_location.GetPosition() != -1 ) {
IP().Set(jump_location);
return true;
@@ -2096,7 +2084,7 @@
return true;
}
- const cCPUHead jump_location(FindLabel(1));
+ const cHeadCPU jump_location(FindLabel(1));
if (jump_location.GetPosition() != -1) {
IP().Set(jump_location);
return true;
@@ -2436,8 +2424,8 @@
bool cHardwareCPU::Inst_Copy()
{
- const cCPUHead from(this, Register(REG_BX));
- cCPUHead to(this, Register(REG_AX) + Register(REG_BX));
+ const cHeadCPU from(this, Register(REG_BX));
+ cHeadCPU to(this, Register(REG_AX) + Register(REG_BX));
sCPUStats & cpu_stats = organism->CPUStats();
if (organism->TestCopyMut()) {
@@ -2460,7 +2448,7 @@
bool cHardwareCPU::Inst_ReadInst()
{
const int reg_used = FindModifiedRegister(REG_CX);
- const cCPUHead from(this, Register(REG_BX));
+ const cHeadCPU from(this, Register(REG_BX));
// Dis-allowing mutations on read, for the moment (write only...)
// @CAO This allows perfect error-correction...
@@ -2470,7 +2458,7 @@
bool cHardwareCPU::Inst_WriteInst()
{
- cCPUHead to(this, Register(REG_AX) + Register(REG_BX));
+ cHeadCPU to(this, Register(REG_AX) + Register(REG_BX));
const int reg_used = FindModifiedRegister(REG_CX);
const int value = Mod(Register(reg_used), GetNumInst());
sCPUStats & cpu_stats = organism->CPUStats();
@@ -2496,7 +2484,7 @@
bool cHardwareCPU::Inst_StackReadInst()
{
const int reg_used = FindModifiedRegister(REG_CX);
- cCPUHead from(this, Register(reg_used));
+ cHeadCPU from(this, Register(reg_used));
StackPush(from.GetInst().GetOp());
return true;
}
@@ -2504,7 +2492,7 @@
bool cHardwareCPU::Inst_StackWriteInst()
{
const int reg_used = FindModifiedRegister(REG_BX);
- cCPUHead to(this, Register(REG_AX) + Register(reg_used));
+ cHeadCPU to(this, Register(REG_AX) + Register(reg_used));
const int value = Mod(StackPop(), GetNumInst());
sCPUStats & cpu_stats = organism->CPUStats();
@@ -2529,8 +2517,8 @@
bool cHardwareCPU::Inst_Compare()
{
const int reg_used = FindModifiedRegister(REG_CX);
- cCPUHead from(this, Register(REG_BX));
- cCPUHead to(this, Register(REG_AX) + Register(REG_BX));
+ cHeadCPU from(this, Register(REG_BX));
+ cHeadCPU to(this, Register(REG_AX) + Register(REG_BX));
// Compare is dangerous -- it can cause mutations!
if (organism->TestCopyMut()) {
@@ -2547,8 +2535,8 @@
bool cHardwareCPU::Inst_IfNCpy()
{
- const cCPUHead from(this, Register(REG_BX));
- const cCPUHead to(this, Register(REG_AX) + Register(REG_BX));
+ const cHeadCPU from(this, Register(REG_BX));
+ const cHeadCPU to(this, Register(REG_AX) + Register(REG_BX));
// Allow for errors in this test...
if (organism->TestCopyMut()) {
@@ -3328,7 +3316,7 @@
bool cHardwareCPU::Inst_HeadWrite()
{
const int head_id = FindModifiedHead(HEAD_WRITE);
- cCPUHead & active_head = GetHead(head_id);
+ cHeadCPU & active_head = GetHead(head_id);
active_head.Adjust();
@@ -3346,8 +3334,8 @@
bool cHardwareCPU::Inst_HeadCopy()
{
// For the moment, this cannot be nop-modified.
- cCPUHead & read_head = GetHead(HEAD_READ);
- cCPUHead & write_head = GetHead(HEAD_WRITE);
+ cHeadCPU & read_head = GetHead(HEAD_READ);
+ cHeadCPU & write_head = GetHead(HEAD_WRITE);
sCPUStats & cpu_stats = organism->CPUStats();
read_head.Adjust();
@@ -3381,8 +3369,8 @@
bool cHardwareCPU::HeadCopy_ErrorCorrect(double reduction)
{
// For the moment, this cannot be nop-modified.
- cCPUHead & read_head = GetHead(HEAD_READ);
- cCPUHead & write_head = GetHead(HEAD_WRITE);
+ cHeadCPU & read_head = GetHead(HEAD_READ);
+ cHeadCPU & write_head = GetHead(HEAD_WRITE);
sCPUStats & cpu_stats = organism->CPUStats();
read_head.Adjust();
@@ -3423,7 +3411,7 @@
{
ReadLabel();
GetLabel().Rotate(1, NUM_NOPS);
- cCPUHead found_pos = FindLabel(0);
+ cHeadCPU found_pos = FindLabel(0);
const int search_size = found_pos.GetPosition() - IP().GetPosition();
Register(REG_BX) = search_size;
Register(REG_CX) = GetLabel().GetSize();
@@ -3452,7 +3440,7 @@
}
// Otherwise, jump to the label.
- cCPUHead jump_location(FindLabel(1));
+ cHeadCPU jump_location(FindLabel(1));
if (jump_location.GetPosition() != -1) {
IP().Set(jump_location);
return true;
Modified: trunk/source/cpu/hardware_cpu.hh
===================================================================
--- trunk/source/cpu/hardware_cpu.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_cpu.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -20,8 +20,8 @@
#ifndef CPU_DEFS_HH
#include "cpu_defs.hh"
#endif
-#ifndef CPU_HEAD_HH
-#include "cpu_head.hh"
+#ifndef HEAD_CPU_HH
+#include "head_cpu.hh"
#endif
#ifndef CPU_MEMORY_HH
#include "cpu_memory.hh"
@@ -62,7 +62,7 @@
**/
class cCodeLabel; // access
-class cCPUHead; // access
+class cHeadCPU; // access
class cCPUMemory; // aggregate
class cCPUStack; // aggregate
class cGenome;
@@ -142,18 +142,18 @@
{ threads[cur_thread].cur_head = (UCHAR) new_head; }
int GetCurHead() const { return threads[cur_thread].cur_head; }
- const cCPUHead & GetHead(int head_id) const
+ const cHeadCPU & GetHead(int head_id) const
{ return threads[cur_thread].heads[head_id]; }
- cCPUHead & GetHead(int head_id) { return threads[cur_thread].heads[head_id];}
+ cHeadCPU & GetHead(int head_id) { return threads[cur_thread].heads[head_id];}
- const cCPUHead & GetActiveHead() const { return GetHead(GetCurHead()); }
- cCPUHead & GetActiveHead() { return GetHead(GetCurHead()); }
+ const cHeadCPU & GetActiveHead() const { return GetHead(GetCurHead()); }
+ cHeadCPU & GetActiveHead() { return GetHead(GetCurHead()); }
void AdjustHeads();
- inline const cCPUHead & IP() const
+ inline const cHeadCPU & IP() const
{ return threads[cur_thread].heads[HEAD_IP]; }
- inline cCPUHead & IP() { return threads[cur_thread].heads[HEAD_IP]; }
+ inline cHeadCPU & IP() { return threads[cur_thread].heads[HEAD_IP]; }
// -------- Label Manipulation -------
@@ -203,13 +203,13 @@
}
// Complex label manipulation...
- cCPUHead FindLabel(int direction);
+ cHeadCPU FindLabel(int direction);
int FindLabel_Forward(const cCodeLabel & search_label,
const cGenome & search_genome, int pos);
int FindLabel_Backward(const cCodeLabel & search_label,
const cGenome & search_genome, int pos);
- cCPUHead FindLabel(const cCodeLabel & in_label, int direction);
- cCPUHead FindFullLabel(const cCodeLabel & in_label);
+ cHeadCPU FindLabel(const cCodeLabel & in_label, int direction);
+ cHeadCPU FindFullLabel(const cCodeLabel & in_label);
int GetType() const { return HARDWARE_TYPE_CPU_ORIGINAL; }
bool InjectHost(const cCodeLabel & in_label, const cGenome & injection);
@@ -220,15 +220,15 @@
int PointMutate(const double mut_rate);
bool TriggerMutations(int trigger);
- bool TriggerMutations(int trigger, cCPUHead & cur_head);
+ bool TriggerMutations(int trigger, cHeadCPU & cur_head);
bool TriggerMutations_ScopeGenome(const cMutation * cur_mut,
- cCPUMemory & target_memory, cCPUHead & cur_head, const double rate);
+ cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate);
bool TriggerMutations_ScopeLocal(const cMutation * cur_mut,
- cCPUMemory & target_memory, cCPUHead & cur_head, const double rate);
+ cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate);
int TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
- cCPUMemory & target_memory, cCPUHead & cur_head, const double rate);
+ cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate);
void TriggerMutations_Body(int type, cCPUMemory & target_memory,
- cCPUHead & cur_head);
+ cHeadCPU & cur_head);
void ReadInst(const int in_inst);
Modified: trunk/source/cpu/hardware_cpu_thread.hh
===================================================================
--- trunk/source/cpu/hardware_cpu_thread.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_cpu_thread.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -16,8 +16,8 @@
#ifndef CPU_DEFS_HH
#include "cpu_defs.hh"
#endif
-#ifndef CPU_HEAD_HH
-#include "cpu_head.hh"
+#ifndef HEAD_CPU_HH
+#include "head_cpu.hh"
#endif
#ifndef CPU_STACK_HH
#include "cpu_stack.hh"
@@ -29,11 +29,11 @@
/**
* This class is needed to run several threads on a single genome.
*
- * @see cCPUStack, cCPUHead, cHardwareCPU
+ * @see cCPUStack, cHeadCPU, cHardwareCPU
**/
class cCodeLabel; // aggregate;
-class cCPUHead; // aggregate
+class cHeadCPU; // aggregate
class cCPUStack; // aggregate
class cHardwareBase;
template <class T> class tBuffer; // aggregate
@@ -43,7 +43,7 @@
int id;
public:
int reg[NUM_REGISTERS];
- cCPUHead heads[NUM_HEADS];
+ cHeadCPU heads[NUM_HEADS];
cCPUStack stack;
UCHAR cur_stack; // 0 = local stack, 1 = global stack.
UCHAR cur_head;
Modified: trunk/source/cpu/hardware_factory.cc
===================================================================
--- trunk/source/cpu/hardware_factory.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_factory.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -10,6 +10,7 @@
#include "hardware_base.hh"
#include "hardware_cpu.hh"
#include "hardware_4stack.hh"
+#include "hardware_smt.h"
#include "inst_set.hh"
#include "organism.hh"
@@ -29,14 +30,20 @@
cHardwareBase * new_hardware = NULL;
// If there is nothing to recycle, just create a new one.
- if (hardware_cpu_list.GetSize() == 0) {
+ if (hardware_cpu_list.GetSize() == 0)
+ {
new_count++;
- if (type == HARDWARE_TYPE_CPU_ORIGINAL) {
- new_hardware = new cHardwareCPU(in_org, inst_set);
+ switch (type)
+ {
+ case HARDWARE_TYPE_CPU_ORIGINAL:
+ new_hardware = new cHardwareCPU(in_org, inst_set);
+ break;
+ case HARDWARE_TYPE_CPU_4STACK:
+ new_hardware = new cHardware4Stack(in_org, inst_set);
+ break;
+ case HARDWARE_TYPE_CPU_SMT:
+ new_hardware = new cHardwareSMT(in_org, inst_set);
}
- else if (type == HARDWARE_TYPE_CPU_4STACK) {
- new_hardware = new cHardware4Stack(in_org, inst_set);
- }
}
// If we do have hardware to recycle, do so!
Copied: trunk/source/cpu/hardware_smt.cc (from rev 296, branches/brysonda/source/cpu/hardware_smt.cc)
Copied: trunk/source/cpu/hardware_smt.h (from rev 296, branches/brysonda/source/cpu/hardware_smt.h)
Copied: trunk/source/cpu/hardware_smt_constants.h (from rev 296, branches/brysonda/source/cpu/hardware_smt_constants.h)
Copied: trunk/source/cpu/hardware_smt_thread.cc (from rev 296, branches/brysonda/source/cpu/hardware_smt_thread.cc)
Copied: trunk/source/cpu/hardware_smt_thread.h (from rev 296, branches/brysonda/source/cpu/hardware_smt_thread.h)
Modified: trunk/source/cpu/hardware_status_printer.cc
===================================================================
--- trunk/source/cpu/hardware_status_printer.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_status_printer.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -5,7 +5,7 @@
// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
//////////////////////////////////////////////////////////////////////////////
-#include "cpu_head.hh"
+#include "head_cpu.hh"
#include "hardware_4stack.hh"
#include "hardware_base.hh"
#include "hardware_cpu.hh"
Modified: trunk/source/cpu/hardware_tracer.hh
===================================================================
--- trunk/source/cpu/hardware_tracer.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_tracer.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -8,8 +8,9 @@
#ifndef HARDWARE_TRACER_HH
#define HARDWARE_TRACER_HH
-struct cHardwareTracer {
- virtual ~cHardwareTracer(){}
+struct cHardwareTracer
+{
+ virtual ~cHardwareTracer() { ; }
};
#endif
Modified: trunk/source/cpu/hardware_tracer_4stack.hh
===================================================================
--- trunk/source/cpu/hardware_tracer_4stack.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_tracer_4stack.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -10,6 +10,7 @@
class cHardware4Stack;
struct cHardwareTracer_4Stack {
+ virtual ~cHardwareTracer_4Stack() { ; }
virtual void TraceHardware_4Stack(cHardware4Stack &) = 0;
virtual void TraceHardware_4StackBonus(cHardware4Stack &) = 0;
};
Modified: trunk/source/cpu/hardware_tracer_cpu.hh
===================================================================
--- trunk/source/cpu/hardware_tracer_cpu.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_tracer_cpu.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -10,6 +10,7 @@
class cHardwareCPU;
struct cHardwareTracer_CPU {
+ virtual ~cHardwareTracer_CPU() { ; }
virtual void TraceHardware_CPU(cHardwareCPU &) = 0;
virtual void TraceHardware_CPUBonus(cHardwareCPU &) = 0;
};
Modified: trunk/source/cpu/hardware_tracer_test_cpu.hh
===================================================================
--- trunk/source/cpu/hardware_tracer_test_cpu.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_tracer_test_cpu.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -10,6 +10,7 @@
class cString;
struct cHardwareTracer_TestCPU {
+ virtual ~cHardwareTracer_TestCPU() { ; }
virtual void TraceHardware_TestCPU(
int time_used,
int time_allocated,
Modified: trunk/source/cpu/hardware_util.cc
===================================================================
--- trunk/source/cpu/hardware_util.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_util.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -21,6 +21,9 @@
#ifndef HARDWARE_4STACK_HH
#include "hardware_4stack.hh"
#endif
+#ifndef HARDWARE_SMT_H
+#include "hardware_smt.h"
+#endif
#ifndef INIT_FILE_HH
#include "init_file.hh"
#endif
@@ -30,55 +33,83 @@
#ifndef INST_SET_HH
#include "inst_set.hh"
#endif
+#ifndef TDICTIONARY_HH
+#include "tDictionary.hh"
+#endif
using namespace std;
-void cHardwareUtil::LoadInstSet(cString filename, cInstSet & inst_set,
- tDictionary<int> & nop_dict,
- tDictionary<int> & inst_dict
-){
- // If there is no filename, use the default for the appropriate hardware.
- cString default_filename = "unknown";
- if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL) {
- default_filename = cHardwareCPU::GetDefaultInstFilename();
+void cHardwareUtil::LoadInstSet(cString filename, cInstSet & inst_set)
+{
+ // Setup the instruction library and collect the default filename
+ cString default_filename;
+ switch (cConfig::GetHardwareType())
+ {
+ case HARDWARE_TYPE_CPU_ORIGINAL:
+ inst_set.SetInstLib(cHardwareCPU::GetInstLib());
+ default_filename = cHardwareCPU::GetDefaultInstFilename();
+ break;
+ case HARDWARE_TYPE_CPU_4STACK:
+ inst_set.SetInstLib(cHardware4Stack::GetInstLib());
+ default_filename = cHardware4Stack::GetDefaultInstFilename();
+ break;
+ case HARDWARE_TYPE_CPU_SMT:
+ inst_set.SetInstLib(cHardwareSMT::GetInstLib());
+ default_filename = cHardwareSMT::GetDefaultInstFilename();
+ break;
+ default:
+ default_filename = "unknown";
}
- else if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_4STACK) {
- default_filename = cHardware4Stack::GetDefaultInstFilename();
- }
-
- if (filename == "") {
- cerr << "Warning: No instruction set specified; using default '"
- << filename << "'." << endl;
+
+ if (filename == "")
+ {
filename = default_filename;
+ cerr << "Warning: No instruction set specified; using default '"
+ << filename << "'." << endl;
}
-
+
cInitFile file(filename);
-
+
// If we could not open the instruction set what to do?
- if (file.IsOpen() == false) {
-
+ if (file.IsOpen() == false)
+ {
+
// If this is the default filename, write the file and try again.
- if (filename == default_filename) {
- if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL) {
- cHardwareCPU::WriteDefaultInstSet();
- }
- else if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_4STACK) {
- cHardware4Stack::WriteDefaultInstSet();
- }
+ if (filename == default_filename)
+ {
+ switch (cConfig::GetHardwareType())
+ {
+ case HARDWARE_TYPE_CPU_ORIGINAL:
+ cHardwareCPU::WriteDefaultInstSet();
+ break;
+ case HARDWARE_TYPE_CPU_4STACK:
+ cHardware4Stack::WriteDefaultInstSet();
+ break;
+ case HARDWARE_TYPE_CPU_SMT:
+ cHardwareSMT::WriteDefaultInstSet();
+ }
}
-
// If this is not the default filename, give and error and stop.
- else {
+ else
+ {
cerr << "Error: Could not open instruction set '" << filename
- << "'. Halting." << endl;
+ << "'. Exiting..." << endl;
exit(1);
}
}
-
+
file.Load();
file.Compress();
-
+
+ tDictionary<int> nop_dict;
+ for(int i = 0; i < inst_set.GetInstLib()->GetNumNops(); i++)
+ nop_dict.Add(inst_set.GetInstLib()->GetNopName(i), i);
+
+ tDictionary<int> inst_dict;
+ for(int i = 0; i < inst_set.GetInstLib()->GetSize(); i++)
+ inst_dict.Add(inst_set.GetInstLib()->GetName(i), i);
+
for (int line_id = 0; line_id < file.GetNumLines(); line_id++) {
cString cur_line = file.GetLine(line_id);
cString inst_name = cur_line.PopWord();
@@ -86,12 +117,12 @@
int cost = cur_line.PopWord().AsInt();
int ft_cost = cur_line.PopWord().AsInt();
double prob_fail = cur_line.PopWord().AsDouble();
-
+
// If this instruction has 0 redundancy, we don't want it!
if (redundancy < 0) continue;
if (redundancy > 256) {
- cerr << "Error: Max redundancy is 256. Resetting redundancy of \""
- << inst_name << "\" from " << redundancy << " to 256." << endl;
+ cerr << "Warning: Max redundancy is 256. Resetting redundancy of \""
+ << inst_name << "\" from " << redundancy << " to 256." << endl;
redundancy = 256;
}
@@ -102,85 +133,30 @@
inst_set.AddNop2(nop_mod, redundancy, ft_cost, cost, prob_fail);
continue;
}
-
+
// Otherwise, it had better be in the main dictionary...
int fun_id = -1;
if(inst_dict.Find(inst_name, fun_id) == true){
inst_set.Add2(fun_id, redundancy, ft_cost, cost, prob_fail);
continue;
}
-
+
// Oh oh! Didn't find an instruction!
cerr << endl
- << "Error: Could not find instruction '" << inst_name << "'" << endl
- << " (Best match = '"
- << inst_dict.NearMatch(inst_name) << "')" << endl;
+ << "Error: Could not find instruction '" << inst_name << "'" << endl
+ << " (Best match = '"
+ << inst_dict.NearMatch(inst_name) << "'). Exiting..." << endl;
exit(1);
}
-
- cerr << "Loaded Instruction Library \"" << filename
- << "\" with " << inst_set.GetSize() << " instructions." << endl;
}
-void cHardwareUtil::LoadInstSet_CPUOriginal(const cString & filename, cInstSet & inst_set)
-{
- // Nops (or other modifying-instructions...) Note: Nops must be the
- // first instructions added to the set.
-
- // Build a dictionary of instructions and their corresponding methods...
-
- tDictionary<int> nop_dict;
- for(int i=0; i<inst_set.GetInstLib()->GetNumNops(); i++)
- nop_dict.Add(inst_set.GetInstLib()->GetNopName(i), i);
-
- tDictionary<int> inst_dict;
- for(int i=0; i<inst_set.GetInstLib()->GetSize(); i++)
- inst_dict.Add(inst_set.GetInstLib()->GetName(i), i);
-
- // And load it on up!
- LoadInstSet(filename, inst_set, nop_dict, inst_dict);
-}
-
-void cHardwareUtil::LoadInstSet_CPU4Stack(const cString & filename, cInstSet & inst_set)
-{
- // Nops (or other modifying-instructions...) Note: Nops must be the
- // first instructions added to the set.
-
- // Build a dictionary of instructions and their corresponding methods...
-
- tDictionary<int> nop_dict;
- for(int i=0; i<inst_set.GetInstLib()->GetNumNops(); i++)
- nop_dict.Add(inst_set.GetInstLib()->GetNopName(i), i);
-
- tDictionary<int> inst_dict;
- for(int i=0; i<inst_set.GetInstLib()->GetSize(); i++)
- inst_dict.Add(inst_set.GetInstLib()->GetName(i), i);
-
- cout << "Instruction Library in util has " << inst_dict.GetSize()
- << " instructions and " << nop_dict.GetSize() << " nops." << endl;
-
-
- // And load it on up!
- LoadInstSet(filename, inst_set, nop_dict, inst_dict);
-}
-
cInstSet & cHardwareUtil::DefaultInstSet(const cString & inst_filename)
{
static cInstSet inst_set;
+
+ // If we don't have an instruction set yet, set it up.
+ if (inst_set.GetSize() == 0) LoadInstSet(inst_filename, inst_set);
- // If we don't have an instruction set yet, and we've been given a filename,
- // set it up.
- if (inst_filename != "" && inst_set.GetSize() == 0) {
- if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL) {
- inst_set.SetInstLib(cHardwareCPU::GetInstLib());
- LoadInstSet_CPUOriginal(inst_filename, inst_set);
- }
- else if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_4STACK) {
- inst_set.SetInstLib(cHardware4Stack::GetInstLib());
- LoadInstSet_CPU4Stack(inst_filename, inst_set);
- }
- }
-
return inst_set;
}
Modified: trunk/source/cpu/hardware_util.hh
===================================================================
--- trunk/source/cpu/hardware_util.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/cpu/hardware_util.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -11,23 +11,14 @@
#ifndef STRING_HH
#include "string.hh"
#endif
-#ifndef TDICTIONARY_HH
-#include "tDictionary.hh"
-#endif
class cString; // aggregate
class cInstSet;
-template <class T> class tDictionary;
class cHardwareUtil {
public:
- static void LoadInstSet( cString filename, cInstSet & inst_set,
- tDictionary<int> & nop_dict, tDictionary<int> & inst_dict );
- static void LoadInstSet_CPUOriginal(const cString & filename,
- cInstSet & inst_set);
- static void LoadInstSet_CPU4Stack(const cString & filename,
- cInstSet & inst_set);
- static cInstSet & DefaultInstSet(const cString & inst_filename);
+ static void LoadInstSet( cString filename, cInstSet& inst_set);
+ static cInstSet& DefaultInstSet(const cString & inst_filename);
};
#endif
Copied: trunk/source/cpu/head_cpu.cc (from rev 296, branches/brysonda/source/cpu/head_cpu.cc)
Copied: trunk/source/cpu/head_cpu.hh (from rev 296, branches/brysonda/source/cpu/head_cpu.hh)
Copied: trunk/source/cpu/head_multi_mem.cc (from rev 296, branches/brysonda/source/cpu/head_multi_mem.cc)
Copied: trunk/source/cpu/head_multi_mem.hh (from rev 296, branches/brysonda/source/cpu/head_multi_mem.hh)
Copied: trunk/source/cpu/tInstLib.h (from rev 296, branches/brysonda/source/cpu/tInstLib.h)
Modified: trunk/source/defs.hh
===================================================================
--- trunk/source/defs.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/defs.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -75,9 +75,9 @@
// the macro VERSION is defined by automake (in the file 'configure.in' in
// the top-level directory).
#ifndef VERSION
- #define VERSION "2.3.0"
+ #define VERSION "2.3.1"
#endif
-#define AVIDA_VERSION VERSION
+#define AVIDA_VERSION "2.3.1 (Padawan)"
#ifdef QUICK_BASE_TEST_CPU
#define QUICK_TEST_CPU
@@ -152,6 +152,7 @@
#ifndef _WINDEF_ // Defined by WINDOWS.H
#define UCHAR unsigned char
+ #undef UINT
#define UINT unsigned int
#endif
@@ -181,29 +182,11 @@
#define FILE_TYPE_TEXT 0
#define FILE_TYPE_HTML 1
-#define HARDWARE_TYPE_CPU_ORIGINAL 0
-#define HARDWARE_TYPE_CPU_4STACK 1
+enum tHARDWARE_TYPE
+{
+ HARDWARE_TYPE_CPU_ORIGINAL = 0,
+ HARDWARE_TYPE_CPU_4STACK,
+ HARDWARE_TYPE_CPU_SMT
+};
-
-
-#define TASK_GET 0
-#define TASK_PUT 1
-#define TASK_GGP 2
-
-#define TASK_ECHO 0
-#define TASK_NAND 1
-#define TASK_NOT 2
-
-#define TASK_AND 3
-#define TASK_ORN 4
-
-#define TASK_ANDN 5
-#define TASK_OR 6
-
-#define TASK_NOR 7
-#define TASK_XOR 8
-#define TASK_EQU 9
-
-#define NUM_TASKS 10
-
#endif
Modified: trunk/source/event/CMakeLists.txt
===================================================================
--- trunk/source/event/CMakeLists.txt 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/CMakeLists.txt 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,43 +1,11 @@
-ADD_CUSTOM_COMMAND(
- OUTPUT
- cPopulation_construct_event_auto.ci
- cPopulation_descr.ci
- cPopulation_descr.hi
- cPopulation_enums_auto.ci
- cPopulation_name2enum_auto.ci
- cPopulation_process_auto.ci
- COMMAND perl
- ARGS
- ${PROJECT_SOURCE_DIR}/source/event/make_events.pl
- ${PROJECT_SOURCE_DIR}/source/event/cPopulation
- MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/source/event/cPopulation.events
- COMMENT
- This is a somewhat ugly hack to build the autogenerated code.
- We pretend that the autogenerated code is actually a program, then
- make builds it correctly. Any other way leads to unnecessary
- recompilation of libevent.a even if nothing has changed.
-)
-
SET(libevent_a_SOURCES
- event.cc
- event_factory.cc
event_factory_manager.cc
event_list.cc
- event_list_entry.cc
event_list_iterator.cc
event_triggers.cc
- population_event.cc
population_event_factory.cc
)
-SET_SOURCE_FILES_PROPERTIES(population_event_factory.cc
- PROPERTIES
- OBJECT_DEPENDS cPopulation_construct_event_auto.ci
- OBJECT_DEPENDS cPopulation_enums_auto.ci
- OBJECT_DEPENDS cPopulation_name2enum_auto.ci
- OBJECT_DEPENDS cPopulation_process_auto.ci
-)
-
INCLUDE_DIRECTORIES(${ALL_INC_DIRS})
ADD_LIBRARY(event ${libevent_a_SOURCES})
Deleted: trunk/source/event/cPopulation.events
===================================================================
--- trunk/source/event/cPopulation.events 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/cPopulation.events 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,2147 +0,0 @@
-######## Meta Events ###########
-exit
-:descr:
-/**
-* Ends the Avida run immediately.
-**/
-:args:
-:body:
-cAvidaDriver_Base::main_driver->SetDone();
-
-exit_if_generation_greater_than
-:descr:
-/**
-* Ends the Avida run when the current generation exceeds the
-* maximum generation given as parameter.
-*
-* Parameters:
-* max generation (int)
-* The generation at which the run should be stopped.
-**/
-:args:
-int max_generation
-:body:
-if( population->GetGeneration() > max_generation ){
- cAvidaDriver_Base::main_driver->SetDone();
-}
-
-exit_if_update_greater_than
-:descr:
-/**
-* Ends the Avida run when the current update exceeds the
-* maximum update given as parameter.
-*
-* Parameters:
-* max update (int)
-* The update at which the run should be stopped.
-**/
-:args:
-int max_update
-:body:
-if( population->GetUpdate() > max_update ){
- cAvidaDriver_Base::main_driver->SetDone();
-}
-
-
-exit_if_ave_lineage_label_smaller
-:descr:
-/**
-* Halts the avida run if the current average lineage label is smaller
-* than the value given as parameter.
-*
-* Parameters:
-* lineage_label_crit_value (int)
-* The critical value to which the average lineage label is compared.
-**/
-:args:
-double lineage_label_crit_value
-:body:
-if( population->GetStats().GetAveLineageLabel() < lineage_label_crit_value ){
- cAvidaDriver_Base::main_driver->SetDone();
-}
-
-exit_if_ave_lineage_label_larger
-:descr:
-/**
-* Halts the avida run if the current average lineage label is larger
-* than the value given as parameter.
-*
-* Parameters:
-* lineage_label_crit_value (int)
-* The critical value to which the average lineage label is compared.
-**/
-:args:
-double lineage_label_crit_value
-:body:
-if( population->GetStats().GetAveLineageLabel() > lineage_label_crit_value ){
- cAvidaDriver_Base::main_driver->SetDone();
-}
-
-echo
-:descr:
-/**
-* Writes out a message. If no message is given, average update and
-* generation are written out.
-*
-* Parameters:
-* message (string)
-**/
-:args:
-cString mesg
-:body:
-if( mesg == "" ){
- mesg.Set("Echo : Update = %f\t AveGeneration = %f",
- population->GetUpdate(), population->GetGeneration());
-}
-cAvidaDriver_Base::main_driver->NotifyComment(mesg);
-
-####### Printing Data Files ###########
-print_data
-:descr:
-/**
-* Output user-defined data from the cStats object...
-*
-* Parameters:
-* filename (string)
-* The name of the data file.
-* format
-* A comma-seperated list of statistics to output.
-**/
-:args:
-cString filename
-cString format
-:body:
-population->GetStats().PrintDataFile(filename, format, ',');
-
-print_average_data
-:descr:
-/**
-* Output various average quantities into datafile.
-*
-* Parameters:
-* filename (string) default: average.dat
-* The name of the data file.
-**/
-:args:
-cString fname "average.dat"
-:body:
-population->GetStats().PrintAverageData(fname);
-
-print_error_data
-:descr:
-/**
-* Prints out various data related to statistical errors.
-*
-* Parameters:
-* filename (string) default: error.dat
-* The name of the data file.
-**/
-:args:
-cString fname "error.dat"
-:body:
-population->GetStats().PrintErrorData(fname);
-
-print_variance_data
-:descr:
-/**
-* Prints out various variances.
-*
-* Parameters:
-* filename (string) default: variance.dat
-* The name of the data file.
-**/
-:args:
-cString fname "variance.dat"
-:body:
-population->GetStats().PrintVarianceData(fname);
-
-print_dominant_data
-:descr:
-/**
-* Output various quantities related to the dominant organism.
-*
-* Parameters:
-* filename (string) default: dominant.dat
-* The name of the data file.
-**/
-:args:
-cString fname "dominant.dat"
-:body:
-population->GetStats().PrintDominantData(fname);
-
-print_stats_data
-:descr:
-/**
-* Output various statistical quantities.
-*
-* Parameters:
-* filename (string) default: stats.dat
-* The name of the data file.
-**/
-:args:
-cString fname "stats.dat"
-:body:
-population->GetStats().PrintStatsData(fname);
-
-print_count_data
-:descr:
-/**
-* Output various counts, such as number of organisms etc.
-*
-* Parameters:
-* filename (string) default: count.dat
-* The name of the data file.
-**/
-:args:
-cString fname "count.dat"
-:body:
-population->GetStats().PrintCountData(fname);
-
-print_totals_data
-:descr:
-/**
-* Various total numbers.
-*
-* Parameters:
-* filename (string) default: totals.dat
-* The name of the data file.
-**/
-:args:
-cString fname "totals.dat"
-:body:
-population->GetStats().PrintTotalsData(fname);
-
-print_tasks_data
-:descr:
-/**
-* Output the number of times the various tasks have been performed in the
-* last update.
-*
-* Parameters:
-* filename (string) default: tasks.dat
-* The name of the data file.
-**/
-:args:
-cString fname "tasks.dat"
-:body:
-population->GetStats().PrintTasksData(fname);
-
-print_tasks_exe_data
-:descr:
-/**
-**/
-:args:
-cString fname "tasks_exe.dat"
-:body:
-population->GetStats().PrintTasksExeData(fname);
-
-print_resource_data
-:descr:
-/**
-**/
-:args:
-cString fname "resource.dat"
-:body:
-population->GetStats().PrintResourceData(fname);
-
-print_time_data
-:descr:
-/**
-* Output time related data, such as update, generation, etc.
-*
-* Parameters:
-* filename (string) default: time.dat
-* The name of the data file.
-**/
-:args:
-cString fname "time.dat"
-:body:
-population->GetStats().PrintTimeData(fname);
-
-print_mutation_data
-:descr:
-/**
-**/
-:args:
-cString fname "mutation.dat"
-:body:
-population->GetStats().PrintMutationData(fname);
-
-print_mutation_rate_data
-:descr:
-/**
-Output (regular and log) statistics about individual copy
-mutation rates (aver, stdev, skew, cur).
-Useful only when mutation rate is set per organism.
-**/
-:args:
-cString fname "mutation_rates.dat"
-:body:
-population->GetStats().PrintMutationRateData(fname);
-
-print_divide_mut_data
-:descr:
-/**
-Output (regular and log) statistics about individual, per site,
-rates divide mutation rates (aver, stdev, skew, cur).
-Use with multiple divide instuction set.
-**/
-:args:
-cString fname "divide_mut.dat"
-:body:
-population->GetStats().PrintDivideMutData(fname);
-
-print_dom_parasite_data
-:descr:
-/**
-* Output various quantities related to the dominant parasite.
-*
-* Parameters:
-* filename (string) default: parasite.dat
-* The name of the data file.
-**/
-:args:
-cString fname "parasite.dat"
-:body:
-population->GetStats().PrintDominantParaData(fname);
-
-######### Instruction Data Output ##############
-print_instruction_data
-:descr:
-/**
-Sum of the by-organisms counts of what instructions they _successfully_
-execute beteween birth and divide. Prior to their first divide, organisms
-report values for their parents.
-**/
-:args:
-cString fname "instruction.dat"
-:body:
-population->GetStats().PrintInstructionData(fname);
-
-########### Population Instruction Abundance ######
-########### ED 2002-Sept-7 #################
-print_instruction_abundance_histogram
-:descr:
-/**
-*
-* Appends a line containing the bulk count (abundance) of
-* each instruction in the population onto a file.
-*
-* Parameters:
-* filename (string) default: "instruction_histogram.dat"
-*
-**/
-:args:
-cString filename "instruction_histogram.dat"
-:body:
-ofstream & fp = population->GetStats().GetDataFileOFStream(filename);
-cAnalyzeUtil::PrintInstructionAbundanceHistogram(fp, population);
-
-
-
-########### Misc Output #################3
-print_depth_histogram
-:descr:
-/**
-**/
-:args:
-cString filename "depth_histogram.dat"
-:body:
-ofstream & fp = population->GetStats().GetDataFileOFStream(filename);
-cAnalyzeUtil::PrintDepthHistogram(fp, population);
-
-print_genotype_abundance_histogram
-:descr:
-/**
-* Writes out a genotype abundance histogram.
-*
-* Parameters:
-* filename (string) default: genotype_abundance_histogram.dat
-* The name of the file into which the histogram is written.
-**/
-:args:
-cString filename "genotype_abundance_histogram.dat"
-:body:
-ofstream & fp = population->GetStats().GetDataFileOFStream(filename);
-cAnalyzeUtil::PrintGenotypeAbundanceHistogram(fp, population);
-
-print_species_abundance_histogram
-:descr:
-/**
-* Writes out a species abundance histogram.
-*
-* Parameters:
-* filename (string) default: species_abundance_histogram.dat
-* The name of the file into which the histogram is written.
-**/
-:args:
-cString filename "species_abundance_histogram.dat"
-:body:
-ofstream & fp = population->GetStats().GetDataFileOFStream(filename);
-cAnalyzeUtil::PrintSpeciesAbundanceHistogram(fp, population);
-
-print_lineage_totals
-:descr:
-/**
-**/
-:args:
-cString fname "lineage_totals.dat"
-int verbose 1
-:body:
-static bool msg_printed = false;
-if (population->GetLineageControl() == NULL) {
- if ( msg_printed == false ){
- ofstream & fp = population->GetStats().GetDataFileOFStream(fname);
- fp << "No lineage data available!" << endl;
- msg_printed = true;
- }
- return;
-}
-population->GetLineageControl()->PrintLineageTotals(fname, verbose);
-
-print_lineage_counts
-:descr:
-/**
-**/
-:args:
-cString fname "lineage_counts.dat"
-int verbose 0
-:body:
-static bool msg_printed = false;
-if (population->GetLineageControl() == NULL) {
- if ( msg_printed == false ){
- ofstream & fp = population->GetStats().GetDataFileOFStream(fname);
- fp << "No lineage data available!" << endl;
- msg_printed = true;
- }
- return;
-}
-if (verbose) { // verbose mode is the same in both methods
- population->GetLineageControl()->PrintLineageTotals(fname, verbose);
- return;
-}
-population->GetLineageControl()->PrintLineageCurCounts(fname);
-
-print_dom
-:descr:
-/**
-* Write the currently dominant genotype to disk.
-*
-* Parameters:
-* filename (string)
-* The name under which the genotype should be saved. If no
-* filename is given, the genotype is saved into the directory
-* genebank, under the name that the genebank has associated with
-* this genotype.
-**/
-:args:
-cString in_filename ""
-:body:
-cGenotype * dom = population->GetGenebank().GetBestGenotype();
-cString filename(in_filename);
-if (filename == "") filename.Set("genebank/%s", dom->GetName()());
-cTestUtil::PrintGenome(dom->GetGenome(), filename, dom, population->GetUpdate());
-
-parasite_debug
-:descr:
-//midget
-:args:
-cString in_filename ""
-:body:
-population->ParasiteDebug();
-
-print_dom_parasite
-:descr:
-/**
-* Write the currently dominant injected genotype to disk.
-*
-* Parameters:
-* filename (string)
-* The name under which the genotype should be saved. If no
-* filename is given, the genotype is saved into the directory
-* genebank, under the name that the genebank has associated with
-* this genotype.
-**/
-:args:
-cString in_filename ""
-:body:
-cInjectGenotype * dom = population->GetInjectGenebank().GetBestInjectGenotype();
-if (dom!=NULL) {
-cString filename(in_filename);
-if (filename == "") filename.Set("genebank/%s", dom->GetName()());
-cTestUtil::PrintGenome(dom, dom->GetGenome(), filename, population->GetUpdate()); }
-
-print_genotype_map
-:descr:
-/**
-* write a matrix of genotype ID's to a file (matlab format)
-**/
-:args:
-cString fname "genotype_map.m"
-:body:
-population->GetStats().PrintGenotypeMap(fname);
-
-print_number_phenotypes
-:descr:
-/**
-Output file with number of phenotypes based on tasks executed
-for this update. Executing a task any numbers of times is considered
-the same as executing it once.
-**/
-:args:
-cString fname "phenotype_count.dat"
-:body:
-population->PrintPhenotypeData(fname);
-
-print_phenotype_status
-:descr:
-/**
-Prints merit status for all the organisms in the population.
-Used for testing/debuging.
-**/
-:args:
-cString fname "phenotype_status.dat"
-:body:
-population->PrintPhenotypeStatus(fname);
-
-######### SAVE/LOAD POPULATION ######################
-save_population
-:descr:
-/**
-* Saves the full state of the population.
-*
-* Parameters:
-* filename (string) default: save_pop.*
-* The name of the file into which the population should
-* be saved. If it is not given, then the name 'save_pop.*'
-* is used, with '*' replaced by the current update.
-**/
-:args:
-cString fname ""
-:body:
-cString filename;
-if( fname == "" ){
- filename.Set("save_pop.%d", population->GetUpdate());
-}
-ofstream fp(filename());
-population->SavePopulation(fp);
-
-load_population
-:descr:
-/**
-* Loads the full state of the population.
-*
-* Parameters:
-* filename (string)
-* The name of the file to open.
-**/
-:args:
-cString fname
-:body:
-ifstream fp(fname());
-population->LoadPopulation(fp);
-
-
-######### CLONES ######################
-save_clone
-:descr:
-/**
-**/
-:args:
-cString fname ""
-:body:
-cString filename;
-if( fname == "" ){
- filename.Set("clone.%d", population->GetUpdate());
-}
-ofstream fp(filename());
-population->SaveClone(fp);
-
-load_clone
-:descr:
-/**
-**/
-:args:
-cString fname
-:body:
-ifstream fp(fname());
-population->LoadClone(fp);
-
-
-load_dump_file
-:descr:
-/**
-* Sets up a population based on a dump file such as written out by
-* detail_pop. It is also possible to append a history file to the dump
-* file, in order to preserve the history of a previous run.
-**/
-:args:
-cString fname
-int update -1
-:body:
-population->LoadDumpFile(fname, update);
-
-########## DUMP A TEXT SUMMARY ###########
-dump_pop
-:descr:
-/**
-* Writes out a line of data for each genotype in the current population. The
-* line contains the genome as string, the number of organisms of that genotype,
-* and the genotype ID.
-*
-* Parameters:
-* filename (string) default: "dump.<update>"
-* The name of the file into which the population dump should be written.
-**/
-:args:
-cString fname ""
-:body:
-cString filename;
-if( fname == "" ){
- filename.Set("dump.%d", population->GetUpdate());
-}
-ofstream fp(filename());
-population->GetGenebank().DumpTextSummary(fp);
-
-print_genotypes
-:descr:
-/**
-* This is a new version of "detail_pop" or "historic_dump". It allows you to
-* output one line per genotype in memory where you get to choose what data
-* should be included.
-*
-* Parameters
-* data_fields (string)
-* This must be a comma separated string of all data you wish to output.
-* Options include: id, parent_id, parent2_id (for sex), parent_dist,
-* num_cpus, total_cpus, length, merit, gest_time, fitness, update_born,
-* update_dead, depth, lineage, sequence
-* historic (int) default: 0
-* How many updates back of history should we include (-1 = all)
-* filename (string) default: "genotypes-<update>.dat"
-* The name of the file into which the population dump should be written.
-**/
-:args:
-cString data_fields "all"
-int historic 0
-cString fname ""
-:body:
-cString filename = fname;
-if (filename == "") {
- filename.Set("genotypes-%d.dat", population->GetUpdate());
-}
-ofstream fp(filename());
-population->GetGenebank().PrintGenotypes(fp, data_fields, historic);
-
-detail_pop
-:descr:
-/**
-* Like dump_pop, but more detailed data is written out.
-*
-* Parameters:
-* filename (string) default: "detail_pop.<update>"
-* The name of the file into which the population dump should be written.
-**/
-:args:
-cString fname ""
-:body:
-cString filename;
-if( fname == "" ){
- filename.Set("detail_pop.%d", population->GetUpdate());
-}
-ofstream fp(filename());
-population->GetGenebank().DumpDetailedSummary(fp);
-
-detail_sex_pop
-:descr:
-/**
-* Like detail_pop, but for sexual populations.
-* Info for both parents is writen out.
-*
-* Parameters:
-* filename (string) default: "detail_pop.<update>"
-* The name of the file into which the population dump should be written.
-**/
-:args:
-cString fname ""
-:body:
-cString filename;
-if( fname == "" ){
- filename.Set("detail_pop.%d", population->GetUpdate());
-}
-ofstream fp(filename());
-population->GetGenebank().DumpDetailedSexSummary(fp);
-
-
-detail_parasite_pop
-:descr:
-/**
-* Like dump_pop, but more detailed data is written out.
-*
-* Parameters:
-* filename (string) default: "detail_pop.<update>"
-* The name of the file into which the population dump should be written.
-**/
-:args:
-cString fname ""
-:body:
-cString filename;
-if( fname == "" ){
- filename.Set("detail_parasite_pop.%d", population->GetUpdate());
-}
-//ofstream fp(filename());
-population->GetInjectGenebank().DumpDetailedSummary(filename, population->GetUpdate());
-
-dump_historic_pop
-:descr:
-/**
-* Similar to detail_pop. However, only genotypes that are not in the
-* current population anymore are included. Genotypes that are not in
-* the line of descent of any of the current genotypes to the ultimate
-* ancestor are excluded.
-*
-* Parameters:
-* back_dist (int) default: -1
-* How many updates back should we print? -1 goes forever. Use the
-* distance to the last dump historic if you only want a "diff".
-* filename (string) default: "historic_dump.<update>"
-* The name of the file into which the historic dump should be written.
-**/
-:args:
-int back_dist -1
-cString fname ""
-:body:
-cString filename;
-if( fname == "" ){
- filename.Set("historic_dump.%d", population->GetUpdate());
-}
-ofstream fp(filename());
-population->GetGenebank().DumpHistoricSummary(fp, back_dist);
-
-dump_historic_sex_pop
-:descr:
-/**
-* Similar to dump_historic_pop, but for sexual populations.
-* ID of both parents is writen out.
-*
-* Parameters:
-* filename (string) default: "historic_dump.<update>"
-* The name of the file into which the historic dump should be written.
-**/
-:args:
-cString fname ""
-:body:
-cString filename;
-if( fname == "" ){
- filename.Set("historic_dump.%d", population->GetUpdate());
-}
-ofstream fp(filename());
-population->GetGenebank().DumpHistoricSexSummary(fp);
-
-dump_memory
-:descr:
-/**
-* Dump the current memory state of all CPUs to a file.
-**/
-:args:
-cString fname ""
-:body:
-cString filename;
-if (fname == "") {
- filename.Set("memory_dump.%d", population->GetUpdate());
-}
-ofstream fp(filename());
-population->DumpMemorySummary(fp);
-
-################ INJECT ###################
-inject
-:descr:
-/**
-* Injects a single organism into the population.
-*
-* Parameters:
-* filename (string)
-* The filename of the genotype to load. If this is left empty, or the keyword
-* "START_CREATURE" is given, than the genotype specified in the genesis
-* file under "START_CREATURE" is used.
-* cell ID (integer) default: 0
-* The grid-point into which the organism should be placed.
-* merit (double) default: -1
-* The initial merit of the organism. If set to -1, this is ignored.
-* lineage label (integer) default: 0
-* An integer that marks all descendants of this organism.
-* neutral metric (double) default: 0
-* A double value that randomly drifts over time.
-**/
-:args:
-cString fname "START_CREATURE"
-int cell_id 0
-double merit -1
-int lineage_label 0
-double neutral_metric 0
-:body:
-if (fname == "START_CREATURE") fname=cConfig::GetStartCreature();
-cGenome genome =
- cInstUtil::LoadGenome(fname, population->GetEnvironment().GetInstSet());
-population->Inject(genome, cell_id, merit, lineage_label, neutral_metric);
-
-inject_all
-:descr:
-/**
-* Injects identical organisms into all cells of the population.
-*
-* Parameters:
-* filename (string)
-* The filename of the genotype to load. If this is left empty, or the keyword
-* "START_CREATURE" is given, than the genotype specified in the genesis
-* file under "START_CREATURE" is used.
-* merit (double) default: -1
-* The initial merit of the organism. If set to -1, this is ignored.
-* lineage label (integer) default: 0
-* An integer that marks all descendants of this organism.
-* neutral metric (double) default: 0
-* A double value that randomly drifts over time.
-**/
-:args:
-cString fname "START_CREATURE"
-double merit -1
-int lineage_label 0
-double neutral_metric 0
-:body:
-if (fname == "START_CREATURE") fname=cConfig::GetStartCreature();
-cGenome genome =
- cInstUtil::LoadGenome(fname, population->GetEnvironment().GetInstSet());
-for (int i = 0; i < population->GetSize(); i++) {
- population->Inject(genome, i, merit, lineage_label, neutral_metric);
-}
-population->SetSyncEvents(true);
-
-inject_range
-:descr:
-/**
-* Injects identical organisms into a range of cells of the population.
-*
-* Parameters:
-* filename (string)
-* The filename of the genotype to load. If this is left empty, or the keyword
-* "START_CREATURE" is given, than the genotype specified in the genesis
-* file under "START_CREATURE" is used.
-* start_cell (int)
-* First cell to inject into.
-* stop_cell (int)
-* First cell *not* to inject into.
-* merit (double) default: -1
-* The initial merit of the organism. If set to -1, this is ignored.
-* lineage label (integer) default: 0
-* An integer that marks all descendants of this organism.
-* neutral metric (double) default: 0
-* A double value that randomly drifts over time.
-*
-* Example:
-* inject_range creature.gen 0 10
-*
-* Will inject 10 organisms into cells 0 through 9.
-**/
-:args:
-cString fname "START_CREATURE"
-int start_cell 0
-int end_cell -1
-double merit -1
-int lineage_label 0
-double neutral_metric 0
-:body:
-if (fname == "START_CREATURE") fname=cConfig::GetStartCreature();
-if (end_cell == -1) end_cell = start_cell + 1;
-if (start_cell < 0 ||
- end_cell > population->GetSize() ||
- start_cell >= end_cell) {
- cout << "Warning: inject_range has invalid range!";
-}
-else {
- cGenome genome =
- cInstUtil::LoadGenome(fname, population->GetEnvironment().GetInstSet());
- for (int i = start_cell; i < end_cell; i++) {
- population->Inject(genome, i, merit, lineage_label, neutral_metric);
- }
- population->SetSyncEvents(true);
-}
-
-inject_sequence
-:descr:
-/**
-* Injects identical organisms into a range of cells of the population.
-*
-* Parameters:
-* sequence (string)
-* The genome sequence for this organism. This is a mandatory argument.
-* start_cell (int)
-* First cell to inject into.
-* stop_cell (int)
-* First cell *not* to inject into.
-* merit (double) default: -1
-* The initial merit of the organism. If set to -1, this is ignored.
-* lineage label (integer) default: 0
-* An integer that marks all descendants of this organism.
-* neutral metric (double) default: 0
-* A double value that randomly drifts over time.
-*
-* Example:
-* inject_range ckdfhgklsahnfsaggdsgajfg 0 10 100
-*
-* Will inject 10 organisms into cells 0 through 9 with a merit of 100.
-**/
-:args:
-cString seq
-int start_cell 0
-int end_cell -1
-double merit -1
-int lineage_label 0
-double neutral_metric 0
-:body:
-if (end_cell == -1) end_cell = start_cell + 1;
-if (start_cell < 0 ||
- end_cell > population->GetSize() ||
- start_cell >= end_cell) {
- cout << "Warning: inject_sequence has invalid range!" << endl;
- cout << "start=" << start_cell << " end=" << end_cell
- << "genome length=" << seq.GetSize() << endl;
-}
-else {
- cGenome genome(seq);
- for (int i = start_cell; i < end_cell; i++) {
- population->Inject(genome, i, merit, lineage_label, neutral_metric);
- }
- population->SetSyncEvents(true);
-}
-
-inject_random
-:descr:
-/**
-* Injects a randomly generated genome into the population.
-*
-* Parameters:
-* length (integer) [required]
-* Number of instructions in the randomly generated genome.
-* cell ID (integer) default: -1
-* The grid-point into which the genome should be placed. Default is random.
-* merit (double) default: -1
-* The initial merit of the organism. If set to -1, this is ignored.
-* lineage label (integer) default: 0
-* An integer that marks all descendants of this organism.
-* neutral metric (double) default: 0
-* A double value that randomly drifts over time.
-**/
-:args:
-int length
-int cell_id -1
-double merit -1
-int lineage_label 0
-double neutral_metric 0
-:body:
-if (cell_id == -1) cell_id = g_random.GetUInt(population->GetSize());
-cGenome genome =
- cInstUtil::RandomGenome(length, population->GetEnvironment().GetInstSet());
-population->Inject(genome, cell_id, merit, lineage_label, neutral_metric);
-
-inject_range_parasite
-:descr:
-/**
-* Injects identical organisms into a range of cells of the population.
-*
-* Parameters:
-* filename (string)
-* The filename of the genotype to load. If this is left empty, or the keyword
-* "START_CREATURE" is given, than the genotype specified in the genesis
-* file under "START_CREATURE" is used.
-* start_cell (int)
-* First cell to inject into.
-* stop_cell (int)
-* First cell *not* to inject into.
-* merit (double) default: -1
-* The initial merit of the organism. If set to -1, this is ignored.
-* lineage label (integer) default: 0
-* An integer that marks all descendants of this organism.
-* neutral metric (double) default: 0
-* A double value that randomly drifts over time.
-*
-* Example:
-* inject_range creature.gen 0 10
-*
-* Will inject 10 organisms into cells 0 through 9.
-**/
-:args:
-cString fname_parasite "organism.parasite"
-int start_cell 0
-int end_cell -1
-double merit -1
-int lineage_label 0
-double neutral_metric 0
-int mem_space 2
-:body:
-if (fname_parasite == "START_CREATURE") fname_parasite=cConfig::GetStartCreature();
-if (end_cell == -1) end_cell = start_cell + 1;
-if (start_cell < 0 ||
- end_cell > population->GetSize() ||
- start_cell >= end_cell) {
- cout << "Warning: inject_range has invalid range!";
-}
-else {
- cGenome genome_parasite =
- cInstUtil::LoadGenome(fname_parasite, population->GetEnvironment().GetInstSet());
- for (int i = start_cell; i < end_cell; i++) {
- population->Inject(genome_parasite, i, merit, lineage_label, neutral_metric, mem_space);
- }
- population->SetSyncEvents(true);
-}
-
-inject_range_pair
-:descr:
-/**
-* Injects identical organisms into a range of cells of the population.
-*
-* Parameters:
-* filename (string)
-* The filename of the genotype to load. If this is left empty, or the keyword
-* "START_CREATURE" is given, than the genotype specified in the genesis
-* file under "START_CREATURE" is used.
-* start_cell (int)
-* First cell to inject into.
-* stop_cell (int)
-* First cell *not* to inject into.
-* merit (double) default: -1
-* The initial merit of the organism. If set to -1, this is ignored.
-* lineage label (integer) default: 0
-* An integer that marks all descendants of this organism.
-* neutral metric (double) default: 0
-* A double value that randomly drifts over time.
-*
-* Example:
-* inject_range creature.gen 0 10
-*
-* Will inject 10 organisms into cells 0 through 9.
-**/
-:args:
-cString fname "START_CREATURE"
-cString fname_parasite "organism.parasite"
-int start_cell 0
-int end_cell -1
-double merit -1
-int lineage_label 0
-double neutral_metric 0
-int mem_space 2
-:body:
-if (fname == "START_CREATURE") fname=cConfig::GetStartCreature();
-if (end_cell == -1) end_cell = start_cell + 1;
-if (start_cell < 0 ||
- end_cell > population->GetSize() ||
- start_cell >= end_cell) {
- cout << "Warning: inject_range has invalid range!";
-}
-else {
- cGenome genome =
- cInstUtil::LoadGenome(fname, population->GetEnvironment().GetInstSet());
- cGenome genome_parasite =
- cInstUtil::LoadGenome(fname_parasite, population->GetEnvironment().GetInstSet());
- for (int i = start_cell; i < end_cell; i++) {
- population->Inject(genome, i, merit, lineage_label, neutral_metric);
- population->Inject(genome_parasite, i, merit, lineage_label, neutral_metric, mem_space);
- }
- population->SetSyncEvents(true);
-}
-
-################ MUTATION RATES ###############
-zero_muts
-:descr:
-/**
- * This event will set all mutation rates to zero...
- **/
-:args:
-:body:
-for (int i = 0; i < population->GetSize(); i++) {
- population->GetCell(i).MutationRates().Clear();
-}
-
-mod_copy_mut
-:descr:
-/**
-**/
-:args:
-double cmut_inc
-int cell -1
-:body:
-const double new_cmut = cConfig::GetCopyMutProb() + cmut_inc;
-if (cell < 0) { // cell == -1 --> all
- for (int i = 0; i < population->GetSize(); i++) {
- population->GetCell(i).MutationRates().SetCopyMutProb(new_cmut);
- }
- cConfig::SetCopyMutProb(new_cmut);
-} else {
- population->GetCell(cell).MutationRates().SetCopyMutProb(new_cmut);
-}
-
-mod_div_mut
-:descr:
-/**
-**/
-:args:
-double dmut_inc
-int cell -1
-:body:
-const double new_div_mut = cConfig::GetDivMutProb() + dmut_inc;
-if (cell < 0) { // cell == -1 --> all
- for (int i = 0; i < population->GetSize(); i++) {
- population->GetCell(i).MutationRates().SetDivMutProb(new_div_mut);
- }
- cConfig::SetDivMutProb(new_div_mut);
-} else {
- population->GetCell(cell).MutationRates().SetDivMutProb(new_div_mut);
-}
-
-
-set_copy_mut
-:descr:
-/**
-**/
-:args:
-double cmut
-int start_cell -1
-int end_cell -1
-:body:
-if (start_cell < 0) { // start_cell == -1 --> all
- cConfig::SetCopyMutProb(cmut);
- start_cell = 0;
- end_cell = population->GetSize();
-}
-else if (end_cell < -1) { // end_cell == -1 --> Only one cell!
- end_cell = start_cell + 1;
-}
-assert(start_cell >= 0 && start_cell < population->GetSize());
-assert(end_cell > 0 && end_cell <= population->GetSize());
-for (int i = start_cell; i < end_cell; i++) {
- population->GetCell(i).MutationRates().SetCopyMutProb(cmut);
-}
-
-mod_point_mut
-:descr:
-/**
-**/
-:args:
-double pmut_inc
-int cell -1
-:body:
-const double new_pmut = cConfig::GetPointMutProb() + pmut_inc;
-if (cell < 0) { // cell == -1 --> all
- for (int i = 0; i < population->GetSize(); i++) {
- population->GetCell(i).MutationRates().SetPointMutProb(new_pmut);
- }
- cConfig::SetPointMutProb(new_pmut);
-} else {
- population->GetCell(cell).MutationRates().SetPointMutProb(new_pmut);
-}
-
-set_point_mut
-:descr:
-/**
-**/
-:args:
-double pmut
-int cell -1
-:body:
-if (cell < 0) { // cell == -1 --> all
- for (int i = 0; i < population->GetSize(); i++) {
- population->GetCell(i).MutationRates().SetPointMutProb(pmut);
- }
- cConfig::SetPointMutProb(pmut);
-} else {
- population->GetCell(cell).MutationRates().SetPointMutProb(pmut);
-}
-
-######## Landscapeing #########
-calc_landscape
-:descr:
-/**
-**/
-:args:
-int landscape_dist 1
-:body:
-cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
-cAnalyzeUtil::CalcLandscape(landscape_dist, genome,
- population->GetEnvironment().GetInstSet());
-
-predict_w_landscape
-:descr:
-/**
-**/
-:args:
-cString datafile "land-predict.dat"
-:body:
-cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
-cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
-static ofstream fp(datafile);
-landscape.PredictWProcess(fp);
-
-predict_nu_landscape
-:descr:
-/**
-**/
-:args:
-cString datafile "land-predict.dat"
-:body:
-cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
-cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
-static ofstream fp(datafile);
-landscape.PredictNuProcess(fp);
-
-sample_landscape
-:descr:
-/**
-**/
-:args:
-int sample_size 0
-:body:
-cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
-cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
-if (sample_size == 0) sample_size = population->GetEnvironment().GetInstSet().GetSize() - 1;
-landscape.SampleProcess(sample_size);
-static ofstream fp("land-sample.dat");
-landscape.PrintStats(fp, population->GetUpdate());
-
-random_landscape
-:descr:
-/**
-**/
-:args:
-int landscape_dist 1
-int sample_size 0
-int min_found 0
-int max_sample_size 0
-bool print_if_found false
-:body:
-cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
-cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
-landscape.RandomProcess(sample_size, landscape_dist, min_found,
- max_sample_size, print_if_found);
-static ofstream fp("land-random.dat");
-landscape.PrintStats(fp, population->GetUpdate());
-
-analyze_landscape
-:descr:
-/**
-**/
-:args:
-int sample_size 1000
-int min_found 0
-int max_sample_size 0
-:body:
-cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
-cAnalyzeUtil::
-AnalyzeLandscape(genome, population->GetEnvironment().GetInstSet(),
- sample_size, min_found, max_sample_size,
- population->GetUpdate());
-
-pairtest_landscape
-:descr:
-/**
-* If sample_size = 0, pairtest the full landscape.
-**/
-:args:
-int sample_size 0
-:body:
-cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
-cAnalyzeUtil::PairTestLandscape(genome, population->GetEnvironment().GetInstSet(), sample_size, population->GetUpdate());
-
-test_dom
-:descr:
-/**
-**/
-:args:
-:body:
-cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
-static ofstream fp("dom-test.dat");
-cAnalyzeUtil::TestGenome(genome, population->GetEnvironment().GetInstSet(), fp, population->GetUpdate());
-
-analyze_population
-:descr:
-/**
-**/
-:args:
-double sample_prob 1
-int landscape 0
-int save_genotype 0
-cString filename ""
-:body:
-static bool auto_filename = false;
-if( filename == "" )
- auto_filename = true;
-if ( auto_filename )
- filename.Set("population_info_%d.dat",population->GetUpdate());
-ofstream population_info(filename());
-cAnalyzeUtil::AnalyzePopulation(population, population_info, sample_prob,
- landscape, save_genotype);
-
-print_detailed_fitness_data
-:descr:
-/**
-**/
-:args:
-int save_max_f_genotype 0
-int print_fitness_histo 0
-double hist_fmax 1
-double hist_fstep 0.1
-cString filename "fitness.dat"
-cString filename2 "fitness_histos.dat"
-cString filename3 "fitness_histos_testCPU.dat"
-:body:
-static ofstream datafile(filename());
-static ofstream histofile;
-static ofstream histofile_testCPU;
-if (print_fitness_histo && !histofile.is_open()){
- histofile.open(filename2());
- histofile_testCPU.open(filename3());
-}
-cAnalyzeUtil::PrintDetailedFitnessData( population, datafile, histofile, histofile_testCPU, save_max_f_genotype, print_fitness_histo, hist_fmax, hist_fstep );
-
-print_genetic_distance_data
-:descr:
-/**
-**/
-:args:
-cString creature_name ""
-cString filename "genetic_distance.dat"
-:body:
-static ofstream popdump(filename());
-if( creature_name == "" || creature_name == "START_CREATURE" ){
- creature_name = cConfig::GetStartCreature(); }
-cAnalyzeUtil::PrintGeneticDistanceData( population, popdump, creature_name() );
-
-genetic_distance_pop_dump
-:descr:
-/**
-**/
-:args:
-cString creature_name ""
-cString filename ""
-int save_genotype 0
-:body:
-static bool auto_filename = false;
-if( creature_name == "" || creature_name == "START_CREATURE" ){
- creature_name = cConfig::GetStartCreature(); }
-if( filename == "" || filename == "AUTO" )
- auto_filename = true;
-if ( auto_filename )
- filename.Set("pop_dump_%d.dat",population->GetUpdate());
-ofstream popdump(filename());
-cAnalyzeUtil::GeneticDistancePopDump( population, popdump, creature_name(), save_genotype );
-
-
-task_snapshot
-:descr:
-/**
-**/
-:args:
-cString filename ""
-:body:
-static bool auto_filename = false;
-if( filename == "" )
- auto_filename = true;
-if ( auto_filename )
- filename.Set("tasks_%d.dat",population->GetUpdate());
-ofstream snapshot_file(filename());
-cAnalyzeUtil::TaskSnapshot( population, snapshot_file );
-
-print_viable_tasks_data
-:descr:
-/**
-**/
-:args:
-cString filename "viable_tasks.dat"
-:body:
-static ofstream datafile(filename());
-cAnalyzeUtil::PrintViableTasksData( population, datafile );
-
-
-############ Removal of creatures #############
-apocalypse
-:descr:
-/**
-* Randomly removes a certain proportion of the population.
-*
-* Parameters:
-* removal probability (double) default: 0.9
-* The probability with which a single organism is removed.
-**/
-:args:
-double kill_prob .9
-:body:
-for (int i = 0; i < population->GetSize(); i++) {
- cPopulationCell & cell = population->GetCell(i);
- if (cell.IsOccupied() == false) continue;
- if (g_random.P(kill_prob)) population->KillOrganism(cell);
-}
-
-kill_rectangle
-:descr:
-/**
-* Kills all cell in a rectangle.
-*
-* Parameters:
-* cell [X1][Y1][x2][Y2] (integer) default: 0
-* The start and stoping grid-points into which the organism should
-be killed.
-**/
-:args:
-int cell_X1 0
-int cell_Y1 0
-int cell_X2 0
-int cell_Y2 0
-:body:
-int i, j, loc;
-/* Be sure the user entered a valid range */
-if (cell_X1 < 0) {
- cell_X1 = 0;
-} else if (cell_X1 > population->GetWorldX() - 1) {
- cell_X1 = population->GetWorldX() - 1;
-}
-if (cell_X2 < 0) {
- cell_X2 = 0;
-} else if (cell_X2 > population->GetWorldX() - 1) {
- cell_X2 = population->GetWorldX() - 1;
-}
-if (cell_Y1 < 0) {
- cell_Y1 = 0;
-} else if (cell_Y1 > population->GetWorldY() - 1) {
- cell_Y1 = population->GetWorldY() - 1;
-}
-if (cell_Y2 < 0) {
- cell_Y2 = 0;
-} else if (cell_Y2 > population->GetWorldY() - 1) {
- cell_Y2 = population->GetWorldY() - 1;
-}
-/* Account for a rectangle that crosses over the Zero X or Y cell */
-if (cell_X2 < cell_X1) {
- cell_X2 = cell_X2 + population->GetWorldX();
-}
-if (cell_Y2 < cell_Y1) {
- cell_Y2 = cell_Y2 + population->GetWorldY();
-}
-for (i = cell_Y1; i <= cell_Y2; i++) {
- for (j = cell_X1; j <= cell_X2; j++) {
- loc = (i % population->GetWorldY()) * population->GetWorldX() +
- (j % population->GetWorldX());
- cPopulationCell & cell = population->GetCell(loc);
- if (cell.IsOccupied() == true) {
- population->KillOrganism(cell);
- }
- }
-}
-population->SetSyncEvents(true);
-
-rate_kill
-:descr:
-/**
-* Randomly removes a certain proportion of the population.
-* In principle, this event does the same thing as the apocalypse event.
-* However, instead of a probability, here one has to specify a rate. The
-* rate has the same unit as fitness. So if the average fitness is 20000,
-* then you remove 50% of the population on every update with a removal rate
-* of 10000.
-*
-* Parameters:
-* removal rate (double)
-* The rate at which organisms are removed.
-**/
-:args:
-double kill_rate
-:body:
-double ave_merit = population->GetStats().SumMerit().Average();
-if ( ave_merit <= 0 )
- ave_merit = 1; // make sure that we don't get NAN's or negative numbers
-ave_merit /= cConfig::GetAveTimeslice();
-const double kill_prob = kill_rate / ave_merit;
-for (int i = 0; i < population->GetSize(); i++) {
- cPopulationCell & cell = population->GetCell(i);
- if (cell.IsOccupied() == false) continue;
- if (g_random.P(kill_prob)) population->KillOrganism(cell);
-}
-
-serial_transfer
-:descr:
-/**
-* This event does again the same thing as apocalypse. However, now
-* the number of organisms to be retained can be specified
-* exactly. Also, it is possible to specify whether any of these
-* organisms may be dead or not.
-*
-* Parameters:
-* transfer size (int) default: 1
-* The number of organisms to retain. If there are fewer living
-* organisms than the specified transfer size, then all living
-* organisms are retained.
-* ignore deads (int) default: 1
-* When set to 1, only living organisms are retained. Otherwise,
-* every type of organism can be retained.
-**/
-:args:
-int transfer_size 1
-int ignore_deads 1
-:body:
-population->SerialTransfer( transfer_size, ignore_deads );
-
-
-############ Hill Climbing #############
-hillclimb
-:descr:
-/**
-* Does a hill climb with the dominant genotype.
-**/
-:args:
-:body:
-cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
-ofstream fp("hillclimb.dat");
-cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
-landscape.HillClimb(fp);
-
-hillclimb_neut
-:descr:
-/**
-**/
-:args:
-:body:
-cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
-ofstream fp("hillclimb.dat");
-cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
-landscape.HillClimb_Neut(fp);
-
-hillclimb_rand
-:descr:
-/**
-**/
-:args:
-:body:
-cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
-ofstream fp("hillclimb.dat");
-cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
-landscape.HillClimb_Rand(fp);
-
-############ Demes ###############
-compete_demes
-:descr:
-/**
-* Compete all of the demes using a basic genetic algorithm approach. Fitness
-* of each deme is determined differently depending on the competition_type:
-* 0: deme fitness = 1 (control, random deme selection)
-* 1: deme fitness = number of births since last competition (default)
-* 2: deme fitness = average organism fitness at the current update
-* 3: deme fitness = average mutation rate at the current update
-* Merit can optionally be passed in.
-**/
-:args:
-int competition_type 1
-:body:
-population->CompeteDemes(competition_type);
-
-reset_demes
-:descr:
-/**
-* Designed to serve as a control for the compete_demes. Each deme is
-* copied into itself and the parameters reset.
-**/
-:args:
-:body:
-population->ResetDemes();
-
-print_deme_stats
-:descr:
-/**
-* Print stats about individual demes
-**/
-:args:
-:body:
-population->PrintDemeStats();
-
-copy_deme
-:descr:
-/**
-* Takes two numbers as arguments and copies the contents of the first deme
-* listed into the second.
-**/
-:args:
-int deme1_id
-int deme2_id
-:body:
-population->CopyDeme(deme1_id, deme2_id);
-
-############ Consensus #############
-calc_consensus
-:descr:
-/**
-* Calculates the consensus sequence.
-*
-* Parameters:
-* lines saved (integer) default: 0
-* ???
-**/
-:args:
-int lines_saved 0
-:body:
-cAnalyzeUtil::CalcConsensus(population, lines_saved);
-
-############ Other Population Called Tests ##########
-test_size_change_robustness
-:descr:
-/**
-**/
-:args:
-int num_trials 100
-cString filename "size_change.dat"
-:body:
-ofstream & fp = population->GetStats().GetDataFileOFStream(filename);
-cAnalyzeUtil::TestInsSizeChangeRobustness(fp,
- population->GetEnvironment().GetInstSet(),
- population->GetGenebank().GetBestGenotype()->GetGenome(),
- num_trials, population->GetUpdate());
-
-########### Threads ################
-test_threads
-:descr:
-/**
-**/
-:args:
-:body:
-cTestCPU::TestThreads(population->GetGenebank().GetBestGenotype()->GetGenome());
-
-print_threads
-:descr:
-/**
-**/
-:args:
-:body:
-cTestCPU::PrintThreads( population->GetGenebank().GetBestGenotype()->GetGenome() );
-
-########### Grid Output ##############
-# This event depends on the ncurses viewer (cSymbolUtil).
-# That's not good. The event can only be reactivated if that
-# dependency is removed. Claus
-#dump_basic_grid
-#:descr:
-#/**
-#**/
-#:args:
-#:body:
-#cString filename;
-#filename.Set("grid.% 05d.out", population->GetUpdate());
-#ofstream fp(filename());
-#for (int i = 0; i < population->GetWorldX(); i++) {
-# for (int j = 0; j < population->GetWorldY(); j++) {
-# cPopulationCell & cell = population->GetCell(j*population->GetWorldX()+i);
-# char out_char = cSymbolUtil::GetBasicSymbol(cell);
-# switch (out_char) {
-# case ' ':
-# fp << -3;
-# break;
-# case '.':
-# fp << -2;
-# break;
-# case '+':
-# fp << -1;
-# break;
-# default:
-# fp << out_char - 'A';
-# }
-# fp << " ";
-# }
-# fp << endl;
-#}
-#
-dump_fitness_grid
-:descr:
-/**
-* Writes out all fitness values of the organisms currently in the
-* population.
-*
-* The output file is called "fgrid.*.out", where '*' is replaced by the
-* number of the current update.
-**/
-:args:
-:body:
-cString filename;
-filename.Set("fgrid.%05d.out", population->GetUpdate());
-ofstream fp(filename());
-for (int i = 0; i < population->GetWorldX(); i++) {
- for (int j = 0; j < population->GetWorldY(); j++) {
- cPopulationCell & cell = population->GetCell(j*population->GetWorldX()+i);
- double fitness = (cell.IsOccupied()) ?
- cell.GetOrganism()->GetGenotype()->GetFitness() : 0.0;
- fp << fitness << " ";
- }
- fp << endl;
-}
-
-dump_genotype_grid
-:descr:
-/**
-* Writes out all genotype id values of the organisms currently in the
-* population.
-*
-* The output file is called "idgrid.*.out", where '*' is replaced by the
-* number of the current update.
-**/
-:args:
-:body:
-cString filename;
-filename.Set("idgrid.%05d.out", population->GetUpdate());
-ofstream fp(filename());
-for (int i = 0; i < population->GetWorldX(); i++) {
- for (int j = 0; j < population->GetWorldY(); j++) {
- cPopulationCell & cell = population->GetCell(j*population->GetWorldX()+i);
- int id = (cell.IsOccupied()) ?
- cell.GetOrganism()->GetGenotype()->GetID() : -1;
- fp << id << " ";
- }
- fp << endl;
-}
-
-dump_task_grid
-:descr:
-/**
-* Writes out a grid of tasks done by each organism
-* Tasks are encoded as a binary string first, and then converted into a
-* base 10 number
-**/
-:args:
-:body:
-cString filename;
-filename.Set("task_grid_%d.dat",population->GetUpdate());
-ofstream fp(filename());
-cAnalyzeUtil::TaskGrid( population, fp );
-
-/**
-* Writes out tasks done for all current organisms
-* output is the base 10 representation of 0-1 binary strings
-* representing the all tasks done, with NOT = 2^0, EQU = 2^8
-*
-* The output file is called "task_grid.*.out", where '*' is replaced by the
-* number of the current update.
-**/
-
-dump_donor_grid
-:descr:
-/**
-* Writes out the grid of donor organisms in the population
-*
-* The output file is called "donor_grid.*.out", where '*' is replaced by the
-* number of the current update.
-**/
-:args:
-:body:
-cString filename;
-filename.Set("donor_grid.%05d.out", population->GetUpdate());
-ofstream fp(filename());
-for (int i = 0; i < population->GetWorldX(); i++) {
- for (int j = 0; j < population->GetWorldY(); j++) {
- cPopulationCell & cell = population->GetCell(j*population->GetWorldX()+i);
- int donor = cell.IsOccupied() ?
- cell.GetOrganism()->GetPhenotype().IsDonorLast() : -1;
- fp << donor << " ";
- }
- fp << endl;
-}
-
-dump_receiver_grid
-:descr:
-/**
-* Writes out the grid of organisms which received merit in the population
-*
-* The output file is called "receiver_grid.*.out", where '*' is replaced by the
-* number of the current update.
-**/
-:args:
-:body:
-cString filename;
-filename.Set("receiver_grid.%05d.out", population->GetUpdate());
-ofstream fp(filename());
-for (int i = 0; i < population->GetWorldX(); i++) {
- for (int j = 0; j < population->GetWorldY(); j++) {
- cPopulationCell & cell = population->GetCell(j*population->GetWorldX()+i);
- int receiver = cell.IsOccupied() ?
- cell.GetOrganism()->GetPhenotype().IsReceiver() : -1;
- fp << receiver << " ";
- }
- fp << endl;
-}
-
-
-######### Tree Reconstruction ##########
-print_tree_depths
-:descr:
-/**
-* Reconstruction of phylogenetic trees.
-**/
-:args:
-cString filename ""
-:body:
-if (filename == "") filename.Set("tree_depth.%d.dat", population->GetUpdate());
-ofstream fp(filename);
-cAnalyzeUtil::PrintTreeDepths(population, fp);
-
-
-########## Grid Structure ############
-sever_grid_col
-:descr:
-/**
-* Remove the connections between cells along a column in an avida grid.
-* Arguments:
-* col_id: indicates the number of columns to the left of the cut.
-* default (or -1) = cut population in half
-* min_row: First row to start cutting from
-* default = 0
-* max_row: Last row to cut to
-* default (or -1) = last row in population.
-**/
-:args:
-int col_id -1
-int min_row 0
-int max_row -1
-:body:
-const int world_x = population->GetWorldX();
-const int world_y = population->GetWorldY();
-if (col_id == -1) col_id = world_x / 2;
-if (max_row == -1) max_row = world_y;
-if (col_id < 0 || col_id >= world_x) {
- cerr << "Event Error: Column ID " << col_id
- << " out of range for sever_grid_col" << endl;
- return;
-}
-// Loop through all of the rows and make the cut on each...
-for (int row_id = min_row; row_id < max_row; row_id++) {
- int idA = row_id * world_x + col_id;
- int idB = GridNeighbor(idA, world_x, world_y, -1, 0);
- int idA0 = GridNeighbor(idA, world_x, world_y, 0, -1);
- int idA1 = GridNeighbor(idA, world_x, world_y, 0, 1);
- int idB0 = GridNeighbor(idA, world_x, world_y, -1, -1);
- int idB1 = GridNeighbor(idA, world_x, world_y, -1, 1);
- cPopulationCell & cellA = population->GetCell(idA);
- cPopulationCell & cellB = population->GetCell(idB);
- tList<cPopulationCell> & cellA_list = cellA.ConnectionList();
- tList<cPopulationCell> & cellB_list = cellB.ConnectionList();
- cellA_list.Remove(&population->GetCell(idB));
- cellA_list.Remove(&population->GetCell(idB0));
- cellA_list.Remove(&population->GetCell(idB1));
- cellB_list.Remove(&population->GetCell(idA));
- cellB_list.Remove(&population->GetCell(idA0));
- cellB_list.Remove(&population->GetCell(idA1));
-}
-
-sever_grid_row
-:descr:
-/**
-* Remove the connections between cells along a column in an avida grid.
-* Arguments:
-* row_id: indicates the number of rows above the cut.
-* default (or -1) = cut population in half
-* min_col: First row to start cutting from
-* default = 0
-* max_col: Last row to cut to
-* default (or -1) = last row in population.
-**/
-:args:
-int row_id -1
-int min_col 0
-int max_col -1
-:body:
-const int world_x = population->GetWorldX();
-const int world_y = population->GetWorldY();
-if (row_id == -1) row_id = world_y / 2;
-if (max_col == -1) max_col = world_x;
-if (row_id < 0 || row_id >= world_y) {
- cerr << "Event Error: Row ID " << row_id
- << " out of range for sever_grid_row" << endl;
- return;
-}
-// Loop through all of the cols and make the cut on each...
-for (int col_id = min_col; col_id < max_col; col_id++) {
- int idA = row_id * world_x + col_id;
- int idB = GridNeighbor(idA, world_x, world_y, 0, -1);
- int idA0 = GridNeighbor(idA, world_x, world_y, -1, 0);
- int idA1 = GridNeighbor(idA, world_x, world_y, 1, 0);
- int idB0 = GridNeighbor(idA, world_x, world_y, -1, -1);
- int idB1 = GridNeighbor(idA, world_x, world_y, 1, -1);
- cPopulationCell & cellA = population->GetCell(idA);
- cPopulationCell & cellB = population->GetCell(idB);
- tList<cPopulationCell> & cellA_list = cellA.ConnectionList();
- tList<cPopulationCell> & cellB_list = cellB.ConnectionList();
- cellA_list.Remove(&population->GetCell(idB));
- cellA_list.Remove(&population->GetCell(idB0));
- cellA_list.Remove(&population->GetCell(idB1));
- cellB_list.Remove(&population->GetCell(idA));
- cellB_list.Remove(&population->GetCell(idA0));
- cellB_list.Remove(&population->GetCell(idA1));
-}
-
-join_grid_col
-:descr:
-/**
-* Join the connections between cells along a column in an avida grid.
-* Arguments:
-* col_id: indicates the number of columns to the left of the joining.
-* default (or -1) = join population halves.
-* min_row: First row to start joining from
-* default = 0
-* max_row: Last row to join to
-* default (or -1) = last row in population.
-**/
-:args:
-int col_id -1
-int min_row 0
-int max_row -1
-:body:
-const int world_x = population->GetWorldX();
-const int world_y = population->GetWorldY();
-if (col_id == -1) col_id = world_x / 2;
-if (max_row == -1) max_row = world_y;
-if (col_id < 0 || col_id >= world_x) {
- cerr << "Event Error: Column ID " << col_id
- << " out of range for join_grid_col" << endl;
- return;
-}
-// Loop through all of the rows and make the cut on each...
-for (int row_id = min_row; row_id < max_row; row_id++) {
- int idA = row_id * world_x + col_id;
- int idB = GridNeighbor(idA, world_x, world_y, -1, 0);
- cPopulationCell & cellA = population->GetCell(idA);
- cPopulationCell & cellB = population->GetCell(idB);
- cPopulationCell & cellA0 =
- population->GetCell(GridNeighbor(idA, world_x, world_y, 0, -1));
- cPopulationCell & cellA1 =
- population->GetCell(GridNeighbor(idA, world_x, world_y, 0, 1));
- cPopulationCell & cellB0 =
- population->GetCell(GridNeighbor(idA, world_x, world_y, -1, -1));
- cPopulationCell & cellB1 =
- population->GetCell(GridNeighbor(idA, world_x, world_y, -1, 1));
- tList<cPopulationCell> & cellA_list = cellA.ConnectionList();
- tList<cPopulationCell> & cellB_list = cellB.ConnectionList();
- if (cellA_list.FindPtr(&cellB) == NULL) cellA_list.Push(&cellB);
- if (cellA_list.FindPtr(&cellB0) == NULL) cellA_list.Push(&cellB0);
- if (cellA_list.FindPtr(&cellB1) == NULL) cellA_list.Push(&cellB1);
- if (cellB_list.FindPtr(&cellA) == NULL) cellB_list.Push(&cellA);
- if (cellB_list.FindPtr(&cellA0) == NULL) cellB_list.Push(&cellA0);
- if (cellB_list.FindPtr(&cellA1) == NULL) cellB_list.Push(&cellA1);
-}
-
-join_grid_row
-:descr:
-/**
-* Remove the connections between cells along a column in an avida grid.
-* Arguments:
-* row_id: indicates the number of rows abovef the cut.
-* default (or -1) = cut population in half
-* min_col: First row to start cutting from
-* default = 0
-* max_col: Last row to cut to
-* default (or -1) = last row in population.
-**/
-:args:
-int row_id -1
-int min_col 0
-int max_col -1
-:body:
-const int world_x = population->GetWorldX();
-const int world_y = population->GetWorldY();
-if (row_id == -1) row_id = world_y / 2;
-if (max_col == -1) max_col = world_x;
-if (row_id < 0 || row_id >= world_y) {
- cerr << "Event Error: Row ID " << row_id
- << " out of range for join_grid_row" << endl;
- return;
-}
-// Loop through all of the cols and make the cut on each...
-for (int col_id = min_col; col_id < max_col; col_id++) {
- int idA = row_id * world_x + col_id;
- int idB = GridNeighbor(idA, world_x, world_y, 0, -1);
- cPopulationCell & cellA = population->GetCell(idA);
- cPopulationCell & cellB = population->GetCell(idB);
- cPopulationCell & cellA0 =
- population->GetCell(GridNeighbor(idA, world_x, world_y, -1, 0));
- cPopulationCell & cellA1 =
- population->GetCell(GridNeighbor(idA, world_x, world_y, 1, 0));
- cPopulationCell & cellB0 =
- population->GetCell(GridNeighbor(idA, world_x, world_y, -1, -1));
- cPopulationCell & cellB1 =
- population->GetCell(GridNeighbor(idA, world_x, world_y, 1, -1));
- tList<cPopulationCell> & cellA_list = cellA.ConnectionList();
- tList<cPopulationCell> & cellB_list = cellB.ConnectionList();
- if (cellA_list.FindPtr(&cellB) == NULL) cellA_list.Push(&cellB);
- if (cellA_list.FindPtr(&cellB0) == NULL) cellA_list.Push(&cellB0);
- if (cellA_list.FindPtr(&cellB1) == NULL) cellA_list.Push(&cellB1);
- if (cellB_list.FindPtr(&cellA) == NULL) cellB_list.Push(&cellA);
- if (cellB_list.FindPtr(&cellA0) == NULL) cellB_list.Push(&cellA0);
- if (cellB_list.FindPtr(&cellA1) == NULL) cellB_list.Push(&cellA1);
-}
-
-connect_cells
-:descr:
-/**
-* Connects a pair of specified cells.
-* Arguments:
-* cellA_x, cellA_y, cellB_x, cellB_y
-**/
-:args:
-int cellA_x
-int cellA_y
-int cellB_x
-int cellB_y
-:body:
-const int world_x = population->GetWorldX();
-const int world_y = population->GetWorldY();
-if (cellA_x < 0 || cellA_x >= world_x ||
- cellA_y < 0 || cellA_y >= world_y ||
- cellB_x < 0 || cellB_x >= world_x ||
- cellB_y < 0 || cellB_y >= world_y) {
- cerr << "Event 'connect_cells' cell out of range." << endl;
- return;
-}
-int idA = cellA_y * world_x + cellA_x;
-int idB = cellB_y * world_x + cellB_x;
-cPopulationCell & cellA = population->GetCell(idA);
-cPopulationCell & cellB = population->GetCell(idB);
-tList<cPopulationCell> & cellA_list = cellA.ConnectionList();
-tList<cPopulationCell> & cellB_list = cellB.ConnectionList();
-cellA_list.PushRear(&cellB);
-cellB_list.PushRear(&cellA);
-
-disconnect_cells
-:descr:
-/**
-* Connects a pair of specified cells.
-* Arguments:
-* cellA_x, cellA_y, cellB_x, cellB_y
-**/
-:args:
-int cellA_x
-int cellA_y
-int cellB_x
-int cellB_y
-:body:
-const int world_x = population->GetWorldX();
-const int world_y = population->GetWorldY();
-if (cellA_x < 0 || cellA_x >= world_x ||
- cellA_y < 0 || cellA_y >= world_y ||
- cellB_x < 0 || cellB_x >= world_x ||
- cellB_y < 0 || cellB_y >= world_y) {
- cerr << "Event 'connect_cells' cell out of range." << endl;
- return;
-}
-int idA = cellA_y * world_x + cellA_x;
-int idB = cellB_y * world_x + cellB_x;
-cPopulationCell & cellA = population->GetCell(idA);
-cPopulationCell & cellB = population->GetCell(idB);
-tList<cPopulationCell> & cellA_list = cellA.ConnectionList();
-tList<cPopulationCell> & cellB_list = cellB.ConnectionList();
-cellA_list.Remove(&cellB);
-cellB_list.Remove(&cellA);
-
-########## Resources ############
-inject_resource
-:descr:
-/**
-* Inject (add) a specified amount of a specified resource.
-**/
-:args:
-cString res_name
-double res_count
-:body:
-cResourceLib & res_lib = population->GetEnvironment().GetResourceLib();
-int res_id = res_lib.GetResource(res_name)->GetID();
-population->UpdateResource(res_id, res_count);
-
-set_resource
-:descr:
-/**
-* Set the resource amount to a specific level
-**/
-:args:
-cString res_name
-double res_count
-:body:
-cResourceLib & res_lib = population->GetEnvironment().GetResourceLib();
-cResource * found_resource = res_lib.GetResource(res_name);
-if (found_resource != NULL) {
- population->SetResource(found_resource->GetID(), res_count);
-}
-
-inject_scaled_resource
-:descr:
-/**
-* Inject (add) a specified amount of a specified resource, scaled by
-* the current average merit divided by the average time slice.
-**/
-:args:
-cString res_name
-double res_count
-:body:
-double ave_merit = population->GetStats().SumMerit().Average();
-if ( ave_merit <= 0 )
- ave_merit = 1; // make sure that we don't get NAN's or negative numbers
-ave_merit /= cConfig::GetAveTimeslice();
-cResourceLib & res_lib = population->GetEnvironment().GetResourceLib();
-int res_id = res_lib.GetResource(res_name)->GetID();
-population->UpdateResource(res_id, res_count/ave_merit);
-
-
-outflow_scaled_resource
-:descr:
-/**
-* Removes a specified percentage of a specified resource, scaled by
-* the current average merit divided by the average time slice.
-**/
-:args:
-cString res_name
-double res_perc
-:body:
-double ave_merit = population->GetStats().SumMerit().Average();
-if ( ave_merit <= 0 )
- ave_merit = 1; // make sure that we don't get NAN's or negative numbers
-ave_merit /= cConfig::GetAveTimeslice();
-cResourceLib & res_lib = population->GetEnvironment().GetResourceLib();
-int res_id = res_lib.GetResource(res_name)->GetID();
-double res_level = population->GetResource(res_id);
-// a quick calculation shows that this formula guarantees that
-// the equilibrium level when resource is not used is independent
-// of the average merit
-double scaled_perc = 1/(1+ave_merit*(1-res_perc)/res_perc);
-res_level -= res_level*scaled_perc;
-population->SetResource(res_id, res_level);
-
-
-set_reaction_value
-:descr:
-/**
-* Set the value associated with a reaction to a specific level
-**/
-:args:
-cString reaction_name
-double reaction_value
-:body:
-population->GetEnvironment().SetReactionValue(reaction_name, reaction_value);
-
-set_reaction_value_mult
-:descr:
-/**
-* Change the value of the reaction by multiplying it with the imput number
-**/
-:args:
-cString reaction_name
-double value_mult
-:body:
-population->GetEnvironment().SetReactionValueMult(reaction_name, value_mult);
-
-set_reaction_inst
-:descr:
-/**
-* Change the instruction triggered by the task **/
-:args:
-cString reaction_name
-cString inst_name
-:body:
-population->GetEnvironment().SetReactionInst(reaction_name, inst_name);
-
Deleted: trunk/source/event/cPopulation_event_list
===================================================================
--- trunk/source/event/cPopulation_event_list 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/cPopulation_event_list 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,109 +0,0 @@
-#### cPopulation-Events ####
-
-exit
-exit_if_generation_greater_than <int max_generation>
-exit_if_update_greater_than <int max_update>
-exit_if_ave_lineage_label_smaller <double lineage_label_crit_value>
-exit_if_ave_lineage_label_larger <double lineage_label_crit_value>
-echo <cString mesg>
-print_data <cString filename> <cString format>
-print_average_data [cString fname="average.dat"]
-print_error_data [cString fname="error.dat"]
-print_variance_data [cString fname="variance.dat"]
-print_dominant_data [cString fname="dominant.dat"]
-print_stats_data [cString fname="stats.dat"]
-print_count_data [cString fname="count.dat"]
-print_totals_data [cString fname="totals.dat"]
-print_tasks_data [cString fname="tasks.dat"]
-print_tasks_exe_data [cString fname="tasks_exe.dat"]
-print_resource_data [cString fname="resource.dat"]
-print_time_data [cString fname="time.dat"]
-print_mutation_data [cString fname="mutation.dat"]
-print_mutation_rate_data [cString fname="mutation_rates.dat"]
-print_divide_mut_data [cString fname="divide_mut.dat"]
-print_dom_parasite_data [cString fname="parasite.dat"]
-print_instruction_data [cString fname="instruction.dat"]
-print_instruction_abundance_histogram [cString filename="instruction_histogram.dat"]
-print_depth_histogram [cString filename="depth_histogram.dat"]
-print_genotype_abundance_histogram [cString filename="genotype_abundance_histogram.dat"]
-print_species_abundance_histogram [cString filename="species_abundance_histogram.dat"]
-print_lineage_totals [cString fname="lineage_totals.dat"] [int verbose=1]
-print_lineage_counts [cString fname="lineage_counts.dat"] [int verbose=0]
-print_dom [cString in_filename=""]
-parasite_debug [cString in_filename=""]
-print_dom_parasite [cString in_filename=""]
-print_genotype_map [cString fname="genotype_map.m"]
-print_number_phenotypes [cString fname="phenotype_count.dat"]
-print_phenotype_status [cString fname="phenotype_status.dat"]
-save_population [cString fname=""]
-load_population <cString fname>
-save_clone [cString fname=""]
-load_clone <cString fname>
-load_dump_file <cString fname> [int update=-1]
-dump_pop [cString fname=""]
-print_genotypes [cString data_fields="all"] [int historic=0] [cString fname=""]
-detail_pop [cString fname=""]
-detail_sex_pop [cString fname=""]
-detail_parasite_pop [cString fname=""]
-dump_historic_pop [int back_dist=-1] [cString fname=""]
-dump_historic_sex_pop [cString fname=""]
-dump_memory [cString fname=""]
-inject [cString fname="START_CREATURE"] [int cell_id=0] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]
-inject_all [cString fname="START_CREATURE"] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]
-inject_range [cString fname="START_CREATURE"] [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]
-inject_sequence <cString seq> [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]
-inject_random <int length> [int cell_id=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]
-inject_range_parasite [cString fname_parasite="organism.parasite"] [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0] [int mem_space=2]
-inject_range_pair [cString fname="START_CREATURE"] [cString fname_parasite="organism.parasite"] [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0] [int mem_space=2]
-zero_muts
-mod_copy_mut <double cmut_inc> [int cell=-1]
-mod_div_mut <double dmut_inc> [int cell=-1]
-set_copy_mut <double cmut> [int start_cell=-1] [int end_cell=-1]
-mod_point_mut <double pmut_inc> [int cell=-1]
-set_point_mut <double pmut> [int cell=-1]
-calc_landscape [int landscape_dist=1]
-predict_w_landscape [cString datafile="land-predict.dat"]
-predict_nu_landscape [cString datafile="land-predict.dat"]
-sample_landscape [int sample_size=0]
-random_landscape [int landscape_dist=1] [int sample_size=0] [int min_found=0] [int max_sample_size=0] [bool print_if_found=false]
-analyze_landscape [int sample_size=1000] [int min_found=0] [int max_sample_size=0]
-pairtest_landscape [int sample_size=0]
-test_dom
-analyze_population [double sample_prob=1] [int landscape=0] [int save_genotype=0] [cString filename=""]
-print_detailed_fitness_data [int save_max_f_genotype=0] [int print_fitness_histo=0] [double hist_fmax=1] [double hist_fstep=0.1] [cString filename="fitness.dat"] [cString filename2="fitness_histos.dat"] [cString filename3="fitness_histos_testCPU.dat"]
-print_genetic_distance_data [cString creature_name=""] [cString filename="genetic_distance.dat"]
-genetic_distance_pop_dump [cString creature_name=""] [cString filename=""] [int save_genotype=0]
-task_snapshot [cString filename=""]
-print_viable_tasks_data [cString filename="viable_tasks.dat"]
-apocalypse [double kill_prob=.9]
-kill_rectangle [int cell_X1=0] [int cell_Y1=0] [int cell_X2=0] [int cell_Y2=0]
-rate_kill <double kill_rate>
-serial_transfer [int transfer_size=1] [int ignore_deads=1]
-hillclimb
-hillclimb_neut
-hillclimb_rand
-compete_demes [int competition_type=1]
-reset_demes
-print_deme_stats
-copy_deme <int deme1_id> <int deme2_id>
-calc_consensus [int lines_saved=0]
-test_size_change_robustness [int num_trials=100] [cString filename="size_change.dat"]
-test_threads
-print_threads
-dump_fitness_grid
-dump_genotype_grid
-dump_donor_grid
-dump_receiver_grid
-print_tree_depths [cString filename=""]
-sever_grid_col [int col_id=-1] [int min_row=0] [int max_row=-1]
-sever_grid_row [int row_id=-1] [int min_col=0] [int max_col=-1]
-join_grid_col [int col_id=-1] [int min_row=0] [int max_row=-1]
-join_grid_row [int row_id=-1] [int min_col=0] [int max_col=-1]
-connect_cells <int cellA_x> <int cellA_y> <int cellB_x> <int cellB_y>
-disconnect_cells <int cellA_x> <int cellA_y> <int cellB_x> <int cellB_y>
-inject_resource <cString res_name> <double res_count>
-set_resource <cString res_name> <double res_count>
-inject_scaled_resource <cString res_name> <double res_count>
-outflow_scaled_resource <cString res_name> <double res_perc>
-set_reaction_value <cString reaction_name> <double reaction_value>
-set_reaction_value_mult <cString reaction_name> <double value_mult>
Deleted: trunk/source/event/event.cc
===================================================================
--- trunk/source/event/event.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/event.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,18 +0,0 @@
-
-
-#include "event.hh"
-
-
-using namespace std;
-
-
-cEvent::cEvent( const cString & name, const cString & args ,
- int factory_id )
- : m_name( name ), m_args( args ), m_factory_id( factory_id )
-{
-}
-
-
-cEvent::~cEvent()
-{
-}
Modified: trunk/source/event/event.hh
===================================================================
--- trunk/source/event/event.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/event.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -25,37 +25,38 @@
enum eTriggerVariable { UPDATE, GENERATION, IMMEDIATE, UNDEFINED };
private:
- cString m_name;
- cString m_args;
-
int m_factory_id;
// not implemented, prevents inadvertent wrong instantiation
- cEvent();
- cEvent( const cEvent & );
- cEvent& operator=( const cEvent& );
+ cEvent(const cEvent&);
+ cEvent& operator=(const cEvent&);
+protected:
+ cString m_args;
+
public:
// constructors
- cEvent( const cString & name = "Undefined",
- const cString & args = "",
- int handler_id = -1 );
- virtual ~cEvent();
+ cEvent(int factory_id = -1 ) : m_factory_id(factory_id), m_args("") { ; }
+ virtual ~cEvent() { ; }
+ int GetFactoryId() const { return m_factory_id; }
+ void SetFactoryId(int factory_id) { m_factory_id = factory_id; }
+
+ const cString& GetArgs() const { return m_args; }
- // manipulators
- void SetFactoryId(int factory_id){ m_factory_id = factory_id; }
-
/**
- * This is a pure virtual function that has to be overloaded by derived
- * classes. It does the actual 'thing' the event is supposed to do.
+ * The following functions are pure virtual and must be supplied by implementations
**/
+
+ // Configures the event for use.
+ virtual void Configure(const cString& args = "") = 0;
+
+ // Does the actual 'thing' the event is supposed to do.
virtual void Process() = 0;
- // accessors
- const cString & GetName() const { return m_name; }
- const cString & GetArgs() const { return m_args; }
- int GetFactoryId() const { return m_factory_id; }
+ // Name and description of the event
+ virtual const cString GetName() const = 0;
+ virtual const cString GetDescription() const = 0;
};
#endif
Modified: trunk/source/event/event.pri
===================================================================
--- trunk/source/event/event.pri 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/event.pri 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,13 +1,11 @@
event {
HEADERS += $$EVENT_HH/event.hh \
- $$EVENT_HH/event_factory.hh \
$$EVENT_HH/event_factory_manager.hh \
$$EVENT_HH/event_list.hh \
$$EVENT_HH/population_event_factory.hh
SOURCES += $$EVENT_CC/event.cc \
- $$EVENT_CC/event_factory.cc \
$$EVENT_CC/event_factory_manager.cc \
$$EVENT_CC/event_list.cc \
$$EVENT_CC/event_list_entry.cc \
Deleted: trunk/source/event/event_factory.cc
===================================================================
--- trunk/source/event/event_factory.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/event_factory.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,28 +0,0 @@
-
-#include "event_factory.hh"
-
-
-#include "defs.hh"
-#include "file.hh"
-#include "string.hh"
-#include "./event.hh"
-
-
-using namespace std;
-
-
-//////// cEventFactory ////////////
-
-cEventFactory::cEventFactory() : m_factory_id( 0 )
-{
-}
-
-
-cEventFactory::~cEventFactory()
-{
-}
-
-
-
-
-
Deleted: trunk/source/event/event_factory.hh
===================================================================
--- trunk/source/event/event_factory.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/event_factory.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,62 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef EVENT_FACTORY_HH
-#define EVENT_FACTORY_HH
-
-/**
- * This class is used to construct events from a given name and argument list.
- * You have to overload it to construct events that need particular additional
- * information (like a pointer to a class they should act on).
- **/
-
-class cEvent;
-class cString;
-
-class cEventFactory {
-private:
- int m_factory_id;
-
- // not implemented, prevents inadvertent wrong instantiation
- cEventFactory( const cEventFactory & );
- cEventFactory& operator=( const cEventFactory& );
-
-public:
- cEventFactory();
- virtual ~cEventFactory();
-
- void SetFactoryId( int id ){
- m_factory_id = id; }
-
- int GetFactoryId(){
- return m_factory_id; }
-
- /**
- * Returns an id for an event name. The id holds only for this factory,
- * a second factory might use the same id for something else.
- **/
- virtual int EventNameToEnum(const cString & name) const = 0;
-
- /**
- * Constructs an event.
- *
- * @param event_enum The identifier of the event to be constructed.
- * @param args The argument list of the event.
- **/
- virtual cEvent * ConstructEvent( int event_enum, const cString & args )=0;
-
- /**
- * Constructs an event.
- *
- * @param name The name of the event to be constructed.
- * @param args The argument list of the event.
- **/
- cEvent * ConstructEvent( const cString & name, const cString & args ){
- return ConstructEvent( EventNameToEnum(name), args ); }
-};
-
-#endif
Modified: trunk/source/event/event_factory_manager.cc
===================================================================
--- trunk/source/event/event_factory_manager.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/event_factory_manager.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -9,11 +9,8 @@
#include "event.hh"
#endif
-#ifndef EVENT_FACTORY_HH
-#include "event_factory.hh"
-#endif
+#include <iostream>
-
using namespace std;
@@ -26,51 +23,61 @@
}
cEventFactoryManager::~cEventFactoryManager(){
- vector<cEventFactory*>::iterator it = m_factory_list.begin();
-
- for( ; it != m_factory_list.end(); it++ )
- delete *it;
+ tListIterator<tObjectFactory<cEvent ()> > it(m_factory_list);
+ while (it.Next() != NULL) delete it.Get();
}
cEvent*
cEventFactoryManager::ConstructEvent(const cString name,
- const cString & args,
- int factory_id){
+ const cString & args,
+ int factory_id){
cEvent* event = NULL;
-
+
// factory_id < 0 => send to all factories
- if( factory_id < 0 ){
- vector<cEventFactory*>::iterator it;
- for( it = m_factory_list.begin(); it != m_factory_list.end(); it++ ){
- if( *it != NULL )
- event = (*it)->ConstructEvent(name,args);
- if ( event != NULL ) // if we have found one factory that can create the
- // event we want we stop.
- break;
+ if( factory_id < 0 ) {
+ tListIterator<tObjectFactory<cEvent ()> > it(m_factory_list);
+ while (it.Next() != NULL) {
+ event = (it.Get())->Create(name);
+
+ // if we have found one factory that can create the event we want we stop.
+ if (event != NULL) break;
}
}
else{
// send to particular factory
- if ( factory_id >= static_cast<int>( m_factory_list.size() ) )
- return NULL;
- if( m_factory_list[factory_id] != NULL )
- event = m_factory_list[factory_id]->ConstructEvent(name,args);
+ if (factory_id >= m_factory_list.GetSize()) return NULL;
+ if( m_factory_list.GetPos(factory_id) != NULL )
+ event = m_factory_list.GetPos(factory_id)->Create(name);
}
+
+ event->Configure(args);
return event;
}
-int
-cEventFactoryManager::AddFactory( cEventFactory *factory )
+int cEventFactoryManager::AddFactory(tObjectFactory<cEvent ()>* factory)
{
assert( factory != NULL );
- m_factory_list.push_back( factory );
-
- int id = m_factory_list.size();
- factory->SetFactoryId( id );
-
+ m_factory_list.Push(factory);
+
+ int id = m_factory_list.GetSize();
+ factory->SetFactoryId(id);
+
return id;
}
-
+void cEventFactoryManager::PrintAllEventDescriptions()
+{
+ tListIterator<tObjectFactory<cEvent ()> > it(m_factory_list);
+ while (it.Next() != NULL) {
+ tList<cEvent> events;
+ it.Get()->CreateAll(events);
+
+ tListIterator<cEvent> events_it(events);
+ while (events_it.Next() != NULL) {
+ cout << events_it.Get()->GetDescription() << endl;
+ delete events_it.Get();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/source/event/event_factory_manager.hh
===================================================================
--- trunk/source/event/event_factory_manager.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/event_factory_manager.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -8,8 +8,14 @@
#ifndef EVENT_FACTORY_MANAGER_HH
#define EVENT_FACTORY_MANAGER_HH
-#include <vector>
+#ifndef TLIST_HH
+#include "tList.hh"
+#endif
+#ifndef TOBJECTFACTORY_H
+#include "tObjectFactory.h"
+#endif
+
#ifndef STRING_HH
#include "string.hh"
#endif
@@ -27,9 +33,8 @@
class cEventFactoryManager {
private:
- std::vector<cEventFactory*> m_factory_list;
+ tList< tObjectFactory<cEvent ()> > m_factory_list;
-
// not implemented, prevents inadvertent wrong instantiation
cEventFactoryManager( const cEventFactoryManager & );
cEventFactoryManager& operator=( const cEventFactoryManager& );
@@ -37,16 +42,16 @@
cEventFactoryManager();
~cEventFactoryManager();
- int AddFactory(cEventFactory* factory);
+ int AddFactory(tObjectFactory<cEvent ()>* factory);
/**
* This function is used to construct an event. It sends the event's name
* to all registered factories if no factory id is given, otherwise it
* sends it to the particular factory requested.
**/
- cEvent* ConstructEvent(const cString name, const cString & args,
- int factory_id = -1);
-
+ cEvent* ConstructEvent(const cString name, const cString & args, int factory_id = -1);
+
+ void PrintAllEventDescriptions();
};
#endif
Modified: trunk/source/event/event_list.cc
===================================================================
--- trunk/source/event/event_list.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/event_list.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -26,6 +26,7 @@
#endif
#include <float.h> // for DBL_MIN
+#include <iostream>
using namespace std;
@@ -39,37 +40,29 @@
// cEventList
/////////////////
cEventList::cEventList( cEventFactoryManager* factory_manager, cEventTriggers *triggers ) :
- m_factory_manager( factory_manager ),
- m_triggers( triggers ),
- m_head(NULL),
- m_tail(NULL),
- m_current(NULL),
- m_num_events(0)
+m_factory_manager( factory_manager ),
+m_triggers( triggers ),
+m_head(NULL),
+m_tail(NULL),
+m_current(NULL),
+m_num_events(0)
{
}
-cEventList::~cEventList() {
- /*
- XXX: modified by kaben. DeleteAll is equivalent.
- */
- //while( m_head != NULL ){
- // m_current = m_head;
- // m_head = m_head->GetNext();
- // delete m_head;
- //}
+cEventList::~cEventList()
+{
DeleteAll();
-
delete m_factory_manager;
delete m_triggers;
}
bool
cEventList::AddEvent( cEventTriggers::eTriggerVariable trigger,
- double start, double interval, double stop,
- const cString & name, const cString & args ){
+ double start, double interval, double stop,
+ const cString & name, const cString & args ){
assert( m_factory_manager != NULL );
cEvent *event = m_factory_manager->ConstructEvent( name, args );
-
+
///// Adding Event to the list /////
if( event != NULL ){
InsertEvent(event, trigger, start, interval, stop);
@@ -80,11 +73,11 @@
void cEventList::InsertEvent(cEvent *event,
- cEventTriggers::eTriggerVariable trigger,
- double start, double interval, double stop){
+ cEventTriggers::eTriggerVariable trigger,
+ double start, double interval, double stop){
assert( event != NULL );
cEventListEntry *entry = new cEventListEntry(event, trigger,
- start, interval, stop);
+ start, interval, stop);
// If there are no events in the list yet.
if( m_tail == NULL ){
assert( m_head == NULL );
@@ -104,7 +97,7 @@
void cEventList::Delete(cEventListEntry *entry){
assert( entry != NULL );
-
+
if( entry->GetPrev() != NULL ){
entry->GetPrev()->SetNext( entry->GetNext() );
}
@@ -119,22 +112,21 @@
assert( entry == m_tail );
m_tail = entry->GetPrev();
}
-
+
delete entry;
}
/*
-public manipulator used while rebuilding event list.
-XXX: added by kaben.
-*/
+ public manipulator used while rebuilding event list.
+ */
void cEventList::DeleteAll(void){
while( m_head != NULL ){
m_current = m_head;
m_head = m_head->GetNext();
delete m_head;
}
-
+
m_head = 0;
m_tail = 0;
m_current = 0;
@@ -144,63 +136,61 @@
void cEventList::Process(){
double t_val = 0; // trigger value
-
+
// Iterate through all entrys in event list
cEventListEntry * entry = m_head;
while( entry != NULL ){
-
+
cEventListEntry * next_entry = entry->GetNext();
-
+
// Check trigger condition
-
+
// IMMEDIATE Events always happen and are always deleted
- if( entry->GetTrigger() == cEventTriggers::IMMEDIATE ){
- //cerr<<"IMMEDIATE EVENT "<<event->GetName()<<endl;
+ if( entry->GetTrigger() == cEventTriggers::IMMEDIATE ) {
entry->GetEvent()->Process();
Delete(entry);
- }else{
-
+ } else {
// Get the value of the appropriate trigger variable
t_val = m_triggers->GetTriggerValue(entry->GetTrigger());
-
+
if( t_val != DBL_MAX &&
- ( t_val >= entry->GetStart() ||
- entry->GetStart() == cEventTriggers::TRIGGER_BEGIN ) &&
- ( t_val <= entry->GetStop() ||
- entry->GetStop() == cEventTriggers::TRIGGER_END ) ){
-
- entry->GetEvent()->Process();
-
- if( entry == NULL ){ // It is possible for an event to kill itself
- }else{
- // Handle the interval thing
- if( entry->GetInterval() == cEventTriggers::TRIGGER_ALL ){
- // Do Nothing
- }else if( entry->GetInterval() == cEventTriggers::TRIGGER_ONCE ){
- // If it is a onetime thing, remove it...
- Delete(entry);
- }else{
- // There is an interal.. so add it
- entry->NextInterval();
- }
-
- // If the event can never happen now... excize it
- if( entry != NULL && entry->GetStop() != cEventTriggers::TRIGGER_END ){
- if( entry->GetStart() > entry->GetStop() &&
- entry->GetInterval() > 0 ){
- Delete(entry);
- }else if( entry->GetStart() < entry->GetStop() &&
- entry->GetInterval() < 0 ){
- Delete(entry);
- }
- }
-
- }
-
+ (t_val >= entry->GetStart() ||
+ entry->GetStart() == cEventTriggers::TRIGGER_BEGIN) &&
+ (t_val <= entry->GetStop() ||
+ entry->GetStop() == cEventTriggers::TRIGGER_END) ) {
+
+ entry->GetEvent()->Process();
+
+ if( entry == NULL ){ // It is possible for an event to kill itself
+ }else{
+ // Handle the interval thing
+ if( entry->GetInterval() == cEventTriggers::TRIGGER_ALL ){
+ // Do Nothing
+ }else if( entry->GetInterval() == cEventTriggers::TRIGGER_ONCE ){
+ // If it is a onetime thing, remove it...
+ Delete(entry);
+ }else{
+ // There is an interval.. so add it
+ entry->NextInterval();
+ }
+
+ // If the event can never happen now... excize it
+ if( entry != NULL && entry->GetStop() != cEventTriggers::TRIGGER_END ){
+ if( entry->GetStart() > entry->GetStop() &&
+ entry->GetInterval() > 0 ){
+ Delete(entry);
+ }else if( entry->GetStart() < entry->GetStop() &&
+ entry->GetInterval() < 0 ){
+ Delete(entry);
+ }
+ }
+
+ }
+
} // End Non-IMMEDITAE events
-
+
} // end condition to do event
-
+
entry = next_entry;
}
}
@@ -221,29 +211,29 @@
void cEventList::SyncEvent(cEventListEntry *entry){
// Ignore events that are immdeiate
if( entry->GetTrigger() == cEventTriggers::IMMEDIATE ){ return; }
-
+
double t_val = m_triggers->GetTriggerValue( entry->GetTrigger() );
-
+
// If t_val has past the end, remove (even if it is TRIGGER_ALL)
if( t_val > entry->GetStop() ){
Delete(entry);
return;
}
-
+
// If it is a trigger once and has passed, remove
if( t_val > entry->GetStart() && entry->GetInterval() == cEventTriggers::TRIGGER_ONCE ){
Delete(entry);
return;
}
-
+
// If for some reason t_val has been reset or soemthing, rewind
if( t_val + entry->GetInterval() <= entry->GetStart() ){
entry->Reset();
}
-
+
// Can't fast forward events that are Triger All
if( entry->GetInterval() == cEventTriggers::TRIGGER_ALL ){ return; }
-
+
// Keep adding interval to start until we are caught up
while( t_val > entry->GetStart() ){
entry->NextInterval();
@@ -261,73 +251,64 @@
}
}
-/*
-XXX: modified by kaben to stream-dump in parseable format.
-*/
void cEventList::PrintEvent(cEventListEntry * entry, ostream & os){
- assert( entry != NULL );
- switch ( entry->GetTrigger() ){
+ assert( entry != NULL );
+ switch ( entry->GetTrigger() ){
case cEventTriggers::UPDATE:
- //os<<"UPDATE ";
- os<<"update ";
+ os << "update ";
break;
case cEventTriggers::GENERATION:
- //os<<"GENERATION ";
- os<<"generation ";
+ os << "generation ";
break;
case cEventTriggers::IMMEDIATE:
- //os<<"IMMEDIATE ";
- os<<"immediate ";
+ os << "immediate ";
break;
default:
- //os<<"UNDEFINED ";
- os<<"undefined ";
+ os << "undefined ";
+ }
+ if (entry->GetTrigger() != cEventTriggers::IMMEDIATE ) {
+ if( entry->GetStart() == cEventTriggers::TRIGGER_BEGIN ) {
+ os << "begin";
+ } else {
+ os << entry->GetStart();
}
- //os<<"[";
- if (entry->GetTrigger() != cEventTriggers::IMMEDIATE ){
- if( entry->GetStart() == cEventTriggers::TRIGGER_BEGIN ){
- os<<"begin";
- }else{
- os<<entry->GetStart();
- }
- os<<":";
- if( entry->GetInterval() == cEventTriggers::TRIGGER_ONCE ){
- os<<"once";
- }else if( entry->GetInterval() == cEventTriggers::TRIGGER_ALL ){
- os<<"all";
- }else{
- os<<entry->GetInterval();
- }
- os<<":";
- if( entry->GetStop() == cEventTriggers::TRIGGER_END ){
- os<<"end";
- }else{
- os<<entry->GetStop();
- }
- os<<" ";
+ os<<":";
+ if( entry->GetInterval() == cEventTriggers::TRIGGER_ONCE ) {
+ os << "once";
+ } else if (entry->GetInterval() == cEventTriggers::TRIGGER_ALL) {
+ os << "all";
+ } else {
+ os << entry->GetInterval();
}
- //os<<"] "<<entry->GetName()<<" "<<entry->GetArgs()<<endl;
- os<<entry->GetName()<<" "<<entry->GetArgs()<<endl;
+ os << ":";
+ if( entry->GetStop() == cEventTriggers::TRIGGER_END ){
+ os << "end";
+ }else{
+ os << entry->GetStop();
+ }
+ os << " ";
+ }
+ os << entry->GetName() << " " << entry->GetArgs() << endl;
}
-
//// Parsing Event List File Format ////
-bool cEventList::AddEventFileFormat(const cString & in_line){
+bool cEventList::AddEventFileFormat(const cString & in_line)
+{
cString cur_line = in_line;
-
+
// Timing
cEventTriggers::eTriggerVariable trigger = cEventTriggers::UPDATE;
double start = cEventTriggers::TRIGGER_BEGIN;
double interval = cEventTriggers::TRIGGER_ONCE;
double stop = cEventTriggers::TRIGGER_END;
-
+
cString name;
cString arg_list;
-
+
cString tmp;
-
+
cString cur_word = cur_line.PopWord();
-
+
// Get the trigger variable if there
if( cur_word == "i" ||
cur_word == "immediate" ){
@@ -335,35 +316,35 @@
name = cur_line.PopWord();
return AddEvent(name, cur_line); // If event is IMMEDIATE shortcut
}else if( cur_word == "u" ||
- cur_word == "update" ){
+ cur_word == "update" ){
trigger = cEventTriggers::UPDATE;
cur_word = cur_line.PopWord();
}else if( cur_word == "g" ||
- cur_word == "generation" ){
+ cur_word == "generation" ){
trigger = cEventTriggers::GENERATION;
cur_word = cur_line.PopWord();
}else{
// If Trigger is skipped so assume IMMEDIATE
trigger = cEventTriggers::IMMEDIATE;
}
-
+
// Do we now have timing specified?
// Parse the Timing
cString timing_str = cur_word;
-
+
// Get the start:interval:stop
tmp = timing_str.Pop(':');
-
+
// If first value is valid, we are getting a timing.
if( tmp.IsNumber() || tmp == "begin" ){
-
+
// First number is start
if( tmp == "begin" ){
start = cEventTriggers::TRIGGER_BEGIN;
}else{
start = tmp.AsDouble();
}
-
+
// If no other words... is "start" syntax
if( timing_str.GetSize() == 0 ){
interval = cEventTriggers::TRIGGER_ONCE;
@@ -372,37 +353,37 @@
// Second word is interval
tmp = timing_str.Pop(':');
if( tmp == "all" ){
- interval = cEventTriggers::TRIGGER_ALL;
+ interval = cEventTriggers::TRIGGER_ALL;
}else if( tmp == "once" ){
- interval = cEventTriggers::TRIGGER_ONCE;
+ interval = cEventTriggers::TRIGGER_ONCE;
}else{
- interval = tmp.AsDouble();
+ interval = tmp.AsDouble();
}
// If no other words... is "start:interval" syntax
if( timing_str.GetSize() == 0 ){
- stop = cEventTriggers::TRIGGER_END;
+ stop = cEventTriggers::TRIGGER_END;
}else{
- // We have "start:interval:stop" syntax
- tmp = timing_str;
- if( tmp == "end" ){
- stop = cEventTriggers::TRIGGER_END;
- }else{
- stop = tmp.AsDouble();
- }
+ // We have "start:interval:stop" syntax
+ tmp = timing_str;
+ if( tmp == "end" ){
+ stop = cEventTriggers::TRIGGER_END;
+ }else{
+ stop = tmp.AsDouble();
+ }
}
}
cur_word = cur_line.PopWord(); // timing provided, so get next word
-
+
}else{ // We don't have timing, so assume IMMEDIATE
trigger = cEventTriggers::IMMEDIATE;
start = cEventTriggers::TRIGGER_BEGIN;
interval = cEventTriggers::TRIGGER_ONCE;
stop = cEventTriggers::TRIGGER_END;
}
-
+
// Get the rest of the info
name = cur_word;
arg_list = cur_line;
-
+
return AddEvent( trigger, start, interval, stop, name, arg_list );
}
Deleted: trunk/source/event/event_list_entry.cc
===================================================================
--- trunk/source/event/event_list_entry.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/event_list_entry.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,40 +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 EVENT_LIST_ENTRY_HH
-#include "event_list_entry.hh"
-#endif
-
-
-/////////////////
-// cEventListEntry
-/////////////////
-
-
-cEventListEntry::cEventListEntry( cEvent * event,
- cEventTriggers::eTriggerVariable trigger,
- double start,
- double interval,
- double stop,
- cEventListEntry * prev,
- cEventListEntry * next ) :
- m_event( event ),
- m_trigger( trigger ),
- m_start( start ),
- m_interval( interval ),
- m_stop( stop ),
- m_original_start( start ),
- m_prev( prev ),
- m_next( next )
-{
-}
-
-
-cEventListEntry::~cEventListEntry()
-{
- delete m_event;
-}
Modified: trunk/source/event/event_list_entry.hh
===================================================================
--- trunk/source/event/event_list_entry.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/event_list_entry.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -45,16 +45,25 @@
cEventListEntry& operator=( const cEventListEntry& );
public:
// creators
- cEventListEntry( cEvent *event = NULL,
- cEventTriggers::eTriggerVariable trigger
- = cEventTriggers::UPDATE,
- double start = cEventTriggers::TRIGGER_BEGIN,
- double interval = cEventTriggers::TRIGGER_ONCE,
- double stop = cEventTriggers::TRIGGER_END,
- cEventListEntry *prev = NULL,
- cEventListEntry *next = NULL );
+ cEventListEntry(cEvent *event = NULL,
+ cEventTriggers::eTriggerVariable trigger = cEventTriggers::UPDATE,
+ double start = cEventTriggers::TRIGGER_BEGIN,
+ double interval = cEventTriggers::TRIGGER_ONCE,
+ double stop = cEventTriggers::TRIGGER_END,
+ cEventListEntry *prev = NULL,
+ cEventListEntry *next = NULL ) :
+ m_event( event ),
+ m_trigger( trigger ),
+ m_start( start ),
+ m_interval( interval ),
+ m_stop( stop ),
+ m_original_start( start ),
+ m_prev( prev ),
+ m_next( next )
+ {
+ }
- virtual ~cEventListEntry();
+ virtual ~cEventListEntry() { delete m_event; }
// manipulators
@@ -82,7 +91,7 @@
cEvent* GetEvent() const {
assert(m_event!=NULL); return m_event; }
- const cString& GetName() const {
+ const cString GetName() const {
assert(m_event!=NULL); return m_event->GetName(); }
const cString& GetArgs() const {
assert(m_event!=NULL); return m_event->GetArgs(); }
Modified: trunk/source/event/event_triggers.hh
===================================================================
--- trunk/source/event/event_triggers.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/event_triggers.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -28,7 +28,8 @@
cEventTriggers( const cEventTriggers& );
cEventTriggers& operator=( const cEventTriggers& );
public:
- cEventTriggers() {}
+ cEventTriggers() { ; }
+ virtual ~cEventTriggers() { ; }
virtual double GetUpdate() const = 0;
virtual double GetGeneration() const = 0;
Deleted: trunk/source/event/make_events.pl
===================================================================
--- trunk/source/event/make_events.pl 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/make_events.pl 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,287 +0,0 @@
-#
-# Make events_auto.cc & events_auto.hh from a simplified template file
-# to handle creation of code for simple events
-#
-# Input file format:
-# _event_name_
-# :descr:
-# /**
-# * Documentation of the event in the typical
-# * class definition style
-# **/
-# :args:
-# _arg_type _arg_name_ [= _default_value_]
-# _arg_type _arg_name_ [= _default_value_]
-# ...
-# :body:
-# _body_of_Process()_function_
-# ...
-#
-# _event_name_...
-
-use strict;
-
-$/ = "\n\n";
-$" = "|"; #" <- this quote sign in the comment is necessary for emacs highlighting mode
-
-my @event_lists = @ARGV; #("cPopulation", ...);
-
-my ( $event_dir, $fname, $fname_root );
-
-# Clobber the events_list
-foreach $fname (@event_lists)
-{
- # separate filename in root name and directory
- if ( $fname =~ m/^-x/ )
- {
- # handle paths from Xcode
- # added by David 2004-12-05
-
- ($fname, $fname_root, $event_dir) = $fname =~ /^-x\[(.*\/)(.*)\]\[(.*)\]/;
- $fname .= $fname_root;
- $event_dir .= "/";
- }
- elsif ( $fname =~ /\// )
- {
- $fname =~ /(.*\/)(.*)/;
- ##
- ## change by kaben...
- ##
- ## this change places all generated files
- ## in the build directory
- ## rather than in the source directory.
- ##
- #$event_dir = $1;
- $event_dir = "./";
- ##
- $fname_root = $2;
-
- }
- else
- {
- $event_dir = "./";
- $fname_root = $fname;
- }
-
- printf " --- make_events.pl: opening ".$fname.".events.\n";
- open(IN,$fname.".events") || die $!;
-
- # open the output files
- open(LIST,"> ".$event_dir.$fname_root."_event_list");
- open(NCI, "> ".$event_dir.$fname_root."_construct_event_auto.ci");
- open(PCI, "> ".$event_dir.$fname_root."_process_auto.ci");
- open(DEFS,"> ".$event_dir.$fname_root."_enums_auto.ci");
- open(N2E,"> ".$event_dir.$fname_root."_name2enum_auto.ci");
- open(DESCR_DECL,"> ".$event_dir.$fname_root."_descr.hi");
- open(DESCR_DEF,"> ".$event_dir.$fname_root."_descr.ci");
-
-
- print LIST "#### ".$fname_root."-Events ####\n\n";
-
- print DEFS " enum eEvent { EVENT_undefined = 0,\n";
-
- print N2E "int ".$fname_root."EventFactory::EventNameToEnum(const cString & name) const{\n";
- print N2E " if( name == \"\" ){\n";
- print N2E " return ".$fname_root."EventFactory::EVENT_NO_EVENT;\n";
-
- print DESCR_DECL "class cEventEntry{
- private:
- const char* m_name;
- const char* m_description;
- public:
- cEventEntry( const char* name, const char* description )
- : m_name( name ), m_description( description ) {;}
- ~cEventEntry() {;}
- /**
- * \@return The name of the event.
- **/
- const char* GetName() const { return m_name; }
-
- /**
- * \@return The description of the event.
- **/
- const char* GetDescription() const { return m_description; }
- };
-
-
- class cEventDescrs{
- public:
- const static int num_of_events;
- const static cEventEntry entries[];
- };
-
- ";
-
- print DESCR_DEF "const cEventEntry cEventDescrs::entries[] = {
- ";
-
- my $no_of_events = 0;
-
- while( <IN> ){
- my @line = split(/\n/);
- my $line_string = "";
- my $i;
-
- # Filter out blank lines and comments (#)
- for $i (0..$#line){
- $_ = $line[$i];
- s/\#.*$//;
- $line_string .= "$_\n" unless( /^\s*$/ );
- }
- my ( $name, $tmp_string ) = split(/\:descr\:\n/, $line_string);
- my ( $descrstring, $tmp_string2 ) = split(/\:args\:\n/, $tmp_string);
- my ( $argstring, $body ) = split(/\:body\:\n/, $tmp_string2);
- my @args = split(/\n/,$argstring);
- $name =~ /^\s*([a-z_0-9]*)\s*$/i; $name = $1; # Trim ws off of name
- # XXX the perl expression below stopped working on
- # rodan.css.msu.edu; I don't know why; the expression above is a
- # quick workaround. @kgn 21 September 2004
- #$name =~ /\s*([^\s]*)\s*$/; $name = $1; # Trim ws off of name
-
-
- if( $name ){
- # print warning if no documentation has been written
- chomp( $descrstring );
- if ( $descrstring eq "" ){
- print "Warning: Event $name comes without documentation!\nPlease change!\n";
- }
-
- ##### Output Class Declaration
- print PCI "///// $name /////\n\n";
- print PCI $descrstring."\n\n";
- print PCI "class ".$fname_root."Event$name : public ".$fname_root."Event {\nprivate:\n";
- for $i (0..$#args){
- my ($type, $vname, $default) = split(/\s+/, $args[$i]);
- print PCI " $type $vname;\n";
- }
- $" = ", ";
- print PCI "public:\n";
- print PCI " ".$fname_root."Event$name(const cString & in_args):\n";
- print PCI " ".$fname_root."Event(\"$name\", in_args) {\n";
-
- # Argument intialization
- if( @args ){
- print PCI "\n";
- print PCI " cString args(in_args);\n";
- for $i (0..$#args){
- my ($type, $vname, $default) = split(/\s+/, $args[$i]);
- # @TCC--- SOMEHOW THIS NEEDS TO TAKE MULTI_WORD DEFAULTS
- my $default_provided_flag = 0; # for checking syntax
- my $pop_cmd = "args.PopWord()";
- if( $type eq "cString" ){
- # This is the default type
- }elsif( $type eq "int" ){
- $pop_cmd .= ".AsInt()";
- }elsif( $type eq "double" ){
- $pop_cmd .= ".AsDouble()";
- }
- if( defined $default ){
- $default_provided_flag = 1;
- print PCI " if (args == \"\") $vname=$default; else $vname=$pop_cmd;\n";
- }else{
- die "Must Provide Defaults for all variables after first default value\n" if( $default_provided_flag == 1 );
- print PCI " $vname = $pop_cmd;\n";
- }
- }
- print PCI " }\n";
-
- }else{
- print PCI " (void)in_args; }\n";
- }
-
- ##### the process command
- print PCI "///// $name /////\n";
- print PCI " void Process(){\n";
- my @body_line = split(/\n/,$body);
- for $i (0..$#body_line){
- print PCI " $body_line[$i]\n";
- }
- print PCI " }\n";
- print PCI "};\n\n";
-
-
-
- ##### CC File stuff... Name to class instantiation
- print NCI " case ".$fname_root."EventFactory::EVENT_$name :\n";
- print NCI " event = new ".$fname_root."Event$name(arg_list);\n";
- print NCI " break;\n";
-
- ##### Name to Enum #########
- print N2E " }else if (name == \"$name\") {\n";
- print N2E " return ".$fname_root."EventFactory::EVENT_$name;\n";
-
- ##### List of Events #####
- print LIST "$name ";
- for $i (0..$#args){
- my ($type, $vname, $default) = split(/\s+/, $args[$i]);
- if( defined $default ){
- print LIST " [$type $vname=$default]";
- }else{
- print LIST " <$type $vname>";
- }
- }
- print LIST "\n";
-
- ###### DEFS ######
- print DEFS " EVENT_$name,\n";
-
- ###### DESCR ######
- #
- # The description needs some reg-expression magic to
- # remove the c-style like comments.
- #
- ###################
- $descrstring =~ s/\"/\\\"/g; #" escape all quote characters
-
-
- # now tokenize and remove comment characters ('\','*')
- my ( $descr_line, $descr, $finaldescr, @tokens );
- @tokens = split /\n/, $descrstring;
-
- $finaldescr = "";
-
- foreach $descr_line (@tokens){
- if ( $descr_line =~ /\s*[\S]+\s(.*)/ ){
- $descr = $1;
- }else{
- $descr = "";
- }
- $finaldescr = $finaldescr."\n".$descr;
- }
-
- # remove leading or trailing '\n's
- if ( $finaldescr =~ /\n*(.*\n)\n*/s ){
- $finaldescr = $1;
- }
- else {
- $finaldescr = "\n";
- }
-
- # finally, escape all \n's.
- $finaldescr =~ s/\n/\\n/g;
-
- if ( $no_of_events > 0 ){
- print DESCR_DEF ",\n";
- }
- print DESCR_DEF " cEventEntry( \"$name\", \"$finaldescr\" )";
-
- $no_of_events += 1;
- } # if( $name )
- }
-
- print DEFS "EVENT_NO_EVENT };\n";
-
- print N2E " }else{\n";
- print N2E " return ".$fname_root."EventFactory::EVENT_undefined;\n";
- print N2E " }\n";
- print N2E "}\n";
-
- print DESCR_DEF " };
-
- const int cEventDescrs::num_of_events = $no_of_events;
-
- ";
-
-} # for each ARGV to fnameroot
-
-
Deleted: trunk/source/event/population_event.cc
===================================================================
--- trunk/source/event/population_event.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/population_event.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,22 +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 POPULATION_EVENT_HH
-#include "population_event.hh"
-#endif
-
-#ifndef EVENT_HH
-#include "event.hh"
-#endif
-#ifndef STRING_HH
-#include "string.hh"
-#endif
-
-cPopulationEvent::cPopulationEvent(const cString & name, const cString & args):
- cEvent(name, args)
-{
-}
Modified: trunk/source/event/population_event.hh
===================================================================
--- trunk/source/event/population_event.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/population_event.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -18,18 +18,15 @@
class cPopulationEvent : public cEvent {
private:
// not implemented. prevents inadvertend wrong instantiation.
- cPopulationEvent();
- cPopulationEvent( const cPopulationEvent & );
- const cPopulationEvent& operator=( cPopulationEvent & );
+ cPopulationEvent(const cPopulationEvent&);
+ const cPopulationEvent& operator=(cPopulationEvent&);
-
protected:
cPopulation *population;
public:
- cPopulationEvent(const cString & name, const cString & args);
-
- void SetPopulation( cPopulation *pop ){ population = pop; }
+ cPopulationEvent() { ; }
+ void SetPopulation(cPopulation* pop) { population = pop; }
};
#endif
Modified: trunk/source/event/population_event_factory.cc
===================================================================
--- trunk/source/event/population_event_factory.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/population_event_factory.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -94,51 +94,3993 @@
// The Process() functions
using namespace std;
-#include "cPopulation_process_auto.ci"
-// EventNameToEnum()
-#include "cPopulation_name2enum_auto.ci"
+///// exit /////
+/**
+* Ends the Avida run immediately.
+ **/
+namespace nPopulation {
+
+ class cEvent_exit : public cPopulationEvent {
+ public:
+ const cString GetName() const { return "exit"; }
+ const cString GetDescription() const { return "exit"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ }
+
+ ///// exit /////
+ void Process(){
+ cAvidaDriver_Base::main_driver->SetDone();
+ }
+ };
+
+ ///// exit_if_generation_greater_than /////
+
+ /**
+ * Ends the Avida run when the current generation exceeds the
+ * maximum generation given as parameter.
+ *
+ * Parameters:
+ * max generation (int)
+ * The generation at which the run should be stopped.
+ **/
+
+
+ class cEvent_exit_if_generation_greater_than : public cPopulationEvent {
+ private:
+ int max_generation;
+ public:
+ const cString GetName() const { return "exit_if_generation_greater_than"; }
+ const cString GetDescription() const { return "exit_if_generation_greater_than <int max_generation>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ max_generation = args.PopWord().AsInt();
+ }
+ ///// exit_if_generation_greater_than /////
+ void Process(){
+ if( population->GetGeneration() > max_generation ){
+ cAvidaDriver_Base::main_driver->SetDone();
+ }
+ }
+ };
+
+ ///// exit_if_update_greater_than /////
+
+ /**
+ * Ends the Avida run when the current update exceeds the
+ * maximum update given as parameter.
+ *
+ * Parameters:
+ * max update (int)
+ * The update at which the run should be stopped.
+ **/
+
+
+ class cEvent_exit_if_update_greater_than : public cPopulationEvent {
+ private:
+ int max_update;
+ public:
+ const cString GetName() const { return "exit_if_update_greater_than"; }
+ const cString GetDescription() const { return "exit_if_update_greater_than <int max_update>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ max_update = args.PopWord().AsInt();
+ }
+ ///// exit_if_update_greater_than /////
+ void Process(){
+ if( population->GetUpdate() > max_update ){
+ cAvidaDriver_Base::main_driver->SetDone();
+ }
+ }
+ };
+
+ ///// exit_if_ave_lineage_label_smaller /////
+
+ /**
+ * Halts the avida run if the current average lineage label is smaller
+ * than the value given as parameter.
+ *
+ * Parameters:
+ * lineage_label_crit_value (int)
+ * The critical value to which the average lineage label is compared.
+ **/
+
+
+ class cEvent_exit_if_ave_lineage_label_smaller : public cPopulationEvent {
+ private:
+ double lineage_label_crit_value;
+ public:
+ const cString GetName() const { return "exit_if_ave_lineage_label_smaller"; }
+ const cString GetDescription() const { return "exit_if_ave_lineage_label_smaller <double lineage_label_crit_value>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ lineage_label_crit_value = args.PopWord().AsDouble();
+ }
+ ///// exit_if_ave_lineage_label_smaller /////
+ void Process(){
+ if( population->GetStats().GetAveLineageLabel() < lineage_label_crit_value ){
+ cAvidaDriver_Base::main_driver->SetDone();
+ }
+ }
+ };
+
+ ///// exit_if_ave_lineage_label_larger /////
+
+ /**
+ * Halts the avida run if the current average lineage label is larger
+ * than the value given as parameter.
+ *
+ * Parameters:
+ * lineage_label_crit_value (int)
+ * The critical value to which the average lineage label is compared.
+ **/
+
+
+ class cEvent_exit_if_ave_lineage_label_larger : public cPopulationEvent {
+ private:
+ double lineage_label_crit_value;
+ public:
+ const cString GetName() const { return "exit_if_ave_lineage_label_larger"; }
+ const cString GetDescription() const { return "exit_if_ave_lineage_label_larger <double lineage_label_crit_value>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ lineage_label_crit_value = args.PopWord().AsDouble();
+ }
+ ///// exit_if_ave_lineage_label_larger /////
+ void Process(){
+ if( population->GetStats().GetAveLineageLabel() > lineage_label_crit_value ){
+ cAvidaDriver_Base::main_driver->SetDone();
+ }
+ }
+ };
+
+ ///// echo /////
+
+ /**
+ * Writes out a message. If no message is given, average update and
+ * generation are written out.
+ *
+ * Parameters:
+ * message (string)
+ **/
+
+
+ class cEvent_echo : public cPopulationEvent {
+ private:
+ cString mesg;
+ public:
+ const cString GetName() const { return "echo"; }
+ const cString GetDescription() const { return "echo <cString mesg>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ mesg = args.PopWord();
+ }
+ ///// echo /////
+ void Process(){
+ if( mesg == "" ){
+ mesg.Set("Echo : Update = %f\t AveGeneration = %f",
+ population->GetUpdate(), population->GetGeneration());
+ }
+ cAvidaDriver_Base::main_driver->NotifyComment(mesg);
+ }
+ };
+
+ ///// print_data /////
+
+ /**
+ * Output user-defined data from the cStats object...
+ *
+ * Parameters:
+ * filename (string)
+ * The name of the data file.
+ * format
+ * A comma-seperated list of statistics to output.
+ **/
+
+
+ class cEvent_print_data : public cPopulationEvent {
+ private:
+ cString filename;
+ cString format;
+ public:
+ const cString GetName() const { return "print_data"; }
+ const cString GetDescription() const { return "print_data <cString filename> <cString format>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ filename = args.PopWord();
+ format = args.PopWord();
+ }
+ ///// print_data /////
+ void Process(){
+ population->GetStats().PrintDataFile(filename, format, ',');
+ }
+ };
+
+ ///// print_average_data /////
+
+ /**
+ * Output various average quantities into datafile.
+ *
+ * Parameters:
+ * filename (string) default: average.dat
+ * The name of the data file.
+ **/
+
+
+ class cEvent_print_average_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_average_data"; }
+ const cString GetDescription() const { return "print_average_data [cString fname=\"average.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="average.dat"; else fname=args.PopWord();
+ }
+ ///// print_average_data /////
+ void Process(){
+ population->GetStats().PrintAverageData(fname);
+ }
+ };
+
+ ///// print_error_data /////
+
+ /**
+ * Prints out various data related to statistical errors.
+ *
+ * Parameters:
+ * filename (string) default: error.dat
+ * The name of the data file.
+ **/
+
+
+ class cEvent_print_error_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_error_data"; }
+ const cString GetDescription() const { return "print_error_data [cString fname=\"error.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="error.dat"; else fname=args.PopWord();
+ }
+ ///// print_error_data /////
+ void Process(){
+ population->GetStats().PrintErrorData(fname);
+ }
+ };
+
+ ///// print_variance_data /////
+
+ /**
+ * Prints out various variances.
+ *
+ * Parameters:
+ * filename (string) default: variance.dat
+ * The name of the data file.
+ **/
+
+
+ class cEvent_print_variance_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_variance_data"; }
+ const cString GetDescription() const { return "print_variance_data [cString fname=\"variance.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="variance.dat"; else fname=args.PopWord();
+ }
+ ///// print_variance_data /////
+ void Process(){
+ population->GetStats().PrintVarianceData(fname);
+ }
+ };
+
+ ///// print_dominant_data /////
+
+ /**
+ * Output various quantities related to the dominant organism.
+ *
+ * Parameters:
+ * filename (string) default: dominant.dat
+ * The name of the data file.
+ **/
+
+
+ class cEvent_print_dominant_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_dominant_data"; }
+ const cString GetDescription() const { return "print_dominant_data [cString fname=\"dominant.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="dominant.dat"; else fname=args.PopWord();
+ }
+ ///// print_dominant_data /////
+ void Process(){
+ population->GetStats().PrintDominantData(fname);
+ }
+ };
+
+ ///// print_stats_data /////
+
+ /**
+ * Output various statistical quantities.
+ *
+ * Parameters:
+ * filename (string) default: stats.dat
+ * The name of the data file.
+ **/
+
+
+ class cEvent_print_stats_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_stats_data"; }
+ const cString GetDescription() const { return "print_stats_data [cString fname=\"stats.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="stats.dat"; else fname=args.PopWord();
+ }
+ ///// print_stats_data /////
+ void Process(){
+ population->GetStats().PrintStatsData(fname);
+ }
+ };
+
+ ///// print_count_data /////
+
+ /**
+ * Output various counts, such as number of organisms etc.
+ *
+ * Parameters:
+ * filename (string) default: count.dat
+ * The name of the data file.
+ **/
+
+
+ class cEvent_print_count_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_count_data"; }
+ const cString GetDescription() const { return "print_count_data [cString fname=\"count.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="count.dat"; else fname=args.PopWord();
+ }
+ ///// print_count_data /////
+ void Process(){
+ population->GetStats().PrintCountData(fname);
+ }
+ };
+
+ ///// print_totals_data /////
+
+ /**
+ * Various total numbers.
+ *
+ * Parameters:
+ * filename (string) default: totals.dat
+ * The name of the data file.
+ **/
+
+
+ class cEvent_print_totals_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_totals_data"; }
+ const cString GetDescription() const { return "print_totals_data [cString fname=\"totals.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="totals.dat"; else fname=args.PopWord();
+ }
+ ///// print_totals_data /////
+ void Process(){
+ population->GetStats().PrintTotalsData(fname);
+ }
+ };
+
+ ///// print_tasks_data /////
+
+ /**
+ * Output the number of times the various tasks have been performed in the
+ * last update.
+ *
+ * Parameters:
+ * filename (string) default: tasks.dat
+ * The name of the data file.
+ **/
+
+
+ class cEvent_print_tasks_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_tasks_data"; }
+ const cString GetDescription() const { return "print_tasks_data [cString fname=\"tasks.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="tasks.dat"; else fname=args.PopWord();
+ }
+ ///// print_tasks_data /////
+ void Process(){
+ population->GetStats().PrintTasksData(fname);
+ }
+ };
+
+ ///// print_tasks_exe_data /////
+
+ /**
+ **/
+
+
+ class cEvent_print_tasks_exe_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_tasks_exe_data"; }
+ const cString GetDescription() const { return "print_tasks_exe_data [cString fname=\"tasks_exe.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="tasks_exe.dat"; else fname=args.PopWord();
+ }
+ ///// print_tasks_exe_data /////
+ void Process(){
+ population->GetStats().PrintTasksExeData(fname);
+ }
+ };
+
+ ///// print_resource_data /////
+
+ /**
+ **/
+
+
+ class cEvent_print_resource_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_resource_data"; }
+ const cString GetDescription() const { return "print_resource_data [cString fname=\"resource.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="resource.dat"; else fname=args.PopWord();
+ }
+ ///// print_resource_data /////
+ void Process(){
+ population->GetStats().PrintResourceData(fname);
+ }
+ };
+
+ ///// print_time_data /////
+
+ /**
+ * Output time related data, such as update, generation, etc.
+ *
+ * Parameters:
+ * filename (string) default: time.dat
+ * The name of the data file.
+ **/
+
+
+ class cEvent_print_time_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_time_data"; }
+ const cString GetDescription() const { return "print_time_data [cString fname=\"time.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="time.dat"; else fname=args.PopWord();
+ }
+ ///// print_time_data /////
+ void Process(){
+ population->GetStats().PrintTimeData(fname);
+ }
+ };
+
+ ///// print_mutation_data /////
+
+ /**
+ **/
+
+
+ class cEvent_print_mutation_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_mutation_data"; }
+ const cString GetDescription() const { return "print_mutation_data [cString fname=\"mutation.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="mutation.dat"; else fname=args.PopWord();
+ }
+ ///// print_mutation_data /////
+ void Process(){
+ population->GetStats().PrintMutationData(fname);
+ }
+ };
+
+ ///// print_mutation_rate_data /////
+
+ /**
+ Output (regular and log) statistics about individual copy
+ mutation rates (aver, stdev, skew, cur).
+ Useful only when mutation rate is set per organism.
+ **/
+
+
+ class cEvent_print_mutation_rate_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_mutation_rate_data"; }
+ const cString GetDescription() const { return "print_mutation_rate_data [cString fname=\"mutation_rates.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="mutation_rates.dat"; else fname=args.PopWord();
+ }
+ ///// print_mutation_rate_data /////
+ void Process(){
+ population->GetStats().PrintMutationRateData(fname);
+ }
+ };
+
+ ///// print_divide_mut_data /////
+
+ /**
+ Output (regular and log) statistics about individual, per site,
+ rates divide mutation rates (aver, stdev, skew, cur).
+ Use with multiple divide instuction set.
+ **/
+
+
+ class cEvent_print_divide_mut_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_divide_mut_data"; }
+ const cString GetDescription() const { return "print_divide_mut_data [cString fname=\"divide_mut.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="divide_mut.dat"; else fname=args.PopWord();
+ }
+ ///// print_divide_mut_data /////
+ void Process(){
+ population->GetStats().PrintDivideMutData(fname);
+ }
+ };
+
+ ///// print_dom_parasite_data /////
+
+ /**
+ * Output various quantities related to the dominant parasite.
+ *
+ * Parameters:
+ * filename (string) default: parasite.dat
+ * The name of the data file.
+ **/
+
+
+ class cEvent_print_dom_parasite_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_dom_parasite_data"; }
+ const cString GetDescription() const { return "print_dom_parasite_data [cString fname=\"parasite.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="parasite.dat"; else fname=args.PopWord();
+ }
+ ///// print_dom_parasite_data /////
+ void Process(){
+ population->GetStats().PrintDominantParaData(fname);
+ }
+ };
+
+ ///// print_instruction_data /////
+
+ /**
+ Sum of the by-organisms counts of what instructions they _successfully_
+ execute beteween birth and divide. Prior to their first divide, organisms
+ report values for their parents.
+ **/
+
+
+ class cEvent_print_instruction_data : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_instruction_data"; }
+ const cString GetDescription() const { return "print_instruction_data [cString fname=\"instruction.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="instruction.dat"; else fname=args.PopWord();
+ }
+ ///// print_instruction_data /////
+ void Process(){
+ population->GetStats().PrintInstructionData(fname);
+ }
+ };
+
+ ///// print_instruction_abundance_histogram /////
+
+ /**
+ *
+ * Appends a line containing the bulk count (abundance) of
+ * each instruction in the population onto a file.
+ *
+ * Parameters:
+ * filename (string) default: "instruction_histogram.dat"
+ *
+ **/
+
+
+ class cEvent_print_instruction_abundance_histogram : public cPopulationEvent {
+ private:
+ cString filename;
+ public:
+ const cString GetName() const { return "print_instruction_abundance_histogram"; }
+ const cString GetDescription() const { return "print_instruction_abundance_histogram [cString filename=\"instruction_histogram.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") filename="instruction_histogram.dat"; else filename=args.PopWord();
+ }
+ ///// print_instruction_abundance_histogram /////
+ void Process(){
+ ofstream & fp = population->GetStats().GetDataFileOFStream(filename);
+ cAnalyzeUtil::PrintInstructionAbundanceHistogram(fp, population);
+ }
+ };
+
+ ///// print_depth_histogram /////
+
+ /**
+ **/
+
+
+ class cEvent_print_depth_histogram : public cPopulationEvent {
+ private:
+ cString filename;
+ public:
+ const cString GetName() const { return "print_depth_histogram"; }
+ const cString GetDescription() const { return "print_depth_histogram [cString filename=\"depth_histogram.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") filename="depth_histogram.dat"; else filename=args.PopWord();
+ }
+ ///// print_depth_histogram /////
+ void Process(){
+ ofstream & fp = population->GetStats().GetDataFileOFStream(filename);
+ cAnalyzeUtil::PrintDepthHistogram(fp, population);
+ }
+ };
+
+ ///// print_genotype_abundance_histogram /////
+
+ /**
+ * Writes out a genotype abundance histogram.
+ *
+ * Parameters:
+ * filename (string) default: genotype_abundance_histogram.dat
+ * The name of the file into which the histogram is written.
+ **/
+
+
+ class cEvent_print_genotype_abundance_histogram : public cPopulationEvent {
+ private:
+ cString filename;
+ public:
+ const cString GetName() const { return "print_genotype_abundance_histogram"; }
+ const cString GetDescription() const { return "print_genotype_abundance_histogram [cString filename=\"genotype_abundance_histogram.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") filename="genotype_abundance_histogram.dat"; else filename=args.PopWord();
+ }
+ ///// print_genotype_abundance_histogram /////
+ void Process(){
+ ofstream & fp = population->GetStats().GetDataFileOFStream(filename);
+ cAnalyzeUtil::PrintGenotypeAbundanceHistogram(fp, population);
+ }
+ };
+
+ ///// print_species_abundance_histogram /////
+
+ /**
+ * Writes out a species abundance histogram.
+ *
+ * Parameters:
+ * filename (string) default: species_abundance_histogram.dat
+ * The name of the file into which the histogram is written.
+ **/
+
+
+ class cEvent_print_species_abundance_histogram : public cPopulationEvent {
+ private:
+ cString filename;
+ public:
+ const cString GetName() const { return "print_species_abundance_histogram"; }
+ const cString GetDescription() const { return "print_species_abundance_histogram [cString filename=\"species_abundance_histogram.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") filename="species_abundance_histogram.dat"; else filename=args.PopWord();
+ }
+ ///// print_species_abundance_histogram /////
+ void Process(){
+ ofstream & fp = population->GetStats().GetDataFileOFStream(filename);
+ cAnalyzeUtil::PrintSpeciesAbundanceHistogram(fp, population);
+ }
+ };
+
+ ///// print_lineage_totals /////
+
+ /**
+ **/
+
+
+ class cEvent_print_lineage_totals : public cPopulationEvent {
+ private:
+ cString fname;
+ int verbose;
+ public:
+ const cString GetName() const { return "print_lineage_totals"; }
+ const cString GetDescription() const { return "print_lineage_totals [cString fname=\"lineage_totals.dat\"] [int verbose=1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="lineage_totals.dat"; else fname=args.PopWord();
+ if (args == "") verbose=1; else verbose=args.PopWord().AsInt();
+ }
+ ///// print_lineage_totals /////
+ void Process(){
+ static bool msg_printed = false;
+ if (population->GetLineageControl() == NULL) {
+ if ( msg_printed == false ){
+ ofstream & fp = population->GetStats().GetDataFileOFStream(fname);
+ fp << "No lineage data available!" << endl;
+ msg_printed = true;
+ }
+ return;
+ }
+ population->GetLineageControl()->PrintLineageTotals(fname, verbose);
+ }
+ };
+
+ ///// print_lineage_counts /////
+
+ /**
+ **/
+
+
+ class cEvent_print_lineage_counts : public cPopulationEvent {
+ private:
+ cString fname;
+ int verbose;
+ public:
+ const cString GetName() const { return "print_lineage_counts"; }
+ const cString GetDescription() const { return "print_lineage_counts [cString fname=\"lineage_counts.dat\"] [int verbose=0]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="lineage_counts.dat"; else fname=args.PopWord();
+ if (args == "") verbose=0; else verbose=args.PopWord().AsInt();
+ }
+ ///// print_lineage_counts /////
+ void Process(){
+ static bool msg_printed = false;
+ if (population->GetLineageControl() == NULL) {
+ if ( msg_printed == false ){
+ ofstream & fp = population->GetStats().GetDataFileOFStream(fname);
+ fp << "No lineage data available!" << endl;
+ msg_printed = true;
+ }
+ return;
+ }
+ if (verbose) { // verbose mode is the same in both methods
+ population->GetLineageControl()->PrintLineageTotals(fname, verbose);
+ return;
+ }
+ population->GetLineageControl()->PrintLineageCurCounts(fname);
+ }
+ };
+
+ ///// print_dom /////
+
+ /**
+ * Write the currently dominant genotype to disk.
+ *
+ * Parameters:
+ * filename (string)
+ * The name under which the genotype should be saved. If no
+ * filename is given, the genotype is saved into the directory
+ * genebank, under the name that the genebank has associated with
+ * this genotype.
+ **/
+
+
+ class cEvent_print_dom : public cPopulationEvent {
+ private:
+ cString in_filename;
+ public:
+ const cString GetName() const { return "print_dom"; }
+ const cString GetDescription() const { return "print_dom [cString in_filename=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") in_filename=""; else in_filename=args.PopWord();
+ }
+ ///// print_dom /////
+ void Process(){
+ cGenotype * dom = population->GetGenebank().GetBestGenotype();
+ cString filename(in_filename);
+ if (filename == "") filename.Set("genebank/%s", dom->GetName()());
+ cTestUtil::PrintGenome(dom->GetGenome(), filename, dom, population->GetUpdate());
+ }
+ };
+
+ ///// parasite_debug /////
+
+ //midget
+
+
+ class cEvent_parasite_debug : public cPopulationEvent {
+ private:
+ cString in_filename;
+ public:
+ const cString GetName() const { return "parasite_debug"; }
+ const cString GetDescription() const { return "parasite_debug [cString in_filename=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") in_filename=""; else in_filename=args.PopWord();
+ }
+ ///// parasite_debug /////
+ void Process(){
+ population->ParasiteDebug();
+ }
+ };
+
+ ///// print_dom_parasite /////
+
+ /**
+ * Write the currently dominant injected genotype to disk.
+ *
+ * Parameters:
+ * filename (string)
+ * The name under which the genotype should be saved. If no
+ * filename is given, the genotype is saved into the directory
+ * genebank, under the name that the genebank has associated with
+ * this genotype.
+ **/
+
+
+ class cEvent_print_dom_parasite : public cPopulationEvent {
+ private:
+ cString in_filename;
+ public:
+ const cString GetName() const { return "print_dom_parasite"; }
+ const cString GetDescription() const { return "print_dom_parasite [cString in_filename=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") in_filename=""; else in_filename=args.PopWord();
+ }
+ ///// print_dom_parasite /////
+ void Process(){
+ cInjectGenotype * dom = population->GetInjectGenebank().GetBestInjectGenotype();
+ if (dom!=NULL) {
+ cString filename(in_filename);
+ if (filename == "") filename.Set("genebank/%s", dom->GetName()());
+ cTestUtil::PrintGenome(dom, dom->GetGenome(), filename, population->GetUpdate()); }
+ }
+ };
+
+ ///// print_genotype_map /////
+
+ /**
+ * write a matrix of genotype ID's to a file (matlab format)
+ **/
+
+
+ class cEvent_print_genotype_map : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_genotype_map"; }
+ const cString GetDescription() const { return "print_genotype_map [cString fname=\"genotype_map.m\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="genotype_map.m"; else fname=args.PopWord();
+ }
+ ///// print_genotype_map /////
+ void Process(){
+ population->GetStats().PrintGenotypeMap(fname);
+ }
+ };
+
+ ///// print_number_phenotypes /////
+
+ /**
+ Output file with number of phenotypes based on tasks executed
+ for this update. Executing a task any numbers of times is considered
+ the same as executing it once.
+ **/
+
+
+ class cEvent_print_number_phenotypes : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_number_phenotypes"; }
+ const cString GetDescription() const { return "print_number_phenotypes [cString fname=\"phenotype_count.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="phenotype_count.dat"; else fname=args.PopWord();
+ }
+ ///// print_number_phenotypes /////
+ void Process(){
+ population->PrintPhenotypeData(fname);
+ }
+ };
+
+ ///// print_phenotype_status /////
+
+ /**
+ Prints merit status for all the organisms in the population.
+ Used for testing/debuging.
+ **/
+
+
+ class cEvent_print_phenotype_status : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "print_phenotype_status"; }
+ const cString GetDescription() const { return "print_phenotype_status [cString fname=\"phenotype_status.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="phenotype_status.dat"; else fname=args.PopWord();
+ }
+ ///// print_phenotype_status /////
+ void Process(){
+ population->PrintPhenotypeStatus(fname);
+ }
+ };
+
+ ///// save_population /////
+
+ /**
+ * Saves the full state of the population.
+ *
+ * Parameters:
+ * filename (string) default: save_pop.*
+ * The name of the file into which the population should
+ * be saved. If it is not given, then the name 'save_pop.*'
+ * is used, with '*' replaced by the current update.
+ **/
+
+
+ class cEvent_save_population : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "save_population"; }
+ const cString GetDescription() const { return "save_population [cString fname=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname=""; else fname=args.PopWord();
+ }
+ ///// save_population /////
+ void Process(){
+ cString filename;
+ if( fname == "" ){
+ filename.Set("save_pop.%d", population->GetUpdate());
+ }
+ ofstream fp(filename());
+ population->SavePopulation(fp);
+ }
+ };
+
+ ///// load_population /////
+
+ /**
+ * Loads the full state of the population.
+ *
+ * Parameters:
+ * filename (string)
+ * The name of the file to open.
+ **/
+
+
+ class cEvent_load_population : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "load_population"; }
+ const cString GetDescription() const { return "load_population <cString fname>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ fname = args.PopWord();
+ }
+ ///// load_population /////
+ void Process(){
+ ifstream fp(fname());
+ population->LoadPopulation(fp);
+ }
+ };
+
+ ///// save_clone /////
+
+ /**
+ **/
+
+
+ class cEvent_save_clone : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "save_clone"; }
+ const cString GetDescription() const { return "save_clone [cString fname=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname=""; else fname=args.PopWord();
+ }
+ ///// save_clone /////
+ void Process(){
+ cString filename;
+ if( fname == "" ){
+ filename.Set("clone.%d", population->GetUpdate());
+ }
+ ofstream fp(filename());
+ population->SaveClone(fp);
+ }
+ };
+
+ ///// load_clone /////
+
+ /**
+ **/
+
+
+ class cEvent_load_clone : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "load_clone"; }
+ const cString GetDescription() const { return "load_clone <cString fname>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ fname = args.PopWord();
+ }
+ ///// load_clone /////
+ void Process(){
+ ifstream fp(fname());
+ population->LoadClone(fp);
+ }
+ };
+
+ ///// load_dump_file /////
+
+ /**
+ * Sets up a population based on a dump file such as written out by
+ * detail_pop. It is also possible to append a history file to the dump
+ * file, in order to preserve the history of a previous run.
+ **/
+
+
+ class cEvent_load_dump_file : public cPopulationEvent {
+ private:
+ cString fname;
+ int update;
+ public:
+ const cString GetName() const { return "load_dump_file"; }
+ const cString GetDescription() const { return "load_dump_file <cString fname> [int update=-1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ fname = args.PopWord();
+ if (args == "") update=-1; else update=args.PopWord().AsInt();
+ }
+ ///// load_dump_file /////
+ void Process(){
+ population->LoadDumpFile(fname, update);
+ }
+ };
+
+ ///// dump_pop /////
+
+ /**
+ * Writes out a line of data for each genotype in the current population. The
+ * line contains the genome as string, the number of organisms of that genotype,
+ * and the genotype ID.
+ *
+ * Parameters:
+ * filename (string) default: "dump.<update>"
+ * The name of the file into which the population dump should be written.
+ **/
+
+
+ class cEvent_dump_pop : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "dump_pop"; }
+ const cString GetDescription() const { return "dump_pop [cString fname=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname=""; else fname=args.PopWord();
+ }
+ ///// dump_pop /////
+ void Process(){
+ cString filename;
+ if( fname == "" ){
+ filename.Set("dump.%d", population->GetUpdate());
+ }
+ ofstream fp(filename());
+ population->GetGenebank().DumpTextSummary(fp);
+ }
+ };
+
+ ///// print_genotypes /////
+
+ /**
+ * This is a new version of "detail_pop" or "historic_dump". It allows you to
+ * output one line per genotype in memory where you get to choose what data
+ * should be included.
+ *
+ * Parameters
+ * data_fields (string)
+ * This must be a comma separated string of all data you wish to output.
+ * Options include: id, parent_id, parent2_id (for sex), parent_dist,
+ * num_cpus, total_cpus, length, merit, gest_time, fitness, update_born,
+ * update_dead, depth, lineage, sequence
+ * historic (int) default: 0
+ * How many updates back of history should we include (-1 = all)
+ * filename (string) default: "genotypes-<update>.dat"
+ * The name of the file into which the population dump should be written.
+ **/
+
+
+ class cEvent_print_genotypes : public cPopulationEvent {
+ private:
+ cString data_fields;
+ int historic;
+ cString fname;
+ public:
+ const cString GetName() const { return "print_genotypes"; }
+ const cString GetDescription() const { return "print_genotypes [cString data_fields=\"all\"] [int historic=0] [cString fname=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") data_fields="all"; else data_fields=args.PopWord();
+ if (args == "") historic=0; else historic=args.PopWord().AsInt();
+ if (args == "") fname=""; else fname=args.PopWord();
+ }
+ ///// print_genotypes /////
+ void Process(){
+ cString filename = fname;
+ if (filename == "") {
+ filename.Set("genotypes-%d.dat", population->GetUpdate());
+ }
+ ofstream fp(filename());
+ population->GetGenebank().PrintGenotypes(fp, data_fields, historic);
+ }
+ };
+
+ ///// detail_pop /////
+
+ /**
+ * Like dump_pop, but more detailed data is written out.
+ *
+ * Parameters:
+ * filename (string) default: "detail_pop.<update>"
+ * The name of the file into which the population dump should be written.
+ **/
+
+
+ class cEvent_detail_pop : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "detail_pop"; }
+ const cString GetDescription() const { return "detail_pop [cString fname=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname=""; else fname=args.PopWord();
+ }
+ ///// detail_pop /////
+ void Process(){
+ cString filename;
+ if( fname == "" ){
+ filename.Set("detail_pop.%d", population->GetUpdate());
+ }
+ ofstream fp(filename());
+ population->GetGenebank().DumpDetailedSummary(fp);
+ }
+ };
+
+ ///// detail_sex_pop /////
+
+ /**
+ * Like detail_pop, but for sexual populations.
+ * Info for both parents is writen out.
+ *
+ * Parameters:
+ * filename (string) default: "detail_pop.<update>"
+ * The name of the file into which the population dump should be written.
+ **/
+
+
+ class cEvent_detail_sex_pop : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "detail_sex_pop"; }
+ const cString GetDescription() const { return "detail_sex_pop [cString fname=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname=""; else fname=args.PopWord();
+ }
+ ///// detail_sex_pop /////
+ void Process(){
+ cString filename;
+ if( fname == "" ){
+ filename.Set("detail_pop.%d", population->GetUpdate());
+ }
+ ofstream fp(filename());
+ population->GetGenebank().DumpDetailedSexSummary(fp);
+ }
+ };
+
+ ///// detail_parasite_pop /////
+
+ /**
+ * Like dump_pop, but more detailed data is written out.
+ *
+ * Parameters:
+ * filename (string) default: "detail_pop.<update>"
+ * The name of the file into which the population dump should be written.
+ **/
+
+
+ class cEvent_detail_parasite_pop : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "detail_parasite_pop"; }
+ const cString GetDescription() const { return "detail_parasite_pop [cString fname=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname=""; else fname=args.PopWord();
+ }
+ ///// detail_parasite_pop /////
+ void Process(){
+ cString filename;
+ if( fname == "" ){
+ filename.Set("detail_parasite_pop.%d", population->GetUpdate());
+ }
+ //ofstream fp(filename());
+ population->GetInjectGenebank().DumpDetailedSummary(filename, population->GetUpdate());
+ }
+ };
+
+ ///// dump_historic_pop /////
+
+ /**
+ * Similar to detail_pop. However, only genotypes that are not in the
+ * current population anymore are included. Genotypes that are not in
+ * the line of descent of any of the current genotypes to the ultimate
+ * ancestor are excluded.
+ *
+ * Parameters:
+ * back_dist (int) default: -1
+ * How many updates back should we print? -1 goes forever. Use the
+ * distance to the last dump historic if you only want a "diff".
+ * filename (string) default: "historic_dump.<update>"
+ * The name of the file into which the historic dump should be written.
+ **/
+
+
+ class cEvent_dump_historic_pop : public cPopulationEvent {
+ private:
+ int back_dist;
+ cString fname;
+ public:
+ const cString GetName() const { return "dump_historic_pop"; }
+ const cString GetDescription() const { return "dump_historic_pop [int back_dist=-1] [cString fname=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") back_dist=-1; else back_dist=args.PopWord().AsInt();
+ if (args == "") fname=""; else fname=args.PopWord();
+ }
+ ///// dump_historic_pop /////
+ void Process(){
+ cString filename;
+ if( fname == "" ){
+ filename.Set("historic_dump.%d", population->GetUpdate());
+ }
+ ofstream fp(filename());
+ population->GetGenebank().DumpHistoricSummary(fp, back_dist);
+ }
+ };
+
+ ///// dump_historic_sex_pop /////
+
+ /**
+ * Similar to dump_historic_pop, but for sexual populations.
+ * ID of both parents is writen out.
+ *
+ * Parameters:
+ * filename (string) default: "historic_dump.<update>"
+ * The name of the file into which the historic dump should be written.
+ **/
+
+
+ class cEvent_dump_historic_sex_pop : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "dump_historic_sex_pop"; }
+ const cString GetDescription() const { return "dump_historic_sex_pop [cString fname=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname=""; else fname=args.PopWord();
+ }
+ ///// dump_historic_sex_pop /////
+ void Process(){
+ cString filename;
+ if( fname == "" ){
+ filename.Set("historic_dump.%d", population->GetUpdate());
+ }
+ ofstream fp(filename());
+ population->GetGenebank().DumpHistoricSexSummary(fp);
+ }
+ };
+
+ ///// dump_memory /////
+
+ /**
+ * Dump the current memory state of all CPUs to a file.
+ **/
+
+
+ class cEvent_dump_memory : public cPopulationEvent {
+ private:
+ cString fname;
+ public:
+ const cString GetName() const { return "dump_memory"; }
+ const cString GetDescription() const { return "dump_memory [cString fname=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname=""; else fname=args.PopWord();
+ }
+ ///// dump_memory /////
+ void Process(){
+ cString filename;
+ if (fname == "") {
+ filename.Set("memory_dump.%d", population->GetUpdate());
+ }
+ ofstream fp(filename());
+ population->DumpMemorySummary(fp);
+ }
+ };
+
+ ///// inject /////
+
+ /**
+ * Injects a single organism into the population.
+ *
+ * Parameters:
+ * filename (string)
+ * The filename of the genotype to load. If this is left empty, or the keyword
+ * "START_CREATURE" is given, than the genotype specified in the genesis
+ * file under "START_CREATURE" is used.
+ * cell ID (integer) default: 0
+ * The grid-point into which the organism should be placed.
+ * merit (double) default: -1
+ * The initial merit of the organism. If set to -1, this is ignored.
+ * lineage label (integer) default: 0
+ * An integer that marks all descendants of this organism.
+ * neutral metric (double) default: 0
+ * A double value that randomly drifts over time.
+ **/
+
+
+ class cEvent_inject : public cPopulationEvent {
+ private:
+ cString fname;
+ int cell_id;
+ double merit;
+ int lineage_label;
+ double neutral_metric;
+ public:
+ const cString GetName() const { return "inject"; }
+ const cString GetDescription() const { return "inject [cString fname=\"START_CREATURE\"] [int cell_id=0] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="START_CREATURE"; else fname=args.PopWord();
+ if (args == "") cell_id=0; else cell_id=args.PopWord().AsInt();
+ if (args == "") merit=-1; else merit=args.PopWord().AsDouble();
+ if (args == "") lineage_label=0; else lineage_label=args.PopWord().AsInt();
+ if (args == "") neutral_metric=0; else neutral_metric=args.PopWord().AsDouble();
+ }
+ ///// inject /////
+ void Process(){
+ if (fname == "START_CREATURE") fname=cConfig::GetStartCreature();
+ cGenome genome =
+ cInstUtil::LoadGenome(fname, population->GetEnvironment().GetInstSet());
+ population->Inject(genome, cell_id, merit, lineage_label, neutral_metric);
+ }
+ };
+
+ ///// inject_all /////
+
+ /**
+ * Injects identical organisms into all cells of the population.
+ *
+ * Parameters:
+ * filename (string)
+ * The filename of the genotype to load. If this is left empty, or the keyword
+ * "START_CREATURE" is given, than the genotype specified in the genesis
+ * file under "START_CREATURE" is used.
+ * merit (double) default: -1
+ * The initial merit of the organism. If set to -1, this is ignored.
+ * lineage label (integer) default: 0
+ * An integer that marks all descendants of this organism.
+ * neutral metric (double) default: 0
+ * A double value that randomly drifts over time.
+ **/
+
+
+ class cEvent_inject_all : public cPopulationEvent {
+ private:
+ cString fname;
+ double merit;
+ int lineage_label;
+ double neutral_metric;
+ public:
+ const cString GetName() const { return "inject_all"; }
+ const cString GetDescription() const { return "inject_all [cString fname=\"START_CREATURE\"] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="START_CREATURE"; else fname=args.PopWord();
+ if (args == "") merit=-1; else merit=args.PopWord().AsDouble();
+ if (args == "") lineage_label=0; else lineage_label=args.PopWord().AsInt();
+ if (args == "") neutral_metric=0; else neutral_metric=args.PopWord().AsDouble();
+ }
+ ///// inject_all /////
+ void Process(){
+ if (fname == "START_CREATURE") fname=cConfig::GetStartCreature();
+ cGenome genome =
+ cInstUtil::LoadGenome(fname, population->GetEnvironment().GetInstSet());
+ for (int i = 0; i < population->GetSize(); i++) {
+ population->Inject(genome, i, merit, lineage_label, neutral_metric);
+ }
+ population->SetSyncEvents(true);
+ }
+ };
+
+ ///// inject_range /////
+
+ /**
+ * Injects identical organisms into a range of cells of the population.
+ *
+ * Parameters:
+ * filename (string)
+ * The filename of the genotype to load. If this is left empty, or the keyword
+ * "START_CREATURE" is given, than the genotype specified in the genesis
+ * file under "START_CREATURE" is used.
+ * start_cell (int)
+ * First cell to inject into.
+ * stop_cell (int)
+ * First cell *not* to inject into.
+ * merit (double) default: -1
+ * The initial merit of the organism. If set to -1, this is ignored.
+ * lineage label (integer) default: 0
+ * An integer that marks all descendants of this organism.
+ * neutral metric (double) default: 0
+ * A double value that randomly drifts over time.
+ *
+ * Example:
+ * inject_range creature.gen 0 10
+ *
+ * Will inject 10 organisms into cells 0 through 9.
+ **/
+
+
+ class cEvent_inject_range : public cPopulationEvent {
+ private:
+ cString fname;
+ int start_cell;
+ int end_cell;
+ double merit;
+ int lineage_label;
+ double neutral_metric;
+ public:
+ const cString GetName() const { return "inject_range"; }
+ const cString GetDescription() const { return "inject_range [cString fname=\"START_CREATURE\"] [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="START_CREATURE"; else fname=args.PopWord();
+ if (args == "") start_cell=0; else start_cell=args.PopWord().AsInt();
+ if (args == "") end_cell=-1; else end_cell=args.PopWord().AsInt();
+ if (args == "") merit=-1; else merit=args.PopWord().AsDouble();
+ if (args == "") lineage_label=0; else lineage_label=args.PopWord().AsInt();
+ if (args == "") neutral_metric=0; else neutral_metric=args.PopWord().AsDouble();
+ }
+ ///// inject_range /////
+ void Process(){
+ if (fname == "START_CREATURE") fname=cConfig::GetStartCreature();
+ if (end_cell == -1) end_cell = start_cell + 1;
+ if (start_cell < 0 ||
+ end_cell > population->GetSize() ||
+ start_cell >= end_cell) {
+ cout << "Warning: inject_range has invalid range!";
+ }
+ else {
+ cGenome genome =
+ cInstUtil::LoadGenome(fname, population->GetEnvironment().GetInstSet());
+ for (int i = start_cell; i < end_cell; i++) {
+ population->Inject(genome, i, merit, lineage_label, neutral_metric);
+ }
+ population->SetSyncEvents(true);
+ }
+ }
+ };
+
+ ///// inject_sequence /////
+
+ /**
+ * Injects identical organisms into a range of cells of the population.
+ *
+ * Parameters:
+ * sequence (string)
+ * The genome sequence for this organism. This is a mandatory argument.
+ * start_cell (int)
+ * First cell to inject into.
+ * stop_cell (int)
+ * First cell *not* to inject into.
+ * merit (double) default: -1
+ * The initial merit of the organism. If set to -1, this is ignored.
+ * lineage label (integer) default: 0
+ * An integer that marks all descendants of this organism.
+ * neutral metric (double) default: 0
+ * A double value that randomly drifts over time.
+ *
+ * Example:
+ * inject_range ckdfhgklsahnfsaggdsgajfg 0 10 100
+ *
+ * Will inject 10 organisms into cells 0 through 9 with a merit of 100.
+ **/
+
+
+ class cEvent_inject_sequence : public cPopulationEvent {
+ private:
+ cString seq;
+ int start_cell;
+ int end_cell;
+ double merit;
+ int lineage_label;
+ double neutral_metric;
+ public:
+ const cString GetName() const { return "inject_sequence"; }
+ const cString GetDescription() const { return "inject_sequence <cString seq> [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ seq = args.PopWord();
+ if (args == "") start_cell=0; else start_cell=args.PopWord().AsInt();
+ if (args == "") end_cell=-1; else end_cell=args.PopWord().AsInt();
+ if (args == "") merit=-1; else merit=args.PopWord().AsDouble();
+ if (args == "") lineage_label=0; else lineage_label=args.PopWord().AsInt();
+ if (args == "") neutral_metric=0; else neutral_metric=args.PopWord().AsDouble();
+ }
+ ///// inject_sequence /////
+ void Process(){
+ if (end_cell == -1) end_cell = start_cell + 1;
+ if (start_cell < 0 ||
+ end_cell > population->GetSize() ||
+ start_cell >= end_cell) {
+ cout << "Warning: inject_sequence has invalid range!" << endl;
+ cout << "start=" << start_cell << " end=" << end_cell
+ << "genome length=" << seq.GetSize() << endl;
+ }
+ else {
+ cGenome genome(seq);
+ for (int i = start_cell; i < end_cell; i++) {
+ population->Inject(genome, i, merit, lineage_label, neutral_metric);
+ }
+ population->SetSyncEvents(true);
+ }
+ }
+ };
+
+ ///// inject_random /////
+
+ /**
+ * Injects a randomly generated genome into the population.
+ *
+ * Parameters:
+ * length (integer) [required]
+ * Number of instructions in the randomly generated genome.
+ * cell ID (integer) default: -1
+ * The grid-point into which the genome should be placed. Default is random.
+ * merit (double) default: -1
+ * The initial merit of the organism. If set to -1, this is ignored.
+ * lineage label (integer) default: 0
+ * An integer that marks all descendants of this organism.
+ * neutral metric (double) default: 0
+ * A double value that randomly drifts over time.
+ **/
+
+
+ class cEvent_inject_random : public cPopulationEvent {
+ private:
+ int length;
+ int cell_id;
+ double merit;
+ int lineage_label;
+ double neutral_metric;
+ public:
+ const cString GetName() const { return "inject_random"; }
+ const cString GetDescription() const { return "inject_random <int length> [int cell_id=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ length = args.PopWord().AsInt();
+ if (args == "") cell_id=-1; else cell_id=args.PopWord().AsInt();
+ if (args == "") merit=-1; else merit=args.PopWord().AsDouble();
+ if (args == "") lineage_label=0; else lineage_label=args.PopWord().AsInt();
+ if (args == "") neutral_metric=0; else neutral_metric=args.PopWord().AsDouble();
+ }
+ ///// inject_random /////
+ void Process(){
+ if (cell_id == -1) cell_id = g_random.GetUInt(population->GetSize());
+ cGenome genome =
+ cInstUtil::RandomGenome(length, population->GetEnvironment().GetInstSet());
+ population->Inject(genome, cell_id, merit, lineage_label, neutral_metric);
+ }
+ };
+
+ ///// inject_range_parasite /////
+
+ /**
+ * Injects identical organisms into a range of cells of the population.
+ *
+ * Parameters:
+ * filename (string)
+ * The filename of the genotype to load. If this is left empty, or the keyword
+ * "START_CREATURE" is given, than the genotype specified in the genesis
+ * file under "START_CREATURE" is used.
+ * start_cell (int)
+ * First cell to inject into.
+ * stop_cell (int)
+ * First cell *not* to inject into.
+ * merit (double) default: -1
+ * The initial merit of the organism. If set to -1, this is ignored.
+ * lineage label (integer) default: 0
+ * An integer that marks all descendants of this organism.
+ * neutral metric (double) default: 0
+ * A double value that randomly drifts over time.
+ *
+ * Example:
+ * inject_range creature.gen 0 10
+ *
+ * Will inject 10 organisms into cells 0 through 9.
+ **/
+
+
+ class cEvent_inject_range_parasite : public cPopulationEvent {
+ private:
+ cString fname_parasite;
+ int start_cell;
+ int end_cell;
+ double merit;
+ int lineage_label;
+ double neutral_metric;
+ int mem_space;
+ public:
+ const cString GetName() const { return "inject_range_parasite"; }
+ const cString GetDescription() const { return "inject_range_parasite [cString fname_parasite=\"organism.parasite\"] [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0] [int mem_space=2]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname_parasite="organism.parasite"; else fname_parasite=args.PopWord();
+ if (args == "") start_cell=0; else start_cell=args.PopWord().AsInt();
+ if (args == "") end_cell=-1; else end_cell=args.PopWord().AsInt();
+ if (args == "") merit=-1; else merit=args.PopWord().AsDouble();
+ if (args == "") lineage_label=0; else lineage_label=args.PopWord().AsInt();
+ if (args == "") neutral_metric=0; else neutral_metric=args.PopWord().AsDouble();
+ if (args == "") mem_space=2; else mem_space=args.PopWord().AsInt();
+ }
+ ///// inject_range_parasite /////
+ void Process(){
+ if (fname_parasite == "START_CREATURE") fname_parasite=cConfig::GetStartCreature();
+ if (end_cell == -1) end_cell = start_cell + 1;
+ if (start_cell < 0 ||
+ end_cell > population->GetSize() ||
+ start_cell >= end_cell) {
+ cout << "Warning: inject_range has invalid range!";
+ }
+ else {
+ cGenome genome_parasite =
+ cInstUtil::LoadGenome(fname_parasite, population->GetEnvironment().GetInstSet());
+ for (int i = start_cell; i < end_cell; i++) {
+ population->Inject(genome_parasite, i, merit, lineage_label, neutral_metric, mem_space);
+ }
+ population->SetSyncEvents(true);
+ }
+ }
+ };
+
+ ///// inject_range_pair /////
+
+ /**
+ * Injects identical organisms into a range of cells of the population.
+ *
+ * Parameters:
+ * filename (string)
+ * The filename of the genotype to load. If this is left empty, or the keyword
+ * "START_CREATURE" is given, than the genotype specified in the genesis
+ * file under "START_CREATURE" is used.
+ * start_cell (int)
+ * First cell to inject into.
+ * stop_cell (int)
+ * First cell *not* to inject into.
+ * merit (double) default: -1
+ * The initial merit of the organism. If set to -1, this is ignored.
+ * lineage label (integer) default: 0
+ * An integer that marks all descendants of this organism.
+ * neutral metric (double) default: 0
+ * A double value that randomly drifts over time.
+ *
+ * Example:
+ * inject_range creature.gen 0 10
+ *
+ * Will inject 10 organisms into cells 0 through 9.
+ **/
+
+
+ class cEvent_inject_range_pair : public cPopulationEvent {
+ private:
+ cString fname;
+ cString fname_parasite;
+ int start_cell;
+ int end_cell;
+ double merit;
+ int lineage_label;
+ double neutral_metric;
+ int mem_space;
+ public:
+ const cString GetName() const { return "inject_range_pair"; }
+ const cString GetDescription() const { return "inject_range_pair [cString fname=\"START_CREATURE\"] [cString fname_parasite=\"organism.parasite\"] [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0] [int mem_space=2]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") fname="START_CREATURE"; else fname=args.PopWord();
+ if (args == "") fname_parasite="organism.parasite"; else fname_parasite=args.PopWord();
+ if (args == "") start_cell=0; else start_cell=args.PopWord().AsInt();
+ if (args == "") end_cell=-1; else end_cell=args.PopWord().AsInt();
+ if (args == "") merit=-1; else merit=args.PopWord().AsDouble();
+ if (args == "") lineage_label=0; else lineage_label=args.PopWord().AsInt();
+ if (args == "") neutral_metric=0; else neutral_metric=args.PopWord().AsDouble();
+ if (args == "") mem_space=2; else mem_space=args.PopWord().AsInt();
+ }
+ ///// inject_range_pair /////
+ void Process(){
+ if (fname == "START_CREATURE") fname=cConfig::GetStartCreature();
+ if (end_cell == -1) end_cell = start_cell + 1;
+ if (start_cell < 0 ||
+ end_cell > population->GetSize() ||
+ start_cell >= end_cell) {
+ cout << "Warning: inject_range has invalid range!";
+ }
+ else {
+ cGenome genome =
+ cInstUtil::LoadGenome(fname, population->GetEnvironment().GetInstSet());
+ cGenome genome_parasite =
+ cInstUtil::LoadGenome(fname_parasite, population->GetEnvironment().GetInstSet());
+ for (int i = start_cell; i < end_cell; i++) {
+ population->Inject(genome, i, merit, lineage_label, neutral_metric);
+ population->Inject(genome_parasite, i, merit, lineage_label, neutral_metric, mem_space);
+ }
+ population->SetSyncEvents(true);
+ }
+ }
+ };
+
+ ///// zero_muts /////
+
+ /**
+ * This event will set all mutation rates to zero...
+ **/
+
+
+ class cEvent_zero_muts : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "zero_muts"; }
+ const cString GetDescription() const { return "zero_muts"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ }
+ ///// zero_muts /////
+ void Process(){
+ for (int i = 0; i < population->GetSize(); i++) {
+ population->GetCell(i).MutationRates().Clear();
+ }
+ }
+ };
+
+ ///// mod_copy_mut /////
+
+ /**
+ **/
+
+
+ class cEvent_mod_copy_mut : public cPopulationEvent {
+ private:
+ double cmut_inc;
+ int cell;
+ public:
+ const cString GetName() const { return "mod_copy_mut"; }
+ const cString GetDescription() const { return "mod_copy_mut <double cmut_inc> [int cell=-1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ cmut_inc = args.PopWord().AsDouble();
+ if (args == "") cell=-1; else cell=args.PopWord().AsInt();
+ }
+ ///// mod_copy_mut /////
+ void Process(){
+ const double new_cmut = cConfig::GetCopyMutProb() + cmut_inc;
+ if (cell < 0) { // cell == -1 --> all
+ for (int i = 0; i < population->GetSize(); i++) {
+ population->GetCell(i).MutationRates().SetCopyMutProb(new_cmut);
+ }
+ cConfig::SetCopyMutProb(new_cmut);
+ } else {
+ population->GetCell(cell).MutationRates().SetCopyMutProb(new_cmut);
+ }
+ }
+ };
+
+ ///// mod_div_mut /////
+
+ /**
+ **/
+
+
+ class cEvent_mod_div_mut : public cPopulationEvent {
+ private:
+ double dmut_inc;
+ int cell;
+ public:
+ const cString GetName() const { return "mod_div_mut"; }
+ const cString GetDescription() const { return "mod_div_mut <double dmut_inc> [int cell=-1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ dmut_inc = args.PopWord().AsDouble();
+ if (args == "") cell=-1; else cell=args.PopWord().AsInt();
+ }
+ ///// mod_div_mut /////
+ void Process(){
+ const double new_div_mut = cConfig::GetDivMutProb() + dmut_inc;
+ if (cell < 0) { // cell == -1 --> all
+ for (int i = 0; i < population->GetSize(); i++) {
+ population->GetCell(i).MutationRates().SetDivMutProb(new_div_mut);
+ }
+ cConfig::SetDivMutProb(new_div_mut);
+ } else {
+ population->GetCell(cell).MutationRates().SetDivMutProb(new_div_mut);
+ }
+ }
+ };
+
+ ///// set_copy_mut /////
+
+ /**
+ **/
+
+
+ class cEvent_set_copy_mut : public cPopulationEvent {
+ private:
+ double cmut;
+ int start_cell;
+ int end_cell;
+ public:
+ const cString GetName() const { return "set_copy_mut"; }
+ const cString GetDescription() const { return "set_copy_mut <double cmut> [int start_cell=-1] [int end_cell=-1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ cmut = args.PopWord().AsDouble();
+ if (args == "") start_cell=-1; else start_cell=args.PopWord().AsInt();
+ if (args == "") end_cell=-1; else end_cell=args.PopWord().AsInt();
+ }
+ ///// set_copy_mut /////
+ void Process(){
+ if (start_cell < 0) { // start_cell == -1 --> all
+ cConfig::SetCopyMutProb(cmut);
+ start_cell = 0;
+ end_cell = population->GetSize();
+ }
+ else if (end_cell < -1) { // end_cell == -1 --> Only one cell!
+ end_cell = start_cell + 1;
+ }
+ assert(start_cell >= 0 && start_cell < population->GetSize());
+ assert(end_cell > 0 && end_cell <= population->GetSize());
+ for (int i = start_cell; i < end_cell; i++) {
+ population->GetCell(i).MutationRates().SetCopyMutProb(cmut);
+ }
+ }
+ };
+
+ ///// mod_point_mut /////
+
+ /**
+ **/
+
+
+ class cEvent_mod_point_mut : public cPopulationEvent {
+ private:
+ double pmut_inc;
+ int cell;
+ public:
+ const cString GetName() const { return "mod_point_mut"; }
+ const cString GetDescription() const { return "mod_point_mut <double pmut_inc> [int cell=-1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ pmut_inc = args.PopWord().AsDouble();
+ if (args == "") cell=-1; else cell=args.PopWord().AsInt();
+ }
+ ///// mod_point_mut /////
+ void Process(){
+ const double new_pmut = cConfig::GetPointMutProb() + pmut_inc;
+ if (cell < 0) { // cell == -1 --> all
+ for (int i = 0; i < population->GetSize(); i++) {
+ population->GetCell(i).MutationRates().SetPointMutProb(new_pmut);
+ }
+ cConfig::SetPointMutProb(new_pmut);
+ } else {
+ population->GetCell(cell).MutationRates().SetPointMutProb(new_pmut);
+ }
+ }
+ };
+
+ ///// set_point_mut /////
+
+ /**
+ **/
+
+
+ class cEvent_set_point_mut : public cPopulationEvent {
+ private:
+ double pmut;
+ int cell;
+ public:
+ const cString GetName() const { return "set_point_mut"; }
+ const cString GetDescription() const { return "set_point_mut <double pmut> [int cell=-1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ pmut = args.PopWord().AsDouble();
+ if (args == "") cell=-1; else cell=args.PopWord().AsInt();
+ }
+ ///// set_point_mut /////
+ void Process(){
+ if (cell < 0) { // cell == -1 --> all
+ for (int i = 0; i < population->GetSize(); i++) {
+ population->GetCell(i).MutationRates().SetPointMutProb(pmut);
+ }
+ cConfig::SetPointMutProb(pmut);
+ } else {
+ population->GetCell(cell).MutationRates().SetPointMutProb(pmut);
+ }
+ }
+ };
+
+ ///// calc_landscape /////
+
+ /**
+ **/
+
+
+ class cEvent_calc_landscape : public cPopulationEvent {
+ private:
+ int landscape_dist;
+ public:
+ const cString GetName() const { return "calc_landscape"; }
+ const cString GetDescription() const { return "calc_landscape [int landscape_dist=1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") landscape_dist=1; else landscape_dist=args.PopWord().AsInt();
+ }
+ ///// calc_landscape /////
+ void Process(){
+ cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
+ cAnalyzeUtil::CalcLandscape(landscape_dist, genome,
+ population->GetEnvironment().GetInstSet());
+ }
+ };
+
+ ///// predict_w_landscape /////
+
+ /**
+ **/
+
+
+ class cEvent_predict_w_landscape : public cPopulationEvent {
+ private:
+ cString datafile;
+ public:
+ const cString GetName() const { return "predict_w_landscape"; }
+ const cString GetDescription() const { return "predict_w_landscape [cString datafile=\"land-predict.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") datafile="land-predict.dat"; else datafile=args.PopWord();
+ }
+ ///// predict_w_landscape /////
+ void Process(){
+ cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
+ cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
+ static ofstream fp(datafile);
+ landscape.PredictWProcess(fp);
+ }
+ };
+
+ ///// predict_nu_landscape /////
+
+ /**
+ **/
+
+
+ class cEvent_predict_nu_landscape : public cPopulationEvent {
+ private:
+ cString datafile;
+ public:
+ const cString GetName() const { return "predict_nu_landscape"; }
+ const cString GetDescription() const { return "predict_nu_landscape [cString datafile=\"land-predict.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") datafile="land-predict.dat"; else datafile=args.PopWord();
+ }
+ ///// predict_nu_landscape /////
+ void Process(){
+ cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
+ cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
+ static ofstream fp(datafile);
+ landscape.PredictNuProcess(fp);
+ }
+ };
+
+ ///// sample_landscape /////
+
+ /**
+ **/
+
+
+ class cEvent_sample_landscape : public cPopulationEvent {
+ private:
+ int sample_size;
+ public:
+ const cString GetName() const { return "sample_landscape"; }
+ const cString GetDescription() const { return "sample_landscape [int sample_size=0]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") sample_size=0; else sample_size=args.PopWord().AsInt();
+ }
+ ///// sample_landscape /////
+ void Process(){
+ cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
+ cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
+ if (sample_size == 0) sample_size = population->GetEnvironment().GetInstSet().GetSize() - 1;
+ landscape.SampleProcess(sample_size);
+ static ofstream fp("land-sample.dat");
+ landscape.PrintStats(fp, population->GetUpdate());
+ }
+ };
+
+ ///// random_landscape /////
+
+ /**
+ **/
+
+
+ class cEvent_random_landscape : public cPopulationEvent {
+ private:
+ int landscape_dist;
+ int sample_size;
+ int min_found;
+ int max_sample_size;
+ bool print_if_found;
+ public:
+ const cString GetName() const { return "random_landscape"; }
+ const cString GetDescription() const { return "random_landscape [int landscape_dist=1] [int sample_size=0] [int min_found=0] [int max_sample_size=0] [bool print_if_found=false]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") landscape_dist=1; else landscape_dist=args.PopWord().AsInt();
+ if (args == "") sample_size=0; else sample_size=args.PopWord().AsInt();
+ if (args == "") min_found=0; else min_found=args.PopWord().AsInt();
+ if (args == "") max_sample_size=0; else max_sample_size=args.PopWord().AsInt();
+ if (args == "") print_if_found=false; else print_if_found=args.PopWord();
+ }
+ ///// random_landscape /////
+ void Process(){
+ cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
+ cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
+ landscape.RandomProcess(sample_size, landscape_dist, min_found,
+ max_sample_size, print_if_found);
+ static ofstream fp("land-random.dat");
+ landscape.PrintStats(fp, population->GetUpdate());
+ }
+ };
+
+ ///// analyze_landscape /////
+
+ /**
+ **/
+
+
+ class cEvent_analyze_landscape : public cPopulationEvent {
+ private:
+ int sample_size;
+ int min_found;
+ int max_sample_size;
+ public:
+ const cString GetName() const { return "analyze_landscape"; }
+ const cString GetDescription() const { return "analyze_landscape [int sample_size=1000] [int min_found=0] [int max_sample_size=0]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") sample_size=1000; else sample_size=args.PopWord().AsInt();
+ if (args == "") min_found=0; else min_found=args.PopWord().AsInt();
+ if (args == "") max_sample_size=0; else max_sample_size=args.PopWord().AsInt();
+ }
+ ///// analyze_landscape /////
+ void Process(){
+ cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
+ cAnalyzeUtil::
+ AnalyzeLandscape(genome, population->GetEnvironment().GetInstSet(),
+ sample_size, min_found, max_sample_size,
+ population->GetUpdate());
+ }
+ };
+
+ ///// pairtest_landscape /////
+
+ /**
+ * If sample_size = 0, pairtest the full landscape.
+ **/
+
+
+ class cEvent_pairtest_landscape : public cPopulationEvent {
+ private:
+ int sample_size;
+ public:
+ const cString GetName() const { return "pairtest_landscape"; }
+ const cString GetDescription() const { return "pairtest_landscape [int sample_size=0]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") sample_size=0; else sample_size=args.PopWord().AsInt();
+ }
+ ///// pairtest_landscape /////
+ void Process(){
+ cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
+ cAnalyzeUtil::PairTestLandscape(genome, population->GetEnvironment().GetInstSet(), sample_size, population->GetUpdate());
+ }
+ };
+
+ ///// test_dom /////
+
+ /**
+ **/
+
+
+ class cEvent_test_dom : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "test_dom"; }
+ const cString GetDescription() const { return "test_dom"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args; }
+ ///// test_dom /////
+ void Process(){
+ cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
+ static ofstream fp("dom-test.dat");
+ cAnalyzeUtil::TestGenome(genome, population->GetEnvironment().GetInstSet(), fp, population->GetUpdate());
+ }
+ };
+
+ ///// analyze_population /////
+
+ /**
+ **/
+
+
+ class cEvent_analyze_population : public cPopulationEvent {
+ private:
+ double sample_prob;
+ int landscape;
+ int save_genotype;
+ cString filename;
+ public:
+ const cString GetName() const { return "analyze_population"; }
+ const cString GetDescription() const { return "analyze_population [double sample_prob=1] [int landscape=0] [int save_genotype=0] [cString filename=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") sample_prob=1; else sample_prob=args.PopWord().AsDouble();
+ if (args == "") landscape=0; else landscape=args.PopWord().AsInt();
+ if (args == "") save_genotype=0; else save_genotype=args.PopWord().AsInt();
+ if (args == "") filename=""; else filename=args.PopWord();
+ }
+ ///// analyze_population /////
+ void Process(){
+ static bool auto_filename = false;
+ if( filename == "" )
+ auto_filename = true;
+ if ( auto_filename )
+ filename.Set("population_info_%d.dat",population->GetUpdate());
+ ofstream population_info(filename());
+ cAnalyzeUtil::AnalyzePopulation(population, population_info, sample_prob,
+ landscape, save_genotype);
+ }
+ };
+
+ ///// print_detailed_fitness_data /////
+
+ /**
+ **/
+
+
+ class cEvent_print_detailed_fitness_data : public cPopulationEvent {
+ private:
+ int save_max_f_genotype;
+ int print_fitness_histo;
+ double hist_fmax;
+ double hist_fstep;
+ cString filename;
+ cString filename2;
+ cString filename3;
+ public:
+ const cString GetName() const { return "print_detailed_fitness_data"; }
+ const cString GetDescription() const { return "print_detailed_fitness_data [int save_max_f_genotype=0] [int print_fitness_histo=0] [double hist_fmax=1] [double hist_fstep=0.1] [cString filename=\"fitness.dat\"] [cString filename2=\"fitness_histos.dat\"] [cString filename3=\"fitness_histos_testCPU.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") save_max_f_genotype=0; else save_max_f_genotype=args.PopWord().AsInt();
+ if (args == "") print_fitness_histo=0; else print_fitness_histo=args.PopWord().AsInt();
+ if (args == "") hist_fmax=1; else hist_fmax=args.PopWord().AsDouble();
+ if (args == "") hist_fstep=0.1; else hist_fstep=args.PopWord().AsDouble();
+ if (args == "") filename="fitness.dat"; else filename=args.PopWord();
+ if (args == "") filename2="fitness_histos.dat"; else filename2=args.PopWord();
+ if (args == "") filename3="fitness_histos_testCPU.dat"; else filename3=args.PopWord();
+ }
+ ///// print_detailed_fitness_data /////
+ void Process(){
+ static ofstream datafile(filename());
+ static ofstream histofile;
+ static ofstream histofile_testCPU;
+ if (print_fitness_histo && !histofile.is_open()){
+ histofile.open(filename2());
+ histofile_testCPU.open(filename3());
+ }
+ cAnalyzeUtil::PrintDetailedFitnessData( population, datafile, histofile, histofile_testCPU, save_max_f_genotype, print_fitness_histo, hist_fmax, hist_fstep );
+ }
+ };
+
+ ///// print_genetic_distance_data /////
+
+ /**
+ **/
+
+
+ class cEvent_print_genetic_distance_data : public cPopulationEvent {
+ private:
+ cString creature_name;
+ cString filename;
+ public:
+ const cString GetName() const { return "print_genetic_distance_data"; }
+ const cString GetDescription() const { return "print_genetic_distance_data [cString creature_name=\"\"] [cString filename=\"genetic_distance.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") creature_name=""; else creature_name=args.PopWord();
+ if (args == "") filename="genetic_distance.dat"; else filename=args.PopWord();
+ }
+ ///// print_genetic_distance_data /////
+ void Process(){
+ static ofstream popdump(filename());
+ if( creature_name == "" || creature_name == "START_CREATURE" ){
+ creature_name = cConfig::GetStartCreature(); }
+ cAnalyzeUtil::PrintGeneticDistanceData( population, popdump, creature_name() );
+ }
+ };
+
+ ///// genetic_distance_pop_dump /////
+
+ /**
+ **/
+
+
+ class cEvent_genetic_distance_pop_dump : public cPopulationEvent {
+ private:
+ cString creature_name;
+ cString filename;
+ int save_genotype;
+ public:
+ const cString GetName() const { return "genetic_distance_pop_dump"; }
+ const cString GetDescription() const { return "genetic_distance_pop_dump [cString creature_name=\"\"] [cString filename=\"\"] [int save_genotype=0]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") creature_name=""; else creature_name=args.PopWord();
+ if (args == "") filename=""; else filename=args.PopWord();
+ if (args == "") save_genotype=0; else save_genotype=args.PopWord().AsInt();
+ }
+ ///// genetic_distance_pop_dump /////
+ void Process(){
+ static bool auto_filename = false;
+ if( creature_name == "" || creature_name == "START_CREATURE" ){
+ creature_name = cConfig::GetStartCreature(); }
+ if( filename == "" || filename == "AUTO" )
+ auto_filename = true;
+ if ( auto_filename )
+ filename.Set("pop_dump_%d.dat",population->GetUpdate());
+ ofstream popdump(filename());
+ cAnalyzeUtil::GeneticDistancePopDump( population, popdump, creature_name(), save_genotype );
+ }
+ };
+
+ ///// task_snapshot /////
+
+ /**
+ **/
+
+
+ class cEvent_task_snapshot : public cPopulationEvent {
+ private:
+ cString filename;
+ public:
+ const cString GetName() const { return "task_snapshot"; }
+ const cString GetDescription() const { return "task_snapshot [cString filename=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") filename=""; else filename=args.PopWord();
+ }
+ ///// task_snapshot /////
+ void Process(){
+ static bool auto_filename = false;
+ if( filename == "" )
+ auto_filename = true;
+ if ( auto_filename )
+ filename.Set("tasks_%d.dat",population->GetUpdate());
+ ofstream snapshot_file(filename());
+ cAnalyzeUtil::TaskSnapshot( population, snapshot_file );
+ }
+ };
+
+ ///// print_viable_tasks_data /////
+
+ /**
+ **/
+
+
+ class cEvent_print_viable_tasks_data : public cPopulationEvent {
+ private:
+ cString filename;
+ public:
+ const cString GetName() const { return "print_viable_tasks_data"; }
+ const cString GetDescription() const { return "print_viable_tasks_data [cString filename=\"viable_tasks.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") filename="viable_tasks.dat"; else filename=args.PopWord();
+ }
+ ///// print_viable_tasks_data /////
+ void Process(){
+ static ofstream datafile(filename());
+ cAnalyzeUtil::PrintViableTasksData( population, datafile );
+ }
+ };
+
+ ///// apocalypse /////
+
+ /**
+ * Randomly removes a certain proportion of the population.
+ *
+ * Parameters:
+ * removal probability (double) default: 0.9
+ * The probability with which a single organism is removed.
+ **/
+
+
+ class cEvent_apocalypse : public cPopulationEvent {
+ private:
+ double kill_prob;
+ public:
+ const cString GetName() const { return "apocalypse"; }
+ const cString GetDescription() const { return "apocalypse [double kill_prob=.9]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") kill_prob=.9; else kill_prob=args.PopWord().AsDouble();
+ }
+ ///// apocalypse /////
+ void Process(){
+ for (int i = 0; i < population->GetSize(); i++) {
+ cPopulationCell & cell = population->GetCell(i);
+ if (cell.IsOccupied() == false) continue;
+ if (g_random.P(kill_prob)) population->KillOrganism(cell);
+ }
+ }
+ };
+
+ ///// kill_rectangle /////
+
+ /**
+ * Kills all cell in a rectangle.
+ *
+ * Parameters:
+ * cell [X1][Y1][x2][Y2] (integer) default: 0
+ * The start and stoping grid-points into which the organism should
+ be killed.
+ **/
+
+
+ class cEvent_kill_rectangle : public cPopulationEvent {
+ private:
+ int cell_X1;
+ int cell_Y1;
+ int cell_X2;
+ int cell_Y2;
+ public:
+ const cString GetName() const { return "kill_rectangle"; }
+ const cString GetDescription() const { return "kill_rectangle [int cell_X1=0] [int cell_Y1=0] [int cell_X2=0] [int cell_Y2=0]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") cell_X1=0; else cell_X1=args.PopWord().AsInt();
+ if (args == "") cell_Y1=0; else cell_Y1=args.PopWord().AsInt();
+ if (args == "") cell_X2=0; else cell_X2=args.PopWord().AsInt();
+ if (args == "") cell_Y2=0; else cell_Y2=args.PopWord().AsInt();
+ }
+ ///// kill_rectangle /////
+ void Process(){
+ int i, j, loc;
+ /* Be sure the user entered a valid range */
+ if (cell_X1 < 0) {
+ cell_X1 = 0;
+ } else if (cell_X1 > population->GetWorldX() - 1) {
+ cell_X1 = population->GetWorldX() - 1;
+ }
+ if (cell_X2 < 0) {
+ cell_X2 = 0;
+ } else if (cell_X2 > population->GetWorldX() - 1) {
+ cell_X2 = population->GetWorldX() - 1;
+ }
+ if (cell_Y1 < 0) {
+ cell_Y1 = 0;
+ } else if (cell_Y1 > population->GetWorldY() - 1) {
+ cell_Y1 = population->GetWorldY() - 1;
+ }
+ if (cell_Y2 < 0) {
+ cell_Y2 = 0;
+ } else if (cell_Y2 > population->GetWorldY() - 1) {
+ cell_Y2 = population->GetWorldY() - 1;
+ }
+ /* Account for a rectangle that crosses over the Zero X or Y cell */
+ if (cell_X2 < cell_X1) {
+ cell_X2 = cell_X2 + population->GetWorldX();
+ }
+ if (cell_Y2 < cell_Y1) {
+ cell_Y2 = cell_Y2 + population->GetWorldY();
+ }
+ for (i = cell_Y1; i <= cell_Y2; i++) {
+ for (j = cell_X1; j <= cell_X2; j++) {
+ loc = (i % population->GetWorldY()) * population->GetWorldX() +
+ (j % population->GetWorldX());
+ cPopulationCell & cell = population->GetCell(loc);
+ if (cell.IsOccupied() == true) {
+ population->KillOrganism(cell);
+ }
+ }
+ }
+ population->SetSyncEvents(true);
+ }
+ };
+
+ ///// rate_kill /////
+
+ /**
+ * Randomly removes a certain proportion of the population.
+ * In principle, this event does the same thing as the apocalypse event.
+ * However, instead of a probability, here one has to specify a rate. The
+ * rate has the same unit as fitness. So if the average fitness is 20000,
+ * then you remove 50% of the population on every update with a removal rate
+ * of 10000.
+ *
+ * Parameters:
+ * removal rate (double)
+ * The rate at which organisms are removed.
+ **/
+
+
+ class cEvent_rate_kill : public cPopulationEvent {
+ private:
+ double kill_rate;
+ public:
+ const cString GetName() const { return "rate_kill"; }
+ const cString GetDescription() const { return "rate_kill <double kill_rate>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ kill_rate = args.PopWord().AsDouble();
+ }
+ ///// rate_kill /////
+ void Process(){
+ double ave_merit = population->GetStats().SumMerit().Average();
+ if ( ave_merit <= 0 )
+ ave_merit = 1; // make sure that we don't get NAN's or negative numbers
+ ave_merit /= cConfig::GetAveTimeslice();
+ const double kill_prob = kill_rate / ave_merit;
+ for (int i = 0; i < population->GetSize(); i++) {
+ cPopulationCell & cell = population->GetCell(i);
+ if (cell.IsOccupied() == false) continue;
+ if (g_random.P(kill_prob)) population->KillOrganism(cell);
+ }
+ }
+ };
+
+ ///// serial_transfer /////
+
+ /**
+ * This event does again the same thing as apocalypse. However, now
+ * the number of organisms to be retained can be specified
+ * exactly. Also, it is possible to specify whether any of these
+ * organisms may be dead or not.
+ *
+ * Parameters:
+ * transfer size (int) default: 1
+ * The number of organisms to retain. If there are fewer living
+ * organisms than the specified transfer size, then all living
+ * organisms are retained.
+ * ignore deads (int) default: 1
+ * When set to 1, only living organisms are retained. Otherwise,
+ * every type of organism can be retained.
+ **/
+
+
+ class cEvent_serial_transfer : public cPopulationEvent {
+ private:
+ int transfer_size;
+ int ignore_deads;
+ public:
+ const cString GetName() const { return "serial_transfer"; }
+ const cString GetDescription() const { return "serial_transfer [int transfer_size=1] [int ignore_deads=1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") transfer_size=1; else transfer_size=args.PopWord().AsInt();
+ if (args == "") ignore_deads=1; else ignore_deads=args.PopWord().AsInt();
+ }
+ ///// serial_transfer /////
+ void Process(){
+ population->SerialTransfer( transfer_size, ignore_deads );
+ }
+ };
+
+ ///// hillclimb /////
+
+ /**
+ * Does a hill climb with the dominant genotype.
+ **/
+
+
+ class cEvent_hillclimb : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "hillclimb"; }
+ const cString GetDescription() const { return "hillclimb"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args; }
+ ///// hillclimb /////
+ void Process(){
+ cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
+ ofstream fp("hillclimb.dat");
+ cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
+ landscape.HillClimb(fp);
+ }
+ };
+
+ ///// hillclimb_neut /////
+
+ /**
+ **/
+
+
+ class cEvent_hillclimb_neut : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "hillclimb_neut"; }
+ const cString GetDescription() const { return "hillclimb_neut"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args; }
+ ///// hillclimb_neut /////
+ void Process(){
+ cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
+ ofstream fp("hillclimb.dat");
+ cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
+ landscape.HillClimb_Neut(fp);
+ }
+ };
+
+ ///// hillclimb_rand /////
+
+ /**
+ **/
+
+
+ class cEvent_hillclimb_rand : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "hillclimb_rand"; }
+ const cString GetDescription() const { return "hillclimb_rand"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args; }
+ ///// hillclimb_rand /////
+ void Process(){
+ cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
+ ofstream fp("hillclimb.dat");
+ cLandscape landscape(genome, population->GetEnvironment().GetInstSet());
+ landscape.HillClimb_Rand(fp);
+ }
+ };
+
+ ///// compete_demes /////
+
+ /**
+ * Compete all of the demes using a basic genetic algorithm approach. Fitness
+ * of each deme is determined differently depending on the competition_type:
+ * 0: deme fitness = 1 (control, random deme selection)
+ * 1: deme fitness = number of births since last competition (default)
+ * 2: deme fitness = average organism fitness at the current update
+ * 3: deme fitness = average mutation rate at the current update
+ * Merit can optionally be passed in.
+ **/
+
+
+ class cEvent_compete_demes : public cPopulationEvent {
+ private:
+ int competition_type;
+ public:
+ const cString GetName() const { return "compete_demes"; }
+ const cString GetDescription() const { return "compete_demes [int competition_type=1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") competition_type=1; else competition_type=args.PopWord().AsInt();
+ }
+ ///// compete_demes /////
+ void Process(){
+ population->CompeteDemes(competition_type);
+ }
+ };
+
+ ///// reset_demes /////
+
+ /**
+ * Designed to serve as a control for the compete_demes. Each deme is
+ * copied into itself and the parameters reset.
+ **/
+
+
+ class cEvent_reset_demes : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "reset_demes"; }
+ const cString GetDescription() const { return "reset_demes"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ }
+ ///// reset_demes /////
+ void Process(){
+ population->ResetDemes();
+ }
+ };
+
+ ///// print_deme_stats /////
+
+ /**
+ * Print stats about individual demes
+ **/
+
+
+ class cEvent_print_deme_stats : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "print_deme_stats"; }
+ const cString GetDescription() const { return "print_deme_stats"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ }
+ ///// print_deme_stats /////
+ void Process(){
+ population->PrintDemeStats();
+ }
+ };
+
+ ///// copy_deme /////
+
+ /**
+ * Takes two numbers as arguments and copies the contents of the first deme
+ * listed into the second.
+ **/
+
+
+ class cEvent_copy_deme : public cPopulationEvent {
+ private:
+ int deme1_id;
+ int deme2_id;
+ public:
+ const cString GetName() const { return "copy_deme"; }
+ const cString GetDescription() const { return "copy_deme <int deme1_id> <int deme2_id>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ deme1_id = args.PopWord().AsInt();
+ deme2_id = args.PopWord().AsInt();
+ }
+ ///// copy_deme /////
+ void Process(){
+ population->CopyDeme(deme1_id, deme2_id);
+ }
+ };
+
+ ///// calc_consensus /////
+
+ /**
+ * Calculates the consensus sequence.
+ *
+ * Parameters:
+ * lines saved (integer) default: 0
+ * ???
+ **/
+
+
+ class cEvent_calc_consensus : public cPopulationEvent {
+ private:
+ int lines_saved;
+ public:
+ const cString GetName() const { return "calc_consensus"; }
+ const cString GetDescription() const { return "calc_consensus [int lines_saved=0]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") lines_saved=0; else lines_saved=args.PopWord().AsInt();
+ }
+ ///// calc_consensus /////
+ void Process(){
+ cAnalyzeUtil::CalcConsensus(population, lines_saved);
+ }
+ };
+
+ ///// test_size_change_robustness /////
+
+ /**
+ **/
+
+
+ class cEvent_test_size_change_robustness : public cPopulationEvent {
+ private:
+ int num_trials;
+ cString filename;
+ public:
+ const cString GetName() const { return "test_size_change_robustness"; }
+ const cString GetDescription() const { return "test_size_change_robustness [int num_trials=100] [cString filename=\"size_change.dat\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") num_trials=100; else num_trials=args.PopWord().AsInt();
+ if (args == "") filename="size_change.dat"; else filename=args.PopWord();
+ }
+ ///// test_size_change_robustness /////
+ void Process(){
+ ofstream & fp = population->GetStats().GetDataFileOFStream(filename);
+ cAnalyzeUtil::TestInsSizeChangeRobustness(fp,
+ population->GetEnvironment().GetInstSet(),
+ population->GetGenebank().GetBestGenotype()->GetGenome(),
+ num_trials, population->GetUpdate());
+ }
+ };
+
+ ///// test_threads /////
+
+ /**
+ **/
+
+
+ class cEvent_test_threads : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "test_threads"; }
+ const cString GetDescription() const { return "test_threads"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ }
+
+ ///// test_threads /////
+ void Process(){
+ cTestCPU::TestThreads(population->GetGenebank().GetBestGenotype()->GetGenome());
+ }
+ };
+
+ ///// print_threads /////
+
+ /**
+ **/
+
+
+ class cEvent_print_threads : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "print_threads"; }
+ const cString GetDescription() const { return "print_threads"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ }
+ ///// print_threads /////
+ void Process(){
+ cTestCPU::PrintThreads( population->GetGenebank().GetBestGenotype()->GetGenome() );
+ }
+ };
+
+ ///// dump_fitness_grid /////
+
+ /**
+ * Writes out all fitness values of the organisms currently in the
+ * population.
+ *
+ * The output file is called "fgrid.*.out", where '*' is replaced by the
+ * number of the current update.
+ **/
+
+
+ class cEvent_dump_fitness_grid : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "dump_fitness_grid"; }
+ const cString GetDescription() const { return "dump_fitness_grid"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ }
+ ///// dump_fitness_grid /////
+ void Process(){
+ cString filename;
+ filename.Set("fgrid.%05d.out", population->GetUpdate());
+ ofstream fp(filename());
+ for (int i = 0; i < population->GetWorldX(); i++) {
+ for (int j = 0; j < population->GetWorldY(); j++) {
+ cPopulationCell & cell = population->GetCell(j*population->GetWorldX()+i);
+ double fitness = (cell.IsOccupied()) ?
+ cell.GetOrganism()->GetGenotype()->GetFitness() : 0.0;
+ fp << fitness << " ";
+ }
+ fp << endl;
+ }
+ }
+ };
+
+ ///// dump_genotype_grid /////
+
+ /**
+ * Writes out all genotype id values of the organisms currently in the
+ * population.
+ *
+ * The output file is called "idgrid.*.out", where '*' is replaced by the
+ * number of the current update.
+ **/
+
+
+ class cEvent_dump_genotype_grid : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "dump_genotype_grid"; }
+ const cString GetDescription() const { return "dump_genotype_grid"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ }
+ ///// dump_genotype_grid /////
+ void Process(){
+ cString filename;
+ filename.Set("idgrid.%05d.out", population->GetUpdate());
+ ofstream fp(filename());
+ for (int i = 0; i < population->GetWorldX(); i++) {
+ for (int j = 0; j < population->GetWorldY(); j++) {
+ cPopulationCell & cell = population->GetCell(j*population->GetWorldX()+i);
+ int id = (cell.IsOccupied()) ?
+ cell.GetOrganism()->GetGenotype()->GetID() : -1;
+ fp << id << " ";
+ }
+ fp << endl;
+ }
+ }
+ };
+
+ ///// dump_task_grid /////
+
+ /**
+ * Writes out a grid of tasks done by each organism
+ * Tasks are encoded as a binary string first, and then converted into a
+ * base 10 number
+ **/
+
+
+ class cEvent_dump_task_grid : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "dump_task_grid"; }
+ const cString GetDescription() const { return "dump_task_grid"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ }
+ ///// dump_task_grid /////
+ void Process(){
+ cString filename;
+ filename.Set("task_grid_%d.dat",population->GetUpdate());
+ ofstream fp(filename());
+ cAnalyzeUtil::TaskGrid( population, fp );
+ }
+ };
+
+ ///// dump_donor_grid /////
+
+ /**
+ * Writes out the grid of donor organisms in the population
+ *
+ * The output file is called "donor_grid.*.out", where '*' is replaced by the
+ * number of the current update.
+ **/
+
+
+ class cEvent_dump_donor_grid : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "dump_donor_grid"; }
+ const cString GetDescription() const { return "dump_donor_grid"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ }
+
+ ///// dump_donor_grid /////
+ void Process(){
+ cString filename;
+ filename.Set("donor_grid.%05d.out", population->GetUpdate());
+ ofstream fp(filename());
+ for (int i = 0; i < population->GetWorldX(); i++) {
+ for (int j = 0; j < population->GetWorldY(); j++) {
+ cPopulationCell & cell = population->GetCell(j*population->GetWorldX()+i);
+ int donor = cell.IsOccupied() ?
+ cell.GetOrganism()->GetPhenotype().IsDonorLast() : -1;
+ fp << donor << " ";
+ }
+ fp << endl;
+ }
+ }
+ };
+
+ ///// dump_receiver_grid /////
+
+ /**
+ * Writes out the grid of organisms which received merit in the population
+ *
+ * The output file is called "receiver_grid.*.out", where '*' is replaced by the
+ * number of the current update.
+ **/
+
+
+ class cEvent_dump_receiver_grid : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "dump_receiver_grid"; }
+ const cString GetDescription() const { return "dump_receiver_grid"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ }
+ ///// dump_receiver_grid /////
+ void Process(){
+ cString filename;
+ filename.Set("receiver_grid.%05d.out", population->GetUpdate());
+ ofstream fp(filename());
+ for (int i = 0; i < population->GetWorldX(); i++) {
+ for (int j = 0; j < population->GetWorldY(); j++) {
+ cPopulationCell & cell = population->GetCell(j*population->GetWorldX()+i);
+ int receiver = cell.IsOccupied() ?
+ cell.GetOrganism()->GetPhenotype().IsReceiver() : -1;
+ fp << receiver << " ";
+ }
+ fp << endl;
+ }
+ }
+ };
+
+ ///// print_tree_depths /////
+
+ /**
+ * Reconstruction of phylogenetic trees.
+ **/
+
+
+ class cEvent_print_tree_depths : public cPopulationEvent {
+ private:
+ cString filename;
+ public:
+ const cString GetName() const { return "print_tree_depths"; }
+ const cString GetDescription() const { return "print_tree_depths [cString filename=\"\"]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") filename=""; else filename=args.PopWord();
+ }
+ ///// print_tree_depths /////
+ void Process(){
+ if (filename == "") filename.Set("tree_depth.%d.dat", population->GetUpdate());
+ ofstream fp(filename);
+ cAnalyzeUtil::PrintTreeDepths(population, fp);
+ }
+ };
+
+ ///// sever_grid_col /////
+
+ /**
+ * Remove the connections between cells along a column in an avida grid.
+ * Arguments:
+ * col_id: indicates the number of columns to the left of the cut.
+ * default (or -1) = cut population in half
+ * min_row: First row to start cutting from
+ * default = 0
+ * max_row: Last row to cut to
+ * default (or -1) = last row in population.
+ **/
+
+
+ class cEvent_sever_grid_col : public cPopulationEvent {
+ private:
+ int col_id;
+ int min_row;
+ int max_row;
+ public:
+ const cString GetName() const { return "sever_grid_col"; }
+ const cString GetDescription() const { return "sever_grid_col [int col_id=-1] [int min_row=0] [int max_row=-1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") col_id=-1; else col_id=args.PopWord().AsInt();
+ if (args == "") min_row=0; else min_row=args.PopWord().AsInt();
+ if (args == "") max_row=-1; else max_row=args.PopWord().AsInt();
+ }
+ ///// sever_grid_col /////
+ void Process(){
+ const int world_x = population->GetWorldX();
+ const int world_y = population->GetWorldY();
+ if (col_id == -1) col_id = world_x / 2;
+ if (max_row == -1) max_row = world_y;
+ if (col_id < 0 || col_id >= world_x) {
+ cerr << "Event Error: Column ID " << col_id
+ << " out of range for sever_grid_col" << endl;
+ return;
+ }
+ // Loop through all of the rows and make the cut on each...
+ for (int row_id = min_row; row_id < max_row; row_id++) {
+ int idA = row_id * world_x + col_id;
+ int idB = GridNeighbor(idA, world_x, world_y, -1, 0);
+ int idA0 = GridNeighbor(idA, world_x, world_y, 0, -1);
+ int idA1 = GridNeighbor(idA, world_x, world_y, 0, 1);
+ int idB0 = GridNeighbor(idA, world_x, world_y, -1, -1);
+ int idB1 = GridNeighbor(idA, world_x, world_y, -1, 1);
+ cPopulationCell & cellA = population->GetCell(idA);
+ cPopulationCell & cellB = population->GetCell(idB);
+ tList<cPopulationCell> & cellA_list = cellA.ConnectionList();
+ tList<cPopulationCell> & cellB_list = cellB.ConnectionList();
+ cellA_list.Remove(&population->GetCell(idB));
+ cellA_list.Remove(&population->GetCell(idB0));
+ cellA_list.Remove(&population->GetCell(idB1));
+ cellB_list.Remove(&population->GetCell(idA));
+ cellB_list.Remove(&population->GetCell(idA0));
+ cellB_list.Remove(&population->GetCell(idA1));
+ }
+ }
+ };
+
+ ///// sever_grid_row /////
+
+ /**
+ * Remove the connections between cells along a column in an avida grid.
+ * Arguments:
+ * row_id: indicates the number of rows above the cut.
+ * default (or -1) = cut population in half
+ * min_col: First row to start cutting from
+ * default = 0
+ * max_col: Last row to cut to
+ * default (or -1) = last row in population.
+ **/
+
+
+ class cEvent_sever_grid_row : public cPopulationEvent {
+ private:
+ int row_id;
+ int min_col;
+ int max_col;
+ public:
+ const cString GetName() const { return "sever_grid_row"; }
+ const cString GetDescription() const { return "sever_grid_row [int row_id=-1] [int min_col=0] [int max_col=-1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") row_id=-1; else row_id=args.PopWord().AsInt();
+ if (args == "") min_col=0; else min_col=args.PopWord().AsInt();
+ if (args == "") max_col=-1; else max_col=args.PopWord().AsInt();
+ }
+ ///// sever_grid_row /////
+ void Process(){
+ const int world_x = population->GetWorldX();
+ const int world_y = population->GetWorldY();
+ if (row_id == -1) row_id = world_y / 2;
+ if (max_col == -1) max_col = world_x;
+ if (row_id < 0 || row_id >= world_y) {
+ cerr << "Event Error: Row ID " << row_id
+ << " out of range for sever_grid_row" << endl;
+ return;
+ }
+ // Loop through all of the cols and make the cut on each...
+ for (int col_id = min_col; col_id < max_col; col_id++) {
+ int idA = row_id * world_x + col_id;
+ int idB = GridNeighbor(idA, world_x, world_y, 0, -1);
+ int idA0 = GridNeighbor(idA, world_x, world_y, -1, 0);
+ int idA1 = GridNeighbor(idA, world_x, world_y, 1, 0);
+ int idB0 = GridNeighbor(idA, world_x, world_y, -1, -1);
+ int idB1 = GridNeighbor(idA, world_x, world_y, 1, -1);
+ cPopulationCell & cellA = population->GetCell(idA);
+ cPopulationCell & cellB = population->GetCell(idB);
+ tList<cPopulationCell> & cellA_list = cellA.ConnectionList();
+ tList<cPopulationCell> & cellB_list = cellB.ConnectionList();
+ cellA_list.Remove(&population->GetCell(idB));
+ cellA_list.Remove(&population->GetCell(idB0));
+ cellA_list.Remove(&population->GetCell(idB1));
+ cellB_list.Remove(&population->GetCell(idA));
+ cellB_list.Remove(&population->GetCell(idA0));
+ cellB_list.Remove(&population->GetCell(idA1));
+ }
+ }
+ };
+
+ ///// join_grid_col /////
+
+ /**
+ * Join the connections between cells along a column in an avida grid.
+ * Arguments:
+ * col_id: indicates the number of columns to the left of the joining.
+ * default (or -1) = join population halves.
+ * min_row: First row to start joining from
+ * default = 0
+ * max_row: Last row to join to
+ * default (or -1) = last row in population.
+ **/
+
+
+ class cEvent_join_grid_col : public cPopulationEvent {
+ private:
+ int col_id;
+ int min_row;
+ int max_row;
+ public:
+ const cString GetName() const { return "join_grid_col"; }
+ const cString GetDescription() const { return "join_grid_col [int col_id=-1] [int min_row=0] [int max_row=-1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") col_id=-1; else col_id=args.PopWord().AsInt();
+ if (args == "") min_row=0; else min_row=args.PopWord().AsInt();
+ if (args == "") max_row=-1; else max_row=args.PopWord().AsInt();
+ }
+ ///// join_grid_col /////
+ void Process(){
+ const int world_x = population->GetWorldX();
+ const int world_y = population->GetWorldY();
+ if (col_id == -1) col_id = world_x / 2;
+ if (max_row == -1) max_row = world_y;
+ if (col_id < 0 || col_id >= world_x) {
+ cerr << "Event Error: Column ID " << col_id
+ << " out of range for join_grid_col" << endl;
+ return;
+ }
+ // Loop through all of the rows and make the cut on each...
+ for (int row_id = min_row; row_id < max_row; row_id++) {
+ int idA = row_id * world_x + col_id;
+ int idB = GridNeighbor(idA, world_x, world_y, -1, 0);
+ cPopulationCell & cellA = population->GetCell(idA);
+ cPopulationCell & cellB = population->GetCell(idB);
+ cPopulationCell & cellA0 =
+ population->GetCell(GridNeighbor(idA, world_x, world_y, 0, -1));
+ cPopulationCell & cellA1 =
+ population->GetCell(GridNeighbor(idA, world_x, world_y, 0, 1));
+ cPopulationCell & cellB0 =
+ population->GetCell(GridNeighbor(idA, world_x, world_y, -1, -1));
+ cPopulationCell & cellB1 =
+ population->GetCell(GridNeighbor(idA, world_x, world_y, -1, 1));
+ tList<cPopulationCell> & cellA_list = cellA.ConnectionList();
+ tList<cPopulationCell> & cellB_list = cellB.ConnectionList();
+ if (cellA_list.FindPtr(&cellB) == NULL) cellA_list.Push(&cellB);
+ if (cellA_list.FindPtr(&cellB0) == NULL) cellA_list.Push(&cellB0);
+ if (cellA_list.FindPtr(&cellB1) == NULL) cellA_list.Push(&cellB1);
+ if (cellB_list.FindPtr(&cellA) == NULL) cellB_list.Push(&cellA);
+ if (cellB_list.FindPtr(&cellA0) == NULL) cellB_list.Push(&cellA0);
+ if (cellB_list.FindPtr(&cellA1) == NULL) cellB_list.Push(&cellA1);
+ }
+ }
+ };
+
+ ///// join_grid_row /////
+
+ /**
+ * Remove the connections between cells along a column in an avida grid.
+ * Arguments:
+ * row_id: indicates the number of rows abovef the cut.
+ * default (or -1) = cut population in half
+ * min_col: First row to start cutting from
+ * default = 0
+ * max_col: Last row to cut to
+ * default (or -1) = last row in population.
+ **/
+
+
+ class cEvent_join_grid_row : public cPopulationEvent {
+ private:
+ int row_id;
+ int min_col;
+ int max_col;
+ public:
+ const cString GetName() const { return "join_grid_row"; }
+ const cString GetDescription() const { return "join_grid_row [int row_id=-1] [int min_col=0] [int max_col=-1]"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ if (args == "") row_id=-1; else row_id=args.PopWord().AsInt();
+ if (args == "") min_col=0; else min_col=args.PopWord().AsInt();
+ if (args == "") max_col=-1; else max_col=args.PopWord().AsInt();
+ }
+ ///// join_grid_row /////
+ void Process(){
+ const int world_x = population->GetWorldX();
+ const int world_y = population->GetWorldY();
+ if (row_id == -1) row_id = world_y / 2;
+ if (max_col == -1) max_col = world_x;
+ if (row_id < 0 || row_id >= world_y) {
+ cerr << "Event Error: Row ID " << row_id
+ << " out of range for join_grid_row" << endl;
+ return;
+ }
+ // Loop through all of the cols and make the cut on each...
+ for (int col_id = min_col; col_id < max_col; col_id++) {
+ int idA = row_id * world_x + col_id;
+ int idB = GridNeighbor(idA, world_x, world_y, 0, -1);
+ cPopulationCell & cellA = population->GetCell(idA);
+ cPopulationCell & cellB = population->GetCell(idB);
+ cPopulationCell & cellA0 =
+ population->GetCell(GridNeighbor(idA, world_x, world_y, -1, 0));
+ cPopulationCell & cellA1 =
+ population->GetCell(GridNeighbor(idA, world_x, world_y, 1, 0));
+ cPopulationCell & cellB0 =
+ population->GetCell(GridNeighbor(idA, world_x, world_y, -1, -1));
+ cPopulationCell & cellB1 =
+ population->GetCell(GridNeighbor(idA, world_x, world_y, 1, -1));
+ tList<cPopulationCell> & cellA_list = cellA.ConnectionList();
+ tList<cPopulationCell> & cellB_list = cellB.ConnectionList();
+ if (cellA_list.FindPtr(&cellB) == NULL) cellA_list.Push(&cellB);
+ if (cellA_list.FindPtr(&cellB0) == NULL) cellA_list.Push(&cellB0);
+ if (cellA_list.FindPtr(&cellB1) == NULL) cellA_list.Push(&cellB1);
+ if (cellB_list.FindPtr(&cellA) == NULL) cellB_list.Push(&cellA);
+ if (cellB_list.FindPtr(&cellA0) == NULL) cellB_list.Push(&cellA0);
+ if (cellB_list.FindPtr(&cellA1) == NULL) cellB_list.Push(&cellA1);
+ }
+ }
+ };
+
+ ///// connect_cells /////
+
+ /**
+ * Connects a pair of specified cells.
+ * Arguments:
+ * cellA_x, cellA_y, cellB_x, cellB_y
+ **/
+
+
+ class cEvent_connect_cells : public cPopulationEvent {
+ private:
+ int cellA_x;
+ int cellA_y;
+ int cellB_x;
+ int cellB_y;
+ public:
+ const cString GetName() const { return "connect_cells"; }
+ const cString GetDescription() const { return "connect_cells <int cellA_x> <int cellA_y> <int cellB_x> <int cellB_y>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ cellA_x = args.PopWord().AsInt();
+ cellA_y = args.PopWord().AsInt();
+ cellB_x = args.PopWord().AsInt();
+ cellB_y = args.PopWord().AsInt();
+ }
+ ///// connect_cells /////
+ void Process(){
+ const int world_x = population->GetWorldX();
+ const int world_y = population->GetWorldY();
+ if (cellA_x < 0 || cellA_x >= world_x ||
+ cellA_y < 0 || cellA_y >= world_y ||
+ cellB_x < 0 || cellB_x >= world_x ||
+ cellB_y < 0 || cellB_y >= world_y) {
+ cerr << "Event 'connect_cells' cell out of range." << endl;
+ return;
+ }
+ int idA = cellA_y * world_x + cellA_x;
+ int idB = cellB_y * world_x + cellB_x;
+ cPopulationCell & cellA = population->GetCell(idA);
+ cPopulationCell & cellB = population->GetCell(idB);
+ tList<cPopulationCell> & cellA_list = cellA.ConnectionList();
+ tList<cPopulationCell> & cellB_list = cellB.ConnectionList();
+ cellA_list.PushRear(&cellB);
+ cellB_list.PushRear(&cellA);
+ }
+ };
+
+ ///// disconnect_cells /////
+
+ /**
+ * Connects a pair of specified cells.
+ * Arguments:
+ * cellA_x, cellA_y, cellB_x, cellB_y
+ **/
+
+
+ class cEvent_disconnect_cells : public cPopulationEvent {
+ private:
+ int cellA_x;
+ int cellA_y;
+ int cellB_x;
+ int cellB_y;
+ public:
+ const cString GetName() const { return "disconnect_cells"; }
+ const cString GetDescription() const { return "disconnect_cells <int cellA_x> <int cellA_y> <int cellB_x> <int cellB_y>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ cellA_x = args.PopWord().AsInt();
+ cellA_y = args.PopWord().AsInt();
+ cellB_x = args.PopWord().AsInt();
+ cellB_y = args.PopWord().AsInt();
+ }
+ ///// disconnect_cells /////
+ void Process(){
+ const int world_x = population->GetWorldX();
+ const int world_y = population->GetWorldY();
+ if (cellA_x < 0 || cellA_x >= world_x ||
+ cellA_y < 0 || cellA_y >= world_y ||
+ cellB_x < 0 || cellB_x >= world_x ||
+ cellB_y < 0 || cellB_y >= world_y) {
+ cerr << "Event 'connect_cells' cell out of range." << endl;
+ return;
+ }
+ int idA = cellA_y * world_x + cellA_x;
+ int idB = cellB_y * world_x + cellB_x;
+ cPopulationCell & cellA = population->GetCell(idA);
+ cPopulationCell & cellB = population->GetCell(idB);
+ tList<cPopulationCell> & cellA_list = cellA.ConnectionList();
+ tList<cPopulationCell> & cellB_list = cellB.ConnectionList();
+ cellA_list.Remove(&cellB);
+ cellB_list.Remove(&cellA);
+ }
+ };
+
+ ///// inject_resource /////
+
+ /**
+ * Inject (add) a specified amount of a specified resource.
+ **/
+
+
+ class cEvent_inject_resource : public cPopulationEvent {
+ private:
+ cString res_name;
+ double res_count;
+ public:
+ const cString GetName() const { return "inject_resource"; }
+ const cString GetDescription() const { return "inject_resource <cString res_name> <double res_count>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ res_name = args.PopWord();
+ res_count = args.PopWord().AsDouble();
+ }
+ ///// inject_resource /////
+ void Process(){
+ cResourceLib & res_lib = population->GetEnvironment().GetResourceLib();
+ int res_id = res_lib.GetResource(res_name)->GetID();
+ population->UpdateResource(res_id, res_count);
+ }
+ };
+
+ ///// set_resource /////
+
+ /**
+ * Set the resource amount to a specific level
+ **/
+
+
+ class cEvent_set_resource : public cPopulationEvent {
+ private:
+ cString res_name;
+ double res_count;
+ public:
+ const cString GetName() const { return "set_resource"; }
+ const cString GetDescription() const { return "set_resource <cString res_name> <double res_count>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ res_name = args.PopWord();
+ res_count = args.PopWord().AsDouble();
+ }
+ ///// set_resource /////
+ void Process(){
+ cResourceLib & res_lib = population->GetEnvironment().GetResourceLib();
+ cResource * found_resource = res_lib.GetResource(res_name);
+ if (found_resource != NULL) {
+ population->SetResource(found_resource->GetID(), res_count);
+ }
+ }
+ };
+
+ ///// inject_scaled_resource /////
+
+ /**
+ * Inject (add) a specified amount of a specified resource, scaled by
+ * the current average merit divided by the average time slice.
+ **/
+
+
+ class cEvent_inject_scaled_resource : public cPopulationEvent {
+ private:
+ cString res_name;
+ double res_count;
+ public:
+ const cString GetName() const { return "inject_scaled_resource"; }
+ const cString GetDescription() const { return "inject_scaled_resource <cString res_name> <double res_count>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ res_name = args.PopWord();
+ res_count = args.PopWord().AsDouble();
+ }
+ ///// inject_scaled_resource /////
+ void Process(){
+ double ave_merit = population->GetStats().SumMerit().Average();
+ if ( ave_merit <= 0 )
+ ave_merit = 1; // make sure that we don't get NAN's or negative numbers
+ ave_merit /= cConfig::GetAveTimeslice();
+ cResourceLib & res_lib = population->GetEnvironment().GetResourceLib();
+ int res_id = res_lib.GetResource(res_name)->GetID();
+ population->UpdateResource(res_id, res_count/ave_merit);
+ }
+ };
+
+
+ ///// outflow_scaled_resource /////
+
+ /**
+ * Removes a specified percentage of a specified resource, scaled by
+ * the current average merit divided by the average time slice.
+ **/
+ class cEvent_outflow_scaled_resource : public cPopulationEvent {
+ private:
+ cString res_name;
+ double res_perc;
+ public:
+ const cString GetName() const { return "outflow_scaled_resource"; }
+ const cString GetDescription() const { return "outflow_scaled_resource <cString res_name> <double res_perc>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ res_name = args.PopWord();
+ res_perc = args.PopWord().AsDouble();
+ }
+ void Process()
+ {
+ double ave_merit = population->GetStats().SumMerit().Average();
+ if ( ave_merit <= 0 )
+ ave_merit = 1; // make sure that we don't get NAN's or negative numbers
+ ave_merit /= cConfig::GetAveTimeslice();
+ cResourceLib & res_lib = population->GetEnvironment().GetResourceLib();
+ int res_id = res_lib.GetResource(res_name)->GetID();
+ double res_level = population->GetResource(res_id);
+ // a quick calculation shows that this formula guarantees that
+ // the equilibrium level when resource is not used is independent
+ // of the average merit
+ double scaled_perc = 1/(1+ave_merit*(1-res_perc)/res_perc);
+ res_level -= res_level*scaled_perc;
+ population->SetResource(res_id, res_level);
+ }
+ };
+
+
+ ///// set_reaction_value /////
+
+ /**
+ * Set the value associated with a reaction to a specific level
+ **/
+ class cEvent_set_reaction_value : public cPopulationEvent {
+ private:
+ cString reaction_name;
+ double reaction_value;
+ public:
+ const cString GetName() const { return "set_reaction_value"; }
+ const cString GetDescription() const { return "set_reaction_value <cString reaction_name> <double reaction_value>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ reaction_name = args.PopWord();
+ reaction_value = args.PopWord().AsDouble();
+ }
+ void Process()
+ {
+ population->GetEnvironment().SetReactionValue(reaction_name, reaction_value);
+ }
+ };
+
+
+ ///// set_reaction_value_mult /////
+
+ /**
+ * Change the value of the reaction by multiplying it with the imput number
+ **/
+ class cEvent_set_reaction_value_mult : public cPopulationEvent {
+ private:
+ cString reaction_name;
+ double value_mult;
+ public:
+ const cString GetName() const { return "set_reaction_value_mult"; }
+ const cString GetDescription() const { return "set_reaction_value_mult <cString reaction_name> <double value_mult>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ reaction_name = args.PopWord();
+ value_mult = args.PopWord().AsDouble();
+ }
+ void Process()
+ {
+ population->GetEnvironment().SetReactionValueMult(reaction_name, value_mult);
+ }
+ };
+
+
+ ///// set_reaction_inst /////
+
+ /**
+ * Change the instruction triggered by the task
+ **/
+ class cEvent_set_reaction_inst : public cPopulationEvent {
+ private:
+ cString reaction_name;
+ cString inst_name;
+ public:
+ const cString GetName() const { return "set_reaction_inst"; }
+ const cString GetDescription() const { return "set_reaction_inst <cString reaction_name> <cString inst_name>"; }
+
+ void Configure(const cString& in_args)
+ {
+ m_args = in_args;
+ cString args(in_args);
+ reaction_name = args.PopWord();
+ inst_name = args.PopWord();
+ }
+ void Process()
+ {
+ population->GetEnvironment().SetReactionInst(reaction_name, inst_name);
+ }
+ };
+
+}
+
/////////////////
-// cPopulationEventFactory
+// cEvent_Factory
/////////////////
-cPopulationEventFactory::cPopulationEventFactory( cPopulation *pop )
- : m_population( pop )
+cPopulationEventFactory::cPopulationEventFactory(cPopulation* pop) : m_population(pop)
{
+ using namespace nPopulation;
+ Register<cEvent_exit>("exit");
+ Register<cEvent_exit_if_generation_greater_than>("exit_if_generation_greater_than");
+ Register<cEvent_exit_if_update_greater_than>("exit_if_update_greater_than");
+ Register<cEvent_exit_if_ave_lineage_label_smaller>("exit_if_ave_lineage_label_smaller");
+ Register<cEvent_exit_if_ave_lineage_label_larger>("exit_if_ave_lineage_label_larger");
+ Register<cEvent_echo>("echo");
+ Register<cEvent_print_data>("print_data");
+ Register<cEvent_print_average_data>("print_average_data");
+ Register<cEvent_print_error_data>("print_error_data");
+ Register<cEvent_print_variance_data>("print_variance_data");
+ Register<cEvent_print_dominant_data>("print_dominant_data");
+ Register<cEvent_print_stats_data>("print_stats_data");
+ Register<cEvent_print_count_data>("print_count_data");
+ Register<cEvent_print_totals_data>("print_totals_data");
+ Register<cEvent_print_tasks_data>("print_tasks_data");
+ Register<cEvent_print_tasks_exe_data>("print_tasks_exe_data");
+ Register<cEvent_print_resource_data>("print_resource_data");
+ Register<cEvent_print_time_data>("print_time_data");
+ Register<cEvent_print_mutation_data>("print_mutation_data");
+ Register<cEvent_print_mutation_rate_data>("print_mutation_rate_data");
+ Register<cEvent_print_divide_mut_data>("print_divide_mut_data");
+ Register<cEvent_print_dom_parasite_data>("print_dom_parasite_data");
+ Register<cEvent_print_instruction_data>("print_instruction_data");
+ Register<cEvent_print_instruction_abundance_histogram>("print_instruction_abundance_histogram");
+ Register<cEvent_print_depth_histogram>("print_depth_histogram");
+ Register<cEvent_print_genotype_abundance_histogram>("print_genotype_abundance_histogram");
+ Register<cEvent_print_species_abundance_histogram>("print_species_abundance_histogram");
+ Register<cEvent_print_lineage_totals>("print_lineage_totals");
+ Register<cEvent_print_lineage_counts>("print_lineage_counts");
+ Register<cEvent_print_dom>("print_dom");
+ Register<cEvent_parasite_debug>("parasite_debug");
+ Register<cEvent_print_dom_parasite>("print_dom_parasite");
+ Register<cEvent_print_genotype_map>("print_genotype_map");
+ Register<cEvent_print_number_phenotypes>("print_number_phenotypes");
+ Register<cEvent_print_phenotype_status>("print_phenotype_status");
+ Register<cEvent_save_population>("save_population");
+ Register<cEvent_load_population>("load_population");
+ Register<cEvent_save_clone>("save_clone");
+ Register<cEvent_load_clone>("load_clone");
+ Register<cEvent_load_dump_file>("load_dump_file");
+ Register<cEvent_dump_pop>("dump_pop");
+ Register<cEvent_print_genotypes>("print_genotypes");
+ Register<cEvent_detail_pop>("detail_pop");
+ Register<cEvent_detail_sex_pop>("detail_sex_pop");
+ Register<cEvent_detail_parasite_pop>("detail_parasite_pop");
+ Register<cEvent_dump_historic_pop>("dump_historic_pop");
+ Register<cEvent_dump_historic_sex_pop>("dump_historic_sex_pop");
+ Register<cEvent_dump_memory>("dump_memory");
+ Register<cEvent_inject>("inject");
+ Register<cEvent_inject_all>("inject_all");
+ Register<cEvent_inject_range>("inject_range");
+ Register<cEvent_inject_sequence>("inject_sequence");
+ Register<cEvent_inject_random>("inject_random");
+ Register<cEvent_inject_range_parasite>("inject_range_parasite");
+ Register<cEvent_inject_range_pair>("inject_range_pair");
+ Register<cEvent_zero_muts>("zero_muts");
+ Register<cEvent_mod_copy_mut>("mod_copy_mut");
+ Register<cEvent_mod_div_mut>("mod_div_mut");
+ Register<cEvent_set_copy_mut>("set_copy_mut");
+ Register<cEvent_mod_point_mut>("mod_point_mut");
+ Register<cEvent_set_point_mut>("set_point_mut");
+ Register<cEvent_calc_landscape>("calc_landscape");
+ Register<cEvent_predict_w_landscape>("predict_w_landscape");
+ Register<cEvent_predict_nu_landscape>("predict_nu_landscape");
+ Register<cEvent_sample_landscape>("sample_landscape");
+ Register<cEvent_random_landscape>("random_landscape");
+ Register<cEvent_analyze_landscape>("analyze_landscape");
+ Register<cEvent_pairtest_landscape>("pairtest_landscape");
+ Register<cEvent_test_dom>("test_dom");
+ Register<cEvent_analyze_population>("analyze_population");
+ Register<cEvent_print_detailed_fitness_data>("print_detailed_fitness_data");
+ Register<cEvent_print_genetic_distance_data>("print_genetic_distance_data");
+ Register<cEvent_genetic_distance_pop_dump>("genetic_distance_pop_dump");
+ Register<cEvent_task_snapshot>("task_snapshot");
+ Register<cEvent_print_viable_tasks_data>("print_viable_tasks_data");
+ Register<cEvent_apocalypse>("apocalypse");
+ Register<cEvent_kill_rectangle>("kill_rectangle");
+ Register<cEvent_rate_kill>("rate_kill");
+ Register<cEvent_serial_transfer>("serial_transfer");
+ Register<cEvent_hillclimb>("hillclimb");
+ Register<cEvent_hillclimb_neut>("hillclimb_neut");
+ Register<cEvent_hillclimb_rand>("hillclimb_rand");
+ Register<cEvent_compete_demes>("compete_demes");
+ Register<cEvent_reset_demes>("reset_demes");
+ Register<cEvent_print_deme_stats>("print_deme_stats");
+ Register<cEvent_copy_deme>("copy_deme");
+ Register<cEvent_calc_consensus>("calc_consensus");
+ Register<cEvent_test_size_change_robustness>("test_size_change_robustness");
+ Register<cEvent_test_threads>("test_threads");
+ Register<cEvent_print_threads>("print_threads");
+ Register<cEvent_dump_fitness_grid>("dump_fitness_grid");
+ Register<cEvent_dump_genotype_grid>("dump_genotype_grid");
+ Register<cEvent_dump_task_grid>("dump_task_grid");
+ Register<cEvent_dump_donor_grid>("dump_donor_grid");
+ Register<cEvent_dump_receiver_grid>("dump_receiver_grid");
+ Register<cEvent_print_tree_depths>("print_tree_depths");
+ Register<cEvent_sever_grid_col>("sever_grid_col");
+ Register<cEvent_sever_grid_row>("sever_grid_row");
+ Register<cEvent_join_grid_col>("join_grid_col");
+ Register<cEvent_join_grid_row>("join_grid_row");
+ Register<cEvent_connect_cells>("connect_cells");
+ Register<cEvent_disconnect_cells>("disconnect_cells");
+ Register<cEvent_inject_resource>("inject_resource");
+ Register<cEvent_set_resource>("set_resource");
+ Register<cEvent_inject_scaled_resource>("inject_scaled_resource");
+ Register<cEvent_outflow_scaled_resource>("outflow_scaled_resource");
+ Register<cEvent_set_reaction_value>("set_reaction_value");
+ Register<cEvent_set_reaction_value_mult>("set_reaction_value_mult");
+ Register<cEvent_set_reaction_inst>("set_reaction_inst");
}
-
-cPopulationEventFactory::~cPopulationEventFactory()
-{
-}
-
-//******* construction of events **********//
-cEvent *
-cPopulationEventFactory::ConstructEvent( int event_enum,
- const cString & arg_list )
-{
- cPopulationEvent *event = NULL;
-
- switch (event_enum){
-
-#include "cPopulation_construct_event_auto.ci"
-
- default:
- event = NULL;
- break;
- }
-
- if( event != NULL ){
- // Have to setup the base class variables
- event->SetFactoryId( GetFactoryId() );
-
- assert( m_population != NULL );
- event->SetPopulation( m_population );
- }
- return event;
-}
-
-
-
-
Modified: trunk/source/event/population_event_factory.hh
===================================================================
--- trunk/source/event/population_event_factory.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/event/population_event_factory.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -8,26 +8,33 @@
#ifndef POPULATION_EVENT_FACTORY_HH
#define POPULATION_EVENT_FACTORY_HH
-#ifndef EVENT_FACTORY_HH
-#include "event_factory.hh"
+#ifndef TOBJECTFACTORY_H
+#include "tObjectFactory.h"
#endif
-class cEvent;
+#ifndef POPULATION_EVENT_HH
+#include "population_event.hh"
+#endif
+
class cPopulation;
class cString;
-class cPopulationEventFactory : public cEventFactory {
+class cPopulationEventFactory : public tObjectFactory<cEvent ()> {
private:
cPopulation *m_population;
-public:
- // event enums
-#include "cPopulation_enums_auto.ci"
+public:
+ cPopulationEventFactory(cPopulation* pop);
+ ~cPopulationEventFactory() { ; }
- cPopulationEventFactory( cPopulation *pop );
- ~cPopulationEventFactory();
-
- int EventNameToEnum(const cString & name) const;
- cEvent * ConstructEvent(int event_enum, const cString & args );
+ cEvent* Create(const cString& key)
+ {
+ cPopulationEvent* event = static_cast<cPopulationEvent*>(this->tObjectFactory<cEvent ()>::Create(key));
+ if( event != NULL ){
+ event->SetFactoryId( GetFactoryId() );
+ event->SetPopulation( m_population );
+ }
+ return event;
+ }
};
#endif
Modified: trunk/source/main/analyze.cc
===================================================================
--- trunk/source/main/analyze.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/analyze.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -183,9 +183,7 @@
void cAnalyze::LoadDetailDump(cString cur_string)
{
- cout << "WARNING: This function is DEPRICATED!" << endl
- << "It is no longer being supported; use \"LOAD\" instead." << endl;
-
+ cout << "Warning: Use of LoadDetailDump() is deprecated. Use \"LOAD\" instead." << endl;
// LOAD_DETAIL_DUMP
cString filename = cur_string.PopWord();
@@ -580,7 +578,6 @@
const cGenome & base_genome = genotype->GetGenome();
const cGenome & parent_genome = parent->GetGenome();
cGenome mod_genome(base_genome);
- double base_fitness = genotype->GetFitness();
// Loop through all the lines of code, testing all mutations ...
tArray<double> test_fitness(num_insts);
@@ -642,11 +639,11 @@
// Calculate entropy ...
double this_entropy = 0.0;
- this_entropy -= (1.0-mut_rate)*log(1.0-mut_rate)/log((double) num_insts);
+ this_entropy -= (1.0 - mut_rate) * log(1.0 - mut_rate) / log(static_cast<double>(num_insts));
for (int i = 0; i < num_insts; i ++) {
if (i == parent_inst) { continue; }
prob[i] = prob[i] * mut_rate;
- this_entropy += prob[i] * log((double) 1.0/prob[i]) / log ((double) num_insts);
+ this_entropy += prob[i] * log(static_cast<double>(1.0/prob[i])) / log (static_cast<double>(num_insts));
}
entropy += this_entropy;
@@ -2935,10 +2932,8 @@
cAnalyzeGenotype * genotype = NULL;
while ((genotype = batch_it.Next()) != NULL) {
cLandscape landscape(genotype->GetGenome(), inst_set);
- if (num_test == 0) landscape.Process(dist);
- else int num_found =
- landscape.RandomProcess(num_test,dist,num_test,num_test*2);
- // fp << genotype->GetName() << " ";
+ if (num_test == 0) landscape.Process(dist);
+ else landscape.RandomProcess(num_test,dist,num_test,num_test*2);
landscape.PrintStats(fp);
}
}
@@ -4618,7 +4613,6 @@
return;
}
cAnalyzeGenotype * child_genotype = NULL;
- const int num_insts = inst_set.GetSize();
double I_P_E; // Information of parent about environment
double H_P_E = AnalyzeEntropy(parent_genotype, mu);
I_P_E = parent_genotype->GetLength() - H_P_E;
@@ -4865,7 +4859,7 @@
// Make sure we have everything we need.
if (batch[cur_batch].IsAligned() == false) {
- cout << " ERROR: sequences not aligned." << endl;
+ cout << " Error: sequences not aligned." << endl;
return;
}
@@ -5626,8 +5620,7 @@
for (int line_num = 0; line_num < seq_length; line_num ++)
for (int inst_num = 0; inst_num < num_insts; inst_num ++)
inst_stat(line_num, inst_num) = 0;
-
- int organism_index = 0;
+
int num_cpus = 0;
int actural_samples = 0;
while (genotype != NULL) {
Modified: trunk/source/main/avida.cc
===================================================================
--- trunk/source/main/avida.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/avida.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -65,16 +65,7 @@
cPopulationInterface &test_interface )
{
// Build the instruction set.
- if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL) {
- environment.GetInstSet().SetInstLib(cHardwareCPU::GetInstLib());
- cHardwareUtil::LoadInstSet_CPUOriginal(cConfig::GetInstFilename(),
- environment.GetInstSet());
- }
- else if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_4STACK) {
- environment.GetInstSet().SetInstLib(cHardware4Stack::GetInstLib());
- cHardwareUtil::LoadInstSet_CPU4Stack(cConfig::GetInstFilename(),
- environment.GetInstSet());
- }
+ cHardwareUtil::LoadInstSet(cConfig::GetInstFilename(), environment.GetInstSet());
// Initialize the default environment...
if (environment.Load(cConfig::GetEnvironmentFilename()) == false) {
Modified: trunk/source/main/avida_driver_population.cc
===================================================================
--- trunk/source/main/avida_driver_population.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/avida_driver_population.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -27,6 +27,7 @@
#include "tools.hh"
#include <iostream>
+#include <iomanip>
using namespace std;
@@ -35,12 +36,9 @@
/////////////////////////////
cAvidaDriver_Population::cAvidaDriver_Population(cEnvironment & environment, cChangeList * change_list)
- : population(NULL)
- , event_manager(NULL)
- , event_list(NULL)
+ : population(NULL), event_manager(NULL), event_list(NULL)
{
- // Setup Population
- cout << "Initializing Population..." << flush;
+ // Setup Population
cPopulationInterface default_interface;
default_interface.SetFun_NewHardware(&cCallbackUtil::CB_NewHardware);
default_interface.SetFun_Recycle(&cCallbackUtil::CB_RecycleHardware);
@@ -64,25 +62,19 @@
default_interface.SetFun_UpdateMerit(&cCallbackUtil::CB_UpdateMerit);
population = new cPopulation(default_interface, environment, change_list);
- cout << " ...done" << endl;
//Setup Event List
- cout<<"Initializing Event Factory Manager..."<<flush;
event_manager = new cEventFactoryManager;
cStats & stats = population->GetStats();
event_list = new cEventList( event_manager, new cAvidaTriggers(stats) );
- cout<<"...Factories..."<<flush;
-
+
// in principle, one could add more than one event factory here.
// however, this is not a good idea, because the automatic documentation
// system cannot cope with this at this point. Claus
event_manager->AddFactory(new cPopulationEventFactory(population));
- cout<<" ...done"<<endl;
- cout<<"Reading Event List File..."<<flush;
ReadEventListFile(cConfig::GetEventFilename());
- cout<<" ...done"<<endl;
-
+
// Make sure the directory 'genebank' exits!
cTools::MkDir("genebank", true);
}
@@ -94,8 +86,6 @@
void cAvidaDriver_Population::Run()
{
- // cout << "DEBUG: Turning control over to driver..." << endl;
-
assert( population != NULL );
// Process until done...
@@ -179,8 +169,6 @@
void cAvidaDriver_Population::ProcessOrganisms()
{
- // cout << "DEBUG: Running viewer-less update..." << endl;
-
// Process the update.
const int UD_size =
cConfig::GetAveTimeslice() * population->GetNumOrganisms();
@@ -199,9 +187,11 @@
// No viewer; print out status for this update....
cStats & stats = population->GetStats();
- cout << "UD: " << stats.GetUpdate() << "\t"
- << "Gen: " << stats.SumGeneration().Average() << "\t"
- << "Fit: " << stats.GetAveFitness() << "\t"
+ cout.setf(ios::left);
+ cout.setf(ios::showpoint);
+ cout << "UD: " << setw(6) << stats.GetUpdate() << " "
+ << "Gen: " << setw(9) << setprecision(7) << stats.SumGeneration().Average() << " "
+ << "Fit: " << setw(9) << setprecision(7) << stats.GetAveFitness() << " "
<< "Size: " << population->GetNumOrganisms()
<< endl;
}
Modified: trunk/source/main/config.cc
===================================================================
--- trunk/source/main/config.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/config.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -8,12 +8,11 @@
#include "config.hh"
#include "defs.hh"
+#include "event_factory_manager.hh"
#include "genesis.hh"
+#include "population_event_factory.hh"
#include "tools.hh"
-#include "cPopulation_descr.hi" // declarations and definitions
-#include "cPopulation_descr.ci" // for event documentation
-
using namespace std;
tList<cConfig::cConfigGroup> cConfig::group_list;
@@ -110,7 +109,7 @@
int cConfig::track_main_lineage;
bool cConfig::log_threshold_only;
bool cConfig::log_creatures;
-bool cConfig::log_genotypes;
+int cConfig::log_genotypes;
bool cConfig::log_threshold;
bool cConfig::log_species;
bool cConfig::log_landscape;
@@ -123,242 +122,244 @@
// Start with the Architecture variables...
cConfigGroup * arch_group = new cConfigGroup("Architecture Variables");
group_list.PushRear(arch_group);
-
+
arch_group->Add(max_updates, "-1", "MAX_UPDATES",
- "Maximum updates to run experiment (-1 = no limit)");
+ "Maximum updates to run experiment (-1 = no limit)");
arch_group->Add(max_generations, "-1", "MAX_GENERATIONS",
- "Maximum generations to run experiment (-1 = no limit)");
+ "Maximum generations to run experiment (-1 = no limit)");
arch_group->Add(end_condition_mode, "0", "END_CONDITION_MODE",
- "End run when ...\n0 = MAX_UPDATES _OR_ MAX_GENERATIONS is reached\n1 = MAX_UPDATES _AND_ MAX_GENERATIONS is reached");
+ "End run when ...\n0 = MAX_UPDATES _OR_ MAX_GENERATIONS is reached\n1 = MAX_UPDATES _AND_ MAX_GENERATIONS is reached");
arch_group->Add(world_x, "100", "WORLD-X",
- "Width of the Avida world");
+ "Width of the Avida world");
arch_group->Add(world_y, "100", "WORLD-Y",
- "Height of the Avida world");
+ "Height of the Avida world");
arch_group->Add(world_geometry, "2", "WORLD_GEOMETRY",
- "1 = Bounded Grid\n2 = Torus");
+ "1 = Bounded Grid\n2 = Torus");
arch_group->Add(num_demes, "0", "NUM_DEMES",
- "Number of independed groups in the population; 0=off");
+ "Number of independed groups in the population; 0=off");
arch_group->Add(rand_seed, "0", "RANDOM_SEED",
- "Random number seed (0 for based on time)");
+ "Random number seed (0 for based on time)");
arch_group->Add(hardware_type, "0", "HARDWARE_TYPE",
- "0 = Original CPUs\n1 = New, Stack-based CPUs");
-
+ "0 = Original CPUs\n1 = New, Stack-based CPUs");
+
// Configuration file group.
cConfigGroup * file_group = new cConfigGroup("Configuration Files");
group_list.PushRear(file_group);
-
+
file_group->Add(default_dir, DEFAULT_DIR, "DEFAULT_DIR",
- "Directory in which config files are found");
+ "Directory in which config files are found");
file_group->Add(inst_filename, "inst_set.default", "INST_SET",
- "File containing instruction set");
+ "File containing instruction set");
file_group->Add(event_filename, "events.cfg", "EVENT_FILE",
- "File containing list of events during run");
+ "File containing list of events during run");
file_group->Add(analyze_filename, "analyze.cfg", "ANALYZE_FILE",
- "File used for analysis mode");
+ "File used for analysis mode");
file_group->Add(env_filename, "environment.cfg", "ENVIRONMENT_FILE",
- "File that describes the environment");
+ "File that describes the environment");
file_group->Add(start_creature, "organism.default", "START_CREATURE",
- "Organism to seed the soup");
-
+ "Organism to seed the soup");
+
// Reproduction group.
cConfigGroup * repro_group = new cConfigGroup("Birth and Death");
group_list.PushRear(repro_group);
-
+
repro_group->Add(birth_method, "4", "BIRTH_METHOD",
- "0 = Replace random organism in neighborhood\n1 = Replace oldest organism in neighborhood\n2 = Replace largest Age/Merit in neighborhood\n3 = Place only in empty cells in neighborhood\n4 = Replace random from population (Mass Action)\n5 = Replace oldest in entire population (like Tierra)\n6 = Replace random within deme");
+ "0 = Replace random organism in neighborhood\n1 = Replace oldest organism in neighborhood\n2 = Replace largest Age/Merit in neighborhood\n3 = Place only in empty cells in neighborhood\n4 = Replace random from population (Mass Action)\n5 = Replace oldest in entire population (like Tierra)\n6 = Replace random within deme");
repro_group->Add(prefer_empty, "1", "PREFER_EMPTY",
- "Are empty cells given preference in offsping placement?");
+ "Are empty cells given preference in offsping placement?");
repro_group->Add(death_method, "0", "DEATH_METHOD",
- "0 = Never die of old age.\n1 = Die when inst executed = AGE_LIMIT (+deviation)\n2 = Die when inst executed = length*AGE_LIMIT (+dev)");
+ "0 = Never die of old age.\n1 = Die when inst executed = AGE_LIMIT (+deviation)\n2 = Die when inst executed = length*AGE_LIMIT (+dev)");
repro_group->Add(age_limit, "5000", "AGE_LIMIT",
- "Modifies DEATH_METHOD");
+ "Modifies DEATH_METHOD");
repro_group->Add(age_deviation, "0", "AGE_DEVIATION",
- "Creates a distribution around AGE_LIMIT");
+ "Creates a distribution around AGE_LIMIT");
repro_group->Add(alloc_method, "0", "ALLOC_METHOD",
- "0 = Allocated space is set to default instruction.\n1 = Set to section of dead genome (Necrophilia)\n2 = Allocated space is set to random instruction.");
+ "0 = Allocated space is set to default instruction.\n1 = Set to section of dead genome (Necrophilia)\n2 = Allocated space is set to random instruction.");
repro_group->Add(divide_method, "1", "DIVIDE_METHOD",
- "0 = Divide leaves state of mother untouched.\n1 = Divide resets state of mother (after the divide, we have 2 children)\n2 = Divide resets state of current thread only(does not touch possible parasite threads)");
+ "0 = Divide leaves state of mother untouched.\n1 = Divide resets state of mother (after the divide, we have 2 children)\n2 = Divide resets state of current thread only(does not touch possible parasite threads)");
repro_group->Add(generation_inc_method, "1", "GENERATION_INC_METHOD",
- "0 = Only the generation of the child is\n increased on divide.\n1 = Both the generation of the mother and child are\n increased on divide (good with DIVIDE_METHOD 1).");
+ "0 = Only the generation of the child is\n increased on divide.\n1 = Both the generation of the mother and child are\n increased on divide (good with DIVIDE_METHOD 1).");
repro_group->Add(recomb_prob, "1", "RECOMBINATION_PROB",
- "probability that recombination will happen when div-sex is used");
+ "probability that recombination will happen when div-sex is used");
repro_group->Add(num_modules, "0", "MODULE_NUM",
- "number of modules in the genome");
+ "number of modules in the genome");
repro_group->Add(cont_rec_regs, "1", "CONT_REC_REGS",
- "are (modular) recombination regions continuous");
+ "are (modular) recombination regions continuous");
repro_group->Add(corespond_rec_regs, "1", "CORESPOND_REC_REGS",
- "are (modular) recombination regions swapped at random or with corresponding ones, by location");
+ "are (modular) recombination regions swapped at random or with corresponding ones, by location");
repro_group->Add(two_fold_cost_sex, "0", "TWO_FOLD_COST_SEX",
- "1 = only one recombined offspring is born.\n2 = both offspring are born");
+ "1 = only one recombined offspring is born.\n2 = both offspring are born");
repro_group->Add(same_length_sex, "0", "SAME_LENGTH_SEX",
- "0 = recombine with any genome\n1 = only recombine w/ same length");
-
-
+ "0 = recombine with any genome\n1 = only recombine w/ same length");
+
+
// Divide Restrictions Group.
cConfigGroup * div_group = new cConfigGroup("Divide Restrictions");
group_list.PushRear(div_group);
-
+
div_group->Add(child_size_range, "2.0", "CHILD_SIZE_RANGE",
- "Maximal differential between child and parent sizes.");
+ "Maximal differential between child and parent sizes.");
div_group->Add(min_copied_lines, "0.5", "MIN_COPIED_LINES",
- "Code fraction which must be copied before divide.");
+ "Code fraction which must be copied before divide.");
div_group->Add(min_exe_lines, "0.5", "MIN_EXE_LINES",
- "Code fraction which must be executed before divide.");
+ "Code fraction which must be executed before divide.");
div_group->Add(require_allocate, "1", "REQUIRE_ALLOCATE",
- "Is a an allocate required before a divide? (0/1)");
+ "Is a an allocate required before a divide? (0/1)");
div_group->Add(required_task, "-1", "REQUIRED_TASK",
- "Task ID required for successful divide.");
+ "Task ID required for successful divide.");
div_group->Add(immunity_task, "-1", "IMMUNITY_TASK",
+ "Task providing immunity from the required task.");
+ div_group->Add(immunity_task, "-1", "IMMUNITY_TASK",
"Task providing immunity from the required task.");
div_group->Add(required_reaction, "-1", "REQUIRED_REACTION",
- "Reaction ID required for successful divide.");
+ "Reaction ID required for successful divide.");
div_group->Add(die_prob, "0", "DIE_PROB",
- "probability of death when 'die' instruction is executed");
-
-
-
+ "probability of death when 'die' instruction is executed");
+
+
+
// Mutations Group
cConfigGroup * muts_group = new cConfigGroup("Mutations");
group_list.PushRear(muts_group);
-
+
muts_group->Add(point_mut_prob, "0.0", "POINT_MUT_PROB",
- "Mutation rate (per-location per update)");
+ "Mutation rate (per-location per update)");
muts_group->Add(copy_mut_prob, "0.0075", "COPY_MUT_PROB",
- "Mutation rate (per copy)");
+ "Mutation rate (per copy)");
muts_group->Add(ins_mut_prob, "0.0", "INS_MUT_PROB",
- "Insertion rate (per site, applied on divide)");
+ "Insertion rate (per site, applied on divide)");
muts_group->Add(del_mut_prob, "0.0", "DEL_MUT_PROB",
- "Deletion rate (per site, applied on divide)");
+ "Deletion rate (per site, applied on divide)");
muts_group->Add(div_mut_prob, "0.0", "DIV_MUT_PROB",
- "Mutation rate (per site, applied on divide)");
+ "Mutation rate (per site, applied on divide)");
muts_group->Add(divide_mut_prob, "0.0", "DIVIDE_MUT_PROB",
- "Mutation rate (per divide)");
+ "Mutation rate (per divide)");
muts_group->Add(divide_ins_prob, "0.05", "DIVIDE_INS_PROB",
- "Insertion rate (per divide)");
+ "Insertion rate (per divide)");
muts_group->Add(divide_del_prob, "0.05", "DIVIDE_DEL_PROB",
- "Deletion rate (per divide)");
+ "Deletion rate (per divide)");
muts_group->Add(parent_mut_prob, "0.0", "PARENT_MUT_PROB",
- "Per-site, in parent, on divide");
+ "Per-site, in parent, on divide");
muts_group->Add(special_mut_line, "-1", "SPECIAL_MUT_LINE",
"If this is >= 0, ONLY this line is mutated");
-
-
+
+
// Mutation reversions group
cConfigGroup * rev_group = new cConfigGroup("Mutation Reversion");
rev_group->SetComment("These slow down avida a lot, and should be set to 0.0 normally.");
group_list.PushRear(rev_group);
-
+
rev_group->Add(revert_fatal, "0.0", "REVERT_FATAL",
- "Should any mutations be reverted on birth?");
+ "Should any mutations be reverted on birth?");
rev_group->Add(revert_neg, "0.0", "REVERT_DETRIMENTAL",
- " 0.0 to 1.0; Probability of reversion.");
+ " 0.0 to 1.0; Probability of reversion.");
rev_group->Add(revert_neut, "0.0", "REVERT_NEUTRAL",
- "");
+ "");
rev_group->Add(revert_pos, "0.0", "REVERT_BENEFICIAL",
- "");
+ "");
rev_group->Add(sterilize_fatal, "0.0", "STERILIZE_FATAL",
- "Should any mutations clear (kill) the organism?");
+ "Should any mutations clear (kill) the organism?");
rev_group->Add(sterilize_neg, "0.0", "STERILIZE_DETRIMENTAL",
- " 0.0 to 1.0; Probability of reset.");
+ " 0.0 to 1.0; Probability of reset.");
rev_group->Add(sterilize_neut, "0.0", "STERILIZE_NEUTRAL",
- "");
+ "");
rev_group->Add(sterilize_pos, "0.0", "STERILIZE_BENEFICIAL",
- "");
+ "");
rev_group->Add(fail_implicit, "0", "FAIL_IMPLICIT",
- "Should copies that failed *not* due to mutations\nbe eliminated?");
-
+ "Should copies that failed *not* due to mutations\nbe eliminated?");
+
// Time slicing group
cConfigGroup * time_group = new cConfigGroup("Time Slicing");
group_list.PushRear(time_group);
-
+
time_group->Add(ave_time_slice, "30", "AVE_TIME_SLICE",
- "Ave number of insts per org per update");
+ "Ave number of insts per org per update");
time_group->Add(slicing_method, "2", "SLICING_METHOD",
- "0 = CONSTANT: all organisms get default...\n1 = PROBABILISTIC: Run _prob_ proportional to merit.\n2 = INTEGRATED: Perfectly integrated deterministic.");
+ "0 = CONSTANT: all organisms get default...\n1 = PROBABILISTIC: Run _prob_ proportional to merit.\n2 = INTEGRATED: Perfectly integrated deterministic.");
time_group->Add(size_merit_method, "0", "SIZE_MERIT_METHOD",
- "0 = off (merit is independent of size)\n1 = Merit proportional to copied size\n2 = Merit prop. to executed size\n3 = Merit prop. to full size\n4 = Merit prop. to min of executed or copied size\n5 = Merit prop. to sqrt of the minimum size");
+ "0 = off (merit is independent of size)\n1 = Merit proportional to copied size\n2 = Merit prop. to executed size\n3 = Merit prop. to full size\n4 = Merit prop. to min of executed or copied size\n5 = Merit prop. to sqrt of the minimum size");
time_group->Add(task_merit_method, "1", "TASK_MERIT_METHOD",
- "0 = No task bonuses\n1 = Bonus just equals the task bonus");
+ "0 = No task bonuses\n1 = Bonus just equals the task bonus");
time_group->Add(max_cpu_threads, "1", "MAX_CPU_THREADS",
- "Number of Threads a CPU can spawn");
+ "Number of Threads a CPU can spawn");
time_group->Add(thread_slicing_method, "0", "THREAD_SLICING_METHOD",
- "Formula for and organism's thread slicing -> 1 + (num_organism_threads-1) * THREAD_SLICING_METHOD.\n0 = One thread executed per time slice.\n1 = All threads executed each time slice.\n");
+ "Formula for and organism's thread slicing -> 1 + (num_organism_threads-1) * THREAD_SLICING_METHOD.\n0 = One thread executed per time slice.\n1 = All threads executed each time slice.\n");
time_group->Add(max_label_exe_size, "1", "MAX_LABEL_EXE_SIZE",
- "Max nops marked as executed when labels are used");
+ "Max nops marked as executed when labels are used");
time_group->Add(base_size_merit, "100", "BASE_SIZE_MERIT",
- "Base merit when size is *not* used");
+ "Base merit when size is *not* used");
time_group->Add(default_bonus, "1", "DEFAULT_BONUS",
- "The bonus an organism gets before it has completed any tasks");
+ "The bonus an organism gets before it has completed any tasks");
time_group->Add(merit_time, "0", "MERIT_TIME",
- "0 = Merit Calculated when task completed\n1 = Merit Calculated on Divide");
+ "0 = Merit Calculated when task completed\n1 = Merit Calculated on Divide");
time_group->Add(merit_given, "0.0", "MERIT_GIVEN",
- "Fraction of merit donated with 'donate' command");
+ "Fraction of merit donated with 'donate' command");
time_group->Add(merit_received, "0.0", "MERIT_RECEIVED",
- "Multiplier of merit given with 'donate' command");
+ "Multiplier of merit given with 'donate' command");
time_group->Add(max_donate_kin_distance, "-1", "MAX_DONATE_KIN_DIST",
- "Limit on distance of relation for donate; -1=no max");
+ "Limit on distance of relation for donate; -1=no max");
time_group->Add(max_donate_edit_distance, "-1", "MAX_DONATE_EDIT_DIST",
- "Limit on genetic (edit) distance for donate; -1=no max");
+ "Limit on genetic (edit) distance for donate; -1=no max");
time_group->Add(max_donates, "1000000", "MAX_DONATES",
- "Limit on number of donates organisms are allowed.");
-
-
+ "Limit on number of donates organisms are allowed.");
+
+
// Geneology group
cConfigGroup * gen_group = new cConfigGroup("Geneology");
group_list.PushRear(gen_group);
-
+
gen_group->Add(track_main_lineage, "0", "TRACK_MAIN_LINEAGE",
- "Keep all ancestors of the active population?\n0=no, 1=yes, 2=yes,w/sexual population");
+ "Keep all ancestors of the active population?\n0=no, 1=yes, 2=yes,w/sexual population");
gen_group->Add(threshold, "3", "THRESHOLD",
- "Number of organisms in a genotype needed for it\n to be considered viable.");
+ "Number of organisms in a genotype needed for it\n to be considered viable.");
gen_group->Add(genotype_print, "0", "GENOTYPE_PRINT",
- "0/1 (off/on) Print out all threshold genotypes?");
+ "0/1 (off/on) Print out all threshold genotypes?");
gen_group->Add(genotype_print_dom, "0", "GENOTYPE_PRINT_DOM",
- "Print out a genotype if it stays dominant for\n this many updates. (0 = off)");
+ "Print out a genotype if it stays dominant for\n this many updates. (0 = off)");
gen_group->Add(species_threshold, "2", "SPECIES_THRESHOLD",
- "max failure count for organisms to be same species");
+ "max failure count for organisms to be same species");
gen_group->Add(species_recording, "0", "SPECIES_RECORDING",
- "1 = full, 2 = limited search (parent only)");
+ "1 = full, 2 = limited search (parent only)");
gen_group->Add(species_print, "0", "SPECIES_PRINT",
- "0/1 (off/on) Print out all species?");
+ "0/1 (off/on) Print out all species?");
gen_group->Add(test_cpu_time_mod, "20", "TEST_CPU_TIME_MOD",
- "Time allocated in test CPUs (multiple of length)");
-
-
+ "Time allocated in test CPUs (multiple of length)");
+
+
// Log Files group
cConfigGroup * log_group = new cConfigGroup("Log Files");
group_list.PushRear(log_group);
-
+
log_group->Add(log_creatures, "0", "LOG_CREATURES",
- "0/1 (off/on) toggle to print file.");
+ "0/1 (off/on) toggle to print file.");
log_group->Add(log_genotypes, "0", "LOG_GENOTYPES",
- "0 = off, 1 = print ALL, 2 = print threshold ONLY.");
+ "0 = off, 1 = print ALL, 2 = print threshold ONLY.");
log_group->Add(log_threshold, "0", "LOG_THRESHOLD",
- "0/1 (off/on) toggle to print file.");
+ "0/1 (off/on) toggle to print file.");
log_group->Add(log_species, "0", "LOG_SPECIES",
- "0/1 (off/on) toggle to print file.");
+ "0/1 (off/on) toggle to print file.");
log_group->Add(log_landscape, "0", "LOG_LANDSCAPE",
- "0/1 (off/on) toggle to print file.");
-
-
+ "0/1 (off/on) toggle to print file.");
+
+
// Viewer group
cConfigGroup * view_group = new cConfigGroup("Viewer Settings");
group_list.PushRear(view_group);
-
+
view_group->Add(view_mode, "0", "VIEW_MODE",
- "Initial viewer screen");
-
+ "Initial viewer screen");
+
// Lineages group
cConfigGroup * lin_group = new cConfigGroup("Lineage");
lin_group->SetComment("NOTE: This should probably be called \"Clade\"\nThis one can slow down avida a lot. It is used to get an idea of how\noften an advantageous mutation arises, and where it goes afterwards.\nLineage creation options are. Works only when LOG_LINEAGES is set to 1.\n 0 = manual creation (on inject, use successive integers as lineage labels).\n 1 = when a child's (potential) fitness is higher than that of its parent.\n 2 = when a child's (potential) fitness is higher than max in population.\n 3 = when a child's (potential) fitness is higher than max in dom. lineage\n*and* the child is in the dominant lineage, or (2)\n 4 = when a child's (potential) fitness is higher than max in dom. lineage\n(and that of its own lineage)\n 5 = same as child's (potential) fitness is higher than that of the\n currently dominant organism, and also than that of any organism\n currently in the same lineage.\n 6 = when a child's (potential) fitness is higher th!
an any organism\n currently in the same lineage.\n 7 = when a child's (potential) fitness is higher than that of any\n organism in its line of descent");
-
+
group_list.PushRear(lin_group);
-
+
lin_group->Add(log_lineages, "0", "LOG_LINEAGES",
- "");
+ "");
lin_group->Add(lineage_creation_method, "0", "LINEAGE_CREATION_METHOD",
- "");
-
+ "");
+
}
void cConfig::Setup(cGenesis & genesis)
@@ -368,22 +369,22 @@
g_random.ResetSeed(rand_seed);
if( rand_seed != g_random.GetSeed() ) cout << " -> " << g_random.GetSeed();
cout << endl;
-
+
tListIterator<cConfigGroup> group_it(group_list);
cConfigGroup * cur_group;
while ((cur_group = group_it.Next()) != NULL) {
cur_group->LoadValues(genesis);
}
-
+
/***
- * Handle any special modifications to any of the variables now that
- * they've been loaded.
- ***/
-
+ * Handle any special modifications to any of the variables now that
+ * they've been loaded.
+ ***/
+
// The default directory should end in a '/'.
char dir_tail = default_dir[default_dir.GetSize() - 1];
if (dir_tail != '\\' && dir_tail != '/') default_dir += "/";
-
+
// Determine if any variables were set that require test CPUs to be run
// at every divide.
test_on_divide = false;
@@ -391,20 +392,20 @@
(revert_pos > 0.0) || (fail_implicit > 0)) {
test_on_divide = true;
}
-
+
test_sterilize = false;
if ((sterilize_fatal > 0.0) || (sterilize_neg > 0.0) ||
(sterilize_neut > 0.0) || (sterilize_pos > 0.0)) {
test_sterilize = true;
}
-
+
// Determine if we are only logging threshold genotypes...
log_threshold_only = false;
if (log_genotypes > 1) log_threshold_only = true;
-
+
// Warn if there are settings in the genesis file that have not been read.
genesis.WarnUnused();
-
+
// Test printing... @CAO
// PrintGenesis("genesis.test");
}
@@ -412,15 +413,15 @@
void cConfig::Setup(int argc, char * argv[])
{
/***
- * Load all of the variables from genesis.
- ***/
-
+ * Load all of the variables from genesis.
+ ***/
+
default_dir = DEFAULT_DIR;
-
+
cGenesis genesis;
genesis.SetVerbose();
ProcessConfiguration(argc, argv, genesis);
-
+
Setup(genesis);
}
@@ -428,7 +429,7 @@
{
#ifdef PLATFORM_WINDOWS
OSVERSIONINFO osVersion;
-
+
SetFileApisToOEM(); // use console character set for files
memset (&osVersion, 0, sizeof (osVersion));
osVersion.dwOSVersionInfoSize = sizeof (osVersion);
@@ -438,11 +439,11 @@
// In fact, these APIs fail on Win95 w/ rc = 120 (API only works in NT
// mode).
if (!SetConsoleCP (GetOEMCP())) // and for Console input
- cerr << "WARNING: Unable to set input character set, rc="
- << GetLastError() << endl;
+ cerr << "Warning: Unable to set input character set, rc="
+ << GetLastError() << endl;
if (!SetConsoleOutputCP (GetOEMCP())) // and for Console output
- cerr << "WARNING: Unable to set output character set, rc="
- << GetLastError() << endl;
+ cerr << "Warning: Unable to set output character set, rc="
+ << GetLastError() << endl;
}
#endif
}
@@ -450,64 +451,64 @@
void cConfig::PrintGenesis(const cString & filename)
{
ofstream fp(filename);
-
+
// Print out the generic header, including the version ID.
fp << "#############################################################################" << endl
- << "# This file includes all the basic run-time defines for avida." << endl
- << "# For more information, see doc/genesis.html" << endl
- << "#############################################################################" << endl
- << endl
- << "VERSION_ID " << AVIDA_VERSION << " # Do not change this value."
- << endl;
-
+ << "# This file includes all the basic run-time defines for avida." << endl
+ << "# For more information, see doc/genesis.html" << endl
+ << "#############################################################################" << endl
+ << endl
+ << "VERSION_ID " << VERSION << " # Do not change this value."
+ << endl;
+
// Loop through the groups, and print out all of the variables.
-
+
tListIterator<cConfigGroup> group_it(group_list);
cConfigGroup * cur_group;
while ((cur_group = group_it.Next()) != NULL) {
// Print out the group name...
fp << endl;
fp << "### " << cur_group->GetName() << " ###" << endl;
-
+
// If we have a comment about the current group, include it.
for (int i = 0; i < cur_group->GetComment().GetSize(); i++) {
fp << "# " << cur_group->GetComment().GetLine(i) << endl;
}
-
+
// Print out everything for this group...
tListIterator<cConfigEntryBase> entry_it(cur_group->GetEntries());
cConfigEntryBase * cur_entry;
-
+
// First, figure out the widest entry so we know where to put comments.
int max_width = 0;
while ((cur_entry = entry_it.Next()) != NULL) {
int cur_width = cur_entry->GetTag().GetSize() +
- cur_entry->GetDefault().GetSize() + 1;
+ cur_entry->GetDefault().GetSize() + 1;
if (cur_width > max_width) max_width = cur_width;
}
-
+
// Now, make a second pass printing everything.
entry_it.Reset();
while ((cur_entry = entry_it.Next()) != NULL) {
int cur_width = cur_entry->GetTag().GetSize() +
- cur_entry->GetDefault().GetSize() + 1;
+ cur_entry->GetDefault().GetSize() + 1;
// Print the variable and its setting...
fp << cur_entry->GetTag() << " " << cur_entry->GetDefault();
-
+
// Print some spaces before the description.
for (int i = cur_width; i < max_width; i++) fp << " ";
-
+
// Print the first line of the description.
if (cur_entry->GetDesc().GetSize() == 0) {
- fp << " # " << endl;
+ fp << " # " << endl;
} else {
- fp << " # " << cur_entry->GetDesc().GetLine(0) << endl;
+ fp << " # " << cur_entry->GetDesc().GetLine(0) << endl;
}
-
+
// Print the remaining lines of a description.
for (int i = 1; i < cur_entry->GetDesc().GetSize(); i++) {
- for (int j = 0; j < max_width; j++) fp << " ";
- fp << " # " << cur_entry->GetDesc().GetLine(i) << endl;
+ for (int j = 0; j < max_width; j++) fp << " ";
+ fp << " # " << cur_entry->GetDesc().GetLine(i) << endl;
}
}
}
@@ -537,19 +538,19 @@
{
const cString default_filename = "genesis";
genesis_filename = default_filename;
-
+
int arg_num = 1; // Argument number being looked at.
analyze_mode = false; // Initialize analyze_mode tp be off.
primitive_mode = false; // Initialize primitive_mode tp be off.
interactive_analyze = false; // Don't start analyze interactively either.
-
+
// Load all of the args into string objects for ease of access.
cString * args = new cString[argc];
for (int i = 0; i < argc; i++) args[i] = argv[i];
-
-
+
+
// -genesis option
-
+
if (argc > 1 && (args[1] == "-g" || args[1] == "-genesis")) {
if (argc < 3) {
cerr << "Need filename for genesis file used." << endl;
@@ -558,75 +559,72 @@
genesis_filename = args[2];
arg_num += 2;
}
-
-
+
+
// Open and verify the genesis file.
-
+
genesis.Open(genesis_filename);
-
+
// If we failed to open the genesis file, and we are using the default,
// try creating it.
if (genesis.IsOpen() == false && genesis_filename == default_filename) {
cerr << "Warning: Unable to find file '" << genesis_filename
- << "'. Creating." << endl;
+ << "'. Creating." << endl;
PrintGenesis(genesis_filename);
genesis.Open(genesis_filename);
}
-
+
cString version_id = genesis.ReadString("VERSION_ID", "Unknown");
- if (genesis.IsOpen() == true && version_id != AVIDA_VERSION) {
+ if (genesis.IsOpen() == true && version_id != VERSION) {
cerr << "/ WARNING WARNING WARNING WARNING WARNING \\" << endl
- << "| Using incorrect genesis file. |" << endl
- << "| Version needed = \"" << AVIDA_VERSION
- << "\". Version used = \"" << version_id() << "\" |" << endl
- << "\\ WARNING WARNING WARNING WARNING WARNING /" << endl
- << endl;
+ << "| Using incorrect genesis file. |" << endl
+ << "| Version needed = \"" << VERSION
+ << "\". Version used = \"" << version_id() << "\" |" << endl
+ << "\\ WARNING WARNING WARNING WARNING WARNING /" << endl
+ << endl;
}
-
+
// Then scan through and process the rest of the args.
-
+
while (arg_num < argc || genesis.IsOpen() == false) {
- cString cur_arg = genesis.IsOpen() ? static_cast<cString>( args[arg_num] )
- : static_cast<cString>( "--help" );
-
+ cString cur_arg = genesis.IsOpen() ? static_cast<cString>( args[arg_num] ) : static_cast<cString>( "--help" );
+
// Test against the possible inputs.
if (cur_arg == "-events" || cur_arg == "-e") {
cout << "Known events:" << endl;
- for ( int i=0; i<cEventDescrs::num_of_events; i++ ){
- cout << "----- "
- << cEventDescrs::entries[i].GetName()
- << " -----" << endl;
- cout << cEventDescrs::entries[i].GetDescription() << endl;
- }
+ // @DMB - A cleaner way of constructing the cEventFactoryManager should be created
+ cEventFactoryManager event_manager;
+ event_manager.AddFactory(new cPopulationEventFactory(NULL));
+ event_manager.PrintAllEventDescriptions();
exit(0);
}
else if (cur_arg == "--help" || cur_arg == "-help" ||
- cur_arg == "-h" || genesis.IsOpen() == false) {
+ cur_arg == "-h" || genesis.IsOpen() == false) {
cout << "Options:"<<endl
- << " -g[enesis] <filename> Set genesis file to be <filename>"<<endl
- << " -h[elp] Help on options (this listing)"<<endl
- << " -e[vents] Print a list of all known events"<< endl
- << " -s[eed] <value> Set random seed to <value>"<<endl
- << " -viewer <value> Sets Viewer to <value>"<<endl
- << " -v[ersion] Prints the version number"<<endl
- << " -set <name> <value> Overide the genesis file"<<endl
- << " -l[oad] <filename> Load a clone file"<<endl
- << " -loadpop <filename> Load a saved population file (precedence over load)"<<endl
- << " -a[nalyze] Process analyze.cfg instead of normal run."<<endl
- << " -i[nteractive] Run analyze mode interactively."
- // << " -p[rimitive] Overide viewer to be primitive."<<endl
- << endl;
-
+ << " -g[enesis] <filename> Set genesis file to be <filename>"<<endl
+ << " -h[elp] Help on options (this listing)"<<endl
+ << " -e[vents] Print a list of all known events"<< endl
+ << " -s[eed] <value> Set random seed to <value>"<<endl
+ << " -viewer <value> Sets Viewer to <value>"<<endl
+ << " -v[ersion] Prints the version number"<<endl
+ << " -set <name> <value> Overide the genesis file"<<endl
+ << " -l[oad] <filename> Load a clone file"<<endl
+ << " -loadpop <filename> Load a saved population file (precedence over load)"<<endl
+ << " -a[nalyze] Process analyze.cfg instead of normal run."<<endl
+ << " -i[nteractive] Run analyze mode interactively."
+ // << " -p[rimitive] Overide viewer to be primitive."<<endl
+ << endl;
+
exit(0);
}
else if (cur_arg == "-seed" || cur_arg == "-s") {
int in_seed = 0;
if (arg_num + 1 == argc || args[arg_num + 1][0] == '-') {
- cerr<<"Must include a number as the random seed!"<<endl;
- exit(0);
+ cerr<<"Must include a number as the random seed!"<<endl;
+ exit(0);
} else {
- arg_num++; if (arg_num < argc) cur_arg = args[arg_num];
- in_seed = cur_arg.AsInt();
+ arg_num++; if (arg_num < argc) cur_arg = args[arg_num];
+ in_seed = cur_arg.AsInt();
}
genesis.AddInput("RANDOM_SEED", in_seed);
} else if (cur_arg == "-analyze" || cur_arg == "-a") {
@@ -638,29 +636,29 @@
primitive_mode = true;
} else if (cur_arg == "-load" || cur_arg == "-l") {
if (arg_num + 1 == argc || args[arg_num + 1][0] == '-') {
- cerr<<"Must include a filename to load from"<<endl;
- exit(0);
+ cerr<<"Must include a filename to load from"<<endl;
+ exit(0);
} else {
- arg_num++; if (arg_num < argc) cur_arg = args[arg_num];
- clone_filename = cur_arg;
+ arg_num++; if (arg_num < argc) cur_arg = args[arg_num];
+ clone_filename = cur_arg;
}
} else if (cur_arg == "-loadpop" || cur_arg == "-lp") {
if (arg_num + 1 == argc || args[arg_num + 1][0] == '-') {
- cerr<<"Must include a filename to load from"<<endl;
- exit(0);
+ cerr<<"Must include a filename to load from"<<endl;
+ exit(0);
} else {
- arg_num++; if (arg_num < argc) cur_arg = args[arg_num];
- load_pop_filename = cur_arg;
+ arg_num++; if (arg_num < argc) cur_arg = args[arg_num];
+ load_pop_filename = cur_arg;
}
} else if (cur_arg == "-version" || cur_arg == "-v") {
cout << " by Charles Ofria" << endl;
cout << " designed by Charles Ofria, Chris Adami, Travis Collier, C. Titus Brown, and Claus Wilke" << endl;
- cout << " For more information, see: http://dllab.caltech.edu/avida/" << endl;
+ cout << " For more information, see: http://devolab.cse.msu.edu/software/avida/" << endl;
exit(0);
} else if (cur_arg == "-set") {
if (arg_num + 1 == argc || arg_num + 2 == argc) {
- cerr << "'-set' option must be followed by name and value" << endl;
- exit(0);
+ cerr << "'-set' option must be followed by name and value" << endl;
+ exit(0);
}
arg_num++; if (arg_num < argc) cur_arg = args[arg_num];
cString name(cur_arg);
@@ -668,18 +666,18 @@
cString value(cur_arg);
cout << "SET " << name() << " = " << value() << endl;
genesis.AddInput(name(), value());
-
+
} else if (cur_arg == "-g" || cur_arg == "-genesis") {
cerr << "Error: -g[enesis] option must be listed first." << endl;
exit(0);
} else {
cerr << "Unknown Option: " << argv[arg_num] << endl
- << "Type: \"" << argv[0] << " -h\" for a full option list." << endl;
+ << "Type: \"" << argv[0] << " -h\" for a full option list." << endl;
exit(0);
}
-
+
arg_num++; if (arg_num < argc) cur_arg = args[arg_num];
}
-
+
delete [] args;
}
Modified: trunk/source/main/config.hh
===================================================================
--- trunk/source/main/config.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/config.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -281,7 +281,7 @@
static bool log_threshold_only;
static bool log_creatures;
- static bool log_genotypes;
+ static int log_genotypes;
static bool log_threshold;
static bool log_species;
static bool log_landscape;
@@ -423,7 +423,7 @@
static bool GetLogThresholdOnly() { return log_threshold_only; }
static bool GetLogCreatures() { return log_creatures; }
- static bool GetLogGenotypes() { return log_genotypes; }
+ static int GetLogGenotypes() { return log_genotypes; }
static bool GetLogThreshold() { return log_threshold; }
static bool GetLogSpecies() { return log_species; }
static bool GetLogLandscape() { return log_landscape; }
Modified: trunk/source/main/environment.cc
===================================================================
--- trunk/source/main/environment.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/environment.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -151,8 +151,6 @@
bool cEnvironment::LoadReactionProcess(cReaction * reaction, cString desc)
{
- // cerr << "ENV: Loading reaction process '" << desc << "'." << endl;
-
cReactionProcess * new_process = reaction->AddProcess();
// Loop through all entries in description.
@@ -251,8 +249,6 @@
bool cEnvironment::LoadReactionRequisite(cReaction * reaction, cString desc)
{
- // cerr << "ENV: Loading reaction requisite '" << desc << "'." << endl;
-
cReactionRequisite * new_requisite = reaction->AddRequisite();
// Loop through all entries in description.
@@ -303,8 +299,6 @@
bool cEnvironment::LoadResource(cString desc)
{
- cerr << "ENV: Loading resource '" << desc << "'." << endl;
-
if (desc.GetSize() == 0) {
cerr << "Warning: Resource line with no resources listed." << endl;
return false;
@@ -435,7 +429,6 @@
// If only a name was present, assume this reaction is a pre-declaration.
if (desc.GetSize() == 0) {
- // cerr << "ENV: Pre-declaring reaction '" << name << "'." << endl;
return true;
}
@@ -448,8 +441,6 @@
// Finish loading in this reaction.
const cString trigger = desc.PopWord();
- cerr << "ENV: Loading reaction '" << name << "' with trigger '"
- << trigger << "'." << endl;
// Load the task trigger
cTaskEntry * cur_task = task_lib.AddTask(trigger);
@@ -490,8 +481,6 @@
bool cEnvironment::LoadMutation(cString desc)
{
- cerr << "ENV: Loading mutation '" << desc << "'." << endl;
-
// Make sure this mutation has a description...
if (desc.CountNumWords() < 5) {
cerr << "Error: Each mutation must include a name, trigger, scope, type, and rate." << endl;
@@ -643,9 +632,6 @@
bool cEnvironment::Load(const cString & filename)
{
- cerr << "--- ENVIRONMENT SETUP ---" << endl;
- cerr << "ENV: Loading file '" << filename << "'." << endl;
-
cInitFile infile(filename);
if (infile.Good() == false) {
cerr << "Error: Failed to load environment '" << filename << "'." << endl;
@@ -656,8 +642,6 @@
infile.Close();
infile.Compress();
- // cerr << "ENV: found " << infile.GetNumLines() << " commands." << endl;
-
for (int line_id = 0; line_id < infile.GetNumLines(); line_id++) {
// Load the next line from the file.
bool load_ok = LoadLine(infile.GetLine(line_id));
Modified: trunk/source/main/genebank.cc
===================================================================
--- trunk/source/main/genebank.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/genebank.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -787,7 +787,6 @@
bool cGenebank::OK()
{
bool ret_value = true;
- int i;
// Check components...
@@ -833,7 +832,7 @@
// Check the species for each genotype and place results in the species.
cGenotype * cur_gen = genotype_control->GetBest();
- for (i = 0; i < genotype_control->GetSize(); i++) {
+ for (int i = 0; i < genotype_control->GetSize(); i++) {
if (cur_gen->GetSpecies()) {
cur_gen->GetSpecies()->debug_num_genotypes++;
if (cur_gen->GetThreshold()) {
Modified: trunk/source/main/genotype.cc
===================================================================
--- trunk/source/main/genotype.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/genotype.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -113,7 +113,7 @@
assert( tmp_sum_merit.Sum() >= 0 && tmp_sum_fitness.Sum() >= 0 );
return ret_value;
-};
+}
void cGenotype::SetParent(cGenotype * parent, cGenotype * parent2)
{
Modified: trunk/source/main/inject_genotype.cc
===================================================================
--- trunk/source/main/inject_genotype.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/inject_genotype.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -105,7 +105,7 @@
assert( birth_data.update_born >= -1);
return ret_value;
-};
+}
void cInjectGenotype::SetParent(cInjectGenotype * parent)
{
Modified: trunk/source/main/inst_lib_base.hh
===================================================================
--- trunk/source/main/inst_lib_base.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/inst_lib_base.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -15,6 +15,7 @@
class cString;
class cInstLibBase {
public:
+ virtual ~cInstLibBase() { ; }
virtual const cString &GetName(const unsigned int id) = 0;
virtual const cString &GetNopName(const unsigned int id) = 0;
virtual int GetNopMod(const unsigned int id) = 0;
Modified: trunk/source/main/inst_set.hh
===================================================================
--- trunk/source/main/inst_set.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/inst_set.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -182,7 +182,7 @@
}
// @CAO Hacking this to make sure we don't have defaults...
- cerr << "ERROR: Unknown instruction '" << in_name << "'. Halting." << endl;
+ cerr << "Error: Unknown instruction '" << in_name << "'. Exiting..." << endl;
exit(1);
Modified: trunk/source/main/inst_util.cc
===================================================================
--- trunk/source/main/inst_util.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/inst_util.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -27,7 +27,7 @@
cInitFile input_file(filename);
if (!input_file.IsOpen()) {
cerr << "Cannot open file: " << filename << endl;
- return cGenome(1);
+ return cGenome(0);
}
input_file.Load();
input_file.Compress();
@@ -51,7 +51,7 @@
}
if(new_genome.GetSize()==0)
- cerr << "WARNING: Genome size is 0!" << endl;
+ cerr << "Warning: Genome size is 0!" << endl;
return new_genome;
}
Modified: trunk/source/main/phenotype.cc
===================================================================
--- trunk/source/main/phenotype.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/phenotype.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -247,8 +247,6 @@
assert(time_used > 0);
assert(initialized == true);
- double pre_reset_merit = merit.GetDouble();
-
// Update these values as needed...
int cur_merit_base = CalcSizeMerit(genome_length,copied_size,executed_size);
merit = cur_merit_base * cur_bonus;
@@ -333,8 +331,6 @@
assert(time_used > 0);
assert(initialized == true);
- double pre_reset_merit = merit.GetDouble();
-
// Update these values as needed...
int cur_merit_base = CalcSizeMerit(genome_length,copied_size,executed_size);
merit = cur_merit_base * cur_bonus;
Modified: trunk/source/main/population.cc
===================================================================
--- trunk/source/main/population.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/population.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -47,28 +47,26 @@
cPopulation::cPopulation(const cPopulationInterface & in_interface,
- cEnvironment & in_environment,
- cChangeList * change_list)
- : schedule(NULL)
- , resource_count(in_environment.GetResourceLib().GetSize())
- , environment(in_environment)
- , default_interface(in_interface)
- , num_organisms(0)
- , sync_events(false)
+ cEnvironment & in_environment,
+ cChangeList * change_list)
+: schedule(NULL)
+, resource_count(in_environment.GetResourceLib().GetSize())
+, environment(in_environment)
+, default_interface(in_interface)
+, num_organisms(0)
+, sync_events(false)
{
- cout << "<cPopulation>" << endl;
-
// Setup the genebank.
genebank = new cGenebank(stats);
inject_genebank = new cInjectGenebank(stats);
birth_chamber.SetGenebank(genebank);
-
+
// are we logging lineages?
if (cConfig::GetLogLineages()) {
lineage_control = new cLineageControl( *genebank, stats );
}
else lineage_control = NULL; // no lineage logging
-
+
// Setup the default mutation rates...
cMutationRates & default_mut_rates = environment.GetMutRates();
default_mut_rates.SetCopyMutProb ( cConfig::GetCopyMutProb() );
@@ -80,17 +78,17 @@
default_mut_rates.SetDivideInsProb( cConfig::GetDivideInsProb() );
default_mut_rates.SetDivideDelProb( cConfig::GetDivideDelProb() );
default_mut_rates.SetParentMutProb( cConfig::GetParentMutProb() );
-
+
// Setup the default population interface...
default_interface.SetPopulation(this);
-
+
// Avida specific information.
world_x = cConfig::GetWorldX();
world_y = cConfig::GetWorldY();
int geometry = cConfig::GetWorldGeometry();
const int num_cells = world_x * world_y;
cout << "Building world " << world_x << "x" << world_y
- << " = " << num_cells << " organisms." << endl;
+ << " = " << num_cells << " organisms." << endl;
if (geometry == GEOMETRY_GRID) {
cout << "Geometry: Bounded grid" << endl;
} else if (geometry == GEOMETRY_TORUS) {
@@ -98,7 +96,8 @@
} else {
cout << "Geometry: Unknown" << endl;
}
-
+ cout << endl;
+
cell_array.Resize(num_cells);
resource_count.ResizeSpatialGrids(world_x, world_y);
@@ -107,8 +106,8 @@
int x = cell_id % world_x;
int y = cell_id / world_x;
cell_array[cell_id].Setup(cell_id, default_mut_rates);
-
-
+
+
if ((y == 0) && (geometry == GEOMETRY_GRID)) {
bottom_flag = false;
} else {
@@ -129,9 +128,9 @@
} else {
right_flag = true;
}
-
+
// Setup the connection list for each cell. (Clockwise from -1 to 1)
-
+
tList<cPopulationCell> & conn_list=cell_array[cell_id].ConnectionList();
if (bottom_flag && left_flag) {
conn_list.Push(&(cell_array[GridNeighbor(cell_id,world_x,world_y, -1, -1)]));
@@ -157,77 +156,78 @@
if (left_flag) {
conn_list.Push(&(cell_array[GridNeighbor(cell_id,world_x,world_y, -1, 0)]));
}
-
+
// Setup the reaper queue...
if (cConfig::GetBirthMethod() == POSITION_CHILD_FULL_SOUP_ELDEST) {
reaper_queue.Push(&(cell_array[cell_id]));
}
}
-
+
BuildTimeSlicer(change_list);
-
+
if (SetupDemes() == false) {
- cerr << "Error -- failed to setup demes. Exiting." << endl;
+ cerr << "Error: Failed to setup demes. Exiting..." << endl;
exit(1);
}
-
+
// Setup the resources...
const cResourceLib & resource_lib = environment.GetResourceLib();
for (int i = 0; i < resource_lib.GetSize(); i++) {
cResource * res = resource_lib.GetResource(i);
const double decay = 1.0 - res->GetOutflow();
resource_count.Setup(i, res->GetName(), res->GetInitial(),
- res->GetInflow(), decay,
- res->GetGeometry(), res->GetXDiffuse(),
- res->GetXGravity(), res->GetYDiffuse(),
- res->GetYGravity(), res->GetInflowX1(),
- res->GetInflowX2(), res->GetInflowY1(),
- res->GetInflowY2(), res->GetOutflowX1(),
- res->GetOutflowX2(), res->GetOutflowY1(),
- res->GetOutflowY2() );
+ res->GetInflow(), decay,
+ res->GetGeometry(), res->GetXDiffuse(),
+ res->GetXGravity(), res->GetYDiffuse(),
+ res->GetYGravity(), res->GetInflowX1(),
+ res->GetInflowX2(), res->GetInflowY1(),
+ res->GetInflowY2(), res->GetOutflowX1(),
+ res->GetOutflowX2(), res->GetOutflowY1(),
+ res->GetOutflowY2() );
stats.SetResourceName(i, res->GetName());
}
-
+
// Give stats information about the environment...
const cTaskLib & task_lib = environment.GetTaskLib();
for (int i = 0; i < task_lib.GetSize(); i++) {
const cTaskEntry & cur_task = task_lib.GetTask(i);
stats.SetTaskName(i, cur_task.GetDesc());
}
-
+
const cInstSet & inst_set = environment.GetInstSet();
for (int i = 0; i < inst_set.GetSize(); i++) {
stats.SetInstName(i, inst_set.GetName(i));
}
-
+
// Load a clone if one is provided, otherwise setup start organism.
if (cConfig::GetCloneFilename() == "") {
- Inject( cInstUtil::LoadGenome(cConfig::GetStartCreature(),
- environment.GetInstSet()) );
+ cGenome start_org = cInstUtil::LoadGenome(cConfig::GetStartCreature(), environment.GetInstSet());
+ if (start_org.GetSize() != 0) Inject(start_org);
+ else cerr << "Warning: Zero length start organism, not injecting into initial population." << endl;
} else {
ifstream fp(cConfig::GetCloneFilename()());
LoadClone(fp);
}
-
+
// Load a saved population if one is provided.
cString fname(cConfig::GetLoadPopFilename());
if (fname != "") {
- fprintf(stderr,"Loding Population from %s\n", fname());
-
+ cout << "Loading Population from " << fname() << endl;
+
// If last three chars of filename are ".gz" , gunzip it first
if (fname.Find(".gz") == fname.GetSize() - 3) {
cString cmd(fname);
cmd.Insert("gunzip ");
fname.ClipEnd(3);
system(cmd);
-
+
ifstream fp(fname);
if( !fp.good() ){
- fprintf(stderr, "ERROR: Failed to load population file %s\n",fname());
- exit(2);
+ cerr << "Error: Failed to load population file " << fname() << ". Exiting...\n" << endl;
+ exit(2);
}
LoadPopulation(fp);
-
+
cmd = fname;
cmd.Insert("gzip ");
system(cmd);
@@ -237,14 +237,14 @@
LoadPopulation(fp);
}
}
-
+
}
cPopulation::~cPopulation()
{
for (int i = 0; i < cell_array.GetSize(); i++) KillOrganism(cell_array[i]);
-
+
if ( lineage_control != NULL ) delete lineage_control;
delete genebank;
delete inject_genebank;
@@ -257,41 +257,41 @@
bool cPopulation::SetupDemes()
{
num_demes = cConfig::GetNumDemes();
-
+
// If we are not using demes, stop here.
if (num_demes == 0) {
if (cConfig::GetBirthMethod() == POSITION_CHILD_DEME_RANDOM) {
cerr << "Using position method that requires demes, but demes are off."
- << endl;
+ << endl;
return false;
}
return true;
}
-
+
// Check to make sure all other settings are reasonable to have demes.
// ...make sure populaiton can be divided up evenly.
if (world_y % num_demes != 0) {
cerr << "World Y size of " << world_y
- << " cannot be divided into " << num_demes << " demes." << endl;
+ << " cannot be divided into " << num_demes << " demes." << endl;
return false;
}
-
+
// ...make sure we are using a legal birth method.
if (cConfig::GetBirthMethod() == POSITION_CHILD_FULL_SOUP_ELDEST ||
cConfig::GetBirthMethod() == POSITION_CHILD_FULL_SOUP_RANDOM) {
cerr << "Illegal birth method " << cConfig::GetBirthMethod()
- << " for use with demes." << endl;
+ << " for use with demes." << endl;
return false;
}
-
+
const int deme_size_x = world_x;
const int deme_size_y = world_y / num_demes;
deme_size = deme_size_x * deme_size_y;
-
+
// Track birth counts...
deme_birth_count.Resize(num_demes);
deme_birth_count.SetAll(0);
-
+
// Build walls in the population.
for (int row_id = 0; row_id < world_y; row_id += deme_size_y) {
// Loop through all of the cols and make the cut on each...
@@ -314,40 +314,40 @@
cellB_list.Remove(&GetCell(idA1));
}
}
-
+
return true;
}
-
+
// Activate the child, given information from the parent.
// Return true if parent lives through this process.
bool cPopulation::ActivateOffspring(cGenome & child_genome,
- cOrganism & parent_organism)
+ cOrganism & parent_organism)
{
assert(&parent_organism != NULL);
-
+
tArray<cOrganism *> child_array;
tArray<cMerit> merit_array;
-
+
// Update the parent's phenotype.
// This needs to be done before the parent goes into the brith chamber
// or the merit doesn't get passed onto the child correctly
cPhenotype & parent_phenotype = parent_organism.GetPhenotype();
parent_phenotype.DivideReset(parent_organism.GetGenome().GetSize());
-
+
birth_chamber.SubmitOffspring(child_genome, parent_organism,
- child_array, merit_array);
-
-
+ child_array, merit_array);
+
+
// First, setup the genotype of all of the offspring.
cGenotype * parent_genotype = parent_organism.GetGenotype();
const int parent_id = parent_organism.PopInterface().GetCellID();
assert(parent_id >= 0 && parent_id < cell_array.GetSize());
cPopulationCell & parent_cell = cell_array[ parent_id ];
-
-
+
+
tArray<int> target_cells(child_array.GetSize());
-
+
// Loop through choosing the later placement of each child in the population.
bool parent_alive = true; // Will the parent live through this process?
for (int i = 0; i < child_array.GetSize(); i++) {
@@ -358,41 +358,41 @@
// Update the mutation rates of each child....
child_array[i]->MutationRates().
Copy(GetCell(target_cells[i]).MutationRates());
-
+
// Update the phenotypes of each child....
const int child_length = child_array[i]->GetGenome().GetSize();
child_array[i]->GetPhenotype().
SetupOffspring(parent_phenotype,child_length);
-
+
child_array[i]->GetPhenotype().SetMerit(merit_array[i]);
-
+
// Do lineage tracking for the new organisms.
LineageSetupOrganism( child_array[i], parent_organism.GetLineage(),
- parent_organism.GetLineageLabel(),
- parent_genotype );
-
+ parent_organism.GetLineageLabel(),
+ parent_genotype );
+
}
-
-
+
+
// If we're not about to kill the parent, do some extra work on it.
if (parent_alive == true) {
schedule->Adjust(parent_cell.GetID(), parent_phenotype.GetMerit());
-
+
// In a local run, face the child toward the parent.
if (cConfig::GetBirthMethod() < NUM_LOCAL_POSITION_CHILD) {
for (int i = 0; i < child_array.GetSize(); i++) {
- GetCell(target_cells[i]).Rotate(parent_cell);
+ GetCell(target_cells[i]).Rotate(parent_cell);
}
}
}
-
+
// Do any statistics on the parent that just gave birth...
parent_genotype->AddGestationTime( parent_phenotype.GetGestationTime() );
parent_genotype->AddFitness( parent_phenotype.GetFitness() );
parent_genotype->AddMerit( parent_phenotype.GetMerit() );
parent_genotype->AddCopiedSize( parent_phenotype.GetCopiedSize() );
parent_genotype->AddExecutedSize( parent_phenotype.GetExecutedSize() );
-
+
// Place all of the offspring...
for (int i = 0; i < child_array.GetSize(); i++) {
ActivateOrganism(child_array[i], GetCell(target_cells[i]));
@@ -400,7 +400,7 @@
child_genotype->DecDeferAdjust();
genebank->AdjustGenotype(*child_genotype);
}
-
+
return parent_alive;
}
@@ -410,28 +410,28 @@
if(injected_code.GetSize() ==0)
return false;
-
+
cHardware4Stack & parent_cpu = (cHardware4Stack &) parent.GetHardware();
cInjectGenotype * parent_genotype = parent_cpu.GetCurThreadOwner();
const int parent_id = parent.PopInterface().GetCellID();
assert(parent_id >= 0 && parent_id < cell_array.GetSize());
cPopulationCell & parent_cell = cell_array[ parent_id ];
-
+
int num_neighbors = parent.GetNeighborhoodSize();
cOrganism * target_organism =
parent_cell.connection_list.GetPos(g_random.GetUInt(num_neighbors))->GetOrganism();
-
+
if(target_organism==NULL)
return false;
-
+
cHardware4Stack & child_cpu = (cHardware4Stack &) target_organism->GetHardware();
if(child_cpu.GetNumThreads()==cConfig::GetMaxCPUThreads())
return false;
-
+
cInjectGenotype * child_genotype = parent_genotype;
-
+
if(target_organism->InjectHost(parent_cpu.GetLabel(), injected_code)) {
// If the parent genotype is not correct for the child, adjust it.
if (parent_genotype == NULL || parent_genotype->GetGenome() != injected_code) {
@@ -447,9 +447,9 @@
}
else
return false;
-
+
return true;
-
+
// And set the genotype now that we know it.
//child_array[i]->SetGenotype(child_genotype);
//parent_genotype->SetBreedStats(*child_genotype);
@@ -474,14 +474,14 @@
//parent_genotype->AddMerit( parent_phenotype.GetMerit() );
//parent_genotype->AddCopiedSize( parent_phenotype.GetCopiedSize() );
//parent_genotype->AddExecutedSize( parent_phenotype.GetExecutedSize() );
-
+
// Place all of the offspring...
/*for (int i = 0; i < child_array.GetSize(); i++) {
ActivateOrganism(child_array[i], GetCell(target_cells[i]));
- cGenotype * child_genotype = child_array[i]->GetGenotype();
- child_genotype->DecDeferAdjust();
- genebank->AdjustGenotype(*child_genotype);
- }*/
+ cGenotype * child_genotype = child_array[i]->GetGenotype();
+ child_genotype->DecDeferAdjust();
+ genebank->AdjustGenotype(*child_genotype);
+ }*/
}
bool cPopulation::ActivateInject(const int cell_id, const cGenome & injected_code)
@@ -489,73 +489,73 @@
cInjectGenotype * child_genotype = inject_genebank->AddInjectGenotype(injected_code);
cHardware4Stack & child_cpu = (cHardware4Stack &) cell_array[cell_id].GetOrganism()->GetHardware();
if(cell_array[cell_id].GetOrganism()->InjectHost(cCodeLabel(), injected_code))
- {
- cell_array[cell_id].GetOrganism()->AddParasite(child_genotype);
- child_genotype->AddParasite();
- child_cpu.SetThreadOwner(child_genotype);
- inject_genebank->AdjustInjectGenotype(*child_genotype);
- }
+ {
+ cell_array[cell_id].GetOrganism()->AddParasite(child_genotype);
+ child_genotype->AddParasite();
+ child_cpu.SetThreadOwner(child_genotype);
+ inject_genebank->AdjustInjectGenotype(*child_genotype);
+ }
else
return false;
-
+
return true;
}
void cPopulation::ActivateOrganism(cOrganism * in_organism,
- cPopulationCell & target_cell)
+ cPopulationCell & target_cell)
{
assert(in_organism != NULL);
assert(in_organism->GetGenome().GetSize() > 1);
-
+
// If the organism does not have a genotype, give it one! No parent
// information is provided so we must set parents to NULL.
if (in_organism->GetGenotype() == NULL) {
cGenotype * new_genotype =
- genebank->AddGenotype(in_organism->GetGenome(), NULL, NULL);
+ genebank->AddGenotype(in_organism->GetGenome(), NULL, NULL);
in_organism->SetGenotype(new_genotype);
}
cGenotype * in_genotype = in_organism->GetGenotype();
-
+
// Save the old genotype from this cell...
cGenotype * old_genotype = NULL;
if (target_cell.IsOccupied()) {
old_genotype = target_cell.GetOrganism()->GetGenotype();
-
+
// Sometimes a new organism will kill off the last member of its genotype
// in the population. Normally this would remove the genotype, so we
// want to defer adjusting that genotype until the new one is placed.
old_genotype->IncDeferAdjust();
}
-
+
// Update the contents of the target cell.
KillOrganism(target_cell);
target_cell.InsertOrganism(*in_organism);
-
+
// Setup the inputs in the target cell.
environment.SetupInputs(target_cell.input_array);
-
+
// Update the genebank...
in_genotype->AddOrganism();
-
+
if (old_genotype != NULL) {
old_genotype->DecDeferAdjust();
genebank->AdjustGenotype(*old_genotype);
}
genebank->AdjustGenotype(*in_genotype);
-
+
// Initialize the time-slice for this new organism.
schedule->Adjust(target_cell.GetID(),in_organism->GetPhenotype().GetMerit());
-
+
// Special handling for certain birth methods.
if (cConfig::GetBirthMethod() == POSITION_CHILD_FULL_SOUP_ELDEST) {
reaper_queue.Push(&target_cell);
}
-
+
num_organisms++;
-
+
// Statistics...
stats.RecordBirth(target_cell.GetID(), in_genotype->GetID(),
- in_organism->GetPhenotype().ParentTrue());
+ in_organism->GetPhenotype().ParentTrue());
}
void cPopulation::KillOrganism(cPopulationCell & in_cell)
@@ -564,41 +564,41 @@
if (in_cell.IsOccupied() == false) {
return;
}
-
+
// Statistics...
cOrganism * organism = in_cell.GetOrganism();
cGenotype * genotype = organism->GetGenotype();
stats.RecordDeath(in_cell.GetID(), genotype->GetID(),
- organism->GetPhenotype().GetAge());
-
-
+ organism->GetPhenotype().GetAge());
+
+
// Do the lineage handling
if (lineage_control != NULL) {
lineage_control->RemoveCreature( organism );
}
-
+
// Do statistics
num_organisms--;
-
+
//if (organism->GetPhenotype().IsParasite() == true) {
// genotype->AddParasite();
//}
genotype->RemoveOrganism();
-
- for(int i=0; i<organism->GetNumParasites(); i++) {
- organism->GetParasite(i).RemoveParasite();
- }
-
- // And clear it!
- in_cell.RemoveOrganism();
- if (organism->GetIsRunning() == false) delete organism;
- else organism->GetPhenotype().SetToDelete();
- // Alert the scheduler that this cell has a 0 merit.
- schedule->Adjust( in_cell.GetID(), cMerit(0) );
+for(int i=0; i<organism->GetNumParasites(); i++) {
+ organism->GetParasite(i).RemoveParasite();
+}
- // Update the genebank (note: genotype adjustment may be defered)
- genebank->AdjustGenotype(*genotype);
+// And clear it!
+in_cell.RemoveOrganism();
+if (organism->GetIsRunning() == false) delete organism;
+else organism->GetPhenotype().SetToDelete();
+
+// Alert the scheduler that this cell has a 0 merit.
+schedule->Adjust( in_cell.GetID(), cMerit(0) );
+
+// Update the genebank (note: genotype adjustment may be defered)
+genebank->AdjustGenotype(*genotype);
}
void cPopulation::Kaboom(cPopulationCell & in_cell)
@@ -615,7 +615,7 @@
for (int i=-1*radius; i<=radius; i++) {
for (int j=-1*radius; j<=radius; j++) {
cPopulationCell & death_cell =
- cell_array[GridNeighbor(in_cell.GetID(), world_x, world_y, i, j)];
+ cell_array[GridNeighbor(in_cell.GetID(), world_x, world_y, i, j)];
//do we actually have something to kill?
if (death_cell.IsOccupied() == false) continue;
@@ -623,23 +623,23 @@
cGenotype * gene_temp = org_temp->GetGenotype();
if (distance == 0) {
- int temp_id = gene_temp->GetID();
- if (temp_id != id) {
- KillOrganism(death_cell);
- count++;
- }
+ int temp_id = gene_temp->GetID();
+ if (temp_id != id) {
+ KillOrganism(death_cell);
+ count++;
+ }
}
else {
- cGenome genome_temp = gene_temp->GetGenome();
- int diff=0;
- for (int i=0; i<genome_temp.GetSize(); i++)
- if (genome_temp.AsString()[i] != genome.AsString()[i])
- diff++;
- if (diff > distance)
- {
- KillOrganism(death_cell);
- count++;
- }
+ cGenome genome_temp = gene_temp->GetGenome();
+ int diff=0;
+ for (int i=0; i<genome_temp.GetSize(); i++)
+ if (genome_temp.AsString()[i] != genome.AsString()[i])
+ diff++;
+ if (diff > distance)
+ {
+ KillOrganism(death_cell);
+ count++;
+ }
}
}
}
@@ -656,17 +656,17 @@
void cPopulation::CompeteDemes(int competition_type)
{
-
+
double total_fitness = 0;
tArray<double> deme_fitness(num_demes);
-
+
switch(competition_type) {
case 0: // deme fitness = 1;
total_fitness = (double) num_demes;
deme_fitness.SetAll(1);
break;
case 1: // deme fitness = number of births
- // Determine the scale for fitness by totaling births across demes.
+ // Determine the scale for fitness by totaling births across demes.
for (int cur_deme = 0; cur_deme < num_demes; cur_deme++) {
deme_fitness[cur_deme] = (double) deme_birth_count[cur_deme];
total_fitness += deme_birth_count[cur_deme];
@@ -678,7 +678,7 @@
for (int i = 0; i < deme_size; i++) {
int cur_cell = cur_deme * deme_size + i;
if (cell_array[cur_cell].IsOccupied() == false) continue;
- cPhenotype & phenotype = GetCell(cur_cell).GetOrganism()->GetPhenotype();
+ cPhenotype & phenotype = GetCell(cur_cell).GetOrganism()->GetPhenotype();
single_deme_fitness.Add(phenotype.GetFitness());
}
deme_fitness[cur_deme] = single_deme_fitness.Ave();
@@ -687,12 +687,12 @@
break;
case 3: // deme fitness = average mutation rate at the current update
for (int cur_deme = 0; cur_deme < num_demes; cur_deme++) {
- cDoubleSum single_deme_div_type;
+ cDoubleSum single_deme_div_type;
for (int i = 0; i < deme_size; i++) {
int cur_cell = cur_deme * deme_size + i;
if (cell_array[cur_cell].IsOccupied() == false) continue;
cPhenotype & phenotype = GetCell(cur_cell).GetOrganism()->GetPhenotype();
- assert(phenotype.GetDivType()>0);
+ assert(phenotype.GetDivType()>0);
single_deme_div_type.Add(1/phenotype.GetDivType());
}
deme_fitness[cur_deme] = single_deme_div_type.Ave();
@@ -700,7 +700,7 @@
}
break;
case 4: // deme fitness = 2^(-deme fitness rank)
- // first find all the deme fitness values ...
+ // first find all the deme fitness values ...
{
for (int cur_deme = 0; cur_deme < num_demes; cur_deme++) {
cDoubleSum single_deme_fitness;
@@ -717,21 +717,21 @@
deme_rank.SetAll(1);
for (int cur_deme = 0; cur_deme < num_demes; cur_deme++) {
for (int test_deme = 0; test_deme < num_demes; test_deme++) {
- if (deme_fitness[cur_deme] < deme_fitness[test_deme]) {
- deme_rank[cur_deme]++;
- }
- }
+ if (deme_fitness[cur_deme] < deme_fitness[test_deme]) {
+ deme_rank[cur_deme]++;
+ }
+ }
}
// ... finally, make deme fitness 2^(-deme rank)
deme_fitness.SetAll(1);
for (int cur_deme = 0; cur_deme < num_demes; cur_deme++) {
- for (int i = 0; i < deme_rank[cur_deme]; i++) {
- deme_fitness[cur_deme] = deme_fitness[cur_deme]/2;
- }
- total_fitness += deme_fitness[cur_deme];
+ for (int i = 0; i < deme_rank[cur_deme]; i++) {
+ deme_fitness[cur_deme] = deme_fitness[cur_deme]/2;
+ }
+ total_fitness += deme_fitness[cur_deme];
}
}
- break;
+ break;
case 5: // deme fitness = average organism life fitness at the current update
for (int cur_deme = 0; cur_deme < num_demes; cur_deme++) {
cDoubleSum single_deme_life_fitness;
@@ -745,8 +745,8 @@
total_fitness += deme_fitness[cur_deme];
}
break;
- case 6: // deme fitness = 2^(-deme life fitness rank) (same as 4, but with life fitness)
- // first find all the deme fitness values ...
+ case 6: // deme fitness = 2^(-deme life fitness rank) (same as 4, but with life fitness)
+ // first find all the deme fitness values ...
{
for (int cur_deme = 0; cur_deme < num_demes; cur_deme++) {
cDoubleSum single_deme_life_fitness;
@@ -764,7 +764,7 @@
for (int cur_deme = 0; cur_deme < num_demes; cur_deme++) {
for (int test_deme = 0; test_deme < num_demes; test_deme++) {
if (deme_fitness[cur_deme] < deme_fitness[test_deme]) {
- deme_rank[cur_deme]++;
+ deme_rank[cur_deme]++;
}
}
}
@@ -777,9 +777,9 @@
total_fitness += deme_fitness[cur_deme];
}
}
- break;
+ break;
}
-
+
// Pick which demes should be in the next generation.
tArray<int> new_demes(num_demes);
for (int i = 0; i < num_demes; i++) {
@@ -788,22 +788,22 @@
for (int test_deme = 0; test_deme < num_demes; test_deme++) {
test_total += deme_fitness[test_deme];
if (birth_choice < test_total) {
- new_demes[i] = test_deme;
- break;
+ new_demes[i] = test_deme;
+ break;
}
}
}
-
+
// Track how many of each deme we should have.
tArray<int> deme_count(num_demes);
deme_count.SetAll(0);
for (int i = 0; i < num_demes; i++) {
deme_count[new_demes[i]]++;
}
-
+
tArray<bool> is_init(num_demes);
is_init.SetAll(false);
-
+
// Copy demes until all deme counts are 1.
while (true) {
// Find the next deme to copy...
@@ -812,26 +812,26 @@
if (deme_count[from_deme] > 1) break;
}
if (from_deme == num_demes) break; // If we don't find another deme to copy
-
+
for (to_deme = 0; to_deme < num_demes; to_deme++) {
if (deme_count[to_deme] == 0) break;
}
-
+
// We now have both a from and a to deme....
deme_count[from_deme]--;
deme_count[to_deme]++;
-
+
// Do the actual copy!
for (int i = 0; i < deme_size; i++) {
int from_cell = from_deme * deme_size + i;
int to_cell = to_deme * deme_size + i;
if (cell_array[from_cell].IsOccupied() == true) {
- InjectClone( to_cell, *(cell_array[from_cell].GetOrganism()) );
+ InjectClone( to_cell, *(cell_array[from_cell].GetOrganism()) );
}
}
is_init[to_deme] = true;
}
-
+
// Now re-inject all remaining demes into themselves to reset them.
for (int cur_deme = 0; cur_deme < num_demes; cur_deme++) {
if (is_init[cur_deme] == true) continue;
@@ -841,7 +841,7 @@
InjectClone( cur_cell, *(cell_array[cur_cell].GetOrganism()) );
}
}
-
+
deme_birth_count.SetAll(0);
}
@@ -887,7 +887,7 @@
cDataFile & df_task = stats.GetDataFile("deme_task.dat");
cDataFile & df_donor = stats.GetDataFile("deme_donor.dat");
cDataFile & df_receiver = stats.GetDataFile("deme_receiver.dat");
-
+
df_fit.WriteComment("Average fitnesses for each deme in the population");
df_life_fit.WriteComment("Average life fitnesses for each deme in the population");
df_merit.WriteComment("Average merits for each deme in population");
@@ -895,7 +895,7 @@
df_task.WriteComment("Num orgs doing each task for each deme in population");
df_donor.WriteComment("Num orgs doing doing a donate for each deme in population");
df_receiver.WriteComment("Num orgs doing receiving a donate for each deme in population");
-
+
df_fit.WriteTimeStamp();
df_life_fit.WriteTimeStamp();
df_merit.WriteTimeStamp();
@@ -903,7 +903,7 @@
df_task.WriteTimeStamp();
df_donor.WriteTimeStamp();
df_receiver.WriteTimeStamp();
-
+
df_fit.Write(GetUpdate(), "update");
df_life_fit.Write(GetUpdate(), "update");
df_merit.Write(GetUpdate(), "update");
@@ -911,21 +911,21 @@
df_task.Write(GetUpdate(), "update");
df_donor.Write(GetUpdate(), "update");
df_receiver.Write(GetUpdate(), "update");
-
+
const int num_inst = cConfig::GetNumInstructions();
const int num_task = environment.GetTaskLib().GetSize();
-
+
for (int cur_deme = 0; cur_deme < num_demes; cur_deme++) {
cString filename;
filename.Set("deme_instruction-%d.dat", cur_deme);
cDataFile & df_inst = stats.GetDataFile(filename);
cString comment;
comment.Set("Number of times each instruction is exectued in deme %d",
- cur_deme);
+ cur_deme);
df_inst.WriteComment(comment);
df_inst.WriteTimeStamp();
df_inst.Write(GetUpdate(), "update");
-
+
cDoubleSum single_deme_fitness;
cDoubleSum single_deme_life_fitness;
cDoubleSum single_deme_merit;
@@ -934,7 +934,7 @@
cDoubleSum single_deme_receiver;
tArray<cIntSum> single_deme_task(num_task);
tArray<cIntSum> single_deme_inst(num_inst);
-
+
for (int i = 0; i < deme_size; i++) {
int cur_cell = cur_deme * deme_size + i;
if (cell_array[cur_cell].IsOccupied() == false) continue;
@@ -945,16 +945,16 @@
single_deme_gest_time.Add(phenotype.GetGestationTime());
single_deme_donor.Add(phenotype.IsDonorLast());
single_deme_receiver.Add(phenotype.IsReceiver());
-
+
for (int j = 0; j < num_inst; j++) {
- single_deme_inst[j].Add(phenotype.GetLastInstCount()[j]);
+ single_deme_inst[j].Add(phenotype.GetLastInstCount()[j]);
}
-
+
for (int j = 0; j < num_task; j++) {
- // only interested in tasks is done once!
- if (phenotype.GetLastTaskCount().ElementAt(j) > 0) {
- single_deme_task[j].Add(1);
- }
+ // only interested in tasks is done once!
+ if (phenotype.GetLastTaskCount().ElementAt(j) > 0) {
+ single_deme_task[j].Add(1);
+ }
}
}
@@ -977,7 +977,7 @@
}
df_inst.Endl();
}
-
+
df_fit.Endl();
df_life_fit.Endl();
df_merit.Endl();
@@ -989,28 +989,28 @@
/**
- * This function is responsible for adding an organism to a given lineage,
+* This function is responsible for adding an organism to a given lineage,
* and setting the organism's lineage label and the lineage pointer.
**/
void cPopulation::LineageSetupOrganism(cOrganism * organism, cLineage * lin,
- int lin_label, cGenotype *parent_genotype)
+ int lin_label, cGenotype *parent_genotype)
{
// If we have some kind of lineage control, adjust the default values
// passed in.
if ( lineage_control ){
lin = lineage_control->
- AddCreature(organism->GetGenotype(), parent_genotype, lin, lin_label);
+ AddCreature(organism->GetGenotype(), parent_genotype, lin, lin_label);
lin_label = lin->GetID();
}
-
+
organism->SetLineageLabel( lin_label );
organism->SetLineage( lin );
}
/**
- * This function directs which position function should be used. It
+* This function directs which position function should be used. It
* could have also been done with a function pointer, but the dividing
* of an organism takes enough time that this will be a negligible addition,
* and it gives a centralized function to work with. The parent_ok flag asks
@@ -1018,14 +1018,14 @@
**/
cPopulationCell & cPopulation::PositionChild(cPopulationCell & parent_cell,
- bool parent_ok)
+ bool parent_ok)
{
assert(parent_cell.IsOccupied());
const int birth_method = cConfig::GetBirthMethod();
-
+
// Try out global/full-deme birth methods first...
-
+
if (birth_method == POSITION_CHILD_FULL_SOUP_RANDOM) {
int out_pos = g_random.GetUInt(cell_array.GetSize());
while (parent_ok == false && out_pos == parent_cell.GetID()) {
@@ -1051,13 +1051,13 @@
deme_birth_count[cur_deme]++;
return GetCell(out_pos);
}
-
+
// Construct a list of equally viable locations to place the child...
tList<cPopulationCell> found_list;
-
+
// First, check if there is an empty organism to work with (always preferred)
tList<cPopulationCell> & conn_list = parent_cell.ConnectionList();
-
+
if (cConfig::GetPreferEmpty() == false &&
birth_method == POSITION_CHILD_RANDOM) {
found_list.Append(conn_list);
@@ -1065,36 +1065,36 @@
} else {
FindEmptyCell(conn_list, found_list);
}
-
+
// If we have not found an empty organism, we must use the specified function
// to determine how to choose among the filled organisms.
if (found_list.GetSize() == 0) {
switch(birth_method) {
- case POSITION_CHILD_AGE:
- PositionAge(parent_cell, found_list, parent_ok);
- break;
- case POSITION_CHILD_MERIT:
- PositionMerit(parent_cell, found_list, parent_ok);
- break;
- case POSITION_CHILD_RANDOM:
- found_list.Append(conn_list);
- if (parent_ok == true) found_list.Push(&parent_cell);
- break;
- case POSITION_CHILD_EMPTY:
- // Nothing is in list if no empty cells are found...
- break;
+ case POSITION_CHILD_AGE:
+ PositionAge(parent_cell, found_list, parent_ok);
+ break;
+ case POSITION_CHILD_MERIT:
+ PositionMerit(parent_cell, found_list, parent_ok);
+ break;
+ case POSITION_CHILD_RANDOM:
+ found_list.Append(conn_list);
+ if (parent_ok == true) found_list.Push(&parent_cell);
+ break;
+ case POSITION_CHILD_EMPTY:
+ // Nothing is in list if no empty cells are found...
+ break;
}
}
-
+
if (num_demes > 0) {
const int parent_id = parent_cell.GetID();
const int cur_deme = parent_id / deme_size;
deme_birth_count[cur_deme]++;
}
-
+
// If there are no possibilities, return parent.
if (found_list.GetSize() == 0) return parent_cell;
-
+
// Choose the organism randomly from those in the list, and return it.
int choice = g_random.GetUInt(found_list.GetSize());
return *( found_list.GetPos(choice) );
@@ -1110,21 +1110,21 @@
{
assert(step_size > 0.0);
assert(cell_id < cell_array.GetSize());
-
+
// If cell_id is negative, no cell could be found -- stop here.
if (cell_id < 0) return;
-
+
cPopulationCell & cell = GetCell(cell_id);
assert(cell.IsOccupied()); // Unoccupied cell getting processor time!
-
-// static ofstream debug_fp("debug.trace");
-// debug_fp << stats.GetUpdate() << " "
-// << cell.GetOrganism()->GetCellID() << " "
-// << cell.GetOrganism()->GetGenotype()->GetID() << " "
-// << g_random.GetDouble() << " "
-// << cell.GetOrganism()->GetHardware().GetMemory().AsString() << " "
-// << endl;
-
+
+ // static ofstream debug_fp("debug.trace");
+ // debug_fp << stats.GetUpdate() << " "
+ // << cell.GetOrganism()->GetCellID() << " "
+ // << cell.GetOrganism()->GetGenotype()->GetID() << " "
+ // << g_random.GetDouble() << " "
+ // << cell.GetOrganism()->GetHardware().GetMemory().AsString() << " "
+ // << endl;
+
cOrganism * cur_org = cell.GetOrganism();
cur_org->GetHardware().SingleProcess();
if (cur_org->GetPhenotype().GetToDelete() == true) {
@@ -1145,7 +1145,7 @@
{
// Loop through all the cells getting stats and doing calculations
// which must be done on a creature by creature basis.
-
+
// Clear out organism sums...
stats.SumFitness().Clear();
stats.SumGestation().Clear();
@@ -1159,14 +1159,14 @@
stats.SumCopySize().Clear();
stats.SumExeSize().Clear();
stats.SumMemSize().Clear();
-
-
+
+
stats.ZeroTasks();
-
+
#ifdef INSTRUCTION_COUNT
stats.ZeroInst();
#endif
-
+
// Counts...
int num_breed_true = 0;
int num_parasites = 0;
@@ -1174,23 +1174,21 @@
int num_multi_thread = 0;
int num_single_thread = 0;
int num_modified = 0;
-
+
// Maximums...
cMerit max_merit(0);
double max_fitness = 0;
int max_gestation_time = 0;
int max_genome_length = 0;
-
+
// Minimums...
cMerit min_merit(HUGE_VAL);
double min_fitness = HUGE_VAL;
int min_gestation_time = INT_MAX;
int min_genome_length = INT_MAX;
-
+
for (int i = 0; i < cell_array.GetSize(); i++) {
-
// Only look at cells with organisms in them.
-
if (cell_array[i].IsOccupied() == false) {
// Genotype map needs zero for all non-occupied cells
@@ -1205,7 +1203,7 @@
const double cur_fitness = phenotype.GetFitness();
const int cur_gestation_time = phenotype.GetGestationTime();
const int cur_genome_length = phenotype.GetGenomeLength();
-
+
stats.SumFitness().Add(cur_fitness);
stats.SumMerit().Add(cur_merit.GetDouble());
stats.SumGestation().Add(phenotype.GetGestationTime());
@@ -1220,24 +1218,24 @@
stats.SumCopySize().Add(phenotype.GetCopiedSize());
stats.SumExeSize().Add(phenotype.GetExecutedSize());
stats.SetGenoMapElement(i, organism->GetGenotype()->GetID());
-
+
#ifdef INSTRUCTION_COUNT
-// for (int j=0; j < environment.GetInstSet().GetSize(); j++) {
+ // for (int j=0; j < environment.GetInstSet().GetSize(); j++) {
for (int j=0; j < cConfig::GetNumInstructions(); j++) {
- stats.SumExeInst()[j].Add(organism->GetPhenotype().GetLastInstCount()[j]);
+ stats.SumExeInst()[j].Add(organism->GetPhenotype().GetLastInstCount()[j]);
}
#endif
-
+
if (cur_merit > max_merit) max_merit = cur_merit;
if (cur_fitness > max_fitness) max_fitness = cur_fitness;
if (cur_gestation_time > max_gestation_time) max_gestation_time = cur_gestation_time;
if (cur_genome_length > max_genome_length) max_genome_length = cur_genome_length;
-
+
if (cur_merit < min_merit) min_merit = cur_merit;
if (cur_fitness < min_fitness) min_fitness = cur_fitness;
if (cur_gestation_time < min_gestation_time) min_gestation_time = cur_gestation_time;
if (cur_genome_length < min_genome_length) min_genome_length = cur_genome_length;
-
+
// Test what tasks this creatures has completed.
for (int j=0; j < phenotype.GetEnvironment().GetTaskLib().GetSize(); j++) {
if (phenotype.GetCurTaskCount()[j] > 0) stats.AddCurTask(j);
@@ -1245,7 +1243,7 @@
if (phenotype.GetLastTaskCount()[j] > 0)
stats.IncTaskExeCount(j, phenotype.GetLastTaskCount()[j]);
}
-
+
// Increment the counts for all qualities the organism has...
if (phenotype.ParentTrue()) num_breed_true++;
if (phenotype.IsParasite()) num_parasites++;
@@ -1253,81 +1251,81 @@
if(phenotype.IsMultiThread()) num_multi_thread++;
else num_single_thread++;
if(phenotype.IsModified()) num_modified++;
-
+
// Hardware specific collections...
if (organism->GetHardware().GetType() == HARDWARE_TYPE_CPU_ORIGINAL) {
cHardwareBase & hardware = organism->GetHardware();
stats.SumMemSize().Add(hardware.GetMemory().GetSize());
}
-
+
// Increment the age of this organism.
organism->GetPhenotype().IncAge();
- }
-
+ }
+
stats.SetBreedTrueCreatures(num_breed_true);
stats.SetNumNoBirthCreatures(num_no_birth);
stats.SetNumParasites(num_parasites);
stats.SetNumSingleThreadCreatures(num_single_thread);
stats.SetNumMultiThreadCreatures(num_multi_thread);
stats.SetNumModified(num_modified);
-
+
stats.SetMaxMerit(max_merit.GetDouble());
stats.SetMaxFitness(max_fitness);
stats.SetMaxGestationTime(max_gestation_time);
stats.SetMaxGenomeLength(max_genome_length);
-
+
stats.SetMinMerit(min_merit.GetDouble());
stats.SetMinFitness(min_fitness);
stats.SetMinGestationTime(min_gestation_time);
stats.SetMinGenomeLength(min_genome_length);
-
+
stats.SetResources(resource_count.GetResources());
stats.SetSpatialRes(resource_count.GetSpatialRes());
stats.SetResourcesGeometry(resource_count.GetResourcesGeometry());
-}
+ }
void cPopulation::UpdateGenotypeStats()
{
// Loop through all genotypes, finding stats and doing calcuations.
-
+
// Clear out genotype sums...
stats.SumGenotypeAge().Clear();
stats.SumAbundance().Clear();
stats.SumGenotypeDepth().Clear();
stats.SumSize().Clear();
stats.SumThresholdAge().Clear();
-
+
double entropy = 0.0;
-
+
cGenotype * cur_genotype = genebank->GetBestGenotype();
for (int i = 0; i < genebank->GetSize(); i++) {
const int abundance = cur_genotype->GetNumOrganisms();
-
+
// If we're at a dead genotype, we've hit the end of the list!
if (abundance == 0) break;
-
+
// Update stats...
const int age = stats.GetUpdate() - cur_genotype->GetUpdateBorn();
stats.SumGenotypeAge().Add(age, abundance);
stats.SumAbundance().Add(abundance);
stats.SumGenotypeDepth().Add(cur_genotype->GetDepth(), abundance);
stats.SumSize().Add(cur_genotype->GetLength(), abundance);
-
+
// Calculate this genotype's contribution to entropy
const double p = ((double) abundance) / (double) num_organisms;
const double partial_ent = -(p * Log(p));
entropy += partial_ent;
-
+
// Do any special calculations for threshold genotypes.
if (cur_genotype->GetThreshold()) {
stats.SumThresholdAge().Add(age, abundance);
}
-
+
// ...and advance to the next genotype...
cur_genotype = cur_genotype->GetNext();
}
-
+
stats.SetEntropy(entropy);
}
@@ -1335,16 +1333,16 @@
void cPopulation::UpdateSpeciesStats()
{
double species_entropy = 0.0;
-
+
stats.SumSpeciesAge().Clear();
-
+
// Loop through all species that need to be reset prior to calculations.
cSpecies * cur_species = genebank->GetFirstSpecies();
for (int i = 0; i < genebank->GetNumSpecies(); i++) {
cur_species->ResetStats();
cur_species = cur_species->GetNext();
}
-
+
// Collect info from genotypes and send it to their species.
cGenotype * genotype = genebank->GetBestGenotype();
for (int i = 0; i < genebank->GetSize(); i++) {
@@ -1353,28 +1351,28 @@
}
genotype = genotype->GetNext();
}
-
+
// Loop through all of the species in the soup, taking info on them.
cur_species = genebank->GetFirstSpecies();
for (int i = 0; i < genebank->GetNumSpecies(); i++) {
const int abundance = cur_species->GetNumOrganisms();
// const int num_genotypes = cur_species->GetNumGenotypes();
-
+
// Basic statistical collection...
const int species_age = stats.GetUpdate() - cur_species->GetUpdateBorn();
stats.SumSpeciesAge().Add(species_age, abundance);
-
+
// Caculate entropy on the species level...
if (abundance > 0) {
double p = ((double) abundance) / (double) num_organisms;
double partial_ent = -(p * Log(p));
species_entropy += partial_ent;
}
-
+
// ...and advance to the next species...
cur_species = cur_species->GetNext();
}
-
+
stats.SetSpeciesEntropy(species_entropy);
}
@@ -1382,7 +1380,7 @@
{
cGenotype * dom_genotype = genebank->GetBestGenotype();
if (dom_genotype == NULL) return;
-
+
stats.SetDomGenotype(dom_genotype);
stats.SetDomMerit(dom_genotype->GetMerit());
stats.SetDomGestation(dom_genotype->GetGestationTime());
@@ -1390,7 +1388,7 @@
stats.SetDomFitness(dom_genotype->GetFitness());
stats.SetDomCopiedSize(dom_genotype->GetCopiedSize());
stats.SetDomExeSize(dom_genotype->GetExecutedSize());
-
+
stats.SetDomSize(dom_genotype->GetLength());
stats.SetDomID(dom_genotype->GetID());
stats.SetDomName(dom_genotype->GetName());
@@ -1407,7 +1405,7 @@
{
cInjectGenotype * dom_inj_genotype = inject_genebank->GetBestInjectGenotype();
if (dom_inj_genotype == NULL) return;
-
+
stats.SetDomInjGenotype(dom_inj_genotype);
//stats.SetDomMerit(dom_genotype->GetMerit());
//stats.SetDomGestation(dom_genotype->GetGestationTime());
@@ -1415,7 +1413,7 @@
//stats.SetDomFitness(dom_genotype->GetFitness());
//stats.SetDomCopiedSize(dom_genotype->GetCopiedSize());
//stats.SetDomExeSize(dom_genotype->GetExecutedSize());
-
+
stats.SetDomInjSize(dom_inj_genotype->GetLength());
stats.SetDomInjID(dom_inj_genotype->GetID());
stats.SetDomInjName(dom_inj_genotype->GetName());
@@ -1432,18 +1430,18 @@
{
// Reset the Genebank to prepare it for stat collection.
genebank->UpdateReset();
-
+
UpdateOrganismStats();
UpdateGenotypeStats();
UpdateSpeciesStats();
UpdateDominantStats();
UpdateDominantParaStats();
-
+
// Do any final calculations...
stats.SetNumCreatures(GetNumOrganisms());
stats.SetNumGenotypes(genebank->GetSize());
stats.SetNumThreshSpecies(genebank->GetNumSpecies());
-
+
// Have stats calculate anything it now can...
stats.CalcEnergy();
stats.CalcFidelity();
@@ -1453,24 +1451,24 @@
bool cPopulation::SaveClone(ofstream & fp)
{
if (fp.good() == false) return false;
-
+
// Save the current update
fp << stats.GetUpdate() << " ";
-
+
// Save the genebank info.
genebank->SaveClone(fp);
-
+
// Save the genotypes manually.
fp << genebank->GetSize() << " ";
-
+
cGenotype * cur_genotype = genebank->GetBestGenotype();
for (int i = 0; i < genebank->GetSize(); i++) {
cur_genotype->SaveClone(fp);
-
+
// Advance...
cur_genotype = cur_genotype->GetNext();
}
-
+
// Save the organim layout...
fp << cell_array.GetSize() << " ";
for (int i = 0; i < cell_array.GetSize(); i++) {
@@ -1479,7 +1477,7 @@
}
else fp << "-1 ";
}
-
+
return true;
}
@@ -1487,49 +1485,49 @@
bool cPopulation::LoadClone(ifstream & fp)
{
if (fp.good() == false) return false;
-
+
// Pick up the update where it was left off.
int cur_update;
fp >> cur_update;
-
+
stats.SetCurrentUpdate(cur_update);
-
+
// Clear out the population
for (int i = 0; i < cell_array.GetSize(); i++) KillOrganism(cell_array[i]);
-
+
// Load the genebank info.
genebank->LoadClone(fp);
-
+
// Load up the genotypes.
int num_genotypes = 0;
fp >> num_genotypes;
-
+
cGenotype * genotype_array = new cGenotype[num_genotypes];
for (int i = 0; i < num_genotypes; i++) genotype_array[i].LoadClone(fp);
-
+
// Now load them into the organims. @CAO make sure cell_array.GetSize() is right!
int in_num_cells;
int genotype_id;
fp >> in_num_cells;
if (cell_array.GetSize() != in_num_cells) return false;
-
+
for (int i = 0; i < cell_array.GetSize(); i++) {
fp >> genotype_id;
if (genotype_id == -1) continue;
int genotype_index = -1;
for (int j = 0; j < num_genotypes; j++) {
if (genotype_array[j].GetID() == genotype_id) {
- genotype_index = j;
- break;
+ genotype_index = j;
+ break;
}
}
-
+
assert(genotype_index != -1);
InjectGenome(i, genotype_array[genotype_index].GetGenome(), 0);
}
-
+
sync_events = true;
-
+
return true;
}
@@ -1543,9 +1541,9 @@
double merit;
int update_born;
int update_dead;
-
+
cGenotype *genotype;
-
+
bool operator<( const cTmpGenotype rhs ) const {
return id_num < rhs.id_num; }
};
@@ -1556,12 +1554,12 @@
// set the update if requested
if ( update >= 0 )
stats.SetCurrentUpdate(update);
-
+
// Clear out the population
for (int i = 0; i < cell_array.GetSize(); i++) KillOrganism(cell_array[i]);
-
+
cout << "Loading: " << filename << endl;
-
+
cInitFile input_file(filename);
if (!input_file.IsOpen()) {
cerr << "Error: Cannot load file: \"" << filename << "\"." << endl;
@@ -1570,14 +1568,14 @@
input_file.Load();
input_file.Compress();
input_file.Close();
-
+
// First, we read in all the genotypes and store them in a list
-
+
vector<cTmpGenotype> genotype_vect;
-
+
for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
cString cur_line = input_file.GetLine(line_id);
-
+
// Setup the genotype for this line...
cTmpGenotype tmp;
tmp.id_num = cur_line.PopWord().AsInt();
@@ -1594,25 +1592,25 @@
/*depth =*/ cur_line.PopWord().AsInt();
cString name = cStringUtil::Stringf("org-%d", tmp.id_num);
cGenome genome( cur_line.PopWord() );
-
+
// we don't allow birth or death times larger than the current update
if ( stats.GetUpdate() > tmp.update_born )
tmp.update_born = stats.GetUpdate();
if ( stats.GetUpdate() > tmp.update_dead )
tmp.update_dead = stats.GetUpdate();
-
+
tmp.genotype =
new cGenotype(tmp.update_born, tmp.id_num);
tmp.genotype->SetGenome( genome );
tmp.genotype->SetName( name );
-
+
genotype_vect.push_back( tmp );
}
-
+
// now, we sort them in ascending order according to their id_num
sort( genotype_vect.begin(), genotype_vect.end() );
// set the parents correctly
-
+
vector<cTmpGenotype>::const_iterator it = genotype_vect.begin();
for ( ; it != genotype_vect.end(); it++ ){
vector<cTmpGenotype>::const_iterator it2 = it;
@@ -1620,16 +1618,16 @@
// search backwards till we find the parent
if ( it2 != genotype_vect.begin() )
do{
- it2--;
- if ( (*it).parent_id == (*it2).id_num ){
- parent = (*it2).genotype;
- break;
- }
+ it2--;
+ if ( (*it).parent_id == (*it2).id_num ){
+ parent = (*it2).genotype;
+ break;
+ }
}
- while ( it2 != genotype_vect.begin() );
+ while ( it2 != genotype_vect.begin() );
(*it).genotype->SetParent( parent, NULL );
}
-
+
int cur_update = stats.GetUpdate();
int current_cell = 0;
bool soup_full = false;
@@ -1637,37 +1635,37 @@
for ( ; it != genotype_vect.end(); it++ ){
genebank->AddGenotype( (*it).genotype );
if ( (*it).num_cpus == 0 ){ // historic organism
- // remove immediately, so that it gets transferred into the
- // historic database. We change the update temporarily to the
- // true death time of this organism, so that all stats are correct.
+ // remove immediately, so that it gets transferred into the
+ // historic database. We change the update temporarily to the
+ // true death time of this organism, so that all stats are correct.
stats.SetCurrentUpdate( (*it).update_dead );
genebank->RemoveGenotype( *(*it).genotype );
stats.SetCurrentUpdate( cur_update );
}
else{ // otherwise, we insert as many organisms as we need
for ( int i=0; i<(*it).num_cpus; i++ ){
- if ( current_cell >= cell_array.GetSize() ){
- soup_full = true;
- break;
- }
- InjectGenotype( current_cell, (*it).genotype );
- cPhenotype & phenotype = GetCell(current_cell).GetOrganism()->GetPhenotype();
- if ( (*it).merit > 0) phenotype.SetMerit( cMerit((*it).merit) );
- schedule->Adjust(current_cell, phenotype.GetMerit());
-
- int lineage_label = 0;
- LineageSetupOrganism(GetCell(current_cell).GetOrganism(),
- 0, lineage_label,
- (*it).genotype->GetParentGenotype());
- current_cell += 1;
+ if ( current_cell >= cell_array.GetSize() ){
+ soup_full = true;
+ break;
+ }
+ InjectGenotype( current_cell, (*it).genotype );
+ cPhenotype & phenotype = GetCell(current_cell).GetOrganism()->GetPhenotype();
+ if ( (*it).merit > 0) phenotype.SetMerit( cMerit((*it).merit) );
+ schedule->Adjust(current_cell, phenotype.GetMerit());
+
+ int lineage_label = 0;
+ LineageSetupOrganism(GetCell(current_cell).GetOrganism(),
+ 0, lineage_label,
+ (*it).genotype->GetParentGenotype());
+ current_cell += 1;
}
}
cout << (*it).id_num << " "
- << (*it).parent_id << " "
- << (*it).genotype->GetParentID() << " "
- << (*it).genotype->GetNumOffspringGenotypes() << " "
- << (*it).num_cpus << " "
- << (*it).genotype->GetNumOrganisms() << endl;
+ << (*it).parent_id << " "
+ << (*it).genotype->GetParentID() << " "
+ << (*it).genotype->GetNumOffspringGenotypes() << " "
+ << (*it).num_cpus << " "
+ << (*it).genotype->GetNumOrganisms() << endl;
if (soup_full){
cout << "cPopulation::LoadDumpFile: You are trying to load more organisms than there is space!" << endl;
cout << "cPopulation::LoadDumpFile: Remaining organisms are ignored." << endl;
@@ -1675,7 +1673,7 @@
}
}
sync_events = true;
-
+
return true;
}
@@ -1683,13 +1681,13 @@
bool cPopulation::SavePopulation(ofstream & fp)
{
if (fp.good() == false) return false;
-
+
// Save the update
fp << stats.GetUpdate() << endl;
-
+
// looping through all cells saving state.
for (int i = 0; i < cell_array.GetSize(); i++) cell_array[i].SaveState(fp);
-
+
return true;
}
@@ -1697,20 +1695,20 @@
bool cPopulation::LoadPopulation(ifstream & fp)
{
if(fp.good() == false) return false;
-
+
// Load Update...
int cur_update;
fp >> cur_update;
stats.SetCurrentUpdate(cur_update);
-
+
// Clear out the current population
for (int i = 0; i < cell_array.GetSize(); i++) KillOrganism( cell_array[i] );
-
+
// looping through all organims
for (int i = 0; i < cell_array.GetSize(); i++) cell_array[i].LoadState(fp);
-
+
sync_events = true;
-
+
return true;
}
@@ -1718,9 +1716,9 @@
bool cPopulation::DumpMemorySummary(ofstream & fp)
{
if (fp.good() == false) return false;
-
+
// Dump the memory...
-
+
for (int i = 0; i < cell_array.GetSize(); i++) {
fp << i << " ";
if (cell_array[i].IsOccupied() == false) {
@@ -1729,7 +1727,7 @@
else {
cGenome & mem = cell_array[i].GetOrganism()->GetHardware().GetMemory();
fp << mem.GetSize() << " "
- << mem.AsString() << endl;
+ << mem.AsString() << endl;
}
}
return true;
@@ -1739,22 +1737,22 @@
{
// First check all sub-objects...
if (!genebank->OK() || !schedule->OK()) return false;
-
+
// Next check organisms...
for (int i = 0; i < cell_array.GetSize(); i++) {
if (cell_array[i].OK() == false) return false;
assert(cell_array[i].GetID() == i);
}
-
+
// And stats...
assert(world_x * world_y == cell_array.GetSize());
-
+
return true;
}
/**
- * This function loads a genome from a given file, and initializes
+* This function loads a genome from a given file, and initializes
* a cpu with it.
*
* @param filename The name of the file to load.
@@ -1765,18 +1763,18 @@
**/
void cPopulation::Inject(const cGenome & genome, int cell_id, double merit,
- int lineage_label, double neutral, int mem_space )
+ int lineage_label, double neutral, int mem_space )
{
// If an invalid cell was given, choose a new ID for it.
if (cell_id < 0) {
switch (cConfig::GetBirthMethod()) {
- case POSITION_CHILD_FULL_SOUP_ELDEST:
- cell_id = reaper_queue.PopRear()->GetID();
- default:
- cell_id = 0;
+ case POSITION_CHILD_FULL_SOUP_ELDEST:
+ cell_id = reaper_queue.PopRear()->GetID();
+ default:
+ cell_id = 0;
}
}
-
+
if(mem_space==0) {
InjectGenome( cell_id, genome, lineage_label );
cPhenotype & phenotype = GetCell(cell_id).GetOrganism()->GetPhenotype();
@@ -1788,10 +1786,10 @@
LineageSetupOrganism(GetCell(cell_id).GetOrganism(), 0, lineage_label);
}
else
- {
- ActivateInject(cell_id, genome);
- }
-
+ {
+ ActivateInject(cell_id, genome);
+ }
+
}
cPopulationCell & cPopulation::GetCell(int in_num)
@@ -1824,42 +1822,38 @@
void cPopulation::BuildTimeSlicer(cChangeList * change_list)
{
switch (cConfig::GetSlicingMethod()) {
- case SLICE_CONSTANT:
- cout << "...Building Constant Time Slicer..." << endl;
- schedule = new cConstSchedule(cell_array.GetSize());
- break;
- case SLICE_PROB_MERIT:
- cout << "...Building Probablistic Time Slicer..." << endl;
- schedule = new cProbSchedule(cell_array.GetSize());
- break;
- case SLICE_INTEGRATED_MERIT:
- cout << "...Building Integrated Time Slicer..." << endl;
- schedule = new cIntegratedSchedule(cell_array.GetSize());
- break;
- default:
- cout << "...Requested Time Slicer not found, defaulting to Integrated..."
- << endl;
- schedule = new cIntegratedSchedule(cell_array.GetSize());
- break;
+ case SLICE_CONSTANT:
+ schedule = new cConstSchedule(cell_array.GetSize());
+ break;
+ case SLICE_PROB_MERIT:
+ schedule = new cProbSchedule(cell_array.GetSize());
+ break;
+ case SLICE_INTEGRATED_MERIT:
+ schedule = new cIntegratedSchedule(cell_array.GetSize());
+ break;
+ default:
+ cout << "Warning: Requested Time Slicer not found, defaulting to Integrated." << endl;
+ schedule = new cIntegratedSchedule(cell_array.GetSize());
+ break;
}
schedule->SetChangeList(change_list);
}
void cPopulation::PositionAge(cPopulationCell & parent_cell,
- tList<cPopulationCell> & found_list,
- bool parent_ok)
+ tList<cPopulationCell> & found_list,
+ bool parent_ok)
{
// Start with the parent organism as the replacement, and see if we can find
// anything equivilent or better.
-
+
found_list.Push(&parent_cell);
int max_age = parent_cell.GetOrganism()->GetPhenotype().GetAge();
if (parent_ok == false) max_age = -1;
-
+
// Now look at all of the neighbors.
tListIterator<cPopulationCell> conn_it( parent_cell.ConnectionList() );
-
+
cPopulationCell * test_cell;
while ( (test_cell = conn_it.Next()) != NULL) {
const int cur_age = test_cell->GetOrganism()->GetPhenotype().GetAge();
@@ -1875,19 +1869,19 @@
}
void cPopulation::PositionMerit(cPopulationCell & parent_cell,
- tList<cPopulationCell> & found_list,
- bool parent_ok)
+ tList<cPopulationCell> & found_list,
+ bool parent_ok)
{
// Start with the parent organism as the replacement, and see if we can find
// anything equivilent or better.
-
+
found_list.Push(&parent_cell);
double max_ratio = parent_cell.GetOrganism()->CalcMeritRatio();
if (parent_ok == false) max_ratio = -1;
-
+
// Now look at all of the neighbors.
tListIterator<cPopulationCell> conn_it( parent_cell.ConnectionList() );
-
+
cPopulationCell * test_cell;
while ( (test_cell = conn_it.Next()) != NULL) {
const double cur_ratio = test_cell->GetOrganism()->CalcMeritRatio();
@@ -1903,11 +1897,11 @@
}
void cPopulation::FindEmptyCell(tList<cPopulationCell> & cell_list,
- tList<cPopulationCell> & found_list)
+ tList<cPopulationCell> & found_list)
{
tListIterator<cPopulationCell> cell_it(cell_list);
cPopulationCell * test_cell;
-
+
while ( (test_cell = cell_it.Next()) != NULL) {
// If this cell is empty, add it to the list...
if (test_cell->IsOccupied() == false) found_list.Push(test_cell);
@@ -1920,36 +1914,36 @@
void cPopulation::InjectGenotype(int cell_id, cGenotype *new_genotype)
{
assert(cell_id >= 0 && cell_id < cell_array.GetSize());
-
+
cOrganism * new_organism = new cOrganism(new_genotype->GetGenome(),
- default_interface,
- environment);
-
+ default_interface,
+ environment);
+
// Set the genotype...
new_organism->SetGenotype(new_genotype);
-
+
// Setup the phenotype...
cPhenotype & phenotype = new_organism->GetPhenotype();
phenotype.SetupInject(new_genotype->GetLength());
phenotype.SetMerit( cMerit(new_genotype->GetTestMerit()) );
-
+
// @CAO are these really needed?
phenotype.SetLinesCopied( new_genotype->GetTestCopiedSize() );
phenotype.SetLinesExecuted( new_genotype->GetTestExecutedSize() );
phenotype.SetGestationTime( new_genotype->GetTestGestationTime() );
-
+
// Prep the cell..
if (cConfig::GetBirthMethod() == POSITION_CHILD_FULL_SOUP_ELDEST &&
cell_array[cell_id].IsOccupied() == true) {
// Have to manually take this cell out of the reaper Queue.
reaper_queue.Remove( &(cell_array[cell_id]) );
}
-
+
// Setup the child's mutation rates. Since this organism is being injected
// and has no parent, we should always take the rate from the environment.
new_organism->MutationRates().Copy(cell_array[cell_id].MutationRates());
-
-
+
+
// Activate the organism in the population...
ActivateOrganism(new_organism, cell_array[cell_id]);
}
@@ -1961,37 +1955,37 @@
void cPopulation::InjectClone(int cell_id, cOrganism & orig_org)
{
assert(cell_id >= 0 && cell_id < cell_array.GetSize());
-
+
cOrganism * new_organism = new cOrganism(orig_org.GetGenome(),
- default_interface, environment);
-
+ default_interface, environment);
+
// Set the genotype...
new_organism->SetGenotype(orig_org.GetGenotype());
-
+
// Setup the phenotype...
new_organism->GetPhenotype().SetupClone(orig_org.GetPhenotype());
-
+
// Prep the cell..
if (cConfig::GetBirthMethod() == POSITION_CHILD_FULL_SOUP_ELDEST &&
cell_array[cell_id].IsOccupied() == true) {
// Have to manually take this cell out of the reaper Queue.
reaper_queue.Remove( &(cell_array[cell_id]) );
}
-
+
// Setup the mutation rate based on the population cell...
new_organism->MutationRates().Copy(cell_array[cell_id].MutationRates());
-
+
// Activate the organism in the population...
ActivateOrganism(new_organism, cell_array[cell_id]);
}
void cPopulation::InjectGenome(int cell_id, const cGenome & genome,
- int lineage_label)
+ int lineage_label)
{
// Setup the genotype...
cGenotype * new_genotype = genebank->InjectGenotype(genome, lineage_label);
-
+
// The rest is done by InjectGenotype();
InjectGenotype( cell_id, new_genotype );
}
@@ -2000,27 +1994,27 @@
void cPopulation::SerialTransfer(int transfer_size, bool ignore_deads)
{
assert(transfer_size > 0);
-
+
// If we are ignoring all dead organisms, remove them from the population.
if (ignore_deads == true) {
for (int i = 0; i < GetSize(); i++) {
cPopulationCell & cell = cell_array[i];
if (cell.IsOccupied() && cell.GetOrganism()->GetTestFitness() == 0.0) {
- KillOrganism(cell);
+ KillOrganism(cell);
}
}
}
-
+
// If removing the dead was enough, stop here.
if (num_organisms <= transfer_size) return;
-
+
// Collect a vector of the occupied cells...
vector<int> transfer_pool;
transfer_pool.reserve(num_organisms);
for (int i = 0; i < GetSize(); i++) {
if (cell_array[i].IsOccupied()) transfer_pool.push_back(i);
}
-
+
// Remove the proper number of cells.
const int removal_size = num_organisms - transfer_size;
for (int i = 0; i < removal_size; i++) {
@@ -2039,13 +2033,13 @@
int total=0;
cInjectGenotype * temp;
for(int x=0; x<cell_array.GetSize(); x++)
+ {
+ if(cell_array[x].GetOrganism()!=NULL)
{
- if(cell_array[x].GetOrganism()!=NULL)
- {
- assert(cell_array[x].GetOrganism()->GetNumParasites()>=0 &&
- cell_array[x].GetOrganism()->GetNumParasites()<=1);
- total+=cell_array[x].GetOrganism()->GetNumParasites();
- if(cell_array[x].GetOrganism()->GetNumParasites())
+ assert(cell_array[x].GetOrganism()->GetNumParasites()>=0 &&
+ cell_array[x].GetOrganism()->GetNumParasites()<=1);
+ total+=cell_array[x].GetOrganism()->GetNumParasites();
+ if(cell_array[x].GetOrganism()->GetNumParasites())
{
cHardware4Stack & cpu = (cHardware4Stack &) cell_array[x].GetOrganism()->GetHardware();
outfile << x << " ";
@@ -2054,8 +2048,8 @@
assert(temp!=NULL);
outfile << temp->GetID() << endl;
}
- }
}
+ }
outfile << total << endl;
outfile.close();
}
@@ -2067,7 +2061,7 @@
{
// Only look at cells with organisms in them.
if (cell_array[i].IsOccupied() == false) continue;
-
+
cOrganism * organism = cell_array[i].GetOrganism();
const cPhenotype & phenotype = organism->GetPhenotype();
@@ -2088,13 +2082,13 @@
void cPopulation::PrintPhenotypeStatus(const cString & filename)
{
cDataFile & df_phen = stats.GetDataFile(filename);
-
+
df_phen.WriteComment("Num orgs doing each task for each deme in population");
df_phen.WriteTimeStamp();
df_phen.Write(GetUpdate(), "update");
-
+
cString comment;
-
+
for (int i = 0; i < cell_array.GetSize(); i++)
{
// Only look at cells with organisms in them.
@@ -2102,34 +2096,34 @@
cOrganism * organism = cell_array[i].GetOrganism();
const cPhenotype & phenotype = organism->GetPhenotype();
-
+
comment.Set("cur_merit %d;", i);
df_phen.Write(phenotype.GetMerit().GetDouble(), comment);
-
+
comment.Set("cur_merit_base %d;", i);
df_phen.Write(phenotype.GetCurMeritBase(), comment);
-
+
comment.Set("cur_merit_bonus %d;", i);
df_phen.Write(phenotype.GetCurBonus(), comment);
-
-// comment.Set("last_merit %d", i);
-// df_phen.Write(phenotype.GetLastMerit(), comment);
-
+
+ // comment.Set("last_merit %d", i);
+ // df_phen.Write(phenotype.GetLastMerit(), comment);
+
comment.Set("last_merit_base %d", i);
df_phen.Write(phenotype.GetLastMeritBase(), comment);
-
+
comment.Set("last_merit_bonus %d", i);
df_phen.Write(phenotype.GetLastBonus(), comment);
-
+
comment.Set("life_fitness %d", i);
df_phen.Write(phenotype.GetLifeFitness(), comment);
-
+
comment.Set("*");
df_phen.Write("*", comment);
-
+
}
df_phen.Endl();
-
+
}
@@ -2137,18 +2131,18 @@
{
assert( GetCell(cell_id).IsOccupied() == true);
assert( new_merit >= 0.0 );
-
+
cPhenotype & phenotype = GetCell(cell_id).GetOrganism()->GetPhenotype();
double old_merit = phenotype.GetMerit().GetDouble();
-
+
phenotype.SetMerit( cMerit(new_merit) );
phenotype.SetLifeFitness(new_merit/phenotype.GetGestationTime());
if (new_merit <= old_merit) {
phenotype.SetIsDonorCur(); }
else { phenotype.SetIsReceiver(); }
-
+
schedule->Adjust(cell_id, phenotype.GetMerit());
-
+
return true;
}
Modified: trunk/source/main/primitive.cc
===================================================================
--- trunk/source/main/primitive.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/primitive.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -42,6 +42,9 @@
#ifndef HARDWARE_CPU_HH
#include "hardware_cpu.hh"
#endif
+#ifndef HARDWARE_SMT_H
+#include "hardware_smt.h"
+#endif
#ifndef INST_LIB_CPU_HH
#include "inst_lib_cpu.hh"
#endif
@@ -62,23 +65,21 @@
using namespace std;
-//void ExitAvidaPrimitive(int exit_code)
-//{
-// signal(SIGINT, SIG_IGN); // Ignore all future interupts.
-// delete cAvidaDriver_Base::main_driver;
-// exit(exit_code);
-//}
-
int main(int argc, char * argv[])
{
// Catch Interrupt making sure to close appropriately
signal(SIGINT, ExitAvida);
// output copyright message
- printf( "Avida version %s\nCopyright (C) 1993-2003 California Institute of Technology.\n\n", AVIDA_VERSION );
- printf( "Avida comes with ABSOLUTELY NO WARRANTY.\n" );
- printf( "This is free software, and you are welcome to redistribute it\nunder certain conditions. See file COPYING for details.\n\n" );
-
+ cout << "Avida " << AVIDA_VERSION << endl;
+ cout << "----------------------------------------------------------------------" << endl;
+ cout << "Copyright (C) 1993-2003 California Institute of Technology." << endl;
+ cout << "Copyright (C) 1999-2005 Michigan State University." << endl << endl;
+
+ cout << "Avida comes with ABSOLUTELY NO WARRANTY." << endl;
+ cout << "This is free software, and you are welcome to redistribute it" << endl;
+ cout << "under certain conditions. See file COPYING for details." << endl << endl;
+
// Initialize the configuration data...
cConfig::InitGroupList();
cConfig::Setup(argc, argv);
@@ -97,6 +98,8 @@
cAvidaDriver_Base::main_driver = new cAvidaDriver_Population(environment);
}
+ cout << endl;
+
cAvidaDriver_Base::main_driver->Run();
// Exit Nicely
Modified: trunk/source/main/task_lib.cc
===================================================================
--- trunk/source/main/task_lib.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/main/task_lib.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -1669,7 +1669,6 @@
double cTaskLib::Task_CommEcho() const
{
const int test_output = output_buffer[0];
- const int num_buffs = other_input_buffers.GetSize();
tListIterator<tBuffer<int> > buff_it(other_input_buffers);
@@ -1687,7 +1686,6 @@
double cTaskLib::Task_CommNot() const
{
const int test_output = output_buffer[0];
- const int num_buffs = other_input_buffers.GetSize();
tListIterator<tBuffer<int> > buff_it(other_input_buffers);
Modified: trunk/source/python/AvidaGui2/pyAvida.py
===================================================================
--- trunk/source/python/AvidaGui2/pyAvida.py 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/python/AvidaGui2/pyAvida.py 2005-08-28 22:25:35 UTC (rev 297)
@@ -29,9 +29,7 @@
return None
self.m_environment.GetInstSet().SetInstLib(cHardwareCPU.GetInstLib())
- cHardwareUtil.LoadInstSet_CPUOriginal(
- cConfig.GetInstFilename(),
- self.m_environment.GetInstSet())
+ cHardwareUtil.LoadInstSet(cConfig.GetInstFilename(), self.m_environment.GetInstSet())
cConfig.SetNumInstructions(self.m_environment.GetInstSet().GetSize())
cConfig.SetNumTasks(self.m_environment.GetTaskLib().GetSize())
cConfig.SetNumReactions(self.m_environment.GetReactionLib().GetSize())
Modified: trunk/source/python/AvidaGui2/pyWriteGenesisEvent.py
===================================================================
--- trunk/source/python/AvidaGui2/pyWriteGenesisEvent.py 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/python/AvidaGui2/pyWriteGenesisEvent.py 2005-08-28 22:25:35 UTC (rev 297)
@@ -86,7 +86,7 @@
event_out_file = open(event_file_name, 'a')
for cell in cells_dict.keys():
- part1 = "u 0 inject_sequence " + organisms_dict[cells_dict[cell]] + " "
+ part1 = "u begin inject_sequence " + organisms_dict[cells_dict[cell]] + " "
part2 = cell + " " + str(int(cell)+1) + " -1 "
part3 = cells_dict[cell] + "\n"
event_out_file.write(part1 + part2 + part3)
@@ -99,4 +99,3 @@
os.path.join(tmp_out_dir, "count.dat") +"\n")
event_out_file.close()
-
Modified: trunk/source/qt-viewer/event_view_widget.cc
===================================================================
--- trunk/source/qt-viewer/event_view_widget.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/qt-viewer/event_view_widget.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -52,7 +52,7 @@
#include <qstatusbar.h>
//event descriptions
-#include "cPopulation_descr.hi"
+#include "cPopulation_descr.h"
#ifndef STRING_HH
#include "string.hh"
Modified: trunk/source/qt-viewer/setup_wizard_config.cc
===================================================================
--- trunk/source/qt-viewer/setup_wizard_config.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/qt-viewer/setup_wizard_config.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -19,8 +19,7 @@
#include "tools.hh"
#endif
-#include "cPopulation_descr.hi" // declarations and definitions
-//#include "cPopulation_descr.ci" // for event documentation
+#include "cPopulation_descr.h" // declarations and definitions
using namespace std;
Modified: trunk/source/support/genesis
===================================================================
--- trunk/source/support/genesis 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/support/genesis 2005-08-28 22:25:35 UTC (rev 297)
@@ -3,7 +3,7 @@
# For more information, see doc/genesis.html
#############################################################################
-VERSION_ID 2.3.0 # Do not change this value!
+VERSION_ID 2.3.1 # Do not change this value!
### Architecture Variables ###
MAX_UPDATES -1 # Maximum updates to run simulation (-1 = no limit)
Modified: trunk/source/support/genesis.4stack
===================================================================
--- trunk/source/support/genesis.4stack 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/support/genesis.4stack 2005-08-28 22:25:35 UTC (rev 297)
@@ -3,7 +3,7 @@
# For more information, see doc/genesis.html
#############################################################################
-VERSION_ID 2.3.0 # Do not change this value!
+VERSION_ID 2.3.1 # Do not change this value!
### Architecture Variables ###
MAX_UPDATES -1 # Maximum updates to run simulation (-1 = no limit)
@@ -24,7 +24,7 @@
EVENT_FILE events.cfg # File containing list of events during run
ANALYZE_FILE analyze.cfg # File used for analysis mode
ENVIRONMENT_FILE environment.cfg # File that describes the environment
-START_CREATURE preset_organisms/organism.4stack # Organism to seed the soup
+START_CREATURE organism.4stack # Organism to seed the soup
### Reproduction ###
BIRTH_METHOD 4 # 0 = Replace random organism in neighborhood
Copied: trunk/source/support/genesis.smt (from rev 296, branches/brysonda/source/support/genesis.smt)
Copied: trunk/source/support/inst_set.smt (from rev 296, branches/brysonda/source/support/inst_set.smt)
Copied: trunk/source/support/organism.smt (from rev 296, branches/brysonda/source/support/organism.smt)
Modified: trunk/source/testsuites/functional_testsuites/default.md5sum/genesis
===================================================================
--- trunk/source/testsuites/functional_testsuites/default.md5sum/genesis 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/testsuites/functional_testsuites/default.md5sum/genesis 2005-08-28 22:25:35 UTC (rev 297)
@@ -3,7 +3,7 @@
# For more information, see doc/genesis.html
#############################################################################
-VERSION_ID 2.3.0 # Do not change this value!
+VERSION_ID 2.3.1 # Do not change this value!
### Architecture Variables ###
MAX_UPDATES -1 # Maximum updates to run simulation (-1 = no limit)
Modified: trunk/source/testsuites/functional_testsuites/default.tail/genesis
===================================================================
--- trunk/source/testsuites/functional_testsuites/default.tail/genesis 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/testsuites/functional_testsuites/default.tail/genesis 2005-08-28 22:25:35 UTC (rev 297)
@@ -3,7 +3,7 @@
# For more information, see doc/genesis.html
#############################################################################
-VERSION_ID 2.3.0 # Do not change this value!
+VERSION_ID 2.3.1 # Do not change this value!
### Architecture Variables ###
MAX_UPDATES -1 # Maximum updates to run simulation (-1 = no limit)
Modified: trunk/source/testsuites/functional_testsuites/default.tail.disabled/genesis
===================================================================
--- trunk/source/testsuites/functional_testsuites/default.tail.disabled/genesis 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/testsuites/functional_testsuites/default.tail.disabled/genesis 2005-08-28 22:25:35 UTC (rev 297)
@@ -3,7 +3,7 @@
# For more information, see doc/genesis.html
#############################################################################
-VERSION_ID 2.3.0 # Do not change this value!
+VERSION_ID 2.3.1 # Do not change this value!
### Architecture Variables ###
MAX_UPDATES -1 # Maximum updates to run simulation (-1 = no limit)
Modified: trunk/source/testsuites/functional_testsuites/tedious.tail.disabled/genesis
===================================================================
--- trunk/source/testsuites/functional_testsuites/tedious.tail.disabled/genesis 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/testsuites/functional_testsuites/tedious.tail.disabled/genesis 2005-08-28 22:25:35 UTC (rev 297)
@@ -3,7 +3,7 @@
# For more information, see doc/genesis.html
#############################################################################
-VERSION_ID 2.3.0 # Do not change this value!
+VERSION_ID 2.3.1 # Do not change this value!
### Architecture Variables ###
MAX_UPDATES -1 # Maximum updates to run simulation (-1 = no limit)
Modified: trunk/source/testsuites/unit_testsuites/4stack_head.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/4stack_head.t.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/testsuites/unit_testsuites/4stack_head.t.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,7 +1,7 @@
#include <iostream>
-#ifndef FOURSTACK_HEAD_HH
-#include "4stack_head.hh"
+#ifndef HEAD_MULTI_MEM_HH
+#include "head_multi_mem.hh"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/cpu_head.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/cpu_head.t.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/testsuites/unit_testsuites/cpu_head.t.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -1,7 +1,7 @@
#include <iostream>
-#ifndef CPU_HEAD_HH
-#include "cpu_head.hh"
+#ifndef HEAD_CPU_HH
+#include "head_cpu.hh"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/third-party/yaktest/cTestCase.hh
===================================================================
--- trunk/source/third-party/yaktest/cTestCase.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/third-party/yaktest/cTestCase.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -154,7 +154,7 @@
#endif // WIN32
return false;
}
- };
+ }
//! check the last result for final test results
const cTestResult& lastResult( void ) const;
Modified: trunk/source/tools/block_struct.cc
===================================================================
--- trunk/source/tools/block_struct.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/tools/block_struct.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -9,6 +9,10 @@
#include "block_struct.hh"
#endif
+#include <iostream>
+
+using namespace std;
+
////////////////////
// cBlockStruct
////////////////////
@@ -59,7 +63,7 @@
int cBlockStruct::Process()
{
if (!fixed_size) {
- printf("Error! No fixed size!\n");
+ cerr << "Error: No fixed size!" << endl;
return -1;
}
@@ -118,7 +122,7 @@
size_left -= fixed_size;
}
- printf("END Process() : Ran out of fixed_blocks...\n");
+ cout << "END Process() : Ran out of fixed_blocks..." << endl;
return -1;
}
@@ -188,7 +192,7 @@
size_left -= fixed_size;
}
- printf("END Update() : Ran out of fixed_blocks...\n");
+ cout << "END Update() : Ran out of fixed_blocks..." << endl;
return -1;
}
Modified: trunk/source/tools/functions.hh
===================================================================
--- trunk/source/tools/functions.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/tools/functions.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -53,7 +53,7 @@
in2 = tmp;
}
-};
+}
inline bool ToggleBool(bool & in_bool)
{
Modified: trunk/source/tools/histogram.cc
===================================================================
--- trunk/source/tools/histogram.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/tools/histogram.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -17,6 +17,10 @@
#include <stdio.h>
}
+#include <iostream>
+
+using namespace std;
+
// cHistogram /////////////////////////////////////////////////////////////////
cHistogram::cHistogram(int in_max, int in_min) {
@@ -34,8 +38,7 @@
{
#ifdef DEBUG
if (new_max < new_min) {
- fprintf(stderr, "ERROR: Trying to resize histogram to [%d,%d]\n",
- new_min, new_max);
+ cerr << "Error: Trying to resize histogram to [" << new_min << "," << new_max << "]" << endl;
return;
}
#endif
Modified: trunk/source/tools/histogram.hh
===================================================================
--- trunk/source/tools/histogram.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/tools/histogram.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -84,7 +84,7 @@
return;
}
if (bins[value] <= 1) {
- std::cerr << "WARNING: Trying to remove " << value << " from bin with "
+ std::cerr << "Warning: Trying to remove " << value << " from bin with "
<< bins[value] << " entries" << std::endl;
return;
}
@@ -99,7 +99,7 @@
{
#ifdef DEBUG
if (value > max_bin || value < min_bin) {
- std::cerr << "WARNING: Trying to remove " << value
+ std::cerr << "Warning: Trying to remove " << value
<< " in histogram of range [" << min_bin << "," << max_bin
<< "]" << std::endl;
return;
Modified: trunk/source/tools/indexed_block_struct.cc
===================================================================
--- trunk/source/tools/indexed_block_struct.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/tools/indexed_block_struct.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -9,6 +9,10 @@
#include "indexed_block_struct.hh"
#endif
+#include <iostream>
+
+using namespace std;
+
//////////////////////////
// cIndexedBlockStruct
//////////////////////////
@@ -249,8 +253,7 @@
scaled_used = write_loc;
if (scaled_used != num_data)
- printf("WARNING: after Compress() scaled_used = %d, while num_data = %d\n",
- scaled_used, num_data);
+ cout << "Warning: after Compress() scaled_used = " << scaled_used << ", while num_data = " << num_data << endl;
return scaled_used;
}
Modified: trunk/source/tools/init_file.cc
===================================================================
--- trunk/source/tools/init_file.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/tools/init_file.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -259,15 +259,14 @@
for (int i = 0; i < line_array.GetSize(); i++) {
if (line_array[i].used == false) {
if (found == false) {
- found = true;
- cerr << "Warning unknown lines in input file '" << filename
- << "':" << endl;
+ found = true;
+ cerr << "Warning: unknown lines in input file '" << filename << "':" << endl;
}
- cerr << " " << line_array[i].line_num + 1
- << ": " << line_array[i].line
- << endl;
+ cerr << " " << line_array[i].line_num + 1 << ": " << line_array[i].line << endl;
}
}
+
+ if (found == true) cerr << endl;
return found;
}
Modified: trunk/source/tools/message_display.cc
===================================================================
--- trunk/source/tools/message_display.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/tools/message_display.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -207,7 +207,7 @@
cMessageClosure::~cMessageClosure(void){
if(!(*_type.m_message_class.m_msg_display)){
- cerr << "<~cMessageClosure> WARNING:" << endl;
+ cerr << "<~cMessageClosure> Warning:" << endl;
cerr << "<~cMessageClosure> message display classes not fully initialized;" << endl;
cerr << "<~cMessageClosure> directing messages of class \""
<< cString(_type.m_type_name)
Modified: trunk/source/tools/message_display.hh
===================================================================
--- trunk/source/tools/message_display.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/tools/message_display.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -25,6 +25,8 @@
class cMessageDisplay{
public:
+ virtual ~cMessageDisplay() { ; }
+
virtual void out(cString &final_msg){}
virtual void abort(){ abort(); }
};
Modified: trunk/source/tools/random.hh
===================================================================
--- trunk/source/tools/random.hh 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/tools/random.hh 2005-08-28 22:25:35 UTC (rev 297)
@@ -108,7 +108,7 @@
* @param max The upper bound for the random numbers (will never be returned).
**/
inline unsigned int GetUInt(const unsigned int min, const unsigned int max){
- return GetUInt(max-min+1)+min; }
+ return GetUInt(max - min) + min; }
/**
* Generate an int out of an interval.
@@ -120,7 +120,7 @@
inline int GetInt(const int max){
return (int)GetUInt(max); }
inline int GetInt(const int min, const int max){
- return ((int)GetUInt(max-min+1))+min; }
+ return ((int)GetUInt(max - min)) + min; }
// Random Event Generation //////////////////////////////////////////////////
Copied: trunk/source/tools/tObjectFactory.h (from rev 296, branches/brysonda/source/tools/tObjectFactory.h)
Modified: trunk/source/tools/tools.cc
===================================================================
--- trunk/source/tools/tools.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/tools/tools.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -30,26 +30,26 @@
bool cTools::MkDir(const cString & dirname, bool verbose)
{
- if (verbose) cout << "Checking for directory '" << dirname << "'..." << endl;
+ if (verbose) cout << "Checking for directory '" << dirname << "'..." << flush;
FILE * fp = fopen ( dirname(), "r" );
if (fp == 0) {
if (errno == ENOENT) {
- if (verbose) cout << " ...not found. Has to be created..." << endl;
+ if (verbose) cout << " not found, creating..." << flush;
if (mkdir( dirname(), (S_IRWXU|S_IRWXG|S_IRWXO) )) {
- if (verbose) cerr << " ...ERROR! Failed to create directory '"
- << dirname << "'. This may cause problems..."
- << endl;
- return false;
+ if (verbose)
+ cerr << endl << "Warning: Failed to create directory '" << dirname << "'." << endl;
+ return false;
}
- if (verbose) cout << " ...done!" << endl;
+ if (verbose) cout << " done." << endl;
return true;
}
- if (verbose) cout << " ...ERROR! -- Failed to open directory! This may cause problems." << endl;
+ if (verbose) cout << "Warning: Failed to open '" << dirname << "'." << endl;
return false;
}
+ if (verbose) cout << " found." << endl;
return true;
}
Modified: trunk/source/viewers/symbol_util.cc
===================================================================
--- trunk/source/viewers/symbol_util.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/viewers/symbol_util.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -17,6 +17,7 @@
#include "hardware_base.hh"
#include "hardware_4stack.hh"
#include "hardware_cpu.hh"
+#include "hardware_smt.h"
using namespace std;
@@ -117,21 +118,18 @@
// if (thread_count < 200) return 'C';
//const cHardwareBase * hardware;
int num_threads;
- if(cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL)
- {
- //const cHardwareCPU & hard_cpu= (cHardwareCPU &) cell.GetOrganism()->GetHardware();
- //num_threads = hard_cpu.GetNumThreads();
+ switch (cConfig::GetHardwareType())
+ {
+ case HARDWARE_TYPE_CPU_ORIGINAL:
num_threads = ((cHardwareCPU &) cell.GetOrganism()->GetHardware()).GetNumThreads();
return (char) ('0' + num_threads);
- }
- else
- {
- //const cHardware4Stack & hard_4stack= (cHardware4Stack &) cell.GetOrganism()->GetHardware();
- //num_threads = hard_4stack.GetNumThreads();
+ case HARDWARE_TYPE_CPU_4STACK:
num_threads = ((cHardware4Stack &) cell.GetOrganism()->GetHardware()).GetNumThreads();
return (char) ('0' + num_threads);
- }
- //return '+';
+ case HARDWARE_TYPE_CPU_SMT:
+ num_threads = static_cast<cHardwareSMT&>(cell.GetOrganism()->GetHardware()).GetNumThreads();
+ return (char) ('0' + num_threads);
+ }
}
char cSymbolUtil::GetLineageSymbol(const cPopulationCell & cell)
Modified: trunk/source/viewers/viewer.cc
===================================================================
--- trunk/source/viewers/viewer.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/viewers/viewer.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -32,10 +32,15 @@
signal(SIGINT, ExitAvida);
// output copyright message
- printf( "Avida version %s\nCopyright (C) 1993-2003 California Institute of Technology.\n\n", AVIDA_VERSION );
- printf( "Avida comes with ABSOLUTELY NO WARRANTY.\n" );
- printf( "This is free software, and you are welcome to redistribute it\nunder certain conditions. See file COPYING for details.\n\n" );
-
+ cout << "Avida " << AVIDA_VERSION << endl;
+ cout << "----------------------------------------------------------------------" << endl;
+ cout << "Copyright (C) 1993-2003 California Institute of Technology." << endl;
+ cout << "Copyright (C) 1999-2005 Michigan State University." << endl << endl;
+
+ cout << "Avida comes with ABSOLUTELY NO WARRANTY." << endl;
+ cout << "This is free software, and you are welcome to redistribute it" << endl;
+ cout << "under certain conditions. See file COPYING for details." << endl << endl;
+
// Initialize the configuration data...
cConfig::InitGroupList();
cConfig::Setup(argc, argv);
Modified: trunk/source/viewers/zoom_screen.cc
===================================================================
--- trunk/source/viewers/zoom_screen.cc 2005-08-28 18:31:57 UTC (rev 296)
+++ trunk/source/viewers/zoom_screen.cc 2005-08-28 22:25:35 UTC (rev 297)
@@ -577,7 +577,7 @@
Print(14, 34, "%14d", hardwareCPU.Register(2));
Print(15, 34, "%14d", hardwareCPU.GetStack(0));
- cCPUHead inst_ptr(hardwareCPU.IP());
+ cHeadCPU inst_ptr(hardwareCPU.IP());
const cInstSet & inst_set = hardwareCPU.GetInstSet();
for (int pos = 0; pos < 3; pos++) {
@@ -597,7 +597,7 @@
Print(CPU_FLAGS_Y + 1, CPU_FLAGS_X + 1, "Mem Allocated");
// And print the IP.
- const cCPUHead & active_inst_ptr = hardwareCPU.IP();
+ const cHeadCPU & active_inst_ptr = hardwareCPU.IP();
// @CAO assume no parasites for now.
int cur_id = info.GetActiveCell()->GetID();
//active_inst_ptr.GetCurHardware()->GetOrganism()->GetEnvironment()->GetID();
@@ -618,7 +618,7 @@
Print(14, 34, "%14d", hardware4Stack.Stack(2).Top());
Print(15, 34, "%14d", hardware4Stack.Stack(3).Top());
- c4StackHead inst_ptr(hardware4Stack.IP());
+ cHeadMultiMem inst_ptr(hardware4Stack.IP());
const cInstSet & inst_set = hardware4Stack.GetInstSet();
for (int pos = 0; pos < 3; pos++) {
@@ -638,7 +638,7 @@
//Print(CPU_FLAGS_Y + 1, CPU_FLAGS_X + 1, "Mem Allocated");
// And print the IP.
- const c4StackHead & active_inst_ptr = hardware4Stack.IP();
+ const cHeadMultiMem & active_inst_ptr = hardware4Stack.IP();
// @CAO assume no parasites for now.
//int cur_id = info.GetActiveCell()->GetID();
//active_inst_ptr.GetCurHardware()->GetOrganism()->GetEnvironment()->GetID();
@@ -851,7 +851,7 @@
cur_mem_space = hardware4Stack.IP(cur_view_thread).GetMemSpace();
}
//hardware4Stack.SetThread(cur_view_thread);
- c4StackHead & cur_ip = hardware4Stack.IP(cur_view_thread);
+ cHeadMultiMem & cur_ip = hardware4Stack.IP(cur_view_thread);
// Place the stacks onto the screen.
SetBoldColor(COLOR_CYAN);
@@ -1059,7 +1059,7 @@
cHardwareCPU & hardware =
(cHardwareCPU &) info.GetActiveCell()->GetOrganism()->GetHardware();
const cInstSet & inst_set = hardware.GetInstSet();
- cCPUHead edit_head( hardware.IP() );
+ cHeadCPU edit_head( hardware.IP() );
if (parasite_zoom == true) {
edit_head.Set(0, &(info.GetActiveCell()->GetOrganism()->GetHardware()) );
}
@@ -1128,7 +1128,7 @@
cHardwareCPU & hardware =
(cHardwareCPU &) info.GetActiveCell()->GetOrganism()->GetHardware();
// cosnt cInstSet & inst_set = hardware.GetInstSet();
- cCPUHead view_head( hardware.IP() );
+ cHeadCPU view_head( hardware.IP() );
if (parasite_zoom == true) {
view_head.Set(0, &(info.GetActiveCell()->GetOrganism()->GetHardware()) );
}
@@ -1185,7 +1185,7 @@
cHardwareCPU & hardware =
(cHardwareCPU &) info.GetActiveCell()->GetOrganism()->GetHardware();
- cCPUHead inst_ptr( hardware.IP() );
+ cHeadCPU inst_ptr( hardware.IP() );
if (parasite_zoom == true) {
inst_ptr.Set(0, &(info.GetActiveCell()->GetOrganism()->GetHardware()) );
}
More information about the Avida-cvs
mailing list