[avida-cvs] avida CVS commits: /current/source/event cPopulation.events cPopulation_construct_event_auto.ci cPopulation_descr.ci cPopulation_enums_auto.ci cPopulation_event_list cPopulation_name2enum_auto.ci cPopulation_process_auto.ci /current/source/main population.cc population.hh
goingssh
avida-cvs at alife.org
Wed Sep 10 21:07:27 PDT 2003
goingssh Wed Sep 10 13:07:27 2003 EDT
Modified files:
/avida/current/source/event cPopulation.events
cPopulation_construct_event_auto.ci
cPopulation_descr.ci
cPopulation_enums_auto.ci
cPopulation_event_list
cPopulation_name2enum_auto.ci
cPopulation_process_auto.ci
/avida/current/source/main population.cc population.hh
Log:
added option to count phenotypes based on tasks completed
-------------- next part --------------
Index: avida/current/source/event/cPopulation.events
diff -u avida/current/source/event/cPopulation.events:1.42 avida/current/source/event/cPopulation.events:1.43
--- avida/current/source/event/cPopulation.events:1.42 Thu Aug 7 20:24:18 2003
+++ avida/current/source/event/cPopulation.events Wed Sep 10 13:07:25 2003
@@ -467,6 +467,18 @@
:body:
population->GetStats().PrintGenotypeMap(fname);
+print_number_phenotypes
+:descr:
+/**
+Output file with number of phenotypes based on tasks executed
+for this update. Executing a task any numbers of times is considered
+the same as executing it once.
+**/
+:args:
+cString fname "phenotype_count.dat"
+:body:
+population->PrintPhenotypeData(fname);
+
######### SAVE/LOAD POPULATION ######################
save_population
:descr:
Index: avida/current/source/event/cPopulation_construct_event_auto.ci
diff -u avida/current/source/event/cPopulation_construct_event_auto.ci:1.4 avida/current/source/event/cPopulation_construct_event_auto.ci:1.5
--- avida/current/source/event/cPopulation_construct_event_auto.ci:1.4 Thu Aug 7 20:24:18 2003
+++ avida/current/source/event/cPopulation_construct_event_auto.ci Wed Sep 10 13:07:25 2003
@@ -94,6 +94,9 @@
case cPopulationEventFactory::EVENT_print_genotype_map :
event = new cPopulationEventprint_genotype_map(arg_list);
break;
+ case cPopulationEventFactory::EVENT_print_number_phenotypes :
+ event = new cPopulationEventprint_number_phenotypes(arg_list);
+ break;
case cPopulationEventFactory::EVENT_save_population :
event = new cPopulationEventsave_population(arg_list);
break;
Index: avida/current/source/event/cPopulation_descr.ci
diff -u avida/current/source/event/cPopulation_descr.ci:1.4 avida/current/source/event/cPopulation_descr.ci:1.5
--- avida/current/source/event/cPopulation_descr.ci:1.4 Thu Aug 7 20:24:18 2003
+++ avida/current/source/event/cPopulation_descr.ci Wed Sep 10 13:07:25 2003
@@ -31,6 +31,7 @@
cEventEntry( "parasite_debug", "\n" ),
cEventEntry( "print_dom_parasite", "Write the currently dominant injected genotype to disk.\n\nParameters:\nfilename (string)\n The name under which the genotype should be saved. If no\n filename is given, the genotype is saved into the directory\n genebank, under the name that the genebank has associated with\n this genotype.\n" ),
cEventEntry( "print_genotype_map", "write a matrix of genotype ID's to a file (matlab format)\n" ),
+ cEventEntry( "print_number_phenotypes", "file with number of phenotypes based on tasks executed\nthis update. Executing a task any numbers of times is considered\nsame as executing it once. \n" ),
cEventEntry( "save_population", "Saves the full state of the population.\n\nParameters:\nfilename (string) default: save_pop.*\n The name of the file into which the population should\n be saved. If it is not given, then the name 'save_pop.*'\n is used, with '*' replaced by the current update.\n" ),
cEventEntry( "load_population", "Loads the full state of the population.\n\nParameters:\nfilename (string)\n The name of the file to open.\n" ),
cEventEntry( "save_clone", "\n" ),
@@ -85,5 +86,5 @@
cEventEntry( "inject_resource", "Inject (add) a specified amount of a specified resource.\n" ),
cEventEntry( "set_resource", "Set the resource amount to a specific level\n" ) };
-const int cEventDescrs::num_of_events = 85;
+const int cEventDescrs::num_of_events = 86;
Index: avida/current/source/event/cPopulation_enums_auto.ci
diff -u avida/current/source/event/cPopulation_enums_auto.ci:1.4 avida/current/source/event/cPopulation_enums_auto.ci:1.5
--- avida/current/source/event/cPopulation_enums_auto.ci:1.4 Thu Aug 7 20:24:18 2003
+++ avida/current/source/event/cPopulation_enums_auto.ci Wed Sep 10 13:07:25 2003
@@ -31,6 +31,7 @@
EVENT_parasite_debug,
EVENT_print_dom_parasite,
EVENT_print_genotype_map,
+ EVENT_print_number_phenotypes,
EVENT_save_population,
EVENT_load_population,
EVENT_save_clone,
Index: avida/current/source/event/cPopulation_event_list
diff -u avida/current/source/event/cPopulation_event_list:1.4 avida/current/source/event/cPopulation_event_list:1.5
--- avida/current/source/event/cPopulation_event_list:1.4 Thu Aug 7 20:24:18 2003
+++ avida/current/source/event/cPopulation_event_list Wed Sep 10 13:07:25 2003
@@ -32,6 +32,7 @@
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"]
save_population [cString fname=""]
load_population <cString fname>
save_clone [cString fname=""]
Index: avida/current/source/event/cPopulation_name2enum_auto.ci
diff -u avida/current/source/event/cPopulation_name2enum_auto.ci:1.4 avida/current/source/event/cPopulation_name2enum_auto.ci:1.5
--- avida/current/source/event/cPopulation_name2enum_auto.ci:1.4 Thu Aug 7 20:24:18 2003
+++ avida/current/source/event/cPopulation_name2enum_auto.ci Wed Sep 10 13:07:25 2003
@@ -65,6 +65,8 @@
return cPopulationEventFactory::EVENT_print_dom_parasite;
}else if (name == "print_genotype_map") {
return cPopulationEventFactory::EVENT_print_genotype_map;
+ }else if (name == "print_number_phenotypes") {
+ return cPopulationEventFactory::EVENT_print_number_phenotypes;
}else if (name == "save_population") {
return cPopulationEventFactory::EVENT_save_population;
}else if (name == "load_population") {
Index: avida/current/source/event/cPopulation_process_auto.ci
diff -u avida/current/source/event/cPopulation_process_auto.ci:1.4 avida/current/source/event/cPopulation_process_auto.ci:1.5
--- avida/current/source/event/cPopulation_process_auto.ci:1.4 Thu Aug 7 20:24:18 2003
+++ avida/current/source/event/cPopulation_process_auto.ci Wed Sep 10 13:07:25 2003
@@ -874,6 +874,31 @@
}
};
+///// 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 cPopulationEventprint_number_phenotypes : public cPopulationEvent {
+private:
+ cString fname;
+public:
+ cPopulationEventprint_number_phenotypes(const cString & in_args):
+ cPopulationEvent("print_number_phenotypes", in_args) {
+
+ cString args(in_args);
+ if (args == "") fname="phenotype_count.dat"; else fname=args.PopWord();
+ }
+///// print_number_phenotypes /////
+ void Process(){
+ population->PrintPhenotypeData(fname);
+ }
+};
+
///// save_population /////
/**
Index: avida/current/source/main/population.cc
diff -u avida/current/source/main/population.cc:1.113 avida/current/source/main/population.cc:1.114
--- avida/current/source/main/population.cc:1.113 Thu Aug 7 20:24:19 2003
+++ avida/current/source/main/population.cc Wed Sep 10 13:07:26 2003
@@ -12,6 +12,7 @@
#include <vector>
#include <algorithm>
+#include <set>
#include "../tools/functions.hh"
#include "../tools/slice.hh"
@@ -1476,3 +1477,28 @@
outfile << endl << total << endl;
outfile.close();
}
+
+void cPopulation::PrintPhenotypeData(const cString & filename)
+{
+ set<int> ids;
+ for (int i = 0; i < cell_array.GetSize(); i++)
+ {
+ // Only look at cells with organisms in them.
+ if (cell_array[i].IsOccupied() == false) continue;
+
+ cOrganism * organism = cell_array[i].GetOrganism();
+ const cPhenotype & phenotype = organism->GetPhenotype();
+
+ int id = 0;
+ for (int j = 0; j < phenotype.GetLastTaskCount().GetSize(); j++)
+ {
+ if (phenotype.GetLastTaskCount().ElementAt(j) > 0)
+ id += (1 << j);
+ }
+ ids.insert(id);
+ }
+ ofstream outfile;
+ outfile.open(filename, ofstream::app);
+ outfile << stats.GetUpdate() << "\t" << ids.size() << endl;
+ outfile.close();
+}
\ No newline at end of file
Index: avida/current/source/main/population.hh
diff -u avida/current/source/main/population.hh:1.57 avida/current/source/main/population.hh:1.58
--- avida/current/source/main/population.hh:1.57 Thu Aug 7 20:24:19 2003
+++ avida/current/source/main/population.hh Wed Sep 10 13:07:26 2003
@@ -161,6 +161,7 @@
bool GetSyncEvents() { return sync_events; }
void SetSyncEvents(bool _in) { sync_events = _in; }
void ParasiteDebug();
+ void PrintPhenotypeData(const cString & filename);
};
#endif
More information about the Avida-cvs
mailing list