diff --git a/avida-core/source/main/cAvidaConfig.h b/avida-core/source/main/cAvidaConfig.h index 0cc04c0b9..256fc8dfc 100644 --- a/avida-core/source/main/cAvidaConfig.h +++ b/avida-core/source/main/cAvidaConfig.h @@ -286,6 +286,7 @@ class cAvidaConfig { CONFIG_ADD_VAR(POP_CAP_ELDEST, int, 0, "Carrying capacity in number of organisms (use 0 for no cap). Will kill oldest organism in population, but still use birth method to place new offspring."); CONFIG_ADD_VAR(FILTER_TIME, int, 10000, "How long does a lineage need to survive to pass the coalesence filter?"); CONFIG_ADD_VAR(OEE_RES, int, 1000, "How often should we print OEE stats?"); + CONFIG_ADD_VAR(TRACK_INDIVIDUALS, bool, 0, "Should we track phylogeny based on individuals or genomes (default)?"); CONFIG_ADD_VAR(PHYLOGENY_SNAPSHOT_RES, int, 1000, "How often should we print phylogeny stats?"); CONFIG_ADD_VAR(SYSTEMATICS_RES, int, 1000, "How often should we print phylodiversity stats?"); diff --git a/avida-core/source/main/cPopulation.cc b/avida-core/source/main/cPopulation.cc index d3a622b4b..54f2987d7 100644 --- a/avida-core/source/main/cPopulation.cc +++ b/avida-core/source/main/cPopulation.cc @@ -1377,7 +1377,8 @@ bool cPopulation::ActivateOrganism(cAvidaContext& ctx, cOrganism* in_organism, c InstructionSequence* nseq = new InstructionSequence(*seq); m_world->curr_genome = in_organism->GetGenome(); m_world->next_cell_id = target_cell.GetID(); - m_world->offspring_ready_sig.Trigger(*nseq); + + m_world->offspring_ready_sig.Trigger(*in_organism); delete nseq; diff --git a/avida-core/source/main/cWorld.cc b/avida-core/source/main/cWorld.cc index 8605c004a..99306e399 100644 --- a/avida-core/source/main/cWorld.cc +++ b/avida-core/source/main/cWorld.cc @@ -70,10 +70,13 @@ cWorld::cWorld(cAvidaConfig* cfg, const cString& wd) return test_info.GetGenotypeFitness(); }; - eval_fun = [this](emp::Ptr tax){ + eval_fun = [this](emp::Ptr tax, cOrganism & org){ // std::cout << "evaluating" << tax << std::endl; - Avida::Genome gen(curr_genome.HardwareType(), curr_genome.Properties(), GeneticRepresentationPtr(new InstructionSequence(tax->GetInfo()))); + // Avida::GeneticRepresentation rep = *(org.GetGenome().Representation()); + // GeneticRepresentationPtr(org.GetGenome().Representation()) + Avida::Genome gen(curr_genome.HardwareType(), curr_genome.Properties(), GeneticRepresentationPtr(new InstructionSequence(tax->GetData().GetPhenotype().genotype))); + // Avida::Genome gen(curr_genome.HardwareType(), curr_genome.Properties(), ); // cAnalyzeGenotype genotype(this, gen); // genotype.Recalculate(*m_ctx); cCPUTestInfo test_info; @@ -90,6 +93,11 @@ cWorld::cWorld(cAvidaConfig* cfg, const cString& wd) for (int i = 0; i < tasks.GetSize(); i++) { p.final_task_count.push_back(tasks[i]); } + ConstInstructionSequencePtr seq; + seq.DynamicCastFrom(org.GetGenome().Representation()); + + p.genotype = Avida::InstructionSequence(*seq); + tax->GetData().RecordPhenotype(p); }; @@ -256,9 +264,11 @@ bool cWorld::setup(World* new_world, cUserFeedback* feedback, const Apto::Map tax){ // std::cout << "Skeletonizing" <GetData().GetPhenotype().genotype; emp::vector skel = emp::Skeletonize(seq, null_inst, fit_fun); for (auto inst : skel) { ss << inst.GetSymbol(); @@ -266,10 +276,19 @@ bool cWorld::setup(World* new_world, cUserFeedback* feedback, const Apto::MapTRACK_INDIVIDUALS.Get()) { + systematics_manager.New([](cOrganism & org){return emp::to_string(org.GetID());}); + } else { + systematics_manager.New([](cOrganism & org){ + ConstInstructionSequencePtr seq; + seq.DynamicCastFrom(org.GetGenome().Representation()); + + return Avida::InstructionSequence(*seq).AsString().GetCString(); + }); + } systematics_manager->PrintStatus(); systematics_manager->AddSnapshotFun([](const taxon_t & tax) { - return emp::to_string(tax.GetInfo().AsString().GetCString()); + return emp::to_string(tax.GetData().GetPhenotype().genotype.AsString().GetCString()); }, "sequence", "Avida instruction sequence for this taxon."); if (m_conf->OEE_RES.Get() != 0) { @@ -284,18 +303,18 @@ bool cWorld::setup(World* new_world, cUserFeedback* feedback, const Apto::MapGetTaxonAt(pos)->GetID(); // } systematics_manager->SetNextParent(pos);}); - OnOffspringReady([this](Avida::InstructionSequence seq){ + OnOffspringReady([this](cOrganism & org){ // std::cout << "on ready" << std::endl; - systematics_manager->AddOrg(seq, emp::WorldPosition(next_cell_id,0), GetStats().GetUpdate()); + systematics_manager->AddOrg(org, emp::WorldPosition(next_cell_id,0)); emp::Ptr tax = systematics_manager->GetMostRecent(); if (tax->GetData().GetPhenotype().gestation_time == -1) { - eval_fun(tax); + eval_fun(tax, org); } // std::cout << "Done with on ready" << std::endl; }); OnOrgDeath([this](int pos){ // std::cout << "on death " << std::endl; - systematics_manager->RemoveOrgAfterRepro(emp::WorldPosition(pos, 0), GetStats().GetUpdate());}); + systematics_manager->RemoveOrgAfterRepro(emp::WorldPosition(pos, 0));}); if (m_conf->OEE_RES.Get() != 0) { OnUpdate([this](int ud){ // std::cout << "On update" << std::endl; diff --git a/avida-core/source/main/cWorld.h b/avida-core/source/main/cWorld.h index 450e2f3da..0d264252c 100644 --- a/avida-core/source/main/cWorld.h +++ b/avida-core/source/main/cWorld.h @@ -62,6 +62,7 @@ class cUserFeedback; template class tDataEntry; struct Phenotype { + Avida::InstructionSequence genotype; int gestation_time = -1; int start_generation = -1; emp::vector final_task_count; @@ -170,8 +171,8 @@ class cWorld // Signals triggered by the world. emp::SignalControl control; // Setup the world to control various signals. emp::Signal before_repro_sig; // Trigger: Immediately prior to producing offspring - emp::Signal offspring_ready_sig; // Trigger: Offspring about to enter population - emp::Signal inject_ready_sig; // Trigger: New org about to be added to population + emp::Signal offspring_ready_sig; // Trigger: Offspring about to enter population + emp::Signal inject_ready_sig; // Trigger: New org about to be added to population emp::Signal org_placement_sig; // Trigger: Organism has been added to population emp::Signal org_death_sig; // Trigger: Organism has been added to population emp::Signal on_update_sig; // Trigger: New update is starting. @@ -183,15 +184,18 @@ class cWorld emp::DataFile lineage_file; emp::DataFile dom_file; - std::function fit_fun; - std::function skel_fun; + using systematics_t = emp::Systematics>; + using taxon_t = emp::Taxon< std::string, emp::datastruct::mut_landscape_info>; + + std::function fit_fun; + std::function)> skel_fun; emp::SignalKey OnBeforeRepro(const std::function & fun) { return before_repro_sig.AddAction(fun); } - emp::SignalKey OnOffspringReady(const std::function & fun) { return offspring_ready_sig.AddAction(fun); } + emp::SignalKey OnOffspringReady(const std::function & fun) { return offspring_ready_sig.AddAction(fun); } emp::SignalKey OnOrgPlacement(const std::function & fun) { return org_placement_sig.AddAction(fun); } emp::SignalKey OnOrgDeath(const std::function & fun) { return org_death_sig.AddAction(fun); } emp::SignalKey OnUpdate(const std::function & fun) { return on_update_sig.AddAction(fun); } - emp::SignalKey OnInjectReady(const std::function & fun) { return inject_ready_sig.AddAction(fun); } + emp::SignalKey OnInjectReady(const std::function & fun) { return inject_ready_sig.AddAction(fun); } void SetDriver(WorldDriver* driver, bool take_ownership = false); @@ -214,11 +218,9 @@ class cWorld bool all_tasks = false; int latest_gen = -1; // Force time to go forward - using systematics_t = emp::Systematics>; - using taxon_t = emp::Taxon< Avida::InstructionSequence, emp::datastruct::mut_landscape_info>; emp::Ptr best_tax; - std::function)> eval_fun; + std::function, cOrganism&)> eval_fun; const emp::vector MUTATION_TYPES = {"substitution", "insertion", "deletion"}; using mut_count_t = std::unordered_map; diff --git a/libs/Empirical b/libs/Empirical index e7ff3cdf7..38b21f85f 160000 --- a/libs/Empirical +++ b/libs/Empirical @@ -1 +1 @@ -Subproject commit e7ff3cdf7f7b0271a31a5d1a4e4e45e7510f710d +Subproject commit 38b21f85f3b06883eb50b7eb88d257d73572daa4