Commit f3be7763 authored by snuverink_j's avatar snuverink_j
Browse files

fix final hypervolume calculation: don't clean population (not needed)

parent 42e6658e
......@@ -149,6 +149,7 @@ void FixedPisaNsga2<CO, MO>::initialize() {
last_clock_ = boost::chrono::system_clock::now();
run();
// run has ended
bool compHyvol = (objectives_m.size() > (hyper_opt / 2 + 1));
if (compHyvol)
current_hvol_ =
......@@ -563,7 +564,8 @@ void FixedPisaNsga2<CO, MO>::runStateMachine() {
dumpPopulationToFile();
dumpPopulationToJSON();
variator_m->population()->clean_population();
// don't clean population otherwise final hypervolume calculation can't be done
//variator_m->population()->clean_population();
curState_m = VariatorStopped;
// notify pilot that we have converged
......@@ -751,9 +753,9 @@ void FixedPisaNsga2<CO, MO>::dumpPopulationToJSON() {
for ( Expressions::Named_t::iterator it = constraints_m.begin();
it != constraints_m.end(); ++it )
{
std::string s = it->second->toString();
/// cleanup string to make json reader happy
s.erase(std::remove(s.begin(), s.end(), '"'), s.end());
std::string s = it->second->toString();
/// cleanup string to make json reader happy
s.erase(std::remove(s.begin(), s.end(), '"'), s.end());
file << "\t\t\"" << s << "\"";
......
......@@ -33,12 +33,9 @@ class Population {
public:
Population() {
last_identity = 0;
hypervolume_ = 0.0;
}
~Population() {
clean_population();
}
~Population() {}
typedef typename Individual_t::genes_t genes_t;
typedef boost::shared_ptr<Individual_t> individual;
......@@ -128,9 +125,9 @@ public:
}
/**
* Remove all non-surviving individuals from the population and put ID's
* back in pool of free ID's.
* @param surviors to keep for next generation
* Remove all non-surviving individuals from the population and put IDs
* back in pool of free IDs.
* @param survivors to keep for next generation
*/
void keepSurvivors(std::set<unsigned int> survivors) {
......@@ -188,8 +185,7 @@ public:
file.flush();
file.close();
hypervolume_ = Hypervolume::FromFile(filename.str(), referencePoint);
return hypervolume_;
return Hypervolume::FromFile(filename.str(), referencePoint);
}
......@@ -216,12 +212,12 @@ public:
/// iterator end on population container
indItr_t end() { return individuals.end(); }
/// Remove (and cleanup) all individuals in the population
void clean_population() {
/* /// Remove (and cleanup) all individuals in the population */
/* void clean_population() { */
stagingArea.clear();
individuals.clear();
}
/* stagingArea.clear(); */
/* individuals.clear(); */
/* } */
private:
......@@ -231,16 +227,14 @@ private:
/// staging area for individuals probably joining population
std::map<unsigned int, individual > stagingArea;
/// queue to handle free individual ID's
/// queue to handle free individual IDs
std::queue<unsigned int> freeids;
/// last used (= next free) ID
unsigned int last_identity;
double hypervolume_;
/**
* Manages free individual ID's
* Manages free individual IDs
* @return lowest free ID
*/
unsigned int getFreeID() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment