This repository has been archived on 2026-03-28. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
eodev/eo/src/eoParetoRanking.h
kuepper 85a326c5e4 Adjust code to perform to C++ standard according to gcc-3.4
interpretation... (Have not compiled/checked/changed paradisEO.)

That is, the current code compiles with gcc-3.4 and the checks
(besides t-MGE1bit) all pass.
2004-12-23 15:29:07 +00:00

71 lines
2.3 KiB
C++

/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
-----------------------------------------------------------------------------
eoParetoRanking.h
(c) Maarten Keijzer, Marc Schoenauer, 2001
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifndef eoParetoRanking_h
#define eoParetoRanking_h
#include <eoPerf2Worth.h>
#include <eoDominanceMap.h>
/**
Straightforward pareto ranking. Every individual gets a rank according to the number
of elements it dominates. Note that without niching, this technique will usually not
find the whole front of non-dominated solutions, but will quite likely converge
on a single spot on the front.
*/
template <class EOT>
class eoParetoRanking : public eoPerf2WorthCached<EOT, double>
{
public:
using eoParetoRanking< EOT>::value;
eoParetoRanking(eoDominanceMap<EOT>& _dominanceMap)
: eoPerf2WorthCached<EOT, double>(), dominanceMap(_dominanceMap)
{}
void calculate_worths(const eoPop<EOT>& _pop)
{
dominanceMap(_pop);
value() = dominanceMap.sum_dominators(); // get rank: 0 means part of current front
// calculate maximum
double maxim = *std::max_element(value().begin(), value().end());
// higher is better, so invert the value
for (unsigned i = 0; i < value().size(); ++i)
{
value()[i] = maxim - value()[i];
}
}
private :
eoDominanceMap<EOT>& dominanceMap;
};
#endif