[Avida-cvs] [Avida2-svn] r283 - in branches/brysonda: Avida2.xcodeproj source/bindings/Boost.Python source/cpu source/event source/python/AvidaGui2 source/tools
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Wed Aug 10 11:53:27 PDT 2005
Author: brysonda
Date: 2005-08-10 14:53:27 -0400 (Wed, 10 Aug 2005)
New Revision: 283
Removed:
branches/brysonda/source/event/cPopulation_event_list
branches/brysonda/source/python/AvidaGui2/untar_in_resource_directory.tar
Modified:
branches/brysonda/Avida2.xcodeproj/project.pbxproj
branches/brysonda/source/bindings/Boost.Python/CMakeLists.txt
branches/brysonda/source/cpu/cpu_test_info.cc
branches/brysonda/source/cpu/cpu_test_info.hh
branches/brysonda/source/cpu/hardware_4stack.cc
branches/brysonda/source/cpu/hardware_base.cc
branches/brysonda/source/cpu/hardware_base.hh
branches/brysonda/source/cpu/hardware_cpu.cc
branches/brysonda/source/cpu/hardware_smt.cc
branches/brysonda/source/cpu/hardware_status_printer.cc
branches/brysonda/source/cpu/test_cpu.cc
branches/brysonda/source/event/event.hh
branches/brysonda/source/event/event_factory_manager.cc
branches/brysonda/source/event/event_factory_manager.hh
branches/brysonda/source/event/event_list_entry.hh
branches/brysonda/source/event/population_event.hh
branches/brysonda/source/event/population_event_factory.cc
branches/brysonda/source/event/population_event_factory.hh
branches/brysonda/source/tools/tDictionary.hh
Log:
Merge in r281 from trunk. Also rework event naming and description setup in preparation for event self-documentation.
Modified: branches/brysonda/Avida2.xcodeproj/project.pbxproj
===================================================================
--- branches/brysonda/Avida2.xcodeproj/project.pbxproj 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/Avida2.xcodeproj/project.pbxproj 2005-08-10 18:53:27 UTC (rev 283)
@@ -844,7 +844,6 @@
DCC30FCE0762539D008F7A48 /* defs.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = defs.hh; sourceTree = "<group>"; };
DCC30FCF0762539D008F7A48 /* Doxyfile */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = Doxyfile; sourceTree = "<group>"; };
DCC30FEB0762539D008F7A48 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
- DCC30FED0762539D008F7A48 /* cPopulation_event_list */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = cPopulation_event_list; sourceTree = "<group>"; };
DCC30FEF0762539D008F7A48 /* event.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = event.hh; sourceTree = "<group>"; };
DCC30FF00762539D008F7A48 /* event.pri */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = event.pri; sourceTree = "<group>"; };
DCC30FF30762539D008F7A48 /* event_factory_manager.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = event_factory_manager.cc; sourceTree = "<group>"; };
@@ -2020,7 +2019,6 @@
isa = PBXGroup;
children = (
DCC30FEB0762539D008F7A48 /* CMakeLists.txt */,
- DCC30FED0762539D008F7A48 /* cPopulation_event_list */,
DCC30FEF0762539D008F7A48 /* event.hh */,
DCC30FF00762539D008F7A48 /* event.pri */,
DCC30FF30762539D008F7A48 /* event_factory_manager.cc */,
Modified: branches/brysonda/source/bindings/Boost.Python/CMakeLists.txt
===================================================================
--- branches/brysonda/source/bindings/Boost.Python/CMakeLists.txt 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/bindings/Boost.Python/CMakeLists.txt 2005-08-10 18:53:27 UTC (rev 283)
@@ -78,7 +78,7 @@
inject_genotype::
integrated_schedule_node::
tBuffer::
- tDictionary::
+ #tDictionary::
##### Each of these wrappers satisfies Pyste, compiles, and loads, but are untested.
analyze_command_def_base:: # XXX XXX
Modified: branches/brysonda/source/cpu/cpu_test_info.cc
===================================================================
--- branches/brysonda/source/cpu/cpu_test_info.cc 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/cpu/cpu_test_info.cc 2005-08-10 18:53:27 UTC (rev 283)
@@ -25,6 +25,7 @@
, trace_task_order(false)
, use_random_inputs(false)
, org_array(max_tests)
+ , m_tracer(NULL)
{
org_array.SetAll(NULL);
Clear();
@@ -55,15 +56,13 @@
}
-void cCPUTestInfo::SetTraceExecution(const cString & filename)
+void cCPUTestInfo::SetTraceExecution(cHardwareTracer *tracer)
{
- trace_execution = true;
- trace_fp.open(filename);
- assert (trace_fp.good() == true); // Unable to open trace file.
+ trace_execution = (tracer)?(true):(false);
+ m_tracer = tracer;
}
-
double cCPUTestInfo::GetGenotypeFitness()
{
if (org_array[0] != NULL) return org_array[0]->GetPhenotype().GetFitness();
Modified: branches/brysonda/source/cpu/cpu_test_info.hh
===================================================================
--- branches/brysonda/source/cpu/cpu_test_info.hh 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/cpu/cpu_test_info.hh 2005-08-10 18:53:27 UTC (rev 283)
@@ -8,8 +8,6 @@
#ifndef CPU_TEST_INFO_HH
#define CPU_TEST_INFO_HH
-#include <fstream>
-
#ifndef CPU_DEFS_HH
#include "cpu_defs.hh"
#endif
@@ -20,6 +18,7 @@
#include "tArray.hh"
#endif
+class cHardwareTracer;
class cOrganism;
class cString;
@@ -33,7 +32,7 @@
bool trace_execution; // Should we trace this CPU?
bool trace_task_order; // Should we keep track of ordering of tasks?
bool use_random_inputs; // Should we give the organism random inputs?
- std::ofstream trace_fp;
+ cHardwareTracer *m_tracer;
// Outputs...
bool is_viable; // Is this organism colony forming?
@@ -58,7 +57,7 @@
void PrintThreads(bool _print=true) { print_threads = _print; }
void TraceTaskOrder(bool _trace=true) { trace_task_order = _trace; }
void UseRandomInputs(bool _rand=true) { use_random_inputs = _rand; }
- void SetTraceExecution(const cString & filename="trace.dat");
+ void SetTraceExecution(cHardwareTracer *tracer = NULL);
// Input Accessors
int GetGenerationTests() const { return generation_tests; }
@@ -67,7 +66,7 @@
bool GetTraceTaskOrder() const { return trace_task_order; }
bool GetUseRandomInputs() const { return use_random_inputs; }
bool GetTraceExecution() const { return trace_execution; }
- std::ofstream & GetTraceFP() { return trace_fp; }
+ cHardwareTracer *GetTracer() { return m_tracer; }
// Output Accessors
Modified: branches/brysonda/source/cpu/hardware_4stack.cc
===================================================================
--- branches/brysonda/source/cpu/hardware_4stack.cc 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/cpu/hardware_4stack.cc 2005-08-10 18:53:27 UTC (rev 283)
@@ -374,8 +374,13 @@
#endif
// Print the status of this CPU at each step...
- const cString & next_name = inst_set->GetName(IP().GetInst())();
- if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
+ if (m_tracer != NULL) {
+ if (cHardwareTracer_4Stack * tracer
+ = dynamic_cast<cHardwareTracer_4Stack *>(m_tracer)
+ ){
+ tracer->TraceHardware_4Stack(*this);
+ }
+ }
// Find the instruction to be executed
const cInstruction & cur_inst = IP().GetInst();
@@ -482,10 +487,14 @@
// @CAO FIX PRINTING TO INDICATE THIS IS A BONUS
// Print the status of this CPU at each step...
- cString next_name = cStringUtil::Stringf("%s (bonus instruction)",
- inst_set->GetName(inst)());
- if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
-
+ if (m_tracer != NULL) {
+ if (cHardwareTracer_4Stack * tracer
+ = dynamic_cast<cHardwareTracer_4Stack *>(m_tracer)
+ ){
+ tracer->TraceHardware_4StackBonus(*this);
+ }
+ }
+
SingleProcess_ExecuteInst(inst);
organism->SetRunning(prev_run_state);
Modified: branches/brysonda/source/cpu/hardware_base.cc
===================================================================
--- branches/brysonda/source/cpu/hardware_base.cc 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/cpu/hardware_base.cc 2005-08-10 18:53:27 UTC (rev 283)
@@ -17,7 +17,7 @@
: organism(in_organism)
, inst_set(in_inst_set)
, viewer_lock(-1)
- , trace_fp(NULL)
+ , m_tracer(NULL)
{
assert(inst_set->OK());
assert(organism != NULL);
Modified: branches/brysonda/source/cpu/hardware_base.hh
===================================================================
--- branches/brysonda/source/cpu/hardware_base.hh 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/cpu/hardware_base.hh 2005-08-10 18:53:27 UTC (rev 283)
@@ -31,7 +31,7 @@
int viewer_lock; // Used if the viewer should only lock onto
// one aspect of the hardware.
- ostream * trace_fp; // Set this if you want execution traced.
+ cHardwareTracer * m_tracer; // Set this if you want execution traced.
static int instance_count;
public:
@@ -73,7 +73,7 @@
virtual void SaveState(std::ostream & fp) = 0;
virtual void LoadState(std::istream & fp) = 0;
- void SetTrace(ostream * in_fp) { trace_fp = in_fp; }
+ void SetTrace(cHardwareTracer * tracer) { m_tracer = tracer; }
// -------- Mutations (Must be Virtual) --------
Modified: branches/brysonda/source/cpu/hardware_cpu.cc
===================================================================
--- branches/brysonda/source/cpu/hardware_cpu.cc 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/cpu/hardware_cpu.cc 2005-08-10 18:53:27 UTC (rev 283)
@@ -472,9 +472,13 @@
#endif
// Print the status of this CPU at each step...
- const cString & next_name = inst_set->GetName(IP().GetInst())();
- if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
-
+ if (m_tracer != NULL) {
+ if (cHardwareTracer_CPU * tracer
+ = dynamic_cast<cHardwareTracer_CPU *>(m_tracer)
+ ){
+ tracer->TraceHardware_CPU(*this);
+ }
+ }
// Find the instruction to be executed
const cInstruction & cur_inst = IP().GetInst();
@@ -582,9 +586,13 @@
// @CAO FIX PRINTING TO INDICATE THIS IS A BONUS
// Print the status of this CPU at each step...
- cString next_name = cStringUtil::Stringf("%s (bonus instruction)",
- inst_set->GetName(inst)());
- if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
+ if (m_tracer != NULL) {
+ if (cHardwareTracer_CPU * tracer
+ = dynamic_cast<cHardwareTracer_CPU *>(m_tracer)
+ ){
+ tracer->TraceHardware_CPUBonus(*this);
+ }
+ }
SingleProcess_ExecuteInst(inst);
Modified: branches/brysonda/source/cpu/hardware_smt.cc
===================================================================
--- branches/brysonda/source/cpu/hardware_smt.cc 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/cpu/hardware_smt.cc 2005-08-10 18:53:27 UTC (rev 283)
@@ -271,10 +271,13 @@
}
#endif
- // Print the status of this CPU at each step...
- const cString& next_name = inst_set->GetName(IP().GetInst())();
- if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
-
+ // DDD - there is no cHardwareTracer_SMT -- Print the status of this CPU at each step...
+ //if (m_tracer != NULL) {
+ // if (cHardwareTracer_SMT* tracer = dynamic_cast<cHardwareTracer_SMT *>(m_tracer)) {
+ // tracer->TraceHardware_SMT(*this);
+ // }
+ //}
+
// Find the instruction to be executed
const cInstruction & cur_inst = IP().GetInst();
@@ -377,9 +380,12 @@
bool prev_run_state = organism->GetIsRunning();
organism->SetRunning(true);
- // Print the status of this CPU at each step...
- cString next_name = cStringUtil::Stringf("%s (bonus instruction)", inst_set->GetName(inst)());
- if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
+ // DDD - there is no cHardwareTracer_SMT -- Print the status of this CPU at each step...
+ //if (m_tracer != NULL) {
+ // if (cHardwareTracer_SMT* tracer = dynamic_cast<cHardwareTracer_SMT *>(m_tracer)) {
+ // tracer->TraceHardware_SMTBonus(*this);
+ // }
+ //}
SingleProcess_ExecuteInst(inst);
Modified: branches/brysonda/source/cpu/hardware_status_printer.cc
===================================================================
--- branches/brysonda/source/cpu/hardware_status_printer.cc 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/cpu/hardware_status_printer.cc 2005-08-10 18:53:27 UTC (rev 283)
@@ -65,14 +65,14 @@
const cString &child_memory
){
if (time_used == time_allocated) {
- m_trace_fp << endl << "TIMEOUT: No offspring produced." << endl;
+ m_trace_fp << endl << "# TIMEOUT: No offspring produced." << endl;
}
else if (size == 0) {
- m_trace_fp << endl << "ORGANISM DEATH: No offspring produced." << endl;
+ m_trace_fp << endl << "# ORGANISM DEATH: No offspring produced." << endl;
}
else {
m_trace_fp
- << endl << "Final Memory: " << final_memory
- << endl << "Child Memory: " << child_memory << endl;
+ << endl << "# Final Memory: " << final_memory
+ << endl << "# Child Memory: " << child_memory << endl;
}
}
Modified: branches/brysonda/source/cpu/test_cpu.cc
===================================================================
--- branches/brysonda/source/cpu/test_cpu.cc 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/cpu/test_cpu.cc 2005-08-10 18:53:27 UTC (rev 283)
@@ -142,17 +142,18 @@
// Prepare the inputs...
cur_input = 0;
+ cur_receive = 0;
// Determine if we're tracing and what we need to print.
- ostream * trace_fp =
- test_info.GetTraceExecution() ? &(test_info.GetTraceFP()) : NULL;
+ cHardwareTracer * tracer =
+ test_info.GetTraceExecution() ? (test_info.GetTracer()) : NULL;
int time_used = 0;
while (time_used < time_allocated &&
organism.GetHardware().GetMemory().GetSize() &&
organism.GetPhenotype().GetNumDivides() == 0) {
time_used++;
- organism.GetHardware().SetTrace(trace_fp);
+ organism.GetHardware().SetTrace(tracer);
organism.GetHardware().SingleProcess();
organism.GetHardware().SetTrace(NULL);
//resource_count.Update(1/cConfig::GetAveTimeslice());
@@ -160,24 +161,22 @@
}
// Print out some final info in trace...
- if (trace_fp != NULL) {
- if (time_used == time_allocated) {
- *trace_fp << endl << "# TIMEOUT: No offspring produced." << endl;
+ if (tracer != NULL) {
+ if (cHardwareTracer_TestCPU * tracer_test_cpu
+ = dynamic_cast<cHardwareTracer_TestCPU *>(tracer)
+ ){
+ tracer_test_cpu->TraceHardware_TestCPU(
+ time_used,
+ time_allocated,
+ organism.GetHardware().GetMemory().GetSize(),
+ organism.GetHardware().GetMemory().AsString(),
+ organism.ChildGenome().AsString()
+ );
}
- else if (organism.GetHardware().GetMemory().GetSize() == 0) {
- *trace_fp << endl << "# ORGANISM DEATH: No offspring produced." << endl;
- }
- else {
- *trace_fp << endl << "# Final Memory: "
- << organism.GetHardware().GetMemory().AsString() << endl
- << "# Child Memory: " << organism.ChildGenome().AsString()
- << endl;
- }
}
// For now, always return true.
return true;
-
}
Deleted: branches/brysonda/source/event/cPopulation_event_list
===================================================================
--- branches/brysonda/source/event/cPopulation_event_list 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/event/cPopulation_event_list 2005-08-10 18:53:27 UTC (rev 283)
@@ -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>
Modified: branches/brysonda/source/event/event.hh
===================================================================
--- branches/brysonda/source/event/event.hh 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/event/event.hh 2005-08-10 18:53:27 UTC (rev 283)
@@ -25,36 +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 factory_id = -1 )
- : m_name( name ), m_args( args ), m_factory_id( factory_id ) { ; }
+ 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: branches/brysonda/source/event/event_factory_manager.cc
===================================================================
--- branches/brysonda/source/event/event_factory_manager.cc 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/event/event_factory_manager.cc 2005-08-10 18:53:27 UTC (rev 283)
@@ -21,7 +21,7 @@
}
cEventFactoryManager::~cEventFactoryManager(){
- vector<tObjectFactory<cEvent (const cString&)>*>::iterator it = m_factory_list.begin();
+ vector<tObjectFactory<cEvent ()>*>::iterator it = m_factory_list.begin();
for( ; it != m_factory_list.end(); it++ )
delete *it;
@@ -36,10 +36,10 @@
// factory_id < 0 => send to all factories
if( factory_id < 0 ){
- vector<tObjectFactory<cEvent (const cString&)>*>::iterator it;
+ vector<tObjectFactory<cEvent ()>*>::iterator it;
for( it = m_factory_list.begin(); it != m_factory_list.end(); it++ ){
if( *it != NULL )
- event = (*it)->Create(name,args);
+ event = (*it)->Create(name);
if ( event != NULL ) // if we have found one factory that can create the
// event we want we stop.
break;
@@ -50,14 +50,15 @@
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]->Create(name,args);
+ event = m_factory_list[factory_id]->Create(name);
}
+
+ event->Configure(args);
return event;
}
-int
-cEventFactoryManager::AddFactory(tObjectFactory<cEvent (const cString&)>* factory)
+int cEventFactoryManager::AddFactory(tObjectFactory<cEvent ()>* factory)
{
assert( factory != NULL );
m_factory_list.push_back(factory);
@@ -68,4 +69,3 @@
return id;
}
-
Modified: branches/brysonda/source/event/event_factory_manager.hh
===================================================================
--- branches/brysonda/source/event/event_factory_manager.hh 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/event/event_factory_manager.hh 2005-08-10 18:53:27 UTC (rev 283)
@@ -31,7 +31,7 @@
class cEventFactoryManager {
private:
- std::vector<tObjectFactory<cEvent (const cString&)>*> m_factory_list;
+ std::vector<tObjectFactory<cEvent ()>*> m_factory_list;
// not implemented, prevents inadvertent wrong instantiation
cEventFactoryManager( const cEventFactoryManager & );
@@ -40,16 +40,14 @@
cEventFactoryManager();
~cEventFactoryManager();
- int AddFactory(tObjectFactory<cEvent (const cString&)>* 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);
};
#endif
Modified: branches/brysonda/source/event/event_list_entry.hh
===================================================================
--- branches/brysonda/source/event/event_list_entry.hh 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/event/event_list_entry.hh 2005-08-10 18:53:27 UTC (rev 283)
@@ -91,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: branches/brysonda/source/event/population_event.hh
===================================================================
--- branches/brysonda/source/event/population_event.hh 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/event/population_event.hh 2005-08-10 18:53:27 UTC (rev 283)
@@ -18,7 +18,6 @@
class cPopulationEvent : public cEvent {
private:
// not implemented. prevents inadvertend wrong instantiation.
- cPopulationEvent();
cPopulationEvent(const cPopulationEvent&);
const cPopulationEvent& operator=(cPopulationEvent&);
@@ -26,8 +25,7 @@
cPopulation *population;
public:
- cPopulationEvent(const cString& name, const cString& args) : cEvent(name, args) { ; }
-
+ cPopulationEvent() { ; }
void SetPopulation(cPopulation* pop) { population = pop; }
};
Modified: branches/brysonda/source/event/population_event_factory.cc
===================================================================
--- branches/brysonda/source/event/population_event_factory.cc 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/event/population_event_factory.cc 2005-08-10 18:53:27 UTC (rev 283)
@@ -103,1382 +103,1573 @@
namespace nPopulation {
-class cEvent_exit : public cPopulationEvent {
-private:
-public:
- cEvent_exit(const cString& in_args)
- :cPopulationEvent("exit", in_args)
+ class cEvent_exit : public cPopulationEvent {
+ public:
+ const cString GetName() const { return "exit"; }
+ const cString GetDescription() const { return "exit"; }
+
+ void Configure(const cString& in_args)
{
- (void)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:
- cEvent_exit_if_generation_greater_than(const cString& in_args):
- cPopulationEvent("exit_if_generation_greater_than", in_args) {
- cString args(in_args);
- max_generation = args.PopWord().AsInt();
- }
- ///// exit_if_generation_greater_than /////
- void Process(){
- if( population->GetGeneration() > max_generation ){
+ ///// exit /////
+ void Process(){
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:
- cEvent_exit_if_update_greater_than(const cString& in_args):
- cPopulationEvent("exit_if_update_greater_than", in_args) {
+ };
+
+ ///// 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>"; }
- cString args(in_args);
- max_update = args.PopWord().AsInt();
+ 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 /////
- 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:
- cEvent_exit_if_ave_lineage_label_smaller(const cString& in_args):
- cPopulationEvent("exit_if_ave_lineage_label_smaller", in_args) {
+
+ /**
+ * 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>"; }
- cString args(in_args);
- lineage_label_crit_value = args.PopWord().AsDouble();
+ 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 /////
- 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:
- cEvent_exit_if_ave_lineage_label_larger(const cString& in_args):
- cPopulationEvent("exit_if_ave_lineage_label_larger", in_args) {
+
+ /**
+ * 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>"; }
- cString args(in_args);
- lineage_label_crit_value = args.PopWord().AsDouble();
+ 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 /////
- 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:
- cEvent_echo(const cString& in_args):
- cPopulationEvent("echo", in_args) {
+
+ /**
+ * 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>"; }
- cString args(in_args);
- mesg = args.PopWord();
+ 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 /////
- void Process(){
- if( mesg == "" ){
- mesg.Set("Echo : Update = %f\t AveGeneration = %f",
- population->GetUpdate(), population->GetGeneration());
- }
- cAvidaDriver_Base::main_driver->NotifyComment(mesg);
+
+ /**
+ * 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();
}
-};
-
-///// 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:
- cEvent_print_data(const cString& in_args):
- cPopulationEvent("print_data", in_args) {
-
- cString args(in_args);
- filename = args.PopWord();
- format = 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 /////
- void Process(){
- population->GetStats().PrintDataFile(filename, format, ',');
- }
-};
-
-///// print_average_data /////
-
-/**
-* Output various average quantities into datafile.
- *
- * Parameters:
- * filename (string) default: average.dat
+
+ /**
+ * 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_average_data : public cPopulationEvent {
-private:
- cString fname;
-public:
- cEvent_print_average_data(const cString& in_args):
- cPopulationEvent("print_average_data", in_args) {
+
+
+ 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>"; }
- cString args(in_args);
- if (args == "") fname="average.dat"; else fname=args.PopWord();
- }
+ 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 /////
- 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:
- cEvent_print_error_data(const cString& in_args):
- cPopulationEvent("print_error_data", in_args) {
+
+ /**
+ * 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\"]"; }
- cString args(in_args);
- if (args == "") fname="error.dat"; else fname=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_variance_data(const cString& in_args):
- cPopulationEvent("print_variance_data", in_args) {
+
+ /**
+ * 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\"]"; }
- cString args(in_args);
- if (args == "") fname="variance.dat"; else fname=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_dominant_data(const cString& in_args):
- cPopulationEvent("print_dominant_data", in_args) {
+
+ /**
+ * 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\"]"; }
- cString args(in_args);
- if (args == "") fname="dominant.dat"; else fname=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_stats_data(const cString& in_args):
- cPopulationEvent("print_stats_data", in_args) {
+
+ /**
+ * 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\"]"; }
- cString args(in_args);
- if (args == "") fname="stats.dat"; else fname=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_count_data(const cString& in_args):
- cPopulationEvent("print_count_data", in_args) {
+
+ /**
+ * 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\"]"; }
- cString args(in_args);
- if (args == "") fname="count.dat"; else fname=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_totals_data(const cString& in_args):
- cPopulationEvent("print_totals_data", in_args) {
+
+ /**
+ * 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\"]"; }
- cString args(in_args);
- if (args == "") fname="totals.dat"; else fname=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_tasks_data(const cString& in_args):
- cPopulationEvent("print_tasks_data", in_args) {
+
+ /**
+ * 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\"]"; }
- cString args(in_args);
- if (args == "") fname="tasks.dat"; else fname=args.PopWord();
+ 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 /////
- void Process(){
- population->GetStats().PrintTasksData(fname);
- }
-};
-
-///// print_tasks_exe_data /////
-
-/**
-**/
-
-
-class cEvent_print_tasks_exe_data : public cPopulationEvent {
-private:
- cString fname;
-public:
- cEvent_print_tasks_exe_data(const cString& in_args):
- cPopulationEvent("print_tasks_exe_data", in_args) {
+
+ /**
+ * 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\"]"; }
- cString args(in_args);
- if (args == "") fname="tasks_exe.dat"; else fname=args.PopWord();
+ 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 /////
- void Process(){
- population->GetStats().PrintTasksExeData(fname);
- }
-};
-
-///// print_resource_data /////
-
-/**
-**/
-
-
-class cEvent_print_resource_data : public cPopulationEvent {
-private:
- cString fname;
-public:
- cEvent_print_resource_data(const cString& in_args):
- cPopulationEvent("print_resource_data", in_args) {
+
+ /**
+ **/
+
+
+ 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\"]"; }
- cString args(in_args);
- if (args == "") fname="resource.dat"; else fname=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_time_data(const cString& in_args):
- cPopulationEvent("print_time_data", in_args) {
+
+ /**
+ **/
+
+
+ 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\"]"; }
- cString args(in_args);
- if (args == "") fname="time.dat"; else fname=args.PopWord();
+ 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 /////
- void Process(){
- population->GetStats().PrintTimeData(fname);
- }
-};
-
-///// print_mutation_data /////
-
-/**
-**/
-
-
-class cEvent_print_mutation_data : public cPopulationEvent {
-private:
- cString fname;
-public:
- cEvent_print_mutation_data(const cString& in_args):
- cPopulationEvent("print_mutation_data", in_args) {
+
+ /**
+ * 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\"]"; }
- cString args(in_args);
- if (args == "") fname="mutation.dat"; else fname=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_mutation_rate_data(const cString& in_args):
- cPopulationEvent("print_mutation_rate_data", in_args) {
+
+ /**
+ **/
+
+
+ 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\"]"; }
- cString args(in_args);
- if (args == "") fname="mutation_rates.dat"; else fname=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_divide_mut_data(const cString& in_args):
- cPopulationEvent("print_divide_mut_data", in_args) {
+
+ /**
+ 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\"]"; }
- cString args(in_args);
- if (args == "") fname="divide_mut.dat"; else fname=args.PopWord();
+ 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 /////
- 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.
+
+ /**
+ 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_dom_parasite_data : public cPopulationEvent {
-private:
- cString fname;
-public:
- cEvent_print_dom_parasite_data(const cString& in_args):
- cPopulationEvent("print_dom_parasite_data", in_args) {
+
+
+ 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\"]"; }
- cString args(in_args);
- if (args == "") fname="parasite.dat"; else fname=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_instruction_data(const cString& in_args):
- cPopulationEvent("print_instruction_data", in_args) {
+
+ /**
+ * 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\"]"; }
- cString args(in_args);
- if (args == "") fname="instruction.dat"; else fname=args.PopWord();
+ 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 /////
- 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"
- *
+
+ /**
+ 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_abundance_histogram : public cPopulationEvent {
-private:
- cString filename;
-public:
- cEvent_print_instruction_abundance_histogram(const cString& in_args):
- cPopulationEvent("print_instruction_abundance_histogram", in_args) {
+
+
+ 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\"]"; }
- cString args(in_args);
- if (args == "") filename="instruction_histogram.dat"; else filename=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_depth_histogram(const cString& in_args):
- cPopulationEvent("print_depth_histogram", in_args) {
+
+ /**
+ *
+ * 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\"]"; }
- cString args(in_args);
- if (args == "") filename="depth_histogram.dat"; else filename=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_genotype_abundance_histogram(const cString& in_args):
- cPopulationEvent("print_genotype_abundance_histogram", in_args) {
+
+ /**
+ **/
+
+
+ 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\"]"; }
- cString args(in_args);
- if (args == "") filename="genotype_abundance_histogram.dat"; else filename=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_species_abundance_histogram(const cString& in_args):
- cPopulationEvent("print_species_abundance_histogram", in_args) {
+
+ /**
+ * 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\"]"; }
- cString args(in_args);
- if (args == "") filename="species_abundance_histogram.dat"; else filename=args.PopWord();
+ 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 /////
- void Process(){
- ofstream & fp = population->GetStats().GetDataFileOFStream(filename);
- cAnalyzeUtil::PrintSpeciesAbundanceHistogram(fp, population);
+
+ /**
+ * 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_lineage_totals /////
-
-/**
-**/
-
-
-class cEvent_print_lineage_totals : public cPopulationEvent {
-private:
- cString fname;
- int verbose;
-public:
- cEvent_print_lineage_totals(const cString& in_args):
- cPopulationEvent("print_lineage_totals", in_args) {
-
+ ///// 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;
+ ///// 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;
}
- return;
+ population->GetLineageControl()->PrintLineageTotals(fname, verbose);
}
- population->GetLineageControl()->PrintLineageTotals(fname, verbose);
- }
-};
-
-///// print_lineage_counts /////
-
-/**
-**/
-
-
-class cEvent_print_lineage_counts : public cPopulationEvent {
-private:
- cString fname;
- int verbose;
-public:
- cEvent_print_lineage_counts(const cString& in_args):
- cPopulationEvent("print_lineage_counts", in_args) {
-
+ };
+
+ ///// 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;
+ ///// 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;
}
- return;
+ if (verbose) { // verbose mode is the same in both methods
+ population->GetLineageControl()->PrintLineageTotals(fname, verbose);
+ return;
+ }
+ population->GetLineageControl()->PrintLineageCurCounts(fname);
}
- 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:
- cEvent_print_dom(const cString& in_args):
- cPopulationEvent("print_dom", 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:
- cEvent_parasite_debug(const cString& in_args):
- cPopulationEvent("parasite_debug", in_args) {
+
+ /**
+ * 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=\"\"]"; }
- cString args(in_args);
- if (args == "") in_filename=""; else in_filename=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_dom_parasite(const cString& in_args):
- cPopulationEvent("print_dom_parasite", in_args) {
+
+ //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=\"\"]"; }
- cString args(in_args);
- if (args == "") in_filename=""; else in_filename=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_genotype_map(const cString& in_args):
- cPopulationEvent("print_genotype_map", in_args) {
+
+ /**
+ * 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=\"\"]"; }
- cString args(in_args);
- if (args == "") fname="genotype_map.m"; else fname=args.PopWord();
- }
+ 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 /////
- 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:
- cEvent_print_number_phenotypes(const cString& in_args):
- cPopulationEvent("print_number_phenotypes", in_args) {
+
+ /**
+ * 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\"]"; }
- cString args(in_args);
- if (args == "") fname="phenotype_count.dat"; else fname=args.PopWord();
+ 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 /////
- 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:
- cEvent_print_phenotype_status(const cString& in_args):
- cPopulationEvent("print_phenotype_status", in_args) {
+
+ /**
+ 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\"]"; }
- cString args(in_args);
- if (args == "") fname="phenotype_status.dat"; else fname=args.PopWord();
+ 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 /////
- 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.
+
+ /**
+ Prints merit status for all the organisms in the population.
+ Used for testing/debuging.
**/
-
-
-class cEvent_save_population : public cPopulationEvent {
-private:
- cString fname;
-public:
- cEvent_save_population(const cString& in_args):
- cPopulationEvent("save_population", in_args) {
+
+
+ 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\"]"; }
- cString args(in_args);
- if (args == "") fname=""; else fname=args.PopWord();
+ 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 /////
- 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:
- cEvent_load_population(const cString& in_args):
- cPopulationEvent("load_population", in_args) {
+
+ /**
+ * 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=\"\"]"; }
- cString args(in_args);
- fname = args.PopWord();
+ 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 /////
- void Process(){
- ifstream fp(fname());
- population->LoadPopulation(fp);
- }
-};
-
-///// save_clone /////
-
-/**
-**/
-
-
-class cEvent_save_clone : public cPopulationEvent {
-private:
- cString fname;
-public:
- cEvent_save_clone(const cString& in_args):
- cPopulationEvent("save_clone", in_args) {
+
+ /**
+ * 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>"; }
- cString args(in_args);
- if (args == "") fname=""; else fname=args.PopWord();
+ 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 /////
- 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:
- cEvent_load_clone(const cString& in_args):
- cPopulationEvent("load_clone", in_args) {
+
+ /**
+ **/
+
+
+ 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=\"\"]"; }
- cString args(in_args);
- fname = args.PopWord();
+ 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 /////
- 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:
- cEvent_load_dump_file(const cString& in_args):
- cPopulationEvent("load_dump_file", in_args) {
-
+
+ /**
+ **/
+
+
+ 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();
- if (args == "") update=-1; else update=args.PopWord().AsInt();
+ }
+ ///// load_clone /////
+ void Process(){
+ ifstream fp(fname());
+ population->LoadClone(fp);
}
+ };
+
///// 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.
+
+ /**
+ * 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_dump_pop : public cPopulationEvent {
-private:
- cString fname;
-public:
- cEvent_dump_pop(const cString& in_args):
- cPopulationEvent("dump_pop", in_args) {
+
+
+ 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]"; }
- cString args(in_args);
- if (args == "") fname=""; else fname=args.PopWord();
- }
+ 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 /////
- 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"
+
+ /**
+ * 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_print_genotypes : public cPopulationEvent {
-private:
- cString data_fields;
- int historic;
- cString fname;
-public:
- cEvent_print_genotypes(const cString& in_args):
- cPopulationEvent("print_genotypes", in_args) {
-
+
+
+ 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());
+ ///// 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);
}
- 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:
- cEvent_detail_pop(const cString& in_args):
- cPopulationEvent("detail_pop", in_args) {
+ };
+
+ ///// 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=\"\"]"; }
- cString args(in_args);
- if (args == "") fname=""; else fname=args.PopWord();
+ 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());
+ ///// detail_pop /////
+ void Process(){
+ cString filename;
+ if( fname == "" ){
+ filename.Set("detail_pop.%d", population->GetUpdate());
+ }
+ ofstream fp(filename());
+ population->GetGenebank().DumpDetailedSummary(fp);
}
- 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:
- cEvent_detail_sex_pop(const cString& in_args):
- cPopulationEvent("detail_sex_pop", in_args) {
+ };
+
+ ///// 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=\"\"]"; }
- cString args(in_args);
- if (args == "") fname=""; else fname=args.PopWord();
+ 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());
+ ///// detail_sex_pop /////
+ void Process(){
+ cString filename;
+ if( fname == "" ){
+ filename.Set("detail_pop.%d", population->GetUpdate());
+ }
+ ofstream fp(filename());
+ population->GetGenebank().DumpDetailedSexSummary(fp);
}
- 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:
- cEvent_detail_parasite_pop(const cString& in_args):
- cPopulationEvent("detail_parasite_pop", in_args) {
+ };
+
+ ///// 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=\"\"]"; }
- cString args(in_args);
- if (args == "") fname=""; else fname=args.PopWord();
+ 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());
+ ///// 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());
}
- //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:
- cEvent_dump_historic_pop(const cString& in_args):
- cPopulationEvent("dump_historic_pop", in_args) {
-
+ };
+
+ ///// 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());
+ ///// 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);
}
- 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 /////
-
-/**
-* 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.
+ ///// 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_historic_sex_pop : public cPopulationEvent {
-private:
- cString fname;
-public:
- cEvent_dump_historic_sex_pop(const cString& in_args):
- cPopulationEvent("dump_historic_sex_pop", in_args) {
+
+
+ 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=\"\"]"; }
- cString args(in_args);
- if (args == "") fname=""; else fname=args.PopWord();
+ 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());
+ ///// dump_memory /////
+ void Process(){
+ cString filename;
+ if (fname == "") {
+ filename.Set("memory_dump.%d", population->GetUpdate());
+ }
+ ofstream fp(filename());
+ population->DumpMemorySummary(fp);
}
- 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:
- cEvent_dump_memory(const cString& in_args):
- cPopulationEvent("dump_memory", in_args) {
+ };
+
+ ///// 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]"; }
- 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());
+ 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();
}
- 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.
+ ///// 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
@@ -1486,304 +1677,273 @@
* 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:
- cEvent_inject(const cString& in_args):
- cPopulationEvent("inject", in_args) {
-
+
+
+ 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 == "") 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:
- cEvent_inject_all(const cString& in_args):
- cPopulationEvent("inject_all", in_args) {
-
+ ///// 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_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);
+ ///// 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);
+ }
}
- 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:
- cEvent_inject_range(const cString& in_args):
- cPopulationEvent("inject_range", in_args) {
-
+ };
+
+ ///// 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);
- if (args == "") fname="START_CREATURE"; else fname=args.PopWord();
+ 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_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);
+ ///// 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;
}
- population->SetSyncEvents(true);
+ 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_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:
- cEvent_inject_sequence(const cString& in_args):
- cPopulationEvent("inject_sequence", in_args) {
-
+ };
+
+ ///// 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);
- 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();
+ 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_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;
+ ///// 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);
}
- 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.
+ };
+
+ ///// 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_random : public cPopulationEvent {
-private:
- int length;
- int cell_id;
- double merit;
- int lineage_label;
- double neutral_metric;
-public:
- cEvent_inject_random(const cString& in_args):
- cPopulationEvent("inject_random", in_args) {
-
+
+
+ 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);
- 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:
- cEvent_inject_range_parasite(const cString& in_args):
- cPopulationEvent("inject_range_parasite", 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();
@@ -1792,68 +1952,71 @@
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);
+ ///// 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!";
}
- population->SetSyncEvents(true);
+ 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:
- cEvent_inject_range_pair(const cString& in_args):
- cPopulationEvent("inject_range_pair", in_args) {
-
+ };
+
+ ///// 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();
@@ -1864,333 +2027,367 @@
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);
+ ///// 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!";
}
- population->SetSyncEvents(true);
+ 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 /////
-
-/**
-* This event will set all mutation rates to zero...
- **/
-
-
-class cEvent_zero_muts : public cPopulationEvent {
-private:
-public:
- cEvent_zero_muts(const cString& in_args):
- cPopulationEvent("zero_muts", in_args) {
- (void)in_args; }
- ///// zero_muts /////
- void Process(){
- for (int i = 0; i < population->GetSize(); i++) {
- population->GetCell(i).MutationRates().Clear();
+ ///// 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:
- cEvent_mod_copy_mut(const cString& in_args):
- cPopulationEvent("mod_copy_mut", in_args) {
-
+ };
+
+ ///// 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);
+ ///// 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);
}
- 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:
- cEvent_mod_div_mut(const cString& in_args):
- cPopulationEvent("mod_div_mut", in_args) {
-
+ };
+
+ ///// 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);
+ ///// 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);
}
- 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:
- cEvent_set_copy_mut(const cString& in_args):
- cPopulationEvent("set_copy_mut", in_args) {
-
+ };
+
+ ///// 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();
+ ///// 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);
+ }
}
- 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:
- cEvent_mod_point_mut(const cString& in_args):
- cPopulationEvent("mod_point_mut", in_args) {
-
+ };
+
+ ///// 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);
+ ///// 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);
}
- 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:
- cEvent_set_point_mut(const cString& in_args):
- cPopulationEvent("set_point_mut", in_args) {
-
+ };
+
+ ///// 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);
+ ///// 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);
}
- cConfig::SetPointMutProb(pmut);
- } else {
- population->GetCell(cell).MutationRates().SetPointMutProb(pmut);
}
- }
-};
-
-///// calc_landscape /////
-
-/**
-**/
-
-
-class cEvent_calc_landscape : public cPopulationEvent {
-private:
- int landscape_dist;
-public:
- cEvent_calc_landscape(const cString& in_args):
- cPopulationEvent("calc_landscape", 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:
- cEvent_predict_w_landscape(const cString& in_args):
- cPopulationEvent("predict_w_landscape", in_args) {
+
+ /**
+ **/
+
+
+ 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]"; }
- cString args(in_args);
- if (args == "") datafile="land-predict.dat"; else datafile=args.PopWord();
+ 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 /////
- 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:
- cEvent_predict_nu_landscape(const cString& in_args):
- cPopulationEvent("predict_nu_landscape", in_args) {
+
+ /**
+ **/
+
+
+ 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\"]"; }
- cString args(in_args);
- if (args == "") datafile="land-predict.dat"; else datafile=args.PopWord();
+ 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 /////
- 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:
- cEvent_sample_landscape(const cString& in_args):
- cPopulationEvent("sample_landscape", in_args) {
+
+ /**
+ **/
+
+
+ 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\"]"; }
- cString args(in_args);
- if (args == "") sample_size=0; else sample_size=args.PopWord().AsInt();
+ 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 /////
- 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());
+
+ /**
+ **/
+
+
+ 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();
}
-};
-
-///// 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:
- cEvent_random_landscape(const cString& in_args):
- cPopulationEvent("random_landscape", in_args) {
-
+ ///// 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();
@@ -2198,145 +2395,160 @@
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:
- cEvent_analyze_landscape(const cString& in_args):
- cPopulationEvent("analyze_landscape", in_args) {
-
+ ///// 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:
- cEvent_pairtest_landscape(const cString& in_args):
- cPopulationEvent("pairtest_landscape", in_args) {
+ ///// 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]"; }
- cString args(in_args);
- if (args == "") sample_size=0; else sample_size=args.PopWord().AsInt();
+ 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:
- cEvent_test_dom(const cString& in_args):
- cPopulationEvent("test_dom", in_args) {
- (void)in_args; }
+ ///// pairtest_landscape /////
+ void Process(){
+ cGenome & genome = population->GetGenebank().GetBestGenotype()->GetGenome();
+ cAnalyzeUtil::PairTestLandscape(genome, population->GetEnvironment().GetInstSet(), sample_size, population->GetUpdate());
+ }
+ };
+
///// 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:
- cEvent_analyze_population(const cString& in_args):
- cPopulationEvent("analyze_population", in_args) {
-
+
+ /**
+ **/
+
+
+ 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:
- cEvent_print_detailed_fitness_data(const cString& in_args):
- cPopulationEvent("print_detailed_fitness_data", in_args) {
-
+ ///// 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();
@@ -2346,1288 +2558,1413 @@
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());
+ ///// 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 );
}
- 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:
- cEvent_print_genetic_distance_data(const cString& in_args):
- cPopulationEvent("print_genetic_distance_data", in_args) {
-
+ };
+
+ ///// 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:
- cEvent_genetic_distance_pop_dump(const cString& in_args):
- cPopulationEvent("genetic_distance_pop_dump", in_args) {
-
+ ///// 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:
- cEvent_task_snapshot(const cString& in_args):
- cPopulationEvent("task_snapshot", in_args) {
-
- cString args(in_args);
- if (args == "") filename=""; else filename=args.PopWord();
- }
+ ///// 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 /////
- 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:
- cEvent_print_viable_tasks_data(const cString& in_args):
- cPopulationEvent("print_viable_tasks_data", in_args) {
+
+ /**
+ **/
+
+
+ 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=\"\"]"; }
- cString args(in_args);
- if (args == "") filename="viable_tasks.dat"; else filename=args.PopWord();
+ 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 /////
- void Process(){
- static ofstream datafile(filename());
- cAnalyzeUtil::PrintViableTasksData( population, datafile );
+
+ /**
+ **/
+
+
+ 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();
}
-};
-
-///// 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:
- cEvent_apocalypse(const cString& in_args):
- cPopulationEvent("apocalypse", in_args) {
+ ///// 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]"; }
- cString args(in_args);
- if (args == "") kill_prob=.9; else kill_prob=args.PopWord().AsDouble();
+ 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);
+ ///// 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:
- cEvent_kill_rectangle(const cString& in_args):
- cPopulationEvent("kill_rectangle", in_args) {
-
+ };
+
+ ///// 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);
+ ///// 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);
}
- 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:
- cEvent_rate_kill(const cString& in_args):
- cPopulationEvent("rate_kill", in_args) {
+ };
+
+ ///// 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>"; }
- cString args(in_args);
- kill_rate = args.PopWord().AsDouble();
+ 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);
+ ///// 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:
- cEvent_serial_transfer(const cString& in_args):
- cPopulationEvent("serial_transfer", in_args) {
-
+ };
+
+ ///// 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:
- cEvent_hillclimb(const cString& in_args):
- cPopulationEvent("hillclimb", in_args) {
- (void)in_args; }
+ ///// serial_transfer /////
+ void Process(){
+ population->SerialTransfer( transfer_size, ignore_deads );
+ }
+ };
+
///// 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:
- cEvent_hillclimb_neut(const cString& in_args):
- cPopulationEvent("hillclimb_neut", in_args) {
- (void)in_args; }
+
+ /**
+ * 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 /////
- 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:
- cEvent_hillclimb_rand(const cString& in_args):
- cPopulationEvent("hillclimb_rand", in_args) {
- (void)in_args; }
+
+ /**
+ **/
+
+
+ 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 /////
- 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:
- cEvent_compete_demes(const cString& in_args):
- cPopulationEvent("compete_demes", in_args) {
+
+ /**
+ **/
+
+
+ class cEvent_hillclimb_rand : public cPopulationEvent {
+ private:
+ public:
+ const cString GetName() const { return "hillclimb_rand"; }
+ const cString GetDescription() const { return "hillclimb_rand"; }
- cString args(in_args);
- if (args == "") competition_type=1; else competition_type=args.PopWord().AsInt();
- }
+ 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 /////
- void Process(){
- population->CompeteDemes(competition_type);
+
+ /**
+ * 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();
}
-};
-
-///// 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:
- cEvent_reset_demes(const cString& in_args):
- cPopulationEvent("reset_demes", in_args) {
- (void)in_args; }
+ ///// compete_demes /////
+ void Process(){
+ population->CompeteDemes(competition_type);
+ }
+ };
+
///// reset_demes /////
- void Process(){
- population->ResetDemes();
+
+ /**
+ * 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;
}
-};
-
-///// print_deme_stats /////
-
-/**
-* Print stats about individual demes
- **/
-
-
-class cEvent_print_deme_stats : public cPopulationEvent {
-private:
-public:
- cEvent_print_deme_stats(const cString& in_args):
- cPopulationEvent("print_deme_stats", in_args) {
- (void)in_args; }
+ ///// reset_demes /////
+ void Process(){
+ population->ResetDemes();
+ }
+ };
+
///// print_deme_stats /////
- void Process(){
- population->PrintDemeStats();
+
+ /**
+ * 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;
}
-};
-
-///// 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:
- cEvent_copy_deme(const cString& in_args):
- cPopulationEvent("copy_deme", 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);
+ ///// 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 /////
-
-/**
-* Calculates the consensus sequence.
- *
- * Parameters:
- * lines saved (integer) default: 0
- * ???
- **/
-
-
-class cEvent_calc_consensus : public cPopulationEvent {
-private:
- int lines_saved;
-public:
- cEvent_calc_consensus(const cString& in_args):
- cPopulationEvent("calc_consensus", in_args) {
+ ///// 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\"]"; }
- 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:
- cEvent_test_size_change_robustness(const cString& in_args):
- cPopulationEvent("test_size_change_robustness", in_args) {
-
+ 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:
- cEvent_test_threads(const cString& in_args):
- cPopulationEvent("test_threads", in_args) {
- (void)in_args; }
+ ///// 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 /////
- void Process(){
- cTestCPU::TestThreads(population->GetGenebank().GetBestGenotype()->GetGenome());
+
+ /**
+ **/
+
+
+ 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;
}
-};
-
-///// print_threads /////
-
-/**
-**/
-
-
-class cEvent_print_threads : public cPopulationEvent {
-private:
-public:
- cEvent_print_threads(const cString& in_args):
- cPopulationEvent("print_threads", in_args) {
- (void)in_args; }
+
+ ///// test_threads /////
+ void Process(){
+ cTestCPU::TestThreads(population->GetGenebank().GetBestGenotype()->GetGenome());
+ }
+ };
+
///// print_threads /////
- void Process(){
- cTestCPU::PrintThreads( population->GetGenebank().GetBestGenotype()->GetGenome() );
+
+ /**
+ **/
+
+
+ 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;
}
-};
-
-///// 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:
- cEvent_dump_fitness_grid(const cString& in_args):
- cPopulationEvent("dump_fitness_grid", in_args) {
- (void)in_args; }
+ ///// print_threads /////
+ void Process(){
+ cTestCPU::PrintThreads( population->GetGenebank().GetBestGenotype()->GetGenome() );
+ }
+ };
+
///// 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 << " ";
+
+ /**
+ * 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;
}
- 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 /////
-
-/**
-* 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:
- cEvent_dump_genotype_grid(const cString& in_args):
- cPopulationEvent("dump_genotype_grid", in_args) {
- (void)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 << " ";
+ ///// 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;
}
- 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:
- cEvent_dump_task_grid(const cString& in_args):
- cPopulationEvent("dump_task_grid", in_args) {
- (void)in_args; }
+ };
+
///// dump_task_grid /////
- void Process(){
- cString filename;
- filename.Set("task_grid_%d.dat",population->GetUpdate());
- ofstream fp(filename());
- cAnalyzeUtil::TaskGrid( population, fp );
+
+ /**
+ * 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_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:
- cEvent_dump_donor_grid(const cString& in_args):
- cPopulationEvent("dump_donor_grid", in_args) {
- (void)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 /////
- 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 << " ";
+
+ /**
+ * 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;
}
- 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 /////
-
-/**
-* 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:
- cEvent_dump_receiver_grid(const cString& in_args):
- cPopulationEvent("dump_receiver_grid", in_args) {
- (void)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 << " ";
+ ///// 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;
}
- 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 /////
-
-/**
-* Reconstruction of phylogenetic trees.
- **/
-
-
-class cEvent_print_tree_depths : public cPopulationEvent {
-private:
- cString filename;
-public:
- cEvent_print_tree_depths(const cString& in_args):
- cPopulationEvent("print_tree_depths", in_args) {
+ ///// 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]"; }
- 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:
- cEvent_sever_grid_col(const cString& in_args):
- cPopulationEvent("sever_grid_col", in_args) {
-
+ 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;
+ ///// 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));
+ }
}
- // 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:
- cEvent_sever_grid_row(const cString& in_args):
- cPopulationEvent("sever_grid_row", in_args) {
-
+ };
+
+ ///// 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;
+ ///// 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));
+ }
}
- // 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:
- cEvent_join_grid_col(const cString& in_args):
- cPopulationEvent("join_grid_col", in_args) {
-
+ };
+
+ ///// 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;
+ ///// 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);
+ }
}
- // 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:
- cEvent_join_grid_row(const cString& in_args):
- cPopulationEvent("join_grid_row", in_args) {
-
+ };
+
+ ///// 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;
+ ///// 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);
+ }
}
- // 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:
- cEvent_connect_cells(const cString& in_args):
- cPopulationEvent("connect_cells", in_args) {
-
+ };
+
+ ///// 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;
+ ///// 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);
}
- 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:
- cEvent_disconnect_cells(const cString& in_args):
- cPopulationEvent("disconnect_cells", in_args) {
-
+ };
+
+ ///// 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;
+ ///// 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);
}
- 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:
- cEvent_inject_resource(const cString& in_args):
- cPopulationEvent("inject_resource", in_args) {
-
+ };
+
+ ///// 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:
- cEvent_set_resource(const cString& in_args):
- cPopulationEvent("set_resource", in_args) {
-
+ ///// 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);
+ ///// 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:
- cEvent_inject_scaled_resource(const cString& in_args):
- cPopulationEvent("inject_scaled_resource", in_args) {
-
+ };
+
+ ///// 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:
- cEvent_outflow_scaled_resource(const cString& in_args):
- cPopulationEvent("outflow_scaled_resource", 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:
- cEvent_set_reaction_value(const cString& in_args):
- cPopulationEvent("set_reaction_value", 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:
- cEvent_set_reaction_value_mult(const cString& in_args):
- cPopulationEvent("set_reaction_value_mult", 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:
- cEvent_set_reaction_inst(const cString& in_args):
- cPopulationEvent("set_reaction_inst", in_args)
- {
- cString args(in_args);
- reaction_name = args.PopWord();
- inst_name = args.PopWord();
- }
- void Process()
- {
- population->GetEnvironment().SetReactionInst(reaction_name, inst_name);
- }
-};
-
+ ///// 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);
+ }
+ };
+
}
/////////////////
Modified: branches/brysonda/source/event/population_event_factory.hh
===================================================================
--- branches/brysonda/source/event/population_event_factory.hh 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/event/population_event_factory.hh 2005-08-10 18:53:27 UTC (rev 283)
@@ -19,16 +19,16 @@
class cPopulation;
class cString;
-class cPopulationEventFactory : public tObjectFactory<cEvent (const cString&)> {
+class cPopulationEventFactory : public tObjectFactory<cEvent ()> {
private:
cPopulation *m_population;
public:
cPopulationEventFactory(cPopulation* pop);
~cPopulationEventFactory() { ; }
- cEvent* Create(const cString& key, const cString& arg)
+ cEvent* Create(const cString& key)
{
- cPopulationEvent* event = static_cast<cPopulationEvent*>(this->tObjectFactory<cEvent (const cString&)>::Create(key, arg));
+ cPopulationEvent* event = static_cast<cPopulationEvent*>(this->tObjectFactory<cEvent ()>::Create(key));
if( event != NULL ){
event->SetFactoryId( GetFactoryId() );
Deleted: branches/brysonda/source/python/AvidaGui2/untar_in_resource_directory.tar
===================================================================
(Binary files differ)
Modified: branches/brysonda/source/tools/tDictionary.hh
===================================================================
--- branches/brysonda/source/tools/tDictionary.hh 2005-08-10 18:53:03 UTC (rev 282)
+++ branches/brysonda/source/tools/tDictionary.hh 2005-08-10 18:53:27 UTC (rev 283)
@@ -114,6 +114,9 @@
// No matches found.
return NULL;
}
+private:
+ // disabled copy constructor.
+ tDictionary(const tDictionary &);
public:
tDictionary(int in_hash_size=DICTIONARY_HASH_DEFAULT)
: dict_size(0)
@@ -130,32 +133,31 @@
bool OK() {
- using namespace std;
- cout << "DICT_SIZE = " << dict_size << endl;
- cout << "HASH_SIZE = " << hash_size << endl;
+ std::cout << "DICT_SIZE = " << dict_size << std::endl;
+ std::cout << "HASH_SIZE = " << hash_size << std::endl;
int count = 0;
- cout << "LIST ELEMENTS:" << endl;
+ std::cout << "LIST ELEMENTS:" << std::endl;
list_it.Reset();
while (list_it.Next() != NULL) {
tDictEntry<T> * cur_entry = list_it.Get();
- cout << " " << count << " : "
+ std::cout << " " << count << " : "
<< cur_entry->id << " "
<< cur_entry->name << " "
<< cur_entry->data << " "
- << endl;
+ << std::endl;
}
- cout << endl;
- cout << "ARRAY CELLS: "
+ std::cout << std::endl;
+ std::cout << "ARRAY CELLS: "
<< cell_array.GetSize()
- << endl;
+ << std::endl;
for (int i = 0; i < hash_size; i++) {
tListNode< tDictEntry<T> > * cur_list_node = cell_array[i];
if (cur_list_node == NULL) {
- cout << " NULL" << endl;
+ std::cout << " NULL" << std::endl;
} else {
- cout << " " << cur_list_node->data->id
+ std::cout << " " << cur_list_node->data->id
<< " " << cur_list_node->data->name
- << endl;
+ << std::endl;
}
}
@@ -204,7 +206,7 @@
// Determine the bin that we are going to be using.
const int bin = HashString(name);
- T out_data = NULL;
+ T out_data;
assert(cell_array[bin] != NULL);
list_it.Set(cell_array[bin]);
More information about the Avida-cvs
mailing list