metrics modification
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@180 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
2deba122b4
commit
6d62e3f13a
4 changed files with 78 additions and 70 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
// moeoBinaryMetricSavingUpdater.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
|
|
@ -20,18 +20,18 @@
|
|||
#include <metric/moeoMetric.h>
|
||||
|
||||
/**
|
||||
* This class allows to save the progression of a binary metric comparing the fitness values of the current population (or archive)
|
||||
* with the fitness values of the population (or archive) of the generation (n-1) into a file
|
||||
* This class allows to save the progression of a binary metric comparing the objective vectors of the current population (or archive)
|
||||
* with the objective vectors of the population (or archive) of the generation (n-1) into a file
|
||||
*/
|
||||
template <class EOT>
|
||||
template < class MOEOT >
|
||||
class moeoBinaryMetricSavingUpdater : public eoUpdater
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* The fitness type of a solution
|
||||
* The objective vector type of a solution
|
||||
*/
|
||||
typedef typename EOT::ObjectiveVector ObjectiveVector;
|
||||
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||
|
||||
/**
|
||||
* Ctor
|
||||
|
|
@ -39,7 +39,7 @@ public:
|
|||
* @param _pop the main population
|
||||
* @param _filename the target filename
|
||||
*/
|
||||
moeoBinaryMetricSavingUpdater (moeoPopVsPopBinaryMetric<EOT,double> & _metric, const eoPop<EOT> & _pop, std::string _filename) :
|
||||
moeoBinaryMetricSavingUpdater (moeoVectorVsVectorBinaryMetric < ObjectiveVector, double > & _metric, const eoPop < MOEOT > & _pop, std::string _filename) :
|
||||
metric(_metric), pop(_pop), filename(_filename), counter(1)
|
||||
{}
|
||||
|
||||
|
|
@ -53,17 +53,15 @@ public:
|
|||
}
|
||||
else {
|
||||
// creation of the two Pareto sets
|
||||
/*
|
||||
std::vector<ObjectiveVector> from;
|
||||
std::vector<ObjectiveVector> to;
|
||||
std::vector < ObjectiveVector > from;
|
||||
std::vector < ObjectiveVector > to;
|
||||
for (unsigned i=0; i<pop.size(); i++)
|
||||
from.push_back(pop[i].objectiveVector());
|
||||
for (unsigned i=0 ; i<oldPop.size(); i++)
|
||||
to.push_back(oldPop[i].objectiveVector());
|
||||
*/
|
||||
// writing the result into the file
|
||||
std::ofstream f (filename.c_str(), std::ios::app);
|
||||
f << counter++ << ' ' << metric(pop,oldPop) << std::endl;
|
||||
f << counter++ << ' ' << metric(from,to) << std::endl;
|
||||
f.close();
|
||||
}
|
||||
oldPop = pop;
|
||||
|
|
@ -73,11 +71,11 @@ public:
|
|||
private:
|
||||
|
||||
/** binary metric comparing two Pareto sets */
|
||||
moeoPopVsPopBinaryMetric<EOT,double> & metric;
|
||||
moeoVectorVsVectorBinaryMetric < ObjectiveVector, double > & metric;
|
||||
/** main population */
|
||||
const eoPop<EOT> & pop;
|
||||
const eoPop < MOEOT > & pop;
|
||||
/** (n-1) population */
|
||||
eoPop<EOT> oldPop;
|
||||
eoPop< MOEOT > oldPop;
|
||||
/** target filename */
|
||||
std::string filename;
|
||||
/** is it the first generation ? */
|
||||
|
|
|
|||
Loading…
Reference in a new issue