add the aggregative scheme
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@335 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
d0f3b5c3b4
commit
0911feb4f7
1 changed files with 35 additions and 0 deletions
|
|
@ -144,4 +144,39 @@ public:
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* Functor allowing to compare two solutions according to their fitness and diversity values, each according to its aggregative value.
|
||||
*/
|
||||
template < class MOEOT >
|
||||
class moeoAggregativeComparator : public moeoComparator < MOEOT >
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Ctor.
|
||||
* @param _weightFitness the weight for fitness
|
||||
* @param _weightDiversity the weight for diversity
|
||||
*/
|
||||
moeoAggregativeComparator(double _weightFitness = 1.0, double _weightDiversity = 1.0) : weightFitness(_weightFitness), weightDiversity(_weightDiversity)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Returns true if _moeo1 < _moeo2 according to the aggregation of their fitness and diversity values
|
||||
* @param _moeo1 the first solution
|
||||
* @param _moeo2 the second solution
|
||||
*/
|
||||
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
|
||||
{
|
||||
return ( weightFitness * _moeo1.fitness() + weightDiversity * _moeo1.diversity() ) < ( weightFitness * _moeo2.fitness() + weightDiversity * _moeo2.diversity() );
|
||||
}
|
||||
|
||||
private:
|
||||
/** the weight for fitness */
|
||||
double weightFitness;
|
||||
/** the weight for diversity */
|
||||
double weightDiversity;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /*MOEOCOMPARATOR_H_*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue