Skip to content

Commit

Permalink
Fix phenotype equality operator
Browse files Browse the repository at this point in the history
  • Loading branch information
emilydolson committed Nov 19, 2018
1 parent 14e854e commit 5bfcb40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions avida-core/source/main/cWorld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ cWorld::cWorld(cAvidaConfig* cfg, const cString& wd)
delete test_cpu;
tax->GetData().RecordFitness(test_info.GetGenotypeFitness());
Phenotype p;
p.merit = test_info.GetTestPhenotype().GetMerit().GetDouble();
// p.merit = test_info.GetTestPhenotype().GetMerit().GetDouble();
p.gestation_time = test_info.GetTestPhenotype().GetGestationTime();
p.start_generation = test_info.GetTestPhenotype().GetGeneration();
auto tasks = test_info.GetTestPhenotype().GetCurTaskCount();
Expand Down Expand Up @@ -284,7 +284,7 @@ bool cWorld::setup(World* new_world, cUserFeedback* feedback, const Apto::Map<Ap
OnOffspringReady([this](Avida::InstructionSequence seq){
systematics_manager->AddOrg(seq, next_cell_id, GetStats().GetUpdate(), false);
emp::Ptr<taxon_t> tax = systematics_manager->GetMostRecent();
if (tax->GetData().GetPhenotype().merit == -1) {
if (tax->GetData().GetPhenotype().gestation_time == -1) {
eval_fun(tax);
}
});
Expand Down
11 changes: 5 additions & 6 deletions avida-core/source/main/cWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,20 @@ class cUserFeedback;
template<class T> class tDataEntry;

struct Phenotype {
double merit = -1;
int gestation_time = -1;
int start_generation = -1;
emp::vector<int> final_task_count;

// bool operator==(const Phenotype & other) {
// return merit == other.merit && gestation_time == other.gestation_time && final_task_count == other.final_task_count;
// }
bool operator==(const Phenotype & other) const {
return gestation_time == other.gestation_time && final_task_count == other.final_task_count;
}

bool operator<(const Phenotype & other) const {
return merit < other.merit || gestation_time < other.gestation_time || final_task_count < other.final_task_count;
return std::tie(gestation_time, final_task_count) < std::tie(other.gestation_time, other.final_task_count);
}

bool operator!=(const Phenotype & other) const {
return merit != other.merit || gestation_time != other.gestation_time || final_task_count != other.final_task_count;
return gestation_time != other.gestation_time || final_task_count != other.final_task_count;
}


Expand Down

0 comments on commit 5bfcb40

Please sign in to comment.