git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@177 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
56388d43fa
commit
f3bf6dcb10
59 changed files with 5880 additions and 0 deletions
|
|
@ -0,0 +1,39 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// moeoAdditiveEpsilonBinaryMetric.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOADDITIVEEPSILONBINARYMETRIC_H_
|
||||
#define MOEOADDITIVEEPSILONBINARYMETRIC_H_
|
||||
|
||||
#include <metric/moeoMetric.h>
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template < class MOEOT >
|
||||
class moeoAdditiveEpsilonBinaryMetric : public moeoSolutionVsSolutionBinaryMetric < MOEOT, double >
|
||||
{
|
||||
public:
|
||||
|
||||
/** the objective vector type of a solution */
|
||||
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||
|
||||
moeoAdditiveEpsilonBinaryMetric();
|
||||
|
||||
|
||||
double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOADDITIVEEPSILONBINARYMETRIC_H_*/
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// moeoBinaryMetricSavingUpdater.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOBINARYMETRICSAVINGUPDATER_H_
|
||||
#define MOEOBINARYMETRICSAVINGUPDATER_H_
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <eoPop.h>
|
||||
#include <utils/eoUpdater.h>
|
||||
#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
|
||||
*/
|
||||
template <class EOT>
|
||||
class moeoBinaryMetricSavingUpdater : public eoUpdater
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* The fitness type of a solution
|
||||
*/
|
||||
typedef typename EOT::ObjectiveVector ObjectiveVector;
|
||||
|
||||
/**
|
||||
* Ctor
|
||||
* @param _metric the binary metric comparing two Pareto sets
|
||||
* @param _pop the main population
|
||||
* @param _filename the target filename
|
||||
*/
|
||||
moeoBinaryMetricSavingUpdater (moeoPopVsPopBinaryMetric<EOT,double> & _metric, const eoPop<EOT> & _pop, std::string _filename) :
|
||||
metric(_metric), pop(_pop), filename(_filename), counter(1)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Saves the metric's value for the current generation
|
||||
*/
|
||||
void operator()() {
|
||||
if (pop.size()) {
|
||||
if (firstGen) {
|
||||
firstGen = false;
|
||||
}
|
||||
else {
|
||||
// creation of the two Pareto sets
|
||||
/*
|
||||
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.close();
|
||||
}
|
||||
oldPop = pop;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** binary metric comparing two Pareto sets */
|
||||
moeoPopVsPopBinaryMetric<EOT,double> & metric;
|
||||
/** main population */
|
||||
const eoPop<EOT> & pop;
|
||||
/** (n-1) population */
|
||||
eoPop<EOT> oldPop;
|
||||
/** target filename */
|
||||
std::string filename;
|
||||
/** is it the first generation ? */
|
||||
bool firstGen;
|
||||
/** counter */
|
||||
unsigned counter;
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOBINARYMETRICSAVINGUPDATER_H_*/
|
||||
111
branches/paradiseo-moeo-1.0/src/metric/moeoContributionMetric.h
Normal file
111
branches/paradiseo-moeo-1.0/src/metric/moeoContributionMetric.h
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// moeoContributionMetric.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOCONTRIBUTIONMETRIC_H_
|
||||
#define MOEOCONTRIBUTIONMETRIC_H_
|
||||
|
||||
#include <metric/moeoMetric.h>
|
||||
|
||||
/**
|
||||
* The contribution metric evaluates the proportion of non-dominated solutions given by a Pareto set relatively to another Pareto set
|
||||
*
|
||||
* (Meunier, Talbi, Reininger: 'A multiobjective genetic algorithm for radio network optimization', in Proc. of the 2000 Congress on Evolutionary Computation, IEEE Press, pp. 317-324)
|
||||
*/
|
||||
template < class MOEOT >
|
||||
class moeoContributionMetric : public moeoPopVsPopBinaryMetric < MOEOT, double >
|
||||
{
|
||||
public:
|
||||
|
||||
/** the objective vector type of a solution */
|
||||
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the contribution of the Pareto set '_set1' relatively to the Pareto set '_set2'
|
||||
* @param _set1 the first Pareto set
|
||||
* @param _set2 the second Pareto set
|
||||
*/
|
||||
double operator()(const eoPop < MOEOT > & _pop1, const eoPop < MOEOT > & _pop2) {
|
||||
/************/
|
||||
std::vector<ObjectiveVector> set1;
|
||||
std::vector<ObjectiveVector> set2;
|
||||
for (unsigned i=0; i<_pop1.size(); i++)
|
||||
set1.push_back(_pop1[i].objectiveVector());
|
||||
for (unsigned i=0 ; i<_pop2.size(); i++)
|
||||
set2.push_back(_pop2[i].objectiveVector());
|
||||
/****************/
|
||||
unsigned c = card_C(set1, set2);
|
||||
unsigned w1 = card_W(set1, set2);
|
||||
unsigned n1 = card_N(set1, set2);
|
||||
unsigned w2 = card_W(set2, set1);
|
||||
unsigned n2 = card_N(set2, set1);
|
||||
return (double) (c / 2.0 + w1 + n1) / (c + w1 + n1 + w2 + n2);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Returns the number of solutions both in '_set1' and '_set2'
|
||||
* @param _set1 the first Pareto set
|
||||
* @param _set2 the second Pareto set
|
||||
*/
|
||||
unsigned card_C (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) {
|
||||
unsigned c=0;
|
||||
for (unsigned i=0; i<_set1.size(); i++)
|
||||
for (unsigned j=0; j<_set2.size(); j++)
|
||||
if (_set1[i] == _set2[j]) {
|
||||
c++;
|
||||
break;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of solutions in '_set1' dominating at least one solution of '_set2'
|
||||
* @param _set1 the first Pareto set
|
||||
* @param _set2 the second Pareto set
|
||||
*/
|
||||
unsigned card_W (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) {
|
||||
unsigned w=0;
|
||||
for (unsigned i=0; i<_set1.size(); i++)
|
||||
for (unsigned j=0; j<_set2.size(); j++)
|
||||
if (_set1[i].dominates(_set2[j])) {
|
||||
w++;
|
||||
break;
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of solutions in '_set1' having no relation of dominance with those from '_set2'
|
||||
* @param _set1 the first Pareto set
|
||||
* @param _set2 the second Pareto set
|
||||
*/
|
||||
unsigned card_N (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) {
|
||||
unsigned n=0;
|
||||
for (unsigned i=0; i<_set1.size(); i++) {
|
||||
bool domin_rel = false;
|
||||
for (unsigned j=0; j<_set2.size(); j++)
|
||||
if (_set1[i].dominates(_set2[j]) || _set2[j].dominates(_set1 [i])) {
|
||||
domin_rel = true;
|
||||
break;
|
||||
}
|
||||
if (! domin_rel)
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOCONTRIBUTIONMETRIC_H_*/
|
||||
149
branches/paradiseo-moeo-1.0/src/metric/moeoEntropyMetric.h
Normal file
149
branches/paradiseo-moeo-1.0/src/metric/moeoEntropyMetric.h
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// moeoEntropyMetric.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOENTROPYMETRIC_H_
|
||||
#define MOEOENTROPYMETRIC_H_
|
||||
|
||||
#include <metric/moeoMetric.h>
|
||||
|
||||
/**
|
||||
* The entropy gives an idea of the diversity of a Pareto set relatively to another Pareto set
|
||||
*
|
||||
* (Basseur, Seynhaeve, Talbi: 'Design of Multi-objective Evolutionary Algorithms: Application to the Flow-shop Scheduling Problem', in Proc. of the 2002 Congress on Evolutionary Computation, IEEE Press, pp. 1155-1156)
|
||||
*/
|
||||
template < class MOEOT >
|
||||
class moeoEntropyMetric : public moeoVectorVsVectorBinaryMetric < MOEOT, double >
|
||||
{
|
||||
public:
|
||||
|
||||
/** the objective vector type of a solution */
|
||||
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||
|
||||
/**
|
||||
* Returns the entropy of the Pareto set '_set1' relatively to the Pareto set '_set2'
|
||||
* @param _set1 the first Pareto set
|
||||
* @param _set2 the second Pareto set
|
||||
*/
|
||||
double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) {
|
||||
// normalization
|
||||
std::vector< ObjectiveVector > set1 = _set1;
|
||||
std::vector< ObjectiveVector > set2= _set2;
|
||||
removeDominated (set1);
|
||||
removeDominated (set2);
|
||||
prenormalize (set1);
|
||||
normalize (set1);
|
||||
normalize (set2);
|
||||
|
||||
// making of PO*
|
||||
std::vector< ObjectiveVector > star; // rotf :-)
|
||||
computeUnion (set1, set2, star);
|
||||
removeDominated (star);
|
||||
|
||||
// making of PO1 U PO*
|
||||
std::vector< ObjectiveVector > union_set1_star; // rotf again ...
|
||||
computeUnion (set1, star, union_set1_star);
|
||||
|
||||
unsigned C = union_set1_star.size();
|
||||
float omega=0;
|
||||
float entropy=0;
|
||||
|
||||
for (unsigned i=0 ; i<C ; i++) {
|
||||
unsigned N_i = howManyInNicheOf (union_set1_star, union_set1_star[i], star.size());
|
||||
unsigned n_i = howManyInNicheOf (set1, union_set1_star[i], star.size());
|
||||
if (n_i > 0) {
|
||||
omega += 1.0 / N_i;
|
||||
entropy += (float) n_i / (N_i * C) * log (((float) n_i / C) / log (2.0));
|
||||
}
|
||||
}
|
||||
entropy /= - log (omega);
|
||||
entropy *= log (2.0);
|
||||
return entropy;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
std::vector<double> vect_min_val;
|
||||
std::vector<double> vect_max_val;
|
||||
|
||||
void removeDominated(std::vector< ObjectiveVector > & _f) {
|
||||
for (unsigned i=0 ; i<_f.size(); i++) {
|
||||
bool dom = false;
|
||||
for (unsigned j=0; j<_f.size(); j++)
|
||||
if (i != j && _f[j].dominates(_f[i])) {
|
||||
dom = true;
|
||||
break;
|
||||
}
|
||||
if (dom) {
|
||||
_f[i] = _f.back();
|
||||
_f.pop_back();
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void prenormalize (const std::vector< ObjectiveVector > & _f) {
|
||||
vect_min_val.clear();
|
||||
vect_max_val.clear();
|
||||
|
||||
for (unsigned char i=0 ; i<ObjectiveVector::nObjectives(); i++) {
|
||||
float min_val = _f.front()[i], max_val = min_val;
|
||||
for (unsigned j=1 ; j<_f.size(); j++) {
|
||||
if (_f[j][i] < min_val)
|
||||
min_val = _f[j][i];
|
||||
if (_f[j][i]>max_val)
|
||||
max_val = _f[j][i];
|
||||
}
|
||||
vect_min_val.push_back(min_val);
|
||||
vect_max_val.push_back (max_val);
|
||||
}
|
||||
}
|
||||
|
||||
void normalize (std::vector< ObjectiveVector > & _f) {
|
||||
for (unsigned i=0 ; i<ObjectiveVector::nObjectives(); i++)
|
||||
for (unsigned j=0; j<_f.size(); j++)
|
||||
_f[j][i] = (_f[j][i] - vect_min_val[i]) / (vect_max_val[i] - vect_min_val[i]);
|
||||
}
|
||||
|
||||
void computeUnion(const std::vector< ObjectiveVector > & _f1, const std::vector< ObjectiveVector > & _f2, std::vector< ObjectiveVector > & _f) {
|
||||
_f = _f1 ;
|
||||
for (unsigned i=0; i<_f2.size(); i++) {
|
||||
bool b = false;
|
||||
for (unsigned j=0; j<_f1.size(); j ++)
|
||||
if (_f1[j] == _f2[i]) {
|
||||
b = true;
|
||||
break;
|
||||
}
|
||||
if (! b)
|
||||
_f.push_back(_f2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned howManyInNicheOf (const std::vector< ObjectiveVector > & _f, const ObjectiveVector & _s, unsigned _size) {
|
||||
unsigned n=0;
|
||||
for (unsigned i=0 ; i<_f.size(); i++) {
|
||||
if (euclidianDistance(_f[i], _s) < (_s.size() / (double) _size))
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
double euclidianDistance (const ObjectiveVector & _set1, const ObjectiveVector & _to, unsigned _deg = 2) {
|
||||
double dist=0;
|
||||
for (unsigned i=0; i<_set1.size(); i++)
|
||||
dist += pow(fabs(_set1[i] - _to[i]), (int)_deg);
|
||||
return pow(dist, 1.0 / _deg);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOENTROPYMETRIC_H_*/
|
||||
86
branches/paradiseo-moeo-1.0/src/metric/moeoMetric.h
Normal file
86
branches/paradiseo-moeo-1.0/src/metric/moeoMetric.h
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// moeoMetric.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOMETRIC_H_
|
||||
#define MOEOMETRIC_H_
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
/**
|
||||
* Base class for performance metrics (also called quality indicators)
|
||||
*/
|
||||
class moeoMetric : public eoFunctorBase
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for unary metrics
|
||||
*/
|
||||
template < class A, class R >
|
||||
class moeoUnaryMetric : public eoUF < A, R >, public moeoMetric
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for binary metrics
|
||||
*/
|
||||
template < class A1, class A2, class R >
|
||||
class moeoBinaryMetric : public eoBF < A1, A2, R >, public moeoMetric
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for unary metrics dedicated to the performance evaluation of a single solution's Pareto fitness
|
||||
*/
|
||||
template < class MOEOT, class R>//, class ObjVector = typename MOEOT::ObjectiveVector >
|
||||
//class moeoSolutionUnaryMetric : public moeoUnaryMetric < const ObjVector &, R >
|
||||
class moeoSolutionUnaryMetric : public moeoUnaryMetric < const MOEOT &, R >
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for unary metrics dedicated to the performance evaluation of a Pareto set (a vector of Pareto fitnesses)
|
||||
*/
|
||||
template < class MOEOT, class R>//, class ObjVector = typename MOEOT::ObjectiveVector >
|
||||
//class moeoVectorUnaryMetric : public moeoUnaryMetric < const std::vector < ObjVector > &, R >
|
||||
class moeoPopUnaryMetric : public moeoUnaryMetric < const eoPop < MOEOT > &, R >
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for binary metrics dedicated to the performance comparison between two solutions's Pareto fitnesses
|
||||
*/
|
||||
template < class MOEOT, class R>//, class ObjVector = typename MOEOT::ObjectiveVector >
|
||||
//class moeoSolutionVsSolutionBinaryMetric : public moeoBinaryMetric < const ObjVector &, const ObjVector &, R >
|
||||
class moeoSolutionVsSolutionBinaryMetric : public moeoBinaryMetric < const MOEOT &, const MOEOT &, R >
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for binary metrics dedicated to the performance comparison between a Pareto set (a vector of Pareto fitnesses) and a single solution's Pareto fitness
|
||||
*/
|
||||
template < class MOEOT, class R>//, class ObjVector = typename MOEOT::ObjectiveVector >
|
||||
//class moeoVectorVsSolutionBinaryMetric : public moeoBinaryMetric < const std::vector < ObjVector > &, const ObjVector &, R >
|
||||
class moeoPopVsSolutionBinaryMetric : public moeoBinaryMetric < const eoPop < MOEOT > &, const MOEOT &, R >
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for binary metrics dedicated to the performance comparison between two Pareto sets (two vectors of Pareto fitnesses)
|
||||
*/
|
||||
template < class MOEOT, class R >//, class ObjVector = typename MOEOT::ObjectiveVector >
|
||||
//class moeoVectorVsVectorBinaryMetric : public moeoBinaryMetric < const std::vector < ObjVector > &, const std::vector < ObjVector > &, R >
|
||||
class moeoPopVsPopBinaryMetric : public moeoBinaryMetric < const eoPop < MOEOT > &, const eoPop < MOEOT > &, R >
|
||||
{};
|
||||
|
||||
|
||||
#endif /*MOEOMETRIC_H_*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue