From 49fc07433e4aee7641fe512448dc7e96c6f7b70e Mon Sep 17 00:00:00 2001 From: Emily Dolson Date: Wed, 26 Sep 2018 01:31:48 -0400 Subject: [PATCH] Drastic reduction in memory use --- avida-core/source/main/cPopulation.cc | 6 +++--- avida-core/source/main/cWorld.cc | 20 +++++++++++++------- avida-core/source/main/cWorld.h | 8 ++++---- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/avida-core/source/main/cPopulation.cc b/avida-core/source/main/cPopulation.cc index 89a78630f..f019df98a 100644 --- a/avida-core/source/main/cPopulation.cc +++ b/avida-core/source/main/cPopulation.cc @@ -6136,9 +6136,9 @@ void cPopulation::ProcessPostUpdate(cAvidaContext& ctx) } for (int i = 0; i < deme_array.GetSize(); i++) deme_array[i].ProcessUpdate(ctx); - if (m_world->fit_fun.size() > 100000) { - m_world->fit_fun.Clear(); - } + // if (m_world->fit_fun.size() > 10) { + // m_world->fit_fun.Clear(); + // } // if (m_world->skel_fun.size() > 100000) { // m_world->skel_fun.Clear(); // } diff --git a/avida-core/source/main/cWorld.cc b/avida-core/source/main/cWorld.cc index 4a572f6df..4d989e0fb 100644 --- a/avida-core/source/main/cWorld.cc +++ b/avida-core/source/main/cWorld.cc @@ -66,6 +66,7 @@ cWorld::cWorld(cAvidaConfig* cfg, const cString& wd) cTestCPU* test_cpu = GetHardwareManager().CreateTestCPU(*m_ctx); // test_info.UseManualInputs(curr_target_cell.GetInputs()); // Test using what the environment will be test_cpu->TestGenome(*m_ctx, test_info, gen); // Use the true genome + delete test_cpu; return test_info.GetGenotypeFitness(); }; @@ -230,15 +231,20 @@ bool cWorld::setup(World* new_world, cUserFeedback* feedback, const Apto::Map skel = emp::Skeletonize(seq, null_inst, fit_fun); + for (auto inst : skel) { + ss << inst.GetSymbol(); + } + return ss.str(); }; systematics_manager.New([](const Avida::InstructionSequence & seq){return Avida::InstructionSequence(seq);}); // systematics_manager->PrintStatus(); - OEE_stats.New(systematics_manager, skel_fun, [null_inst](const emp::vector & org){return org.size();}); + OEE_stats.New(systematics_manager, skel_fun, [null_inst](const std::string & org){return org.size();}, m_conf->WORLD_X.Get() * m_conf->WORLD_Y.Get() * 200000); OEE_stats->SetGenerationInterval(m_conf->FILTER_TIME.Get()); OEE_stats->SetResolution(m_conf->OEE_RES.Get()); @@ -248,9 +254,9 @@ bool cWorld::setup(World* new_world, cUserFeedback* feedback, const Apto::MapGetTaxonAt(pos)->GetID(); // } systematics_manager->SetNextParent(pos);}); - OnOffspringReady([this](Avida::InstructionSequence seq){ systematics_manager->AddOrg(seq, next_cell_id, GetStats().GetGeneration(), false);}); - OnOrgDeath([this](int pos){ systematics_manager->RemoveOrgAfterRepro(pos, GetStats().GetGeneration());}); - OnUpdate([this](int ud){if (std::round(GetStats().GetGeneration()) > latest_gen) { latest_gen = std::round(GetStats().GetGeneration()); OEE_stats->Update(latest_gen); oee_file.Update(latest_gen);}}); + OnOffspringReady([this](Avida::InstructionSequence seq){ systematics_manager->AddOrg(seq, next_cell_id, GetStats().GetUpdate(), false);}); + OnOrgDeath([this](int pos){ systematics_manager->RemoveOrgAfterRepro(pos, GetStats().GetUpdate());}); + OnUpdate([this](int ud){if (std::round(GetStats().GetGeneration()) > latest_gen) { latest_gen = std::round(GetStats().GetGeneration()); OEE_stats->Update(latest_gen, GetStats().GetUpdate()); oee_file.Update(latest_gen);}}); std::function update_fun = [this](){return std::round(GetStats().GetGeneration());}; diff --git a/avida-core/source/main/cWorld.h b/avida-core/source/main/cWorld.h index c220ce84b..c5270471f 100644 --- a/avida-core/source/main/cWorld.h +++ b/avida-core/source/main/cWorld.h @@ -153,8 +153,8 @@ class cWorld int next_cell_id = -1; emp::DataFile oee_file; - emp::memo_function fit_fun; - std::function(const Avida::InstructionSequence&)> skel_fun; + 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); } @@ -184,9 +184,9 @@ class cWorld bool all_tasks = false; int latest_gen = -1; // Force time to go forward - emp::Ptr > > > systematics_manager; + emp::Ptr > > systematics_manager; // // If there are multiple instruction ets this could be a problem - emp::Ptr, emp::datastruct::oee_data > > > OEE_stats; + emp::Ptr > > OEE_stats; Genome curr_genome; Data::ManagerPtr& GetDataManager() { return m_data_mgr; }