New fitness assignments extended moeoParetoBasedFitnessAssignment.
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1193 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
c137da31c5
commit
7f70be8f2a
3 changed files with 426 additions and 0 deletions
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* <moeoDominanceCountFitnessAssignment.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
* Jeremie Humeau
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// moeoDominanceCountFitnessAssignment.h
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef MOEODOMINANCECOUNTFITNESSASSIGNMENT_H_
|
||||
#define MOEODOMINANCECOUNTFITNESSASSIGNMENT_H_
|
||||
|
||||
#include <vector>
|
||||
#include <eoPop.h>
|
||||
#include <archive/moeoArchive.h>
|
||||
#include <archive/moeoUnboundedArchive.h>
|
||||
#include <comparator/moeoObjectiveVectorComparator.h>
|
||||
#include <comparator/moeoParetoObjectiveVectorComparator.h>
|
||||
#include <fitness/moeoParetoBasedFitnessAssignment.h>
|
||||
#include <utils/moeoDominanceMatrix.h>
|
||||
|
||||
/**
|
||||
* moeoDominanceCountFitnessAssignment is a fitness assignment which count for each moeot the others moeot it dominates.
|
||||
*/
|
||||
template < class MOEOT >
|
||||
class moeoDominanceCountFitnessAssignment : public moeoParetoBasedFitnessAssignment < MOEOT >
|
||||
{
|
||||
public:
|
||||
|
||||
/** the objective vector type of the solutions */
|
||||
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||
|
||||
/**
|
||||
* Default ctor
|
||||
* @param _nocopy boolean to move away copies
|
||||
*/
|
||||
moeoDominanceCountFitnessAssignment(bool _nocopy=true) : comparator(paretoComparator), archive(defaultArchive), matrix(_nocopy)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Ctor where you can choose your own archive
|
||||
* @param _archive the archive used
|
||||
* @param _nocopy boolean to move away copies
|
||||
*/
|
||||
moeoDominanceCountFitnessAssignment(moeoArchive < MOEOT > & _archive, bool _nocopy=true) : comparator(paretoComparator), archive(_archive), matrix(_nocopy)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Ctor where you can choose your own way to compare objective vectors
|
||||
* @param _comparator the functor used to compare objective vectors
|
||||
* @param _nocopy boolean to move away copies
|
||||
*/
|
||||
moeoDominanceCountFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _nocopy=true) : comparator(_comparator), archive(defaultArchive), matrix(_comparator, _nocopy)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Ctor where you can choose your own archive and your own way to compare objective vectors
|
||||
* @param _comparator the functor used to compare objective vectors
|
||||
* @param _archive the archive used
|
||||
* @param _nocopy boolean to move away copies
|
||||
*/
|
||||
moeoDominanceCountFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, moeoArchive < MOEOT > & _archive, bool _nocopy=true) : comparator(_comparator), archive(_archive), matrix(_comparator, _nocopy)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Sets the fitness values for every solution contained in the population _pop and in archive
|
||||
* @param _pop the population
|
||||
*/
|
||||
void operator()(eoPop < MOEOT > & _pop) {
|
||||
unsigned int j= _pop.size();
|
||||
unsigned int i= archive.size();
|
||||
matrix(archive,_pop);
|
||||
for (unsigned int k=0; k<i+j; k++)
|
||||
{
|
||||
if (k<i)
|
||||
archive[k].fitness(matrix.count(k));
|
||||
else
|
||||
_pop[k-i].fitness(matrix.count(k));
|
||||
}
|
||||
}
|
||||
|
||||
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
|
||||
{
|
||||
//not yet implemented
|
||||
}
|
||||
|
||||
private:
|
||||
/** Functor to compare two objective vectors */
|
||||
moeoObjectiveVectorComparator < ObjectiveVector > & comparator;
|
||||
/** Functor to compare two objective vectors according to Pareto dominance relation */
|
||||
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
|
||||
/** Archive */
|
||||
moeoArchive < MOEOT > & archive;
|
||||
/** Default archive */
|
||||
moeoUnboundedArchive < MOEOT > defaultArchive;
|
||||
/** Dominance Matrix */
|
||||
moeoDominanceMatrix < MOEOT > matrix;
|
||||
};
|
||||
|
||||
#endif /*MOEODOMINANCECOUNTFITNESSASSIGNMENT_H_*/
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* <moeoDominanceCountRankingFitnessAssignment.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
* Jeremie Humeau
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// moeoDominanceCountRankingFitnessAssignment.h
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEODOMINANCECOUNTRANKINGFITNESSASSIGNMENT_H_
|
||||
#define MOEODOMINANCECOUNTRANKINGFITNESSASSIGNMENT_H_
|
||||
|
||||
#include <vector>
|
||||
#include <eoPop.h>
|
||||
#include <archive/moeoArchive.h>
|
||||
#include <archive/moeoUnboundedArchive.h>
|
||||
#include <comparator/moeoObjectiveVectorComparator.h>
|
||||
#include <comparator/moeoParetoObjectiveVectorComparator.h>
|
||||
#include <fitness/moeoParetoBasedFitnessAssignment.h>
|
||||
#include <utils/moeoDominanceMatrix.h>
|
||||
|
||||
/**
|
||||
* moeoDominanceCountRankingFitnessAssignment is a rank fitness assignment with value determine by a count fitness assignment.
|
||||
*/
|
||||
template < class MOEOT >
|
||||
class moeoDominanceCountRankingFitnessAssignment : public moeoParetoBasedFitnessAssignment < MOEOT >
|
||||
{
|
||||
public:
|
||||
|
||||
/** the objective vector type of the solutions */
|
||||
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||
|
||||
/**
|
||||
* Default ctor
|
||||
* @param _nocopy boolean to move away copies
|
||||
*/
|
||||
moeoDominanceCountRankingFitnessAssignment(bool _nocopy=true) : comparator(paretoComparator), archive(defaultArchive), matrix(_nocopy)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Ctor where you can choose your own archive
|
||||
* @param _archive the archive used
|
||||
* @param _nocopy boolean to move away copies
|
||||
*/
|
||||
moeoDominanceCountRankingFitnessAssignment(moeoArchive < MOEOT > & _archive, bool _nocopy=true) : comparator(paretoComparator), archive(_archive), matrix(_nocopy)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Ctor where you can choose your own way to compare objective vectors
|
||||
* @param _comparator the functor used to compare objective vectors
|
||||
* @param _nocopy boolean to move away copies
|
||||
*/
|
||||
moeoDominanceCountRankingFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _nocopy=true) : comparator(_comparator), archive(defaultArchive), matrix(_comparator, _nocopy)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Ctor where you can choose your own archive and your own way to compare objective vectors
|
||||
* @param _comparator the functor used to compare objective vectors
|
||||
* @param _archive the archive used
|
||||
* @param _nocopy boolean to move away copies
|
||||
*/
|
||||
moeoDominanceCountRankingFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, moeoArchive < MOEOT > & _archive, bool _nocopy=true) : comparator(_comparator), archive(_archive), matrix(_comparator, _nocopy)
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the fitness values for every solution contained in the population _pop and in archive
|
||||
* @param _pop the population
|
||||
*/
|
||||
void operator()(eoPop < MOEOT > & _pop)
|
||||
{
|
||||
/*std::cout <<"\n\n";
|
||||
for(unsigned k=0;k<_pop.size();k++){
|
||||
std::cout << "pop " << k << " :\n";
|
||||
for(unsigned l=0 ; l<2 ; l++)
|
||||
std::cout << "\tobjVec " << l << " : " << _pop[k].objectiveVector()[l] << "\n";
|
||||
}
|
||||
for(unsigned k=0;k<archive.size();k++){
|
||||
std::cout << "archive " << k << " :\n";
|
||||
for(unsigned l=0 ; l<2 ; l++)
|
||||
std::cout << "\tobjVec " << l << " : " << archive[k].objectiveVector()[l] << "\n";
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned int i= _pop.size();
|
||||
unsigned int j= archive.size();
|
||||
matrix(archive,_pop);
|
||||
|
||||
for (unsigned int k=0; k<i+j; k++) {
|
||||
if (k<j)
|
||||
archive[k].fitness(countRanking(k));
|
||||
else
|
||||
_pop[k-j].fitness(countRanking(k));
|
||||
}
|
||||
}
|
||||
|
||||
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
|
||||
{
|
||||
//not yet implemented
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
/** Functor to compare two objective vectors */
|
||||
moeoObjectiveVectorComparator < ObjectiveVector > & comparator;
|
||||
/** Functor to compare two objective vectors according to Pareto dominance relation */
|
||||
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
|
||||
/** Archive */
|
||||
moeoArchive < MOEOT > & archive;
|
||||
/** Default archive */
|
||||
moeoUnboundedArchive < MOEOT > defaultArchive;
|
||||
/** Dominance Matrix*/
|
||||
moeoDominanceMatrix <MOEOT> matrix;
|
||||
|
||||
double countRanking(unsigned int _i) {
|
||||
double res=0;
|
||||
for (unsigned int k=0; k<matrix.size(); k++) {
|
||||
if (matrix[k][_i])
|
||||
res+=matrix.count(k);
|
||||
}
|
||||
return -res;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEODOMINANCECOUNTRANKINGFITNESSASSIGNMENT_H_*/
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* <moeoDominanceRankFitnessAssignment.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
* Jeremie Humeau
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// moeoDominanceRankFitnessAssignment.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef MOEODOMINANCERANKFITNESSASSIGNEMENT_H_
|
||||
#define MOEODOMINANCERANKFITNESSASSIGNEMENT_H_
|
||||
|
||||
#include <vector>
|
||||
#include <eoPop.h>
|
||||
#include <archive/moeoArchive.h>
|
||||
#include <comparator/moeoObjectiveVectorComparator.h>
|
||||
#include <comparator/moeoParetoObjectiveVectorComparator.h>
|
||||
#include <fitness/moeoParetoBasedFitnessAssignment.h>
|
||||
#include <utils/moeoDominancematrix.h>
|
||||
|
||||
/**
|
||||
* moeoDominanceRankFitnessAssignment is a fitness assignment which count for each moeot how many others dominates it.
|
||||
*/
|
||||
template < class MOEOT >
|
||||
class moeoDominanceRankFitnessAssignment : public moeoParetoBasedFitnessAssignment < MOEOT >
|
||||
{
|
||||
public:
|
||||
|
||||
/** the objective vector type of the solutions */
|
||||
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||
|
||||
/**
|
||||
* Default ctor
|
||||
* @param _start a start value used to determine the fitness (default _start = 1.0)
|
||||
* @param _nocopy boolean to move away copies
|
||||
*/
|
||||
moeoDominanceRankFitnessAssignment(double _start=1.0, bool _nocopy=true) : comparator(paretoComparator), archive(defaultArchive), start(_start), matrix(_nocopy)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Ctor where you can choose your own archive
|
||||
* @param _archive the archive used
|
||||
* @param _start a start value used to determine the fitness (default _start = 1.0)
|
||||
* @param _nocopy boolean to move away copies
|
||||
*/
|
||||
moeoDominanceRankFitnessAssignment(moeoArchive < MOEOT > & _archive, double _start=1.0, bool _nocopy=true) : comparator(paretoComparator), archive(_archive), start(_start), matrix(_nocopy)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Ctor where you can choose your own way to compare objective vectors
|
||||
* @param _comparator the functor used to compare objective vectors
|
||||
* @param _start a start value used to determine the fitness (default _start = 1.0)
|
||||
* @param _nocopy boolean to move away copies
|
||||
*/
|
||||
moeoDominanceRankFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, double _start=1.0, bool _nocopy=true) : comparator(_comparator), archive(defaultArchive), start(_start), matrix(_comparator, _nocopy)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Ctor where you can choose your own archive and your own way to compare objective vectors
|
||||
* @param _comparator the functor used to compare objective vectors
|
||||
* @param _archive the archive used
|
||||
* @param _start a start value used to determine the fitness (default _start = 1.0)
|
||||
* @param _nocopy boolean to move away copies
|
||||
*/
|
||||
moeoDominanceRankFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, moeoArchive < MOEOT > & _archive, double _start=1.0, bool _nocopy=true) : comparator(_comparator), archive(_archive), start(_start), matrix(_comparator, _nocopy)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Sets the fitness values for every solution contained in the population _pop and in archive
|
||||
* @param _pop the population
|
||||
*/
|
||||
void operator()(eoPop < MOEOT > & _pop)
|
||||
{
|
||||
unsigned int i= archive.size();
|
||||
unsigned int j= _pop.size();
|
||||
matrix(archive, _pop);
|
||||
for (unsigned int k=0; k<i+j; k++)
|
||||
{
|
||||
if (k<i)
|
||||
archive[k].fitness(-(matrix.rank(k)+start));
|
||||
else
|
||||
_pop[k-i].fitness(-(matrix.rank(k)+start));
|
||||
}
|
||||
}
|
||||
|
||||
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
|
||||
{
|
||||
//not yet implemented
|
||||
}
|
||||
|
||||
private:
|
||||
/** Functor to compare two objective vectors */
|
||||
moeoObjectiveVectorComparator < ObjectiveVector > & comparator;
|
||||
/** Functor to compare two objective vectors according to Pareto dominance relation */
|
||||
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
|
||||
/** Archive*/
|
||||
moeoArchive < MOEOT > & archive;
|
||||
/** Default archive*/
|
||||
moeoUnboundedArchive < MOEOT > defaultArchive;
|
||||
/** start value*/
|
||||
double start;
|
||||
/** Dominance Matrix*/
|
||||
moeoDominanceMatrix < MOEOT > matrix;
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEODOMINANCERANKFITNESSASSIGNMENT_H_*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue