Skip to content

Commit

Permalink
Drastic reduction in memory use
Browse files Browse the repository at this point in the history
  • Loading branch information
emilydolson committed Sep 26, 2018
1 parent f28b4ca commit 49fc074
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
6 changes: 3 additions & 3 deletions avida-core/source/main/cPopulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
// }
Expand Down
20 changes: 13 additions & 7 deletions avida-core/source/main/cWorld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

Expand Down Expand Up @@ -230,15 +231,20 @@ bool cWorld::setup(World* new_world, cUserFeedback* feedback, const Apto::Map<Ap
// std::cout << "test" << std::endl;

// std::cout << "Got hardware manager" << std::endl;

// emp_assert(false);
skel_fun = [this, null_inst](const Avida::InstructionSequence & seq){
// std::cout << std::endl; for (auto inst : emp::Skeletonize(seq, null_inst, fit_fun.to_function())){std::cout << inst.AsString() << std::endl;}; std::cout << std::endl;
return emp::Skeletonize(seq, null_inst, fit_fun.to_function());
// std::cout << "Skeletonizing" <<std::endl;
std::stringstream ss;
emp::vector<Avida::Instruction> 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<Instruction> & 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());

Expand All @@ -248,9 +254,9 @@ bool cWorld::setup(World* new_world, cUserFeedback* feedback, const Apto::Map<Ap
// std::cout << systematics_manager->GetTaxonAt(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<int()> update_fun = [this](){return std::round(GetStats().GetGeneration());};

Expand Down
8 changes: 4 additions & 4 deletions avida-core/source/main/cWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ class cWorld
int next_cell_id = -1;
emp::DataFile oee_file;

emp::memo_function<double(const Avida::InstructionSequence&)> fit_fun;
std::function<emp::vector<Avida::Instruction>(const Avida::InstructionSequence&)> skel_fun;
std::function<double(const Avida::InstructionSequence&)> fit_fun;
std::function<std::string(const Avida::InstructionSequence&)> skel_fun;

emp::SignalKey OnBeforeRepro(const std::function<void(int)> & fun) { return before_repro_sig.AddAction(fun); }
emp::SignalKey OnOffspringReady(const std::function<void(Avida::InstructionSequence)> & fun) { return offspring_ready_sig.AddAction(fun); }
Expand Down Expand Up @@ -184,9 +184,9 @@ class cWorld
bool all_tasks = false;
int latest_gen = -1; // Force time to go forward

emp::Ptr<emp::Systematics<Avida::InstructionSequence, Avida::InstructionSequence, emp::datastruct::oee_data<emp::vector<Avida::Instruction> > > > systematics_manager;
emp::Ptr<emp::Systematics<Avida::InstructionSequence, Avida::InstructionSequence, emp::datastruct::oee_data<std::string > > > systematics_manager;
// // If there are multiple instruction ets this could be a problem
emp::Ptr<emp::OEETracker<Avida::InstructionSequence, Avida::InstructionSequence, emp::vector<Instruction>, emp::datastruct::oee_data<emp::vector<Avida::Instruction> > > > OEE_stats;
emp::Ptr<emp::OEETracker<Avida::InstructionSequence, Avida::InstructionSequence, std::string, emp::datastruct::oee_data<std::string > > > OEE_stats;
Genome curr_genome;

Data::ManagerPtr& GetDataManager() { return m_data_mgr; }
Expand Down

0 comments on commit 49fc074

Please sign in to comment.