git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2710 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
quemy 2012-07-16 09:38:48 +00:00
commit e3a610506b
1731 changed files with 105122 additions and 63920 deletions

View file

@ -0,0 +1,44 @@
######################################################################################
### 0) Include directories
######################################################################################
include_directories(${EO_SRC_DIR})
include_directories(${MO_SRC_DIR}/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
######################################################################################
### 1) Set paths
######################################################################################
set(MOEO_LIB_OUTPUT_PATH ${MOEO_BIN_DIR}/lib)
set(LIBRARY_OUTPUT_PATH ${MOEO_LIB_OUTPUT_PATH})
######################################################################################
### 2) Build lib
######################################################################################
set (MOEO_CORE core/moeoObjectiveVectorTraits.cpp)
add_library(moeo STATIC ${MOEO_CORE})
set(MOEO_VERSION ${GLOBAL_VERSION})
set_target_properties(moeo PROPERTIES VERSION "${MOEO_VERSION}")
install(TARGETS moeo ARCHIVE DESTINATION ${LIB} COMPONENT libraries)
######################################################################################
### 3) Look for headers
######################################################################################
file(GLOB HDRS moeo)
install(FILES ${HDRS} DESTINATION include${INSTALL_SUB_DIR}/paradiseo-moeo COMPONENT headers)
######################################################################################
### 4) Install directories
######################################################################################
install(DIRECTORY acceptCrit algo archive comparator core distance diversity do explorer fitness hybridization metric replacement scalarStuffs selection utils
DESTINATION include${INSTALL_SUB_DIR}/moeo
COMPONENT headers
FILES_MATCHING PATTERN "*.h"
)

View file

@ -0,0 +1,208 @@
/*
* <moeoASEEA.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
* Jérémie Humeau
* François Legillon
* Thibaut demaret
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOASEEA_H_
#define MOEOASEEA_H_
#include <eoBreed.h>
#include <eoCloneOps.h>
#include <eoContinue.h>
#include <eoEvalFunc.h>
#include <eoGenContinue.h>
#include <eoGeneralBreeder.h>
#include <eoGenOp.h>
#include <eoPopEvalFunc.h>
#include <eoSGAGenOp.h>
#include <algo/moeoEA.h>
#include <archive/moeoArchive.h>
#include <selection/moeoRandomSelect.h>
#include <selection/moeoSelectFromPopAndArch.h>
#include <selection/moeoDetArchiveSelect.h>
/**
* ASEEA (Adaptive Simple Elitist Evolutionary Algorithm).
*/
template < class MOEOT >
class moeoASEEA : public moeoEA < MOEOT >
{
public:
/**
* Ctor with a crossover, a mutation and their corresponding rates.
* @param _maxGen number of generations before stopping
* @param _eval evaluation function
* @param _crossover crossover
* @param _pCross crossover probability
* @param _mutation mutation
* @param _pMut mutation probability
* @param _archive archive
* @param _max the max size for the pop
*/
moeoASEEA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoArchive < MOEOT > & _archive, unsigned int _max) :
defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), selectMany(_archive, _max), transform(_crossover, _pCross, _mutation, _pMut), selectTransform(selectMany, transform), breed (selectTransform), archive(_archive)
{}
/**
* Ctor with a eoContinue.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _crossover crossover
* @param _pCross crossover probability
* @param _mutation mutation
* @param _pMut mutation probability
* @param _archive archive
* @param _max the max size for the pop
*/
moeoASEEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoArchive < MOEOT > & _archive, unsigned int _max) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), selectMany(_archive, _max), transform(_crossover, _pCross, _mutation, _pMut), selectTransform(selectMany, transform), breed(selectTransform), archive(_archive)
{}
/**
* Ctor with a eoContinue, a eoPopEval.
* @param _continuator stopping criteria
* @param _popEval population evaluation function
* @param _crossover crossover
* @param _pCross crossover probability
* @param _mutation mutation
* @param _pMut mutation probability
* @param _archive archive
* @param _max the max size for the pop
*/
moeoASEEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoArchive < MOEOT > & _archive, unsigned int _max) :
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), selectMany(_archive, _max), transform(_crossover, _pCross, _mutation, _pMut), selectTransform(selectMany, transform), breed(selectTransform), archive(_archive)
{}
/**
* Ctor with a eoContinue and a eoTransform.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _transform variation operator
* @param _archive archive
* @param _max the max size for the pop
*/
moeoASEEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _transform, moeoArchive < MOEOT > & _archive, unsigned int _max) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), selectMany(_archive, _max), transform(defaultQuadOp, 0.0, defaultMonOp, 0.0), selectTransform(selectMany, _transform), breed(selectTransform), archive(_archive)
{}
/**
* Ctor with a eoContinue, a eoPopEval and a eoTransform.
* @param _continuator stopping criteria
* @param _popEval population evaluation function
* @param _transform variation operator
* @param _archive archive
* @param _max the max size for the pop
*/
moeoASEEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoTransform < MOEOT > & _transform, moeoArchive < MOEOT > & _archive, unsigned int _max) :
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), selectMany(_archive, _max), transform(defaultQuadOp, 0.0, defaultMonOp, 0.0), selectTransform(selectMany, _transform), breed(selectTransform), archive(_archive)
{}
/**
* Apply a few generation of evolution to the population _pop until the stopping criteria is verified.
* @param _pop the population
*/
virtual void operator () (eoPop < MOEOT > &_pop)
{
eoPop < MOEOT > empty_pop, offspring;
popEval (empty_pop, _pop); // a first eval of _pop
archive(_pop); // archive update
while (continuator (_pop))
{
// generate offspring
breed (_pop, offspring);
popEval (_pop, offspring); // eval of offspring
// archive (_pop); // archive update
archive (offspring); // archive update
_pop.resize(0);
offspring.resize(0);
}
}
protected:
/** default eval */
class DummyEval : public eoEvalFunc < MOEOT >{
public:
void operator()(MOEOT &) {}
}defaultEval;
/** default transform */
class DummyTransform : public eoTransform < MOEOT >{
public :
void operator()(eoPop<MOEOT>&) {}
}defaultTransform;
/** a continuator based on the number of generations (used as default) */
eoGenContinue < MOEOT > defaultGenContinuator;
/** stopping criteria */
eoContinue < MOEOT > & continuator;
/** evaluation function */
eoEvalFunc < MOEOT > & eval;
/** default popEval */
eoPopLoopEval < MOEOT > defaultPopEval;
/** evaluation function used to evaluate the whole population */
eoPopEvalFunc < MOEOT > & popEval;
/** default select many */
moeoDetArchiveSelect < MOEOT > selectMany; // A REMPLACER !!!!!!!!!!! => add/moeoDetArchiveSelect.h
/** eoTransform */
eoSGATransform < MOEOT > transform;
/** select transform */
eoSelectTransform < MOEOT > selectTransform;
/** a default crossover */
eoQuadCloneOp < MOEOT > defaultQuadOp;
/** a default mutation */
eoMonCloneOp < MOEOT > defaultMonOp;
/** an object for genetic operators (used as default) */
//eoSGAGenOp < MOEOT > defaultSGAGenOp;
/** an object for genetic operators (used as default) */
//eoSGAGenOp < MOEOT >& genOp;
/** breeder */
eoBreed < MOEOT > & breed;
/**archive */
moeoArchive < MOEOT > & archive;
};
#endif /*MOEOASEEA_H_*/

View file

@ -0,0 +1,47 @@
/*
* <moeoAlgo.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOALGO_H_
#define MOEOALGO_H_
/**
* Abstract class for multi-objective algorithms.
*/
class moeoAlgo
{};
#endif /*MOEOALGO_H_*/

View file

@ -0,0 +1,50 @@
/*
* <moeoEA.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOEA_H_
#define MOEOEA_H_
#include <algo/moeoPopAlgo.h>
/**
* Abstract class for multi-objective evolutionary algorithms.
*/
template < class MOEOT >
class moeoEA : public moeoPopAlgo < MOEOT >
{};
#endif /*MOEOEA_H_*/

View file

@ -0,0 +1,217 @@
/*
* <moeoEasyEA.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEOEASYEA_H
#define _MOEOEASYEA_H
#include <apply.h>
#include <eoBreed.h>
#include <eoContinue.h>
#include <eoMergeReduce.h>
#include <eoPopEvalFunc.h>
#include <eoSelect.h>
#include <eoTransform.h>
#include <algo/moeoEA.h>
#include <diversity/moeoDiversityAssignment.h>
#include <diversity/moeoDummyDiversityAssignment.h>
#include <fitness/moeoFitnessAssignment.h>
#include <replacement/moeoReplacement.h>
/**
* An easy class to design multi-objective evolutionary algorithms.
*/
template < class MOEOT >
class moeoEasyEA: public moeoEA < MOEOT >
{
public:
/**
* Ctor taking a breed.
* @param _continuator the stopping criteria
* @param _eval the evaluation functions
* @param _breed the breeder
* @param _replace the replacement strategy
* @param _fitnessEval the fitness evaluation scheme
* @param _diversityEval the diversity evaluation scheme
* @param _evalFitAndDivBeforeSelection put this parameter to 'true' if you want to re-evalue the fitness and the diversity of the population before the selection process
*/
moeoEasyEA(eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoBreed < MOEOT > & _breed, moeoReplacement < MOEOT > & _replace, moeoFitnessAssignment < MOEOT > & _fitnessEval, moeoDiversityAssignment < MOEOT > & _diversityEval, bool _evalFitAndDivBeforeSelection = false) :
continuator(_continuator), eval (_eval), loopEval(_eval), popEval(loopEval), selectTransform(dummySelect, dummyTransform), breed(_breed), replace(_replace), fitnessEval(_fitnessEval), diversityEval(_diversityEval), evalFitAndDivBeforeSelection(_evalFitAndDivBeforeSelection)
{}
/**
* Ctor taking a breed and a popEval.
* @param _continuator the stopping criteria
* @param _popEval the evaluation functions for the whole population
* @param _breed the breeder
* @param _replace the replacement strategy
* @param _fitnessEval the fitness evaluation scheme
* @param _diversityEval the diversity evaluation scheme
* @param _evalFitAndDivBeforeSelection put this parameter to 'true' if you want to re-evalue the fitness and the diversity of the population before the selection process
*/
moeoEasyEA(eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoBreed < MOEOT > & _breed, moeoReplacement < MOEOT > & _replace, moeoFitnessAssignment < MOEOT > & _fitnessEval, moeoDiversityAssignment < MOEOT > & _diversityEval, bool _evalFitAndDivBeforeSelection = false) :
continuator(_continuator), eval(dummyEval), loopEval(dummyEval), popEval(_popEval), selectTransform(dummySelect, dummyTransform), breed(_breed), replace(_replace), fitnessEval(_fitnessEval), diversityEval(_diversityEval), evalFitAndDivBeforeSelection(_evalFitAndDivBeforeSelection)
{}
/**
* Ctor taking a select and a transform.
* @param _continuator the stopping criteria
* @param _eval the evaluation functions
* @param _select the selection scheme
* @param _transform the tranformation scheme
* @param _replace the replacement strategy
* @param _fitnessEval the fitness evaluation scheme
* @param _diversityEval the diversity evaluation scheme
* @param _evalFitAndDivBeforeSelection put this parameter to 'true' if you want to re-evalue the fitness and the diversity of the population before the selection process
*/
moeoEasyEA(eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoSelect < MOEOT > & _select, eoTransform < MOEOT > & _transform, moeoReplacement < MOEOT > & _replace, moeoFitnessAssignment < MOEOT > & _fitnessEval, moeoDiversityAssignment < MOEOT > & _diversityEval, bool _evalFitAndDivBeforeSelection = false) :
continuator(_continuator), eval(_eval), loopEval(_eval), popEval(loopEval), selectTransform(_select, _transform), breed(selectTransform), replace(_replace), fitnessEval(_fitnessEval), diversityEval(_diversityEval), evalFitAndDivBeforeSelection(_evalFitAndDivBeforeSelection)
{}
/**
* Ctor taking a select, a transform.and a popEval
* @param _continuator the stopping criteria
* @param _popEval the evaluation functions
* @param _select the selection scheme
* @param _transform the tranformation scheme
* @param _replace the replacement strategy
* @param _fitnessEval the fitness evaluation scheme
* @param _diversityEval the diversity evaluation scheme
* @param _evalFitAndDivBeforeSelection put this parameter to 'true' if you want to re-evalue the fitness and the diversity of the population before the selection process
*/
moeoEasyEA(eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoSelect < MOEOT > & _select, eoTransform < MOEOT > & _transform, moeoReplacement < MOEOT > & _replace, moeoFitnessAssignment < MOEOT > & _fitnessEval, moeoDiversityAssignment < MOEOT > & _diversityEval, bool _evalFitAndDivBeforeSelection = false) :
continuator(_continuator), eval(dummyEval), loopEval(dummyEval), popEval(_popEval), selectTransform(_select, _transform), breed(selectTransform), replace(_replace), fitnessEval(_fitnessEval), diversityEval(_diversityEval), evalFitAndDivBeforeSelection(_evalFitAndDivBeforeSelection)
{}
/**
* Applies a few generation of evolution to the population _pop.
* @param _pop the population
*/
virtual void operator()(eoPop < MOEOT > & _pop)
{
eoPop < MOEOT > offspring, empty_pop;
popEval(empty_pop, _pop); // A first eval of pop.
bool firstTime = true;
do
{
try
{
unsigned int pSize = _pop.size();
offspring.clear(); // new offspring
// fitness and diversity assignment (if you want to or if it is the first generation)
if (evalFitAndDivBeforeSelection || firstTime)
{
firstTime = false;
//std::cout << "fitness eval" << std::endl;
fitnessEval(_pop);
//std::cout << "diversity eval" << std::endl;
diversityEval(_pop);
}
breed(_pop, offspring);
popEval(_pop, offspring); // eval of parents + offspring if necessary
replace(_pop, offspring); // after replace, the new pop. is in _pop
if (pSize > _pop.size())
{
throw std::runtime_error("Population shrinking!");
}
else if (pSize < _pop.size())
{
throw std::runtime_error("Population growing!");
}
}
catch (std::exception& e)
{
std::string s = e.what();
s.append( " in moeoEasyEA");
throw std::runtime_error( s );
}
}
while (continuator(_pop));
}
protected:
/** the stopping criteria */
eoContinue < MOEOT > & continuator;
/** a dummy eval */
class eoDummyEval : public eoEvalFunc < MOEOT >
{
public:
void operator()(MOEOT &) {}
}
dummyEval;
/** the evaluation functions */
eoEvalFunc < MOEOT > & eval;
/** to evaluate the whole population */
eoPopLoopEval < MOEOT > loopEval;
/** to evaluate the whole population */
eoPopEvalFunc < MOEOT > & popEval;
/** dummy select */
class DummySelect : public eoSelect < MOEOT >
{
public :
void operator()(const eoPop<MOEOT>&, eoPop<MOEOT>&) {}
}
dummySelect;
/** breed: a select followed by a transform */
eoSelectTransform < MOEOT > selectTransform;
/** dummy transform */
class DummyTransform : public eoTransform < MOEOT >
{
public :
void operator()(eoPop<MOEOT>&) {}
}
dummyTransform;
/** the breeder */
eoBreed < MOEOT > & breed;
/** the replacment strategy */
moeoReplacement < MOEOT > & replace;
/** the fitness assignment strategy */
moeoFitnessAssignment < MOEOT > & fitnessEval;
/** the diversity assignment strategy */
moeoDiversityAssignment < MOEOT > & diversityEval;
/** if this parameter is set to 'true', the fitness and the diversity of the whole population will be re-evaluated before the selection process */
bool evalFitAndDivBeforeSelection;
};
#endif /*MOEOEASYEA_H_*/

View file

@ -0,0 +1,225 @@
/*
* <moeoIBEA.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOIBEA_H_
#define MOEOIBEA_H_
#include <eoBreed.h>
#include <eoCloneOps.h>
#include <eoContinue.h>
#include <eoEvalFunc.h>
#include <eoGenContinue.h>
#include <eoGeneralBreeder.h>
#include <eoGenOp.h>
#include <eoPopEvalFunc.h>
#include <eoSGAGenOp.h>
#include <algo/moeoEA.h>
#include <diversity/moeoDummyDiversityAssignment.h>
#include <fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h>
#include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
#include <replacement/moeoEnvironmentalReplacement.h>
#include <selection/moeoDetTournamentSelect.h>
/**
* IBEA (Indicator-Based Evolutionary Algorithm).
* E. Zitzler, S. Künzli, "Indicator-Based Selection in Multiobjective Search", Proc. 8th International Conference on Parallel Problem Solving from Nature (PPSN VIII), pp. 832-842, Birmingham, UK (2004).
* This class builds the IBEA algorithm only by using the fine-grained components of the ParadisEO-MOEO framework.
*/
template < class MOEOT >
class moeoIBEA : public moeoEA < MOEOT >
{
public:
/** The type of objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Ctor with a crossover, a mutation and their corresponding rates.
* @param _maxGen maximum number of generations before stopping
* @param _eval evaluation function
* @param _crossover crossover
* @param _pCross crossover probability
* @param _mutation mutation
* @param _pMut mutation probability
* @param _metric metric
* @param _kappa scaling factor kappa
*/
moeoIBEA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select (2), selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), genBreed (select, defaultSGAGenOp), breed (genBreed), fitnessAssignment(_metric, _kappa), replace (fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue and a eoGenOp.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _op variation operators
* @param _metric metric
* @param _kappa scaling factor kappa
*/
moeoIBEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select(2),
selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), fitnessAssignment(_metric, _kappa), replace (fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue, a eoPopEval and a eoGenOp.
* @param _continuator stopping criteria
* @param _popEval population evaluation function
* @param _op variation operators
* @param _metric metric
* @param _kappa scaling factor kappa
*/
moeoIBEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoGenOp < MOEOT > & _op, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), select(2),
selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), fitnessAssignment(_metric, _kappa), replace (fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue and a eoTransform.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _transform variation operator
* @param _metric metric
* @param _kappa scaling factor kappa
*/
moeoIBEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _transform, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval),
select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), fitnessAssignment(_metric, _kappa), replace(fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue, a eoPopEval and a eoTransform.
* @param _continuator stopping criteria
* @param _popEval population evaluation function
* @param _transform variation operator
* @param _metric metric
* @param _kappa scaling factor kappa
*/
moeoIBEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoTransform < MOEOT > & _transform, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) :
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval),
select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), fitnessAssignment(_metric, _kappa), replace(fitnessAssignment, diversityAssignment)
{}
/**
* Apply the algorithm to the population _pop until the stopping criteria is satified.
* @param _pop the population
*/
virtual void operator () (eoPop < MOEOT > &_pop)
{
eoPop < MOEOT > offspring, empty_pop;
popEval (empty_pop, _pop); // a first eval of _pop
// evaluate fitness and diversity
fitnessAssignment(_pop);
diversityAssignment(_pop);
do
{
// generate offspring, worths are recalculated if necessary
breed (_pop, offspring);
// eval of offspring
popEval (_pop, offspring);
// after replace, the new pop is in _pop. Worths are recalculated if necessary
replace (_pop, offspring);
}
while (continuator (_pop));
}
protected:
/** a continuator based on the number of generations (used as default) */
eoGenContinue < MOEOT > defaultGenContinuator;
/** stopping criteria */
eoContinue < MOEOT > & continuator;
/** default eval */
class DummyEval : public eoEvalFunc < MOEOT >
{
public:
void operator()(MOEOT &) {}
}
defaultEval;
/** evaluation function */
eoEvalFunc < MOEOT > & eval;
/** default popEval */
eoPopLoopEval < MOEOT > defaultPopEval;
/** evaluation function used to evaluate the whole population */
eoPopEvalFunc < MOEOT > & popEval;
/** default select */
class DummySelect : public eoSelect < MOEOT >
{
public :
void operator()(const eoPop<MOEOT>&, eoPop<MOEOT>&) {}
}
defaultSelect;
/** binary tournament selection */
moeoDetTournamentSelect < MOEOT > select;
/** default select many */
eoSelectMany < MOEOT > selectMany;
/** select transform */
eoSelectTransform < MOEOT > selectTransform;
/** a default crossover */
eoQuadCloneOp < MOEOT > defaultQuadOp;
/** a default mutation */
eoMonCloneOp < MOEOT > defaultMonOp;
/** an object for genetic operators (used as default) */
eoSGAGenOp < MOEOT > defaultSGAGenOp;
/** default transform */
class DummyTransform : public eoTransform < MOEOT >
{
public :
void operator()(eoPop<MOEOT>&) {}
}
defaultTransform;
/** general breeder */
eoGeneralBreeder < MOEOT > genBreed;
/** breeder */
eoBreed < MOEOT > & breed;
/** fitness assignment used in IBEA */
moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT > fitnessAssignment;
/** dummy diversity assignment */
moeoDummyDiversityAssignment < MOEOT > diversityAssignment;
/** environmental replacement */
moeoEnvironmentalReplacement < MOEOT > replace;
};
#endif /*MOEOIBEA_H_*/

View file

@ -0,0 +1,213 @@
/*
* <moeoNSGA.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOMOGA_H_
#define MOEOMOGA_H_
#include <eoBreed.h>
#include <eoContinue.h>
#include <eoEvalFunc.h>
#include <eoGenContinue.h>
#include <eoGeneralBreeder.h>
#include <eoGenOp.h>
#include <eoPopEvalFunc.h>
#include <eoSGAGenOp.h>
#include <algo/moeoEA.h>
#include <diversity/moeoFrontByFrontSharingDiversityAssignment.h>
#include <fitness/moeoDominanceRankFitnessAssignment.h>
#include <replacement/moeoElitistReplacement.h>
#include <selection/moeoDetTournamentSelect.h>
/**
* MOGA.
*/
template < class MOEOT >
class moeoMOGA: public moeoEA < MOEOT >
{
public:
/**
* Ctor with a crossover, a mutation and their corresponding rates.
* @param _maxGen maximum number of generations before stopping
* @param _eval evaluation function
* @param _crossover crossover
* @param _pCross crossover probability
* @param _mutation mutation
* @param _pMut mutation probability
* @param _nicheSize niche size
*/
moeoMOGA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, double _nicheSize = 0.5) :
defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select (2), selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), genBreed (select, defaultSGAGenOp), breed (genBreed), diversityAssignment(_nicheSize), replace (fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue and a eoGenOp.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _op variation operators
* @param _nicheSize niche size
*/
moeoMOGA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, double _nicheSize = 0.5) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select(2),
selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), diversityAssignment(_nicheSize), replace (fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue, a eoPopEval and a eoGenOp.
* @param _continuator stopping criteria
* @param _popEval population evaluation function
* @param _op variation operators
* @param _nicheSize niche size
*/
moeoMOGA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoGenOp < MOEOT > & _op, double _nicheSize = 0.5) :
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), select(2),
selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), diversityAssignment(_nicheSize), replace (fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue and a eoTransform.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _transform variation operator
* @param _nicheSize niche size
*/
moeoMOGA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _transform, double _nicheSize = 0.5) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval),
select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), diversityAssignment(_nicheSize), replace(fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue, a eoPopEval and a eoTransform.
* @param _continuator stopping criteria
* @param _popEval population evaluation function
* @param _transform variation operator
* @param _nicheSize niche size
*/
moeoMOGA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoTransform < MOEOT > & _transform, double _nicheSize = 0.5) :
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval),
select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), diversityAssignment(_nicheSize), replace(fitnessAssignment, diversityAssignment)
{}
/**
* Apply the algorithm to the population _pop until the stopping criteria is satified.
* @param _pop the population
*/
virtual void operator () (eoPop < MOEOT > &_pop)
{
eoPop < MOEOT > offspring, empty_pop;
popEval (empty_pop, _pop); // a first eval of _pop
// evaluate fitness and diversity
fitnessAssignment(_pop);
diversityAssignment(_pop);
do
{
// generate offspring, worths are recalculated if necessary
breed (_pop, offspring);
// eval of offspring
popEval (_pop, offspring);
// after replace, the new pop is in _pop. Worths are recalculated if necessary
replace (_pop, offspring);
}
while (continuator (_pop));
}
protected:
/** a continuator based on the number of generations (used as default) */
eoGenContinue < MOEOT > defaultGenContinuator;
/** stopping criteria */
eoContinue < MOEOT > & continuator;
/** default eval */
class DummyEval : public eoEvalFunc < MOEOT >
{
public:
void operator()(MOEOT &) {}
}
defaultEval;
/** evaluation function */
eoEvalFunc < MOEOT > & eval;
/** default popEval */
eoPopLoopEval < MOEOT > defaultPopEval;
/** evaluation function used to evaluate the whole population */
eoPopEvalFunc < MOEOT > & popEval;
/** default select */
class DummySelect : public eoSelect < MOEOT >
{
public :
void operator()(const eoPop<MOEOT>&, eoPop<MOEOT>&) {}
}
defaultSelect;
/** binary tournament selection */
moeoDetTournamentSelect < MOEOT > select;
/** default select many */
eoSelectMany < MOEOT > selectMany;
/** select transform */
eoSelectTransform < MOEOT > selectTransform;
/** a default crossover */
eoQuadCloneOp < MOEOT > defaultQuadOp;
/** a default mutation */
eoMonCloneOp < MOEOT > defaultMonOp;
/** an object for genetic operators (used as default) */
eoSGAGenOp < MOEOT > defaultSGAGenOp;
/** default transform */
class DummyTransform : public eoTransform < MOEOT >
{
public :
void operator()(eoPop<MOEOT>&) {}
}
defaultTransform;
/** general breeder */
eoGeneralBreeder < MOEOT > genBreed;
/** breeder */
eoBreed < MOEOT > & breed;
/** fitness assignment used in NSGA-II */
moeoDominanceRankFitnessAssignment < MOEOT > fitnessAssignment;
/** diversity assignment used in NSGA-II */
moeoFrontByFrontSharingDiversityAssignment < MOEOT > diversityAssignment;
/** elitist replacement */
moeoElitistReplacement < MOEOT > replace;
};
#endif /*MOEOMOGA_H_*/

View file

@ -0,0 +1,215 @@
/*
* <moeoNSGA.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEONSGA_H_
#define MOEONSGA_H_
#include <eoBreed.h>
#include <eoContinue.h>
#include <eoEvalFunc.h>
#include <eoGenContinue.h>
#include <eoGeneralBreeder.h>
#include <eoGenOp.h>
#include <eoPopEvalFunc.h>
#include <eoSGAGenOp.h>
#include <algo/moeoEA.h>
#include <diversity/moeoFrontByFrontSharingDiversityAssignment.h>
#include <fitness/moeoDominanceDepthFitnessAssignment.h>
#include <replacement/moeoElitistReplacement.h>
#include <selection/moeoDetTournamentSelect.h>
/**
* NSGA (Non-dominated Sorting Genetic Algorithm).
* N. Srinivas, K. Deb, "Multiobjective Optimization Using Nondominated Sorting in Genetic Algorithms".
* Evolutionary Computation, Vol. 2(3), No 2, pp. 221-248 (1994).
* This class builds the NSGA algorithm only by using the fine-grained components of the ParadisEO-MOEO framework.
*/
template < class MOEOT >
class moeoNSGA: public moeoEA < MOEOT >
{
public:
/**
* Ctor with a crossover, a mutation and their corresponding rates.
* @param _maxGen maximum number of generations before stopping
* @param _eval evaluation function
* @param _crossover crossover
* @param _pCross crossover probability
* @param _mutation mutation
* @param _pMut mutation probability
* @param _nicheSize niche size
*/
moeoNSGA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, double _nicheSize = 0.5) :
defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select (2), selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), genBreed (select, defaultSGAGenOp), breed (genBreed), diversityAssignment(_nicheSize), replace (fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue and a eoGenOp.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _op variation operators
* @param _nicheSize niche size
*/
moeoNSGA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, double _nicheSize = 0.5) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select(2),
selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), diversityAssignment(_nicheSize), replace (fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue, a eoPopEval and a eoGenOp.
* @param _continuator stopping criteria
* @param _popEval population evaluation function
* @param _op variation operators
* @param _nicheSize niche size
*/
moeoNSGA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoGenOp < MOEOT > & _op, double _nicheSize = 0.5) :
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), select(2),
selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), diversityAssignment(_nicheSize), replace (fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue and a eoTransform.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _transform variation operator
* @param _nicheSize niche size
*/
moeoNSGA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _transform, double _nicheSize = 0.5) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval),
select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), diversityAssignment(_nicheSize), replace(fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue, a eoPopEval and a eoTransform.
* @param _continuator stopping criteria
* @param _popEval population evaluation function
* @param _transform variation operator
* @param _nicheSize niche size
*/
moeoNSGA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoTransform < MOEOT > & _transform, double _nicheSize = 0.5) :
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval),
select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), diversityAssignment(_nicheSize), replace(fitnessAssignment, diversityAssignment)
{}
/**
* Apply the algorithm to the population _pop until the stopping criteria is satified.
* @param _pop the population
*/
virtual void operator () (eoPop < MOEOT > &_pop)
{
eoPop < MOEOT > offspring, empty_pop;
popEval (empty_pop, _pop); // a first eval of _pop
// evaluate fitness and diversity
fitnessAssignment(_pop);
diversityAssignment(_pop);
do
{
// generate offspring, worths are recalculated if necessary
breed (_pop, offspring);
// eval of offspring
popEval (_pop, offspring);
// after replace, the new pop is in _pop. Worths are recalculated if necessary
replace (_pop, offspring);
}
while (continuator (_pop));
}
protected:
/** a continuator based on the number of generations (used as default) */
eoGenContinue < MOEOT > defaultGenContinuator;
/** stopping criteria */
eoContinue < MOEOT > & continuator;
/** default eval */
class DummyEval : public eoEvalFunc < MOEOT >
{
public:
void operator()(MOEOT &) {}
}
defaultEval;
/** evaluation function */
eoEvalFunc < MOEOT > & eval;
/** default popEval */
eoPopLoopEval < MOEOT > defaultPopEval;
/** evaluation function used to evaluate the whole population */
eoPopEvalFunc < MOEOT > & popEval;
/** default select */
class DummySelect : public eoSelect < MOEOT >
{
public :
void operator()(const eoPop<MOEOT>&, eoPop<MOEOT>&) {}
}
defaultSelect;
/** binary tournament selection */
moeoDetTournamentSelect < MOEOT > select;
/** default select many */
eoSelectMany < MOEOT > selectMany;
/** select transform */
eoSelectTransform < MOEOT > selectTransform;
/** a default crossover */
eoQuadCloneOp < MOEOT > defaultQuadOp;
/** a default mutation */
eoMonCloneOp < MOEOT > defaultMonOp;
/** an object for genetic operators (used as default) */
eoSGAGenOp < MOEOT > defaultSGAGenOp;
/** default transform */
class DummyTransform : public eoTransform < MOEOT >
{
public :
void operator()(eoPop<MOEOT>&) {}
}
defaultTransform;
/** general breeder */
eoGeneralBreeder < MOEOT > genBreed;
/** breeder */
eoBreed < MOEOT > & breed;
/** fitness assignment used in NSGA-II */
moeoDominanceDepthFitnessAssignment < MOEOT > fitnessAssignment;
/** diversity assignment used in NSGA-II */
moeoFrontByFrontSharingDiversityAssignment < MOEOT > diversityAssignment;
/** elitist replacement */
moeoElitistReplacement < MOEOT > replace;
};
#endif /*MOEONSGA_H_*/

View file

@ -0,0 +1,210 @@
/*
* <moeoNSGAII.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEONSGAII_H_
#define MOEONSGAII_H_
#include <eoBreed.h>
#include <eoCloneOps.h>
#include <eoContinue.h>
#include <eoEvalFunc.h>
#include <eoGenContinue.h>
#include <eoGeneralBreeder.h>
#include <eoGenOp.h>
#include <eoPopEvalFunc.h>
#include <eoSGAGenOp.h>
#include <algo/moeoEA.h>
#include <diversity/moeoFrontByFrontCrowdingDiversityAssignment.h>
#include <fitness/moeoDominanceDepthFitnessAssignment.h>
#include <replacement/moeoElitistReplacement.h>
#include <selection/moeoDetTournamentSelect.h>
/**
* NSGA-II (Non-dominated Sorting Genetic Algorithm II).
* Deb, K., S. Agrawal, A. Pratap, and T. Meyarivan. A fast elitist non-dominated sorting genetic algorithm for multi-objective optimization: NSGA-II. IEEE Transactions on Evolutionary Computation, Vol. 6, No 2, pp 182-197 (2002).
* This class builds the NSGA-II algorithm only by using the fine-grained components of the ParadisEO-MOEO framework.
*/
template < class MOEOT >
class moeoNSGAII: public moeoEA < MOEOT >
{
public:
/**
* Ctor with a crossover, a mutation and their corresponding rates.
* @param _maxGen maximum number of generations before stopping
* @param _eval evaluation function
* @param _crossover crossover
* @param _pCross crossover probability
* @param _mutation mutation
* @param _pMut mutation probability
*/
moeoNSGAII (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut) :
defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select (2), selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), genBreed (select, defaultSGAGenOp), breed (genBreed), replace (fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue and a eoGenOp.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _op variation operators
*/
moeoNSGAII (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select(2),
selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), replace (fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue, a eoPopEval and a eoGenOp.
* @param _continuator stopping criteria
* @param _popEval population evaluation function
* @param _op variation operators
*/
moeoNSGAII (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoGenOp < MOEOT > & _op) :
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), select(2),
selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), replace (fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue and a eoTransform.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _transform variation operator
*/
moeoNSGAII (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _transform) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval),
select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), replace(fitnessAssignment, diversityAssignment)
{}
/**
* Ctor with a eoContinue, a eoPopEval and a eoTransform.
* @param _continuator stopping criteria
* @param _popEval population evaluation function
* @param _transform variation operator
*/
moeoNSGAII (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoTransform < MOEOT > & _transform) :
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval),
select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), replace(fitnessAssignment, diversityAssignment)
{}
/**
* Apply a the algorithm to the population _pop until the stopping criteria is satified.
* @param _pop the population
*/
virtual void operator () (eoPop < MOEOT > &_pop)
{
eoPop < MOEOT > offspring, empty_pop;
popEval (empty_pop, _pop); // a first eval of _pop
// evaluate fitness and diversity
fitnessAssignment(_pop);
diversityAssignment(_pop);
do
{
// generate offspring, worths are recalculated if necessary
breed (_pop, offspring);
// eval of offspring
popEval (_pop, offspring);
// after replace, the new pop is in _pop. Worths are recalculated if necessary
replace (_pop, offspring);
}
while (continuator (_pop));
}
protected:
/** a continuator based on the number of generations (used as default) */
eoGenContinue < MOEOT > defaultGenContinuator;
/** stopping criteria */
eoContinue < MOEOT > & continuator;
/** default eval */
class DummyEval : public eoEvalFunc < MOEOT >
{
public:
void operator()(MOEOT &) {}
}
defaultEval;
/** evaluation function */
eoEvalFunc < MOEOT > & eval;
/** default popEval */
eoPopLoopEval < MOEOT > defaultPopEval;
/** evaluation function used to evaluate the whole population */
eoPopEvalFunc < MOEOT > & popEval;
/** default select */
class DummySelect : public eoSelect < MOEOT >
{
public :
void operator()(const eoPop<MOEOT>&, eoPop<MOEOT>&) {}
}
defaultSelect;
/** binary tournament selection */
moeoDetTournamentSelect < MOEOT > select;
/** default select many */
eoSelectMany < MOEOT > selectMany;
/** select transform */
eoSelectTransform < MOEOT > selectTransform;
/** a default crossover */
eoQuadCloneOp < MOEOT > defaultQuadOp;
/** a default mutation */
eoMonCloneOp < MOEOT > defaultMonOp;
/** an object for genetic operators (used as default) */
eoSGAGenOp < MOEOT > defaultSGAGenOp;
/** default transform */
class DummyTransform : public eoTransform < MOEOT >
{
public :
void operator()(eoPop<MOEOT>&) {}
}
defaultTransform;
/** general breeder */
eoGeneralBreeder < MOEOT > genBreed;
/** breeder */
eoBreed < MOEOT > & breed;
/** fitness assignment used in NSGA */
moeoDominanceDepthFitnessAssignment < MOEOT > fitnessAssignment;
/** diversity assignment used in NSGA-II */
moeoFrontByFrontCrowdingDiversityAssignment < MOEOT > diversityAssignment;
/** elitist replacement */
moeoElitistReplacement < MOEOT > replace;
};
#endif /*MOEONSGAII_H_*/

View file

@ -0,0 +1,87 @@
/*
* <moeoPLS1.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEOPLS1_H
#define _MOEOPLS1_H
#include <algo/moeoUnifiedDominanceBasedLS.h>
#include <selection/moeoNumberUnvisitedSelect.h>
#include <explorer/moeoExhaustiveNeighborhoodExplorer.h>
/**
* PLS1 algorithm
*
* Paquete L, Chiarandini M, St ̈ tzle T (2004) Pareto local optimum sets in the biobjective
* traveling salesman problem: An experimental study. In: Metaheuristics for Multiobjective
* Optimisation, Lecture Notes in Economics and Mathematical Systems, vol 535, Springer-
* Verlag, Berlin, Germany, chap 7, pp 177199
*/
template < class Neighbor >
class moeoPLS1 : public moeoUnifiedDominanceBasedLS < Neighbor >
{
public:
/** Alias for the type */
typedef typename Neighbor::EOT MOEOT;
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Ctor
* @param _continuator a stop creterion
* @param _eval a evaluation function
* @param _archive a archive to store no-dominated individuals
* @param _neighborhood a neighborhood
* @param _incrEval neighbor evaluation function
*/
moeoPLS1(
eoContinue < MOEOT > & _continuator,
eoEvalFunc < MOEOT > & _eval,
moeoArchive < MOEOT > & _archive,
moNeighborhood<Neighbor>& _neighborhood,
moEval < Neighbor > & _incrEval):
moeoUnifiedDominanceBasedLS<Neighbor>(
_continuator,
_eval,
_archive,
*(new moeoExhaustiveNeighborhoodExplorer<Neighbor>(_neighborhood, _incrEval)),
*(new moeoNumberUnvisitedSelect<MOEOT>(1))
){}
};
#endif /*MOEOPLS1_H_*/

View file

@ -0,0 +1,95 @@
/*
* <moeoPLS2.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEOPLS2_H
#define _MOEOPLS2_H
#include <algo/moeoUnifiedDominanceBasedLS.h>
#include <selection/moeoExhaustiveUnvisitedSelect.h>
#include <explorer/moeoExhaustiveNeighborhoodExplorer.h>
/**
* PLS2 algorithm
*
* Talbi EG, Rahoual M, Mabed MH, Dhaenens C (2001) A hybrid evolutionary approach for
* multicriteria optimization problems : Application to the fow shop. In: First International
* Conference on Evolutionary Multi-criterion Optimization (EMO 2001), Springer-Verlag,
* Zurich, Switzerland, Lecture Notes in Computer Science, vol 1993, pp 416428
*
* Basseur M, Seynhaeve F, Talbi E (2003) Adaptive mechanisms for multiobjective evolution-
* ary algorithms. In: Congress on Engineering in System Application (CESA 2003), Lille,
* France, pp 7286
*
* Angel E, Bampis E, Gourv ́ s L (2004) A dynasearch neighbohood for the bicriteria travel-
* ing salesman problem. In: Metaheuristics for Multiobjective Optimisation, Lecture Notes
* in Economics and Mathematical Systems, vol 535, Springer-Verlag, Berlin, Germany,
* chap 6, pp 153176
*/
template < class Neighbor >
class moeoPLS2 : public moeoUnifiedDominanceBasedLS < Neighbor >
{
public:
/** Alias for the type */
typedef typename Neighbor::EOT MOEOT;
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Ctor
* @param _continuator a stop creterion
* @param _eval a evaluation function
* @param _archive a archive to store no-dominated individuals
* @param _neighborhood a neighborhood
* @param _incrEval neighbor evaluation function
*/
moeoPLS2(
eoContinue < MOEOT > & _continuator,
eoEvalFunc < MOEOT > & _eval,
moeoArchive < MOEOT > & _archive,
moNeighborhood<Neighbor>& _neighborhood,
moEval < Neighbor > & _incrEval):
moeoUnifiedDominanceBasedLS<Neighbor>(
_continuator,
_eval,
_archive,
*(new moeoExhaustiveNeighborhoodExplorer<Neighbor>(_neighborhood, _incrEval)),
*(new moeoExhaustiveUnvisitedSelect<MOEOT>())
){}
};
#endif /*MOEOPLS2_H_*/

View file

@ -0,0 +1,52 @@
/*
* <moeoPopAlgo.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOPOPALGO_H_
#define MOEOPOPALGO_H_
#include <eoAlgo.h>
#include <algo/moeoAlgo.h>
/**
* Abstract class for population based multi-objective evolutionary algorithms.
*/
template < class MOEOT >
class moeoPopAlgo : public moeoAlgo, public eoAlgo < MOEOT >
{};
#endif /*MOEOPOPALGO_H_*/

View file

@ -0,0 +1,50 @@
/*
* <moeoPopLS.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOPOPLS_H_
#define MOEOPOPLS_H_
#include <algo/moeoPopAlgo.h>
/**
* Abstract class for Population based multi-objective local search.
*/
template < class Neighborhhod >
class moeoPopLS : public moeoPopAlgo < typename Neighborhhod::EOT > {};
#endif /*MOEOPOPLS_H_*/

View file

@ -0,0 +1,211 @@
/*
* <moeoSEEA.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
*
* 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
*
*/
#ifndef MOEOSEEA_H_
#define MOEOSEEA_H_
#include <eoBreed.h>
#include <eoCloneOps.h>
#include <eoContinue.h>
#include <eoEvalFunc.h>
#include <eoGenContinue.h>
#include <eoGeneralBreeder.h>
#include <eoGenOp.h>
#include <eoPopEvalFunc.h>
#include <eoSGAGenOp.h>
#include <algo/moeoEA.h>
#include <archive/moeoArchive.h>
#include <replacement/moeoGenerationalReplacement.h>
#include <selection/moeoRandomSelect.h>
#include <selection/moeoSelectFromPopAndArch.h>
/**
* SEEA (Simple Elitist Evolutionary Algorithm).
* Liefooghe A. Jourdan L., Talbi E.-G.. Metaheuristics and Their Hybridization to Solve the Bi-objective Ring Star Problem: a Comparative Study. Technical Report RR-6515, INRIA, 2008
* This class builds SEEA by using the fine-grained components of the ParadisEO-MOEO framework.
*/
template < class MOEOT >
class moeoSEEA : public moeoEA < MOEOT >
{
public:
/**
* Ctor with a crossover, a mutation and their corresponding rates.
* @param _maxGen number of generations before stopping
* @param _eval evaluation function
* @param _crossover crossover
* @param _pCross crossover probability
* @param _mutation mutation
* @param _pMut mutation probability
* @param _archive archive
*/
moeoSEEA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoArchive < MOEOT > & _archive) :
defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select(randomSelect, _archive, 0.0), selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), genBreed (select, defaultSGAGenOp), breed (genBreed), archive(_archive)
{}
/**
* Ctor with a eoContinue and a eoGenOp.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _op variation operators
* @param _archive archive
*/
moeoSEEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, moeoArchive < MOEOT > & _archive) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select(randomSelect, _archive, 0.0), selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), archive(_archive)
{}
/**
* Ctor with a eoContinue, a eoPopEval and a eoGenOp.
* @param _continuator stopping criteria
* @param _popEval population evaluation function
* @param _op variation operators
* @param _archive archive
*/
moeoSEEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoGenOp < MOEOT > & _op, moeoArchive < MOEOT > & _archive) :
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), select(randomSelect, _archive, 0.0), selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), archive(_archive)
{}
/**
* Ctor with a eoContinue and a eoTransform.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _transform variation operator
* @param _archive archive
*/
moeoSEEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _transform, moeoArchive < MOEOT > & _archive) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select(randomSelect, _archive, 0.0), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), archive(_archive)
{}
/**
* Ctor with a eoContinue, a eoPopEval and a eoTransform.
* @param _continuator stopping criteria
* @param _popEval population evaluation function
* @param _transform variation operator
* @param _archive archive
*/
moeoSEEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoTransform < MOEOT > & _transform, moeoArchive < MOEOT > & _archive) :
defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), select(randomSelect, _archive, 0.0), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), archive(_archive)
{}
/**
* Apply a few generation of evolution to the population _pop until the stopping criteria is verified.
* @param _pop the population
*/
virtual void operator () (eoPop < MOEOT > &_pop)
{
eoPop < MOEOT > empty_pop, offspring;
popEval (empty_pop, _pop); // a first eval of _pop
archive(_pop); // archive update
while (continuator (_pop))
{
// generate offspring, worths are recalculated if necessary
genBreed (_pop, offspring);
popEval (_pop, offspring); // eval of offspring
// after replace, the new pop is in _pop
// replace (_pop, offspring);
// archive (_pop); // archive update
archive(offspring);
// _pop.resize(0);
// offspring.resize(0);
}
}
protected:
/** a continuator based on the number of generations (used as default) */
eoGenContinue < MOEOT > defaultGenContinuator;
/** stopping criteria */
eoContinue < MOEOT > & continuator;
/** default eval */
class DummyEval : public eoEvalFunc < MOEOT >
{
public:
void operator()(MOEOT &) {}
}
defaultEval;
/** evaluation function */
eoEvalFunc < MOEOT > & eval;
/** default popEval */
eoPopLoopEval < MOEOT > defaultPopEval;
/** evaluation function used to evaluate the whole population */
eoPopEvalFunc < MOEOT > & popEval;
/** default select */
class DummySelect : public eoSelect < MOEOT >
{
public :
void operator()(const eoPop<MOEOT>&, eoPop<MOEOT>&) {}
}
defaultSelect;
/** random select */
moeoRandomSelect < MOEOT > randomSelect;
/** elitist selection */
moeoSelectFromPopAndArch < MOEOT > select;
/** default select many */
eoSelectMany < MOEOT > selectMany;
/** select transform */
eoSelectTransform < MOEOT > selectTransform;
/** a default crossover */
eoQuadCloneOp < MOEOT > defaultQuadOp;
/** a default mutation */
eoMonCloneOp < MOEOT > defaultMonOp;
/** an object for genetic operators (used as default) */
eoSGAGenOp < MOEOT > defaultSGAGenOp;
/** default transform */
class DummyTransform : public eoTransform < MOEOT >
{
public :
void operator()(eoPop<MOEOT>&) {}
}
defaultTransform;
/** general breeder */
eoGeneralBreeder < MOEOT > genBreed;
/** breeder */
eoBreed < MOEOT > & breed;
/** generational replacement */
moeoGenerationalReplacement < MOEOT > replace;
/**archive*/
moeoArchive < MOEOT >& archive;
};
#endif /*MOEOSEEA_H_*/

View file

@ -0,0 +1,278 @@
/*
* <moeoSPEA2.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
*
*/
//-----------------------------------------------------------------------------
// moeoSPEA2.h
//-----------------------------------------------------------------------------
#ifndef MOEOSPEA2_H_
#define MOEOSPEA2_H_
#include <eoBreed.h>
#include <eoCloneOps.h>
#include <eoContinue.h>
#include <eoEvalFunc.h>
#include <eoGenContinue.h>
#include <eoGeneralBreeder.h>
#include <eoGenOp.h>
#include <eoPopEvalFunc.h>
#include <eoSGAGenOp.h>
#include <algo/moeoEA.h>
#include <diversity/moeoNearestNeighborDiversityAssignment.h>
#include <fitness/moeoDominanceCountFitnessAssignment.h>
#include <fitness/moeoDominanceCountRankingFitnessAssignment.h>
#include <replacement/moeoGenerationalReplacement.h>
#include <selection/moeoDetTournamentSelect.h>
#include <archive/moeoFixedSizeArchive.h>
#include <distance/moeoEuclideanDistance.h>
#include <selection/moeoSelectFromPopAndArch.h>
/**
* SPEA2 algorithm.
* E. Zitzler, M. Laumanns, and L. Thiele. SPEA2: Improving the Strength Pareto Evolutionary Algorithm. Technical Report 103,
* Computer Engineering and Networks Laboratory (TIK), ETH Zurich, Zurich, Switzerland, 2001.
*/
template < class MOEOT >
class moeoSPEA2: public moeoEA < MOEOT >
{
public:
/**
* Ctor with a crossover, a mutation and their corresponding rates.
* @param _maxGen number of generations before stopping
* @param _eval evaluation function
* @param _crossover crossover
* @param _pCross crossover probability
* @param _mutation mutation
* @param _pMut mutation probability
* @param _archive archive
* @param _k the k-ieme distance used to fixe diversity
* @param _nocopy boolean allow to consider copies and doublons as bad elements whose were dominated by all other MOEOT in fitness assignment.
*/
moeoSPEA2 (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoArchive < MOEOT >& _archive, unsigned int _k=1, bool _nocopy=false) :
defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), eval(_eval), loopEval(_eval), popEval(loopEval), archive(_archive),defaultSelect(2),select(defaultSelect, defaultSelect, _archive, 0.0),
defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), fitnessAssignment(_archive, _nocopy),
genBreed(defaultSelect, defaultSGAGenOp),selectMany(defaultSelect,0.0), selectTransform(selectMany, dummyTransform), breed(genBreed), diversityAssignment(dist,_archive, _k)
{}
/**
* Ctor with a crossover, a mutation and their corresponding rates.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _crossover crossover
* @param _pCross crossover probability
* @param _mutation mutation
* @param _pMut mutation probability
* @param _archive archive
* @param _k the k-ieme distance used to fixe diversity
* @param _nocopy boolean allow to consider copies and doublons as bad elements whose were dominated by all other MOEOT in fitness assignment.
*/
moeoSPEA2 (eoContinue < MOEOT >& _continuator, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoArchive < MOEOT >& _archive, unsigned int _k=1, bool _nocopy=false) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), loopEval(_eval), popEval(loopEval), archive(_archive),defaultSelect(2),select(defaultSelect, defaultSelect, _archive, 0.0),
defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), fitnessAssignment(_archive, _nocopy),
genBreed(defaultSelect, defaultSGAGenOp),selectMany(defaultSelect,0.0), selectTransform(selectMany, dummyTransform), breed(genBreed), diversityAssignment(dist,_archive, _k)
{}
/**
* Ctor with a crossover, a mutation and their corresponding rates.
* @param _continuator stopping criteria
* @param _eval pop evaluation function
* @param _crossover crossover
* @param _pCross crossover probability
* @param _mutation mutation
* @param _pMut mutation probability
* @param _archive archive
* @param _k the k-ieme distance used to fixe diversity
* @param _nocopy boolean allow to consider copies and doublons as bad elements whose were dominated by all other MOEOT in fitness assignment.
*/
moeoSPEA2 (eoContinue < MOEOT >& _continuator, eoPopEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoArchive < MOEOT >& _archive, unsigned int _k=1, bool _nocopy=false) :
defaultGenContinuator(0), continuator(_continuator), eval(dummyEval), loopEval(dummyEval), popEval(_eval), archive(_archive),defaultSelect(2),select(defaultSelect, defaultSelect, _archive, 0.0),
defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), fitnessAssignment(_archive, _nocopy),
genBreed(defaultSelect, defaultSGAGenOp),selectMany(defaultSelect,0.0), selectTransform(selectMany, dummyTransform), breed(genBreed), diversityAssignment(dist,_archive, _k)
{}
/**
* Ctor with a crossover, a mutation and their corresponding rates.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _op general operator
* @param _archive archive
* @param _k the k-ieme distance used to fixe diversity
* @param _nocopy boolean allow to consider copies and doublons as bad elements whose were dominated by all other MOEOT in fitness assignment.
*/
moeoSPEA2 (eoContinue < MOEOT >& _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, moeoArchive < MOEOT >& _archive, unsigned int _k=1, bool _nocopy=false) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), loopEval(_eval), popEval(loopEval), archive(_archive),defaultSelect(2),select(defaultSelect, defaultSelect, _archive, 0.0),
defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), fitnessAssignment(_archive, _nocopy),
genBreed(select, _op),selectMany(defaultSelect,0.0), selectTransform(selectMany, dummyTransform), breed(genBreed), diversityAssignment(dist,_archive, _k)
{}
/**
* Ctor with a crossover, a mutation and their corresponding rates.
* @param _continuator stopping criteria
* @param _eval evaluation function
* @param _op transformer
* @param _archive archive
* @param _k the k-ieme distance used to fixe diversity
* @param _nocopy boolean allow to consider copies and doublons as bad elements whose were dominated by all other MOEOT in fitness assignment.
*/
moeoSPEA2 (eoContinue < MOEOT >& _continuator, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _op, moeoArchive < MOEOT >& _archive, unsigned int _k=1, bool _nocopy=false) :
defaultGenContinuator(0), continuator(_continuator), eval(_eval), loopEval(_eval), popEval(loopEval), archive(_archive),defaultSelect(2),select(defaultSelect, defaultSelect, _archive, 0.0),
defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), fitnessAssignment(_archive, _nocopy),
genBreed(defaultSelect, defaultSGAGenOp),selectMany(select,1.0), selectTransform(selectMany, _op), breed(selectTransform), diversityAssignment(dist,_archive, _k)
{}
/**
* Ctor with a crossover, a mutation and their corresponding rates.
* @param _continuator stopping criteria
* @param _eval pop evaluation function
* @param _op general operator
* @param _archive archive
* @param _k the k-ieme distance used to fixe diversity
* @param _nocopy boolean allow to consider copies and doublons as bad elements whose were dominated by all other MOEOT in fitness assignment.
*/
moeoSPEA2 (eoContinue < MOEOT >& _continuator, eoPopEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, moeoArchive < MOEOT >& _archive, unsigned int _k=1, bool _nocopy=false) :
defaultGenContinuator(0), continuator(_continuator),eval(dummyEval), loopEval(dummyEval), popEval(_eval), archive(_archive),defaultSelect(2),select(defaultSelect, defaultSelect, _archive, 0.0),
defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), fitnessAssignment(_archive, _nocopy),
genBreed(select, _op),selectMany(defaultSelect,0.0), selectTransform(selectMany, dummyTransform), breed(genBreed), diversityAssignment(dist,_archive, _k)
{}
/**
* Ctor with a crossover, a mutation and their corresponding rates.
* @param _continuator stopping criteria
* @param _eval pop evaluation function
* @param _op transformer
* @param _archive archive
* @param _k the k-ieme distance used to fixe diversity
* @param _nocopy boolean allow to consider copies and doublons as bad elements whose were dominated by all other MOEOT in fitness assignment.
*/
moeoSPEA2 (eoContinue < MOEOT >& _continuator, eoPopEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _op, moeoArchive < MOEOT >& _archive, unsigned int _k=100, bool _nocopy=false) :
defaultGenContinuator(0), continuator(_continuator),eval(dummyEval), loopEval(dummyEval), popEval(_eval), archive(_archive),defaultSelect(2),select(defaultSelect, defaultSelect, _archive, 0.0),
defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), fitnessAssignment(_archive, _nocopy),
genBreed(defaultSelect, defaultSGAGenOp),selectMany(select,1.0), selectTransform(selectMany, _op), breed(selectTransform), diversityAssignment(dist,_archive, _k)
{}
/**
* Apply a few generation of evolution to the population _pop until the stopping criteria is verified.
* @param _pop the population
*/
virtual void operator () (eoPop < MOEOT > &_pop)
{
eoPop < MOEOT >empty_pop, offspring;
popEval (empty_pop, _pop);// a first eval of _pop
fitnessAssignment(_pop); //a first fitness assignment of _pop
diversityAssignment(_pop);//a first diversity assignment of _pop
archive(_pop);//a first filling of archive
while (continuator (_pop))
{
// generate offspring, worths are recalculated if necessary
breed (_pop, offspring);
popEval (_pop, offspring); // eval of offspring
// after replace, the new pop is in _pop. Worths are recalculated if necessary
replace (_pop, offspring);
fitnessAssignment(_pop); //fitness assignment of _pop
diversityAssignment(_pop); //diversity assignment of _pop
archive(_pop); //control of archive
}
}
protected:
/** dummy evaluation */
class eoDummyEval : public eoEvalFunc< MOEOT >
{
public:
void operator()(MOEOT &) {}
}
dummyEval;
/** dummy transform */
class eoDummyTransform : public eoTransform<MOEOT>
{
public :
void operator()(eoPop<MOEOT>&) {}
}
dummyTransform;
/** a continuator based on the number of generations (used as default) */
eoGenContinue < MOEOT > defaultGenContinuator;
/** stopping criteria */
eoContinue < MOEOT > & continuator;
/** evaluation function */
eoEvalFunc < MOEOT > & eval;
/** loop eval */
eoPopLoopEval < MOEOT > loopEval;
/** evaluation function used to evaluate the whole population */
eoPopEvalFunc < MOEOT > & popEval;
/**archive*/
moeoArchive < MOEOT >& archive;
/**SelectOne*/
moeoDetTournamentSelect < MOEOT > defaultSelect;
/** binary tournament selection */
moeoSelectFromPopAndArch < MOEOT > select;
/** a default mutation */
eoMonCloneOp < MOEOT > defaultMonOp;
/** a default crossover */
eoQuadCloneOp < MOEOT > defaultQuadOp;
/** an object for genetic operators (used as default) */
eoSGAGenOp < MOEOT > defaultSGAGenOp;
/** fitness assignment used in NSGA-II */
moeoDominanceCountRankingFitnessAssignment < MOEOT > fitnessAssignment;
/** general breeder */
eoGeneralBreeder < MOEOT > genBreed;
/** selectMany */
eoSelectMany <MOEOT> selectMany;
/** select Transform*/
eoSelectTransform <MOEOT> selectTransform;
/** breeder */
eoBreed < MOEOT > & breed;
/** diversity assignment used in NSGA-II */
moeoNearestNeighborDiversityAssignment < MOEOT > diversityAssignment;
/** elitist replacement */
moeoGenerationalReplacement < MOEOT > replace;
/**distance*/
moeoEuclideanDistance < MOEOT > dist;
};
#endif /*MOEOSPEA2_H_*/

View file

@ -0,0 +1,149 @@
/*
* <moeoUnifiedDominanceBasedLS.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEOUNIFIEDDOMINANCEBASEDLS_H
#define _MOEOUNIFIEDDOMINANCEBASEDLS_H
#include <eoPop.h>
#include <eoContinue.h>
#include <eoEvalFunc.h>
#include <eoPopEvalFunc.h>
#include <archive/moeoArchive.h>
#include <algo/moeoPopLS.h>
#include <explorer/moeoPopNeighborhoodExplorer.h>
#include <selection/moeoUnvisitedSelect.h>
/**
* A class to design dominance based local searches
*/
template < class Neighbor >
class moeoUnifiedDominanceBasedLS : public moeoPopLS < Neighbor >
{
public:
/** Alias for the type */
typedef typename Neighbor::EOT MOEOT;
/**
* Ctor
* @param _continuator a stop creterion
* @param _eval a evaluation function
* @param _archive a archive to store no-dominated individuals
* @param _explorer a neighborhood explorer
* @param _select a selector of unvisited individuals of a population
*/
moeoUnifiedDominanceBasedLS(
eoContinue < MOEOT > & _continuator,
eoEvalFunc < MOEOT > & _eval,
moeoArchive < MOEOT > & _archive,
moeoPopNeighborhoodExplorer < Neighbor > & _explorer,
moeoUnvisitedSelect < MOEOT > & _select) :
continuator(_continuator), loopEval(_eval), popEval(loopEval), archive(_archive), explorer(_explorer), select(_select) {}
/**
* Applies a few generation of evolution to the population _pop.
* @param _pop the population
*/
virtual void operator()(eoPop < MOEOT > & _pop)
{
std::vector < unsigned int> selectionVector;
eoPop < MOEOT > tmp_pop;
popEval(tmp_pop, _pop);
archive(_pop);
do{
tmp_pop.resize(0);
//selection
selectionVector = select(archive);
//exploration
explorer(archive, selectionVector, tmp_pop);
//archivage
archive(tmp_pop);
}
while (continuator(archive) && naturalContinuator(archive));
}
protected:
/** continuator */
eoContinue < MOEOT > & continuator;
/** loopEval */
eoPopLoopEval < MOEOT > loopEval;
/** popEval */
eoPopEvalFunc < MOEOT > & popEval;
/** archive */
moeoArchive < MOEOT > & archive;
/** explorer */
moeoPopNeighborhoodExplorer < Neighbor > & explorer;
/** selector */
moeoUnvisitedSelect < MOEOT > & select;
/**
* Natural Continuator (Stop when all individuals of the population are visited)
*/
class moeoContinue : public eoUF < eoPop < MOEOT > &, bool >
{
public:
/**
* Ctor
*/
moeoContinue(){}
/**
* functor which evaluate if the algorithm continue or not
* @param _pop the population
* @return true if the algorithm continue, else return false
*/
virtual bool operator()(eoPop < MOEOT > & _pop)
{
bool res = false;
unsigned int i=0;
while (!res && i < _pop.size()){
res = (_pop[i].flag() != 1);
i++;
}
//if (res==false)
//std::cout << "[Natural stop]" << std::endl;
return res;
}
} naturalContinuator;
};
#endif /*MOEOUNIFIEDDOMINANCEBASEDLS_H_*/

View file

@ -0,0 +1,445 @@
// j'ai installé le svn :)
// re-test
/*
* <moeo2DMinHypervolumeArchive.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEO2DMINHYPERVOLUMEARCHIVE_H_
#define MOEO2DMINHYPERVOLUMEARCHIVE_H_
#include <set>
#include <climits>
template < class MOEOT >
struct comp
{
// returns a "before" b
// all objectives = min
bool operator() (const MOEOT & a, const MOEOT & b)
{
return ((a.objectiveVector()[1] < b.objectiveVector()[1]) || ((a.objectiveVector()[1] == b.objectiveVector()[1]) && (a.objectiveVector()[0] < b.objectiveVector()[0])));
}
};
/** 2D (minimization) bounded archive by hypervolume , base on a set */
template < class MOEOT >
class moeo2DMinHypervolumeArchive : public std::set<MOEOT , comp < MOEOT > >
{
public:
typedef typename MOEOT::Fitness Fitness;
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
typedef typename std::set < MOEOT, comp<MOEOT> >::iterator Iterator;
using std::set < MOEOT, comp<MOEOT> > :: begin;
using std::set < MOEOT, comp<MOEOT> > :: end;
using std::set < MOEOT, comp<MOEOT> > :: insert;
using std::set < MOEOT, comp<MOEOT> > :: erase;
using std::set < MOEOT, comp<MOEOT> > :: size;
using std::set < MOEOT, comp<MOEOT> > :: upper_bound;
/**
* Ctr.
* @param _maxSize size of the archive (must be >= 2)
* @param _maxValue fitness assigned to the first and the last solution in the archive (default LONG_MAX)
*/
moeo2DMinHypervolumeArchive(unsigned int _maxSize=100, double _maxValue=LONG_MAX) : std::set < MOEOT, comp<MOEOT> > (), maxSize(_maxSize), maxValue(_maxValue)
{
maxSize = std::max((unsigned int) 2, maxSize);
}
/**
* Update the archive with a solution
* @param _moeo a solution
* @return true if _moeo has been added to the archive
*/
bool operator()(const MOEOT & _moeo)
{
//store result
bool result;
Iterator it;
//If archive is empty -> add the sol and affect its fitness value
if (size()==0)
{
result = true;
insert(_moeo);
it=begin();
fitness(it, maxValue);
}
else // test if sol can be added to the archive
{
result = insert(_moeo.objectiveVector());
if (result)
{
if(size() < maxSize)
{
// if yes, insert it and recompute fitness value of MOEOT and its neighbors
insert(hint, _moeo);
if(size() > 2)
{
//general case
hint--;
computeFitness(hint);
}
else
{
//archive size <= 2, fitness=maxValue for each sol
it=begin();
while(it!=end())
{
fitness(it, maxValue);
it++;
}
}
}
else
{
result = filter(_moeo);
}
}
}
return result;
}
/**
* update the archive with a population
* @param _pop a pop
* @return true if at least one solution of _pop has been added to the archive
*/
bool operator()(const eoPop < MOEOT > & _pop)
{
bool result = false;
bool tmp = false;
for (unsigned int i=0; i<_pop.size(); i++)
{
std::cout << "insert " << _pop[i].objectiveVector()[0] << ", " << _pop[i].objectiveVector()[1] << std::endl;
tmp = (*this)(_pop[i]);
result = tmp || result;
}
return result;
}
/**
* Test if insertion wrt Pareto-dominance is possible, and fix 'hint' if possible
* @param _objVec the objective vector of the sol to insert
* @return true if objVec can be added to the archive wrt Pareto-dominance
*/
bool insert(const ObjectiveVector & _objVec)
{
bool result = false;
Iterator it;
double min;
// set the objVec to the empty solution
empty.objectiveVector(_objVec);
// compute the position where it would possibly be added
it = upper_bound(empty);
// compute the weigth from the previous solution
min = begin()->objectiveVector()[0];
if (it != begin())
{
it--;
min = (*it).objectiveVector()[0];
it++;
}
// if it has a better weitgh, or if it's an extreme sol, let's add it
if (it == begin() || _objVec[0]<min)
{
// remove dominated solutions
remove(it,_objVec);
// set hint to the current iterator (probably modified by "remove")
hint=it;
// set result to true
result = true;
}
return result;
}
/**
* print objective vector and fitness value of the archive
*/
void print()
{
Iterator it = begin();
while(it!=end())
{
std::cout << (*it).objectiveVector()[0] << " " << (*it).objectiveVector()[1] << ", fit: " << (*it).fitness() << std::endl;
it++;
}
}
protected:
/** size max of the archive */
unsigned int maxSize;
/** fitness assigned to the first and the last solution in the archive */
double maxValue;
/** hint for the insertion */
Iterator hint;
/** an empty MOEOT used for checking insertion */
MOEOT empty;
/**
* set fitness
*/
void fitness(Iterator & _it, double _fitnessValue)
{
MOEOT* tmp;
tmp = (MOEOT*)&(*_it);
tmp->fitness(_fitnessValue);
}
/**
* remove solutions from the archive that are dominated by _objVec
* @param _it an iterator beginning on the first potentialy sol to remove
* @param _objVec the objective vector of the new solution
*/
void remove(Iterator & _it, const ObjectiveVector & _objVec)
{
Iterator itd;
while ((_it!=end()) && ((*_it).objectiveVector()[0] >= _objVec[0]))
{
itd = _it;
_it++;
erase(itd);
}
}
/**
* compute fitness value of a solution and its two neighbors
* @param _it refer to the solution
*/
void computeFitness(Iterator & _it)
{
Iterator tmp;
if(_it!=begin())
{
tmp=_it;
tmp--;
compute(tmp);
}
_it++;
if(_it!=end())
{
_it--;
tmp=_it;
tmp++;
compute(tmp);
}
else
{
_it--;
}
compute(_it);
}
/**
* compute fitness value of a solution
* @param _it refer to the solution
*/
void compute(Iterator & _it)
{
double x0, x1, y0, y1, fit;
if (_it==begin())
{
fitness(_it, maxValue);
}
else if ((++_it)==end())
{
_it--;
fitness(_it, maxValue);
}
else
{
_it--;
x0 = (*_it).objectiveVector()[0];
y0 = (*_it).objectiveVector()[1];
_it--;
x1 = (*_it).objectiveVector()[0];
_it++;
_it++;
y1 = (*_it).objectiveVector()[1];
_it--;
fit = (x1 - x0) * (y1 - y0);
fitness(_it, fit);
//tmp = (MOEOT*)&(*_it);
//tmp->fitness(fit);
}
}
double computeTmp(const ObjectiveVector & _objVec, int _where)
{
double res, tmp;
if(hint==begin() || hint==end())
res=maxValue;
else{
if(_where==0){
//on calcule la fit de celui à potentiellement inserer
res= (*hint).objectiveVector()[1] - _objVec[1];
hint--;
res*= ((*hint).objectiveVector()[0] - _objVec[0]);
hint++;
}
else if(_where <0){
// on calcule la fit de son predecesseur
res= _objVec[1] - (*hint).objectiveVector()[1];
tmp=(*hint).objectiveVector()[0];
hint--;
res*= ((*hint).objectiveVector()[0] - tmp);
hint++;
}
else{
// on calcule la fit de son successeur
res= _objVec[0] - (*hint).objectiveVector()[0];
tmp=(*hint).objectiveVector()[1];
hint++;
res*= ((*hint).objectiveVector()[1] - tmp);
hint--;
}
}
return res;
}
void filterbis()
{
Iterator it, itd;
//used to find sol with minimum fitness value
double minFit = maxValue;
// remove MOEOT with the lowest fitness value while archive size > maxSize
while (size() > maxSize)
{
//find sol with minimum fitness
for(it=begin(); it!=end(); it++)
{
if(it->fitness() < minFit)
{
minFit = it->fitness();
itd = it;
}
}
//remove it and recompute fitness of its neighbors
it = itd;
it--;
erase(itd);
compute(it);
it++;
compute(it);
}
}
/**
* iteratively removes the less-contributing solution from the acrhive
*/
bool filter(const MOEOT & _moeo)
{
bool res;
double x, y, pred, succ, tmp=0;
if(hint==begin() || hint==end())
{
insert(hint, _moeo);
hint--;
computeFitness(hint);
filterbis();
res=true;
}
else
{
//compute fitness tmp
tmp=computeTmp(_moeo.objectiveVector(), 0);
hint--;
pred=computeTmp(_moeo.objectiveVector(), -1);
hint++;
succ=computeTmp(_moeo.objectiveVector(), 1);
if(tmp>succ || tmp>pred)
{
insert(hint, _moeo);
hint--;
//ici faudrait utiliser les valeurs qu'on vient de calculer pour les affecter direct (faire attention à ou on se trouve)
computeFitness(hint);
filterbis();
res=true;
}
else
{
Iterator it;
double minFit = maxValue;
for(it=begin(); it!=end(); it++)
{
if(it->fitness() < minFit)
{
minFit = it->fitness();
}
}
if (tmp<=minFit)
{
res = false;
}
else
{
// REDONDANT arranger le code
insert(hint, _moeo);
hint--;
//ici faudrait utiliser les valeurs qu'on vient de calculer pour les affecter direct (faire attention à ou on se trouve)
computeFitness(hint);
filterbis();
res=true;
}
}
}
return res;
}
};
#endif /* MOEO2DMINHYPERVOLUMEARCHIVE_H_ */

View file

@ -0,0 +1,235 @@
/*
* <moeoArchive.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOARCHIVE_H_
#define MOEOARCHIVE_H_
#include <eoPop.h>
#include <comparator/moeoObjectiveVectorComparator.h>
#include <comparator/moeoParetoObjectiveVectorComparator.h>
/**
* Abstract class for representing an archive ;
* an archive is a secondary population that stores non-dominated solutions.
*/
template < class MOEOT >
class moeoArchive : public eoPop < MOEOT >, public eoUF < const MOEOT &, bool>, public eoUF < const eoPop < MOEOT > &, bool>
{
public:
using eoPop < MOEOT > :: size;
using eoPop < MOEOT > :: operator[];
using eoPop < MOEOT > :: back;
using eoPop < MOEOT > :: pop_back;
/**
* The type of an objective vector for a solution
*/
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Default ctor.
* The moeoObjectiveVectorComparator used to compare solutions is based on Pareto dominance
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoArchive(bool _replace=true) : eoPop < MOEOT >(), comparator(paretoComparator), replace(_replace)
{}
/**
* Ctor
* @param _comparator the moeoObjectiveVectorComparator used to compare solutions
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoArchive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _replace=true) : eoPop < MOEOT >(), comparator(_comparator), replace(_replace)
{}
/**
* Returns true if the current archive dominates _objectiveVector according to the moeoObjectiveVectorComparator given in the constructor
* @param _objectiveVector the objective vector to compare with the current archive
*/
bool dominates (const ObjectiveVector & _objectiveVector) const
{
for (unsigned int i = 0; i<size(); i++)
{
// if _objectiveVector is dominated by the ith individual of the archive...
if ( comparator(_objectiveVector, operator[](i).objectiveVector()) )
{
return true;
}
}
return false;
}
/**
* Returns true if the current archive already contains a solution with the same objective values than _objectiveVector
* @param _objectiveVector the objective vector to compare with the current archive
*/
bool contains (const ObjectiveVector & _objectiveVector) const
{
for (unsigned int i = 0; i<size(); i++)
{
if (operator[](i).objectiveVector() == _objectiveVector)
{
return true;
}
}
return false;
}
/**
* Updates the archive with a given individual _moeo
* @param _moeo the given individual
* @return if the _moeo is added to the archive
*/
virtual bool operator()(const MOEOT & _moeo) = 0;
/**
* Updates the archive with a given population _pop
* @param _pop the given population
* @return if at least one _pop[i] is added to the archive
*/
virtual bool operator()(const eoPop < MOEOT > & _pop) = 0;
/**
* Returns true if the current archive contains the same objective vectors than the given archive _arch
* @param _arch the given archive
*/
bool equals (const moeoArchive < MOEOT > & _arch)
{
for (unsigned int i=0; i<size(); i++)
{
if (! _arch.contains(operator[](i).objectiveVector()))
{
return false;
}
}
for (unsigned int i=0; i<_arch.size() ; i++)
{
if (! contains(_arch[i].objectiveVector()))
{
return false;
}
}
return true;
}
protected:
/**
* Updates the archive with a given individual _moeo
* @param _moeo the given individual
*/
bool update(const MOEOT & _moeo)
{
// first step: removing the dominated solutions from the archive
for (unsigned int j=0; j<size();)
{
// if the jth solution contained in the archive is dominated by _moeo
if ( comparator(operator[](j).objectiveVector(), _moeo.objectiveVector()) )
{
operator[](j) = back();
pop_back();
}
else if (replace && (_moeo.objectiveVector() == operator[](j).objectiveVector()))
{
operator[](j) = back();
pop_back();
}
else
{
j++;
}
}
// second step: is _moeo dominated?
bool dom = false;
for (unsigned int j=0; j<size(); j++)
{
// if _moeo is dominated by the jth solution contained in the archive
if ( comparator(_moeo.objectiveVector(), operator[](j).objectiveVector()) )
{
dom = true;
break;
}
else if (!replace && (_moeo.objectiveVector() == operator[](j).objectiveVector()) )
{
dom = true;
break;
}
}
if (!dom)
{
this->push_back(_moeo);
}
return !dom;
}
/**
* Updates the archive with a given population _pop
* @param _pop the given population
*/
bool update(const eoPop < MOEOT > & _pop)
{
bool res = false;
bool tmp = false;
for (unsigned int i=0; i<_pop.size(); i++)
{
tmp = (*this).update(_pop[i]);
res = tmp || res;
}
return res;
}
/** The moeoObjectiveVectorComparator used to compare solutions */
moeoObjectiveVectorComparator < ObjectiveVector > & comparator;
/** A moeoObjectiveVectorComparator based on Pareto dominance (used as default) */
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
/** boolean */
bool replace;
};
#endif /*MOEOARCHIVE_H_ */

View file

@ -0,0 +1,81 @@
/*
* <moeoBoundedArchive.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
*
*/
//-----------------------------------------------------------------------------
// moeoBoundedArchive.h
//-----------------------------------------------------------------------------
#ifndef MOEOBOUNDEDARCHIVE_H_
#define MOEOBOUNDEDARCHIVE_H_
#include <archive/moeoArchive.h>
/**
* This class represents a bounded archive which different parameters to specify.
*/
template < class MOEOT >
class moeoBoundedArchive : public moeoArchive < MOEOT >
{
public:
/**
* The type of an objective vector for a solution
*/
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Ctor where you can choose your own moeoObjectiveVectorComparator and archive size.
* @param _comparator the functor used to compare objective vectors
* @param _maxSize the size of archive (must be smaller or egal to the population size)
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoBoundedArchive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100, bool _replace=true) : moeoArchive < MOEOT >(_comparator, _replace), maxSize(_maxSize){}
/**
* Ctor with moeoParetoObjectiveVectorComparator where you can choose your own archive size.
* @param _maxSize the size of archive (must be smaller or egal to the population size)
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoBoundedArchive(unsigned int _maxSize=100, bool _replace=true) : moeoArchive < MOEOT >(_replace), maxSize(_maxSize){}
protected:
/** archive max size */
unsigned int maxSize;
};
#endif /*MOEOBOUNDEDARCHIVE_H_*/

View file

@ -0,0 +1,421 @@
/*
* <moeoEpsilonHyperboxArchive.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
*
*/
//-----------------------------------------------------------------------------
// moeoEpsilonHyperboxArchive.h
//-----------------------------------------------------------------------------
#ifndef MOEOEPSILONBOXARCHIVE_H_
#define MOEOEPSILONBOXARCHIVE_H_
#include <eoPop.h>
#include <comparator/moeoComparator.h>
#include <comparator/moeoObjectiveVectorComparator.h>
#include <distance/moeoEuclideanDistance.h>
#include <utils/moeoObjectiveVectorNormalizer.h>
#include <utils/eoRealBounds.h>
/**
* This class represents an epsilon hyperbox archive.
*/
template < class MOEOT >
class moeoEpsilonHyperboxArchive : public moeoArchive < MOEOT >
{
public:
using moeoArchive < MOEOT > :: size;
using moeoArchive < MOEOT > :: resize;
using moeoArchive < MOEOT > :: operator[];
using moeoArchive < MOEOT > :: back;
using moeoArchive < MOEOT > :: pop_back;
using moeoArchive < MOEOT > :: push_back;
using moeoArchive < MOEOT > :: begin;
using moeoArchive < MOEOT > :: end;
using moeoArchive < MOEOT > :: replace;
/**
* The type of an objective vector for a solution
*/
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Ctor where you can choose your own moeoObjectiveVectorComparator
* @param _comparator the functor used to compare objective vectors
* @param _epsilon the vector contains epsilon values for each objective
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoEpsilonHyperboxArchive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, std::vector<double> _epsilon, bool _replace=true) : moeoArchive < MOEOT >(_comparator, _replace), epsilon(_epsilon), bounds(0.0, 1.0), normalizer(bounds, 1.0)
{}
/**
* Default Ctor
* @param _epsilon the vector contains epsilon values for each objective
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoEpsilonHyperboxArchive(std::vector<double> _epsilon, bool _replace=true) : moeoArchive < MOEOT >(paretoComparator, _replace), epsilon(_epsilon), bounds(0.0, 1.0), normalizer(bounds, 1.0)
{}
/**
* Updates the archive with a given individual _moeo
* @param _moeo the given individual
* @return true if _moeo is non-dominated (and not if it is added to the archive)
*/
bool operator()(const MOEOT & _moeo)
{
bool res=false;
unsigned int i=0;
bool nonstop = true;
bool same = true;
int change = 0;
MOEOT removed;
//if the archive is empty, we accept automaticaly _moeo
if(size()==0){
push_back(_moeo);
ideal = _moeo.objectiveVector();
nadir = _moeo.objectiveVector();
res = true;
}
else{
//change bounds if necessary
change = changeBounds(_moeo);
//if change < 0, we have detected that _moeo is bad
//else there are 4 cases:
if(change >= 0){
//calculate the hyperbox corner of _moeo
ObjectiveVector corner, tmp;
corner=hyperbox(_moeo);
//test if _moeo hyperbox corner dominates a hyperbox corner of an element of the archive
while(nonstop && (i<size())){
same = true;
//calculate the hyperbox corner of the ieme element of the archive
tmp=hyperbox(operator[](i));
//CASE 1: _moeo epsilon-domine the ieme element of the archive
if(this->comparator(tmp, corner)){
std::cout << "ENTER CASE 1" << std::endl;
//test if bounds changed
//removed=operator[](i);
//delete the ieme element of the archive
if(i==size()-1)
pop_back();
else{
operator[](i)=back();
pop_back();
i--;
}
//changeBoundsByDeleting(removed);
res = true;
}//END CASE 1
//CASE 2: the ieme element of the archive epsilon-domine _moeo
else if(this->comparator(corner, tmp)){
std::cout << "ENTER CASE 2" << std::endl;
if(change == 1)
changeBoundsByDeleting(_moeo);
//we can stop
nonstop = false;
}//END CASE 2
// _moeo is no-epsilon-dominated by archive[i] and arhcive[i] is no-epsilon-dominated by _moeo
else{
//test if the hyperbox corner are the same
for(unsigned int j=0; j<corner.size(); j++)
same = same && (corner[j] == tmp[j]);
//CASE 3: _moeo is in the same hyperbox of archive[i]
if(same){
std::cout << "ENTER CASE 3" << std::endl;
// _moeo dominates archive[i]
if(this->comparator(operator[](i).objectiveVector(), _moeo.objectiveVector())){
if(i==size()-1)
pop_back();
else{
operator[](i)=back();
pop_back();
i--;
}
// removed=operator[](i);
// operator[](i) = _moeo;
// changeBoundsByDeleting(removed);
res=true;
}
// _moeo is dominated by archive[i]
else if(this->comparator(_moeo.objectiveVector(), operator[](i).objectiveVector())){
changeBoundsByDeleting(_moeo);
nonstop=false;
}
else{
//keep the one who have the shortest euclidian distance between the corner
moeoEuclideanDistance < MOEOT > dist;
double d1 = dist(_moeo.objectiveVector(), corner);
double d2 = dist(operator[](i).objectiveVector(), corner);
if(d1 <= d2){
if(i==size()-1)
pop_back();
else{
operator[](i)=back();
pop_back();
i--;
}
// removed=operator[](i);
// operator[](i) = _moeo;
// changeBoundsByDeleting(removed);
res=true;
}
else{
nonstop=false;
// changeBoundsByDeleting(_moeo);
res=true;
}
}
}//END CASE 3
}
i++;
}
//CASE 4: _moeo have is place in a empty hyperbox
if(nonstop){
std::cout << "ENTER CASE 4" << std::endl;
push_back(_moeo);
res=true;
recalculateBounds();
}//END CASE 4
}
else{
std::cout << "ENTER CASE 5" << std::endl;
}
}
return res;
}
/**
* Updates the archive with a given population _pop
* @param _pop the given population
* @return if an archive's element is non-dominated (and not if it is added to the archive)
*/
bool operator()(const eoPop < MOEOT > & _pop)
{
bool res, tmp = false;
for(unsigned int i=0; i<_pop.size(); i++){
tmp = (*this)(_pop[i]);
res = res || tmp;
}
return res;
}
/**
* get the nadir point
* @return ObjectiveVector corresponding to the nadir point
*/
ObjectiveVector getNadir(){
return nadir;
}
/**
* get the idealpoint
* @return ObjectiveVector corresponding to the ideal point
*/
ObjectiveVector getIdeal(){
return ideal;
}
void filtre(){
eoPop<MOEOT> pop;
for(int i=0; i<size(); i++)
pop.push_back(operator[](i));
for(int i=0; i<pop.size(); i++)
(*this)(pop[i]);
}
private:
/**
* calculate the hyperbox corner of _moeo
* @param _moeo the given individual
* @return the ObjectiveVector contains the hyperbox corner values
*/
ObjectiveVector hyperbox(const MOEOT & _moeo){
//normalize _moeo's objectiveVector
ObjectiveVector res;
res = normalizer(_moeo.objectiveVector());
// std::cout << "ObjectiveVector non normalise:"<< _moeo.objectiveVector() << std::endl;
// std::cout << "ObjectiveVector normalise:"<< res << std::endl;
//calculate the hyperbox corner
for(unsigned int i=0; i<ObjectiveVector::nObjectives(); i++){
if(ObjectiveVector::minimizing(i))
res[i] = floor(res[i]*1.0/epsilon[i]);
else
res[i] = ceil(res[i]*1.0/epsilon[i]);
}
// std::cout << "ObjectiveVector epsilone:" << res << std::endl;
return res;
}
/**
* changes ideal and nadir point if _moeo is out of bounds and is not bad
* @param _moeo the given individual
* @return if bounds changed or not (1 -> changed, 0 -> not changed, -1 -> _moeo is bad)
*/
int changeBounds(const MOEOT & _moeo){
// std::cout << "changebounds objVec: "<< _moeo.objectiveVector() << std::endl;
int res = 0;
//check if an objective is better than the corresponding of the current ideal point
for(unsigned int i=0; i<ObjectiveVector::nObjectives(); i++){
if(ObjectiveVector::minimizing(i)){
if(_moeo.objectiveVector()[i] < ideal[i]){
ideal[i]=_moeo.objectiveVector()[i];
res = 1;
}
}
else{
if(_moeo.objectiveVector()[i] > ideal[i]){
ideal[i]=_moeo.objectiveVector()[i];
res = 1;
}
}
}
//check if an objective is worst than the corresponding of the current nadir point
for(unsigned int i=0; i<ObjectiveVector::nObjectives(); i++){
if(ObjectiveVector::minimizing(i)){
if(_moeo.objectiveVector()[i] > nadir[i]){
if(res == 1)
nadir[i]=_moeo.objectiveVector()[i];
else
res = -1; // no objective is better than the ideal and some are worst than nadir -> _moeo is bad
}
}
else{
if(_moeo.objectiveVector()[i] < nadir[i]){
if(res == 1)
nadir[i]=_moeo.objectiveVector()[i];
else
res = -1; // no objective is better than the ideal and some are worst than nadir -> _moeo is bad
}
}
}
//If bounds are changed, change the scale of normalizer
if(res == 1){
ObjectiveVector mini;
ObjectiveVector maxi;
for(unsigned int i=0; i<ObjectiveVector::nObjectives(); i++){
mini[i]=std::min(ideal[i], nadir[i]);
maxi[i]=std::max(ideal[i], nadir[i]);
}
normalizer.update_by_min_max(mini, maxi);
}
// std::cout << "change nadir: " << nadir << std::endl;
// std::cout << "change ideal: " << ideal << std::endl;
// std::cout << "res: " << res << std::endl;
return res;
}
/**
* when a element is deleting, change the bounds if neccesary.
* @param _moeo the deleted individual
*/
void changeBoundsByDeleting(const MOEOT & _moeo){
for(unsigned int i=0; i< ObjectiveVector::nObjectives(); i++){
if((_moeo.objectiveVector()[i]==nadir[i]) || (_moeo.objectiveVector()[i]==ideal[i]) )
return recalculateBounds();
}
}
/**
* recalculate ideal and nadir point and change scale of normalizer
*/
void recalculateBounds(){
ObjectiveVector tmp;
ideal=operator[](0).objectiveVector();
nadir=operator[](0).objectiveVector();
if (size() > 1){
for(unsigned int i=0; i< ObjectiveVector::nObjectives(); i++){
for(unsigned int j=1; j<size(); j++){
tmp=operator[](j).objectiveVector();
if(ObjectiveVector::minimizing(i)){
if(tmp[i] < ideal[i])
ideal[i] = tmp[i];
else if(tmp[i] > nadir[i])
nadir[i] = tmp[i];
}
else{
if(tmp[i] > ideal[i]){
ideal[i] = tmp[i];
}
else if(tmp[i] < nadir[i]){
nadir[i] = tmp[i];
}
}
}
}
}
ObjectiveVector mini;
ObjectiveVector maxi;
for(unsigned int i=0; i<ObjectiveVector::nObjectives(); i++){
mini[i]=std::min(ideal[i], nadir[i]);
maxi[i]=std::max(ideal[i], nadir[i]);
}
normalizer.update_by_min_max(mini, maxi);
}
/** A moeoObjectiveVectorComparator based on Pareto dominance (used as default) */
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
/** epsilon values */
std::vector <double> epsilon;
/** ideal point of the archive */
ObjectiveVector ideal;
/** nadir point of the archive */
ObjectiveVector nadir;
/** bounds use by default to initialize the normalizer */
eoRealInterval bounds;
/** the objective vector normalizer */
moeoObjectiveVectorNormalizer <MOEOT> normalizer;
};
#endif /*MOEOEPSILONBOXARCHIVE_H_*/

View file

@ -0,0 +1,174 @@
/*
* <moeoFitDivBoundedArchive.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
*
*/
//-----------------------------------------------------------------------------
// moeoFitDivBoundedArchive.h
//-----------------------------------------------------------------------------
#ifndef MOEOFITDIVBOUNDEDARCHIVE_H_
#define MOEOFITDIVBOUNDEDARCHIVE_H_
#include <list>
#include <eoPop.h>
#include <comparator/moeoComparator.h>
#include <comparator/moeoObjectiveVectorComparator.h>
#include <diversity/moeoDiversityAssignment.h>
#include <fitness/moeoFitnessAssignment.h>
/**
* This class represents a bounded archive which different parameters to specify.
*/
template < class MOEOT >
class moeoFitDivBoundedArchive : public moeoBoundedArchive < MOEOT >
{
public:
using moeoArchive < MOEOT > :: size;
using moeoArchive < MOEOT > :: resize;
using moeoArchive < MOEOT > :: operator[];
using moeoArchive < MOEOT > :: back;
using moeoArchive < MOEOT > :: pop_back;
using moeoArchive < MOEOT > :: push_back;
using moeoArchive < MOEOT > :: begin;
using moeoArchive < MOEOT > :: end;
using moeoArchive < MOEOT > :: replace;
using moeoBoundedArchive < MOEOT > :: maxSize;
/**
* The type of an objective vector for a solution
*/
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Ctor where you can choose your own moeoComparator, moeoObjectiveVectorComparator, moeoFitnessAssignment, moeoDiversityAssignment and archive size.
* @param _indiComparator the functor used to compare MOEOT
* @param _comparator the functor used to compare objective vectors
* @param _fitness the assignment fitness method
* @param _diversity the diversity assignment method
* @param _maxSize the size of archive (must be smaller or egal to the population size)
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoFitDivBoundedArchive(moeoComparator < MOEOT > & _indiComparator, moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, moeoFitnessAssignment < MOEOT > & _fitness, moeoDiversityAssignment < MOEOT > & _diversity, unsigned int _maxSize=100, bool _replace=true) : moeoBoundedArchive < MOEOT >(_comparator, _maxSize, _replace), indiComparator(_indiComparator), fitness(_fitness), diversity(_diversity)
{}
/**
* Ctor with moeoParetoObjectiveVectorComparator where you can choose your own moeoComparator, moeoFitnessAssignment, moeoDiversityAssignment and archive size.
* @param _indiComparator the functor used to compare MOEOT
* @param _fitness the assignment fitness method
* @param _diversity the diversity assignment method
* @param _maxSize the size of archive (must be smaller or egal to the population size)
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoFitDivBoundedArchive(moeoComparator < MOEOT > & _indiComparator, moeoFitnessAssignment < MOEOT > & _fitness, moeoDiversityAssignment < MOEOT > & _diversity, unsigned int _maxSize=100, bool _replace=true) : moeoBoundedArchive < MOEOT >(_maxSize, _replace), indiComparator(_indiComparator), fitness(_fitness), diversity(_diversity)
{}
/**
* Updates the archive with a given individual _moeo
* @param _moeo the given individual
* @return true if _moeo is non-dominated (and not if it is added to the archive)
*/
bool operator()(const MOEOT & _moeo)
{
bool res;
res = this->update(_moeo);
if(size() > maxSize){
fitness(*this);
diversity(*this);
std::sort(begin(), end(), indiComparator);
resize(maxSize);
}
return res;
}
/**
* Updates the archive with a given population _pop
* @param _pop the given population
* @return true if a _pop[i] is non-dominated (and not if it is added to the archive)
*/
bool operator()(const eoPop < MOEOT > & _pop)
{
bool res;
res = this->update(_pop);
if(size() > maxSize){
fitness(*this);
diversity(*this);
std::sort(begin(), end(), indiComparator);
resize(maxSize);
}
return res;
}
private:
/**
* Wrapper which allow to used an moeoComparator in std::sort
* @param _comp the comparator to used
*/
class Wrapper
{
public:
/**
* Ctor.
* @param _comp the comparator
*/
Wrapper(moeoComparator < MOEOT > & _comp) : comp(_comp) {}
/**
* Returns true if _moeo1 is greater than _moeo2 according to the comparator
* _moeo1 the first individual
* _moeo2 the first individual
*/
bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
return comp(_moeo1,_moeo2);
}
private:
/** the comparator */
moeoComparator < MOEOT > & comp;
}
indiComparator;
/** fitness assignment */
moeoFitnessAssignment < MOEOT > & fitness;
/** diversity assignment */
moeoDiversityAssignment < MOEOT > & diversity;
};
#endif /*MOEOFITDIVBOUNDEDARCHIVE_H_*/

View file

@ -0,0 +1,80 @@
/*
* <moeoFixedSizeArchive.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
*
*/
//-----------------------------------------------------------------------------
// moeoFixedSizeArchive.h
//-----------------------------------------------------------------------------
#ifndef MOEOFIXEDSIZEARCHIVE_H_
#define MOEOFIXEDSIZEARCHIVE_H_
#include <eoPop.h>
#include <archive/moeoArchive.h>
#include <comparator/moeoObjectiveVectorComparator.h>
/**
* Abstract class for representing a fixed size archive ;
* a fixed size archive is an archive containing a given number of solutions.
*/
template < class MOEOT >
class moeoFixedSizeArchive : public moeoArchive < MOEOT >
{
public:
/**
* The type of an objective vector for a solution
*/
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Default ctor.
* The moeoObjectiveVectorComparator used to compare solutions is based on Pareto dominance
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoFixedSizeArchive(bool _replace=true) : moeoArchive < MOEOT >(_replace) {}
/**
* Ctor
* @param _comparator the moeoObjectiveVectorComparator used to compare solutions
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoFixedSizeArchive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _replace=true) : moeoArchive < MOEOT >( _comparator, _replace) {}
};
#endif /*MOEOFIXEDSIZEARCHIVE_H_*/

View file

@ -0,0 +1,170 @@
/*
* <moeoImprOnlyBoundedArchive.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
*
*/
//-----------------------------------------------------------------------------
// moeoIMPRONLYBOUNDEDARCHIVE.h
//-----------------------------------------------------------------------------
#ifndef MOEOImprOnlyBoundedArchive_H_
#define MOEOImprOnlyBoundedArchive_H_
#include <archive/moeoBoundedArchive.h>
#include <archive/moeoArchive.h>
/**
* This class represents a bounded archive which different parameters to specify.
*/
template < class MOEOT >
class moeoImprOnlyBoundedArchive : public moeoBoundedArchive < MOEOT >
{
public:
using moeoArchive < MOEOT > :: size;
using moeoArchive < MOEOT > :: resize;
using moeoArchive < MOEOT > :: operator[];
using moeoArchive < MOEOT > :: back;
using moeoArchive < MOEOT > :: pop_back;
using moeoArchive < MOEOT > :: push_back;
using moeoArchive < MOEOT > :: begin;
using moeoArchive < MOEOT > :: end;
using moeoArchive < MOEOT > :: replace;
using moeoBoundedArchive < MOEOT > :: maxSize;
/**
* The type of an objective vector for a solution
*/
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Ctor where you can choose your own moeoComparator and archive size.
* @param _comparator the functor used to compare objective vectors
* @param _maxSize the size of archive (must be smaller or egal to the population size)
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoImprOnlyBoundedArchive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100, bool _replace=true) : moeoBoundedArchive < MOEOT >(_comparator, _maxSize, _replace){}
/**
* Ctor with moeoParetoObjectiveVectorComparator where you can choose your own archive size.
* @param _maxSize the size of archive (must be smaller or egal to the population size)
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoImprOnlyBoundedArchive(unsigned int _maxSize=100, bool _replace=true) : moeoBoundedArchive < MOEOT >(_maxSize, _replace){}
/**
* Updates the archive with a given individual _moeo
* @param _moeo the given individual
* @return true if _moeo is non-dominated (and not if it is added to the archive)
*/
bool operator()(const MOEOT & _moeo)
{
return update(_moeo);
}
/**
* Updates the archive with a given population _pop
* @param _pop the given population
* @return true if a _pop[i] is non-dominated (and not if it is added to the archive)
*/
bool operator()(const eoPop < MOEOT > & _pop)
{
bool res = false;
bool tmp = false;
for (unsigned int i=0; i<_pop.size(); i++)
{
tmp = (*this).update(_pop[i]);
res = tmp || res;
}
return res;
}
private:
/**
* Updates the archive with a given individual _moeo *** NEW ***
* @param _moeo the given individual
*/
bool update(const MOEOT & _moeo)
{
// first step: removing the dominated solutions from the archive
for (unsigned int j=0; j<size();)
{
// if the jth solution contained in the archive is dominated by _moeo
if ( this->comparator(operator[](j).objectiveVector(), _moeo.objectiveVector()) )
{
operator[](j) = back();
pop_back();
}
else if (replace && (_moeo.objectiveVector() == operator[](j).objectiveVector()))
{
operator[](j) = back();
pop_back();
}
else
{
j++;
}
}
// second step: is _moeo dominated?
bool dom = false;
for (unsigned int j=0; j<size(); j++)
{
// if _moeo is dominated by the jth solution contained in the archive
if ( this->comparator(_moeo.objectiveVector(), operator[](j).objectiveVector()) )
{
dom = true;
break;
}
else if (!replace && (_moeo.objectiveVector() == operator[](j).objectiveVector()) )
{
dom = true;
break;
}
}
if (!dom)
{
if(size()<maxSize)
push_back(_moeo);
else
dom=!dom;
}
return !dom;
}
};
#endif /*MOEOIMPRONLYBOUNDEDARCHIVE_H_*/

View file

@ -0,0 +1,386 @@
/*
* <moeoSPEA2Archive.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
*
*/
//-----------------------------------------------------------------------------
// moeoSPEA2Archive.h
//-----------------------------------------------------------------------------
#ifndef MOEOSPEA2ARCHIVE_H_
#define MOEOSPEA2ARCHIVE_H_
#include <limits>
#include <list>
#include <eoPop.h>
#include <archive/moeoFixedSizeArchive.h>
#include <comparator/moeoComparator.h>
#include <comparator/moeoFitnessThenDiversityComparator.h>
#include <comparator/moeoObjectiveVectorComparator.h>
#include <distance/moeoDistance.h>
#include <distance/moeoEuclideanDistance.h>
/**
* This class represents a bounded archive as defined in the SPEA2 algorithm.
* E. Zitzler, M. Laumanns, and L. Thiele. SPEA2: Improving the Strength Pareto Evolutionary Algorithm. Technical Report 103,
* Computer Engineering and Networks Laboratory (TIK), ETH Zurich, Zurich, Switzerland, 2001.
*/
template < class MOEOT >
class moeoSPEA2Archive : public moeoFixedSizeArchive < MOEOT >
{
public:
using moeoFixedSizeArchive < MOEOT > :: size;
using moeoFixedSizeArchive < MOEOT > :: resize;
using moeoFixedSizeArchive < MOEOT > :: operator[];
using moeoFixedSizeArchive < MOEOT > :: back;
using moeoFixedSizeArchive < MOEOT > :: pop_back;
using moeoFixedSizeArchive < MOEOT > :: push_back;
using moeoFixedSizeArchive < MOEOT > :: begin;
using moeoFixedSizeArchive < MOEOT > :: end;
/**
* The type of an objective vector for a solution
*/
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Default ctor.
* @param _maxSize the size of archive (must be smaller or equal to the population size)
*/
moeoSPEA2Archive(unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), indiComparator(defaultComparator), distance(defaultDistance)
{}
/**l
* Ctor where you can choose your own moeoDistance
* @param _dist the distance used
* @param _maxSize the size of archive (must be smaller or egal to the population size)
*/
moeoSPEA2Archive(moeoDistance <MOEOT, double>& _dist, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), indiComparator(defaultComparator), distance(_dist)
{}
/**
* Ctor where you can choose your own moeoObjectiveVectorComparator
* @param _comparator the functor used to compare objective vectors
* @param _maxSize the size of archive (must be smaller or egal to the population size)
*/
moeoSPEA2Archive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(_comparator, true), maxSize(_maxSize), borne(0), indiComparator(defaultComparator), distance(defaultDistance)
{}
/**
* Ctor where you can choose your own moeoComparator
* @param _indiComparator the functor used to compare MOEOT
* @param _maxSize the size of archive (must be smaller or egal to the population size)
*/
moeoSPEA2Archive(moeoComparator <MOEOT>& _indiComparator, unsigned int _maxSize=100): moeoFixedSizeArchive < MOEOT >(true), maxSize(_maxSize), borne(0), indiComparator(_indiComparator), distance(defaultDistance)
{}
/**
* Ctor where you can choose your own moeoComparator, moeoDistance and moeoObjectiveVectorComparator
* @param _indiComparator the functor used to compare MOEOT
* @param _dist the distance used
* @param _comparator the functor used to compare objective vectors
* @param _maxSize the size of archive (must be smaller or egal to the population size)
*/
moeoSPEA2Archive(moeoComparator <MOEOT>& _indiComparator, moeoDistance <MOEOT, double>& _dist, moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100) : moeoFixedSizeArchive < MOEOT >(_comparator, true), maxSize(_maxSize), borne(0), indiComparator(_indiComparator), distance(_dist)
{}
/**
* Updates the archive with a given individual _moeo
* @param _moeo the given individual
* @return true (TODO)
*/
bool operator()(const MOEOT & _moeo)
{
eoPop < MOEOT > pop_tmp;
pop_tmp.push_back(_moeo);
operator()(pop_tmp);
return true;
}
/**
* Updates the archive with a given population _pop
* @param _pop the given population
* @return true (TODO)
*/
bool operator()(const eoPop < MOEOT > & _pop)
{
unsigned int i;
unsigned int foo=0;
//Creation of the vector that contains minimal pop's informations
std::vector<struct refpop> copy_pop(_pop.size());
for (i=0;i<_pop.size(); i++)
{
copy_pop[i].index=i;
copy_pop[i].fitness=_pop[i].fitness();
copy_pop[i].diversity=_pop[i].diversity();
}
//Sort this vector in decrease order of fitness+diversity
std::sort(copy_pop.begin(), copy_pop.end(), Cmp());
//If the archive is empty, put in the best elements of the pop
if (borne < maxSize)
{
foo= std::min((unsigned int)_pop.size(), maxSize-borne);
for (i=0; i< foo ; i++)
{
push_back(_pop[copy_pop[i].index]);
borne++;
}
}
else
{
unsigned int j=0;
//Sort the archive
std::sort(begin(), end(), indiComparator);
i=0;
//While we have a better element in pop than the worst <= -1 in the archive, replace the worst(of archive) by the best(of pop)
while ( (i<borne) && ( (operator[](i).fitness()+operator[](i).diversity()) < (copy_pop[j].fitness + copy_pop[j].diversity) ) && (operator[](i).fitness()<=-1) && ( j < copy_pop.size() ) )
{
operator[](i)= back();
pop_back();
push_back(_pop[copy_pop[j].index]);
i++;
j++;
}
//If their are others goods elements in pop (fitness=0) , keep only archive's size elements between the archive's elements and the good element in the pop (k ieme smallest distance is used)
if (copy_pop[j].fitness > -1)
{
unsigned int inf=j;
unsigned int p;
unsigned int k=0;
unsigned int l=0;
double tmp=0;
unsigned int tmp2=0;
//search bounds of copy_pop where are the goods elements
while ((j < copy_pop.size()) && (copy_pop[j].fitness > -1.0))
j++;
p=j-inf;
std::vector< std::vector< std::pair<int,double> > > matrice(borne+p);
//Build the distance matrice(vector of vector) between each keeped elements
if (borne+p>0)
{
for (k=0; k<borne+p-1; k++)
{
for (l=k+1; l<borne+p; l++)
{
if ( (k<borne) && (l<borne) )
tmp=distance(operator[](k), operator[](l));
else if ( (k<borne) && (l>=borne) )
tmp=distance(operator[](k), _pop[copy_pop[l-borne+inf].index]);
else
tmp=distance(_pop[copy_pop[k-borne+inf].index], _pop[copy_pop[l-borne+inf].index]);
matrice[k].push_back(std::pair<int,double>(l,tmp));
matrice[l].push_back(std::pair<int,double>(k,tmp));
}
}
}
for (k=0; k<borne+p; k++)
{
//sort each line of the matrice
std::sort(matrice[k].begin(),matrice[k].end(), CmpPair());
//insert an indice at the end of each line after they were be sorted
matrice[k].push_back(std::pair<int,double>(-1,k));
}
//sort the lines of the matrice between us (by shortest distance)
std::sort(matrice.begin(),matrice.end(), CmpVector());
//vectors and iterators used to replace some archive element by some pop element
std::vector<unsigned int> notkeeped;
std::vector<unsigned int> keeped;
std::vector< std::vector< std::pair<int,double> > >::iterator matrice_it=matrice.begin();
std::vector< std::pair<int,double> >::iterator it;
//search elements of the archive to delete
for (k=0; k<p; k++)
{
tmp2=(unsigned int)matrice[0].back().second;
if (tmp2<borne)
notkeeped.push_back(tmp2);
matrice.erase(matrice_it);
for (l=0; l<matrice.size(); l++)
{
it=matrice[l].begin();
while ((unsigned int)(*it).first != tmp2)
it++;
matrice[l].erase(it);
}
if (k != (p-1))
std::sort(matrice.begin(),matrice.end(), CmpVector());
}
//search elements of pop to put in archive
for (k=0; k<borne; k++)
{
tmp2=(unsigned int)matrice[k].back().second;
if (tmp2 >= borne)
keeped.push_back(tmp2);
}
//replace some archive element by some pop element
for (k=0; k<keeped.size(); k++)
{
push_back( _pop[ copy_pop[keeped[k]-borne+inf].index ] );
operator[](notkeeped[k]) = back();
pop_back();
}
}
}
return true;
}//endoperator()
private:
/** archive max size */
unsigned int maxSize;
/** archive size */
unsigned int borne;
/**
* Wrapper which allow to used an moeoComparator in std::sort
* @param _comp the comparator to used
*/
class Wrapper
{
public:
/**
* Ctor.
* @param _comp the comparator
*/
Wrapper(moeoComparator < MOEOT > & _comp) : comp(_comp) {}
/**
* Returns true if _moeo1 is greater than _moeo2 according to the comparator
* _moeo1 the first individual
* _moeo2 the first individual
*/
bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
return comp(_moeo1,_moeo2);
}
private:
/** the comparator */
moeoComparator < MOEOT > & comp;
}
indiComparator;
/** default moeoComparator*/
moeoFitnessThenDiversityComparator < MOEOT > defaultComparator;
/** distance */
moeoDistance <MOEOT, double>& distance;
/** default distance */
moeoEuclideanDistance < MOEOT > defaultDistance;
/**
* Structure needs to copy informations of the pop in order to sort it
*/
struct refpop
{
unsigned int index;
double fitness;
double diversity;
};
/**
* Comparator of struct refpop : compare fitness+divesity
*/
struct Cmp
{
bool operator()(const struct refpop& _a, const struct refpop& _b)
{
return ( (_a.diversity + _a.fitness) > (_b.diversity + _b.fitness) );
}
};
/**
* Comparator of two vector of pair
* Compare the second pair's value of the first element vector, if equals compare the next element vector...
*/
struct CmpVector
{
bool operator()( const std::vector< std::pair<int,double> >& _a, const std::vector< std::pair<int,double> >& _b)
{
std::vector< std::pair<int,double> >::const_iterator it1= _a.begin();
std::vector< std::pair<int,double> >::const_iterator it2= _b.begin();
while ( (it1 != _a.end()) && (it2 != _b.end()))
{
if ((*it1).second < (*it2).second)
return true;
else if ((*it1).second > (*it2).second)
return false;
it1++;
it2++;
}
return true;
}
};
/**
* Comparator of two pair : compare the second pair's value
*/
struct CmpPair
{
bool operator()(const std::pair<int,double>& _a, const std::pair<int,double>& _b)
{
return _a.second < _b.second;
}
};
};
#endif /*MOEOSPEA2ARCHIVE_H_*/

View file

@ -0,0 +1,100 @@
/*
* <moeoUnboundedArchive.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
*
*/
//-----------------------------------------------------------------------------
// moeoUnboundedArchive.h
//-----------------------------------------------------------------------------
#ifndef MOEOUNBOUNDEDARCHIVE_H_
#define MOEOUNBOUNDEDARCHIVE_H_
#include <eoPop.h>
#include <archive/moeoArchive.h>
#include <comparator/moeoObjectiveVectorComparator.h>
/**
* An unbounded archive is an archive storing an unbounded number of non-dominated solutions.
*/
template < class MOEOT >
class moeoUnboundedArchive : public moeoArchive < MOEOT >
{
public:
/**
* The type of an objective vector for a solution
*/
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Default ctor.
* The moeoObjectiveVectorComparator used to compare solutions is based on Pareto dominance
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoUnboundedArchive(bool _replace=true) : moeoArchive < MOEOT >(_replace) {}
/**
* Ctor
* @param _comparator the moeoObjectiveVectorComparator used to compare solutions
* @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not
*/
moeoUnboundedArchive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _replace=true) : moeoArchive < MOEOT >(_comparator, _replace) {}
/**
* Updates the archive with a given individual _moeo
* @param _moeo the given individual
* @return true if _moeo is added to the archive
*/
bool operator()(const MOEOT & _moeo)
{
return this->update(_moeo);
}
/**
* Updates the archive with a given population _pop
* @param _pop the given population
* @return true if a _pop[i] is added to the archive
*/
bool operator()(const eoPop < MOEOT > & _pop)
{
return this->update(_pop);
}
};
#endif /*MOEOUNBOUNDEDARCHIVE_H_*/

View file

@ -0,0 +1,80 @@
/*
* <moeoAggregativeComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOAGGREGATIVECOMPARATOR_H_
#define MOEOAGGREGATIVECOMPARATOR_H_
#include <comparator/moeoComparator.h>
/**
* 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 /*MOEOAGGREGATIVECOMPARATOR_H_*/

View file

@ -0,0 +1,50 @@
/*
* <moeoComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOCOMPARATOR_H_
#define MOEOCOMPARATOR_H_
#include <eoFunctor.h>
/**
* Functor allowing to compare two solutions.
*/
template < class MOEOT >
class moeoComparator : public eoBF < const MOEOT &, const MOEOT &, const bool >
{};
#endif /*MOEOCOMPARATOR_H_*/

View file

@ -0,0 +1,70 @@
/*
* <moeoDiversityThenFitnessComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEODIVERSITYTHENFITNESSCOMPARATOR_H_
#define MOEODIVERSITYTHENFITNESSCOMPARATOR_H_
#include <comparator/moeoComparator.h>
/**
* Functor allowing to compare two solutions according to their diversity values, then according to their fitness values.
*/
template < class MOEOT >
class moeoDiversityThenFitnessComparator : public moeoComparator < MOEOT >
{
public:
/**
* Returns true if _moeo1 < _moeo2 according to their diversity values, then according to their fitness values
* @param _moeo1 the first solution
* @param _moeo2 the second solution
*/
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
if (_moeo1.diversity() == _moeo2.diversity())
{
return _moeo1.fitness() < _moeo2.fitness();
}
else
{
return _moeo1.diversity() < _moeo2.diversity();
}
}
};
#endif /*MOEODIVERSITYTHENFITNESSCOMPARATOR_H_*/

View file

@ -0,0 +1,94 @@
/*
* <moeoEpsilonObjectiveVectorComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOEPSILONOBJECTIVEVECTORCOMPARATOR_H_
#define MOEOEPSILONOBJECTIVEVECTORCOMPARATOR_H_
#include <comparator/moeoObjectiveVectorComparator.h>
/**
* This functor class allows to compare 2 objective vectors according to epsilon dominance.
*/
template < class ObjectiveVector >
class moeoEpsilonObjectiveVectorComparator : public moeoObjectiveVectorComparator < ObjectiveVector >
{
public:
/**
* Ctor.
* @param _epsilon the epsilon value
*/
moeoEpsilonObjectiveVectorComparator(double _epsilon) : epsilon(_epsilon)
{}
/**
* Returns true if _objectiveVector1 is epsilon-dominated by _objectiveVector2
* @param _objectiveVector1 the first objective vector
* @param _objectiveVector2 the second objective vector
*/
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{
// _objectiveVector1[i] == _objectiveVector2[i] ?
if ( fabs((_objectiveVector1[i]/ epsilon) - _objectiveVector2[i]) > ObjectiveVector::Traits::tolerance() )
{
if (ObjectiveVector::minimizing(i))
{
if ((_objectiveVector1[i] / epsilon) <= _objectiveVector2[i])
{
return false; // _objectiveVector1[i] is not better than _objectiveVector2[i]
}
}
else if (ObjectiveVector::maximizing(i))
{
if ((_objectiveVector1[i] / epsilon) >= _objectiveVector2[i])
{
return false; // _objectiveVector1[i] is not better than _objectiveVector2[i]
}
}
}
}
return true;
}
private:
/** the reference point */
double epsilon;
};
#endif /*MOEOEPSILONOBJECTIVEVECTORCOMPARATOR_H_*/

View file

@ -0,0 +1,64 @@
/*
* <moeoFitnessComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
* François Legillon
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOFITNESSCOMPARATOR_H_
#define MOEOFITNESSCOMPARATOR_H_
#include <comparator/moeoComparator.h>
/**
* Functor allowing to compare two solutions according to their fitness values
*/
template < class MOEOT >
class moeoFitnessComparator : public moeoComparator < MOEOT >
{
public:
/**
* Returns true if _moeo1 < _moeo2 according to their fitness values
* @param _moeo1 the first solution
* @param _moeo2 the second solution
*/
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
return _moeo1.fitness() < _moeo2.fitness();
}
};
#endif /*MOEOFITNESSCOMPARATOR_H_*/

View file

@ -0,0 +1,70 @@
/*
* <moeoFitnessThenDiversityComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOFITNESSTHENDIVERSITYCOMPARATOR_H_
#define MOEOFITNESSTHENDIVERSITYCOMPARATOR_H_
#include <comparator/moeoComparator.h>
/**
* Functor allowing to compare two solutions according to their fitness values, then according to their diversity values.
*/
template < class MOEOT >
class moeoFitnessThenDiversityComparator : public moeoComparator < MOEOT >
{
public:
/**
* Returns true if _moeo1 < _moeo2 according to their fitness values, then according to their diversity values
* @param _moeo1 the first solution
* @param _moeo2 the second solution
*/
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
if (_moeo1.fitness() == _moeo2.fitness())
{
return _moeo1.diversity() < _moeo2.diversity();
}
else
{
return _moeo1.fitness() < _moeo2.fitness();
}
}
};
#endif /*MOEOFITNESSTHENDIVERSITYCOMPARATOR_H_*/

View file

@ -0,0 +1,127 @@
/*
* <moeoGDominanceObjectiveVectorComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOGDOMINANCEOBJECTIVEVECTORCOMPARATOR_H_
#define MOEOGDOMINANCEOBJECTIVEVECTORCOMPARATOR_H_
#include <comparator/moeoObjectiveVectorComparator.h>
/**
* This functor class allows to compare 2 objective vectors according to g-dominance.
* The concept of g-dominance as been introduced in:
* J. Molina, L. V. Santana, A. G. Hernandez-Diaz, C. A. Coello Coello, R. Caballero,
* "g-dominance: Reference point based dominance" (2007)
*/
template < class ObjectiveVector >
class moeoGDominanceObjectiveVectorComparator : public moeoObjectiveVectorComparator < ObjectiveVector >
{
public:
/**
* Ctor.
* @param _ref the reference point
*/
moeoGDominanceObjectiveVectorComparator(ObjectiveVector & _ref) : ref(_ref)
{}
/**
* Returns true if _objectiveVector1 is g-dominated by _objectiveVector2.
* @param _objectiveVector1 the first objective vector
* @param _objectiveVector2 the second objective vector
*/
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{
unsigned int flag1 = flag(_objectiveVector1);
unsigned int flag2 = flag(_objectiveVector2);
if (flag2==0)
{
// cannot dominate
return false;
}
else if ( (flag2==1) && (flag1==0) )
{
// is dominated
return true;
}
else // (flag1==1) && (flag2==1)
{
// both are on the good region, so let's use the classical Pareto dominance
return paretoComparator(_objectiveVector1, _objectiveVector2);
}
}
private:
/** the reference point */
ObjectiveVector & ref;
/** Pareto comparator */
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
/**
* Returns the flag of _objectiveVector according to the reference point
* @param _objectiveVector the first objective vector
*/
unsigned int flag(const ObjectiveVector & _objectiveVector)
{
unsigned int result=1;
for (unsigned int i=0; i<ref.nObjectives(); i++)
{
if (_objectiveVector[i] > ref[i])
{
result=0;
}
}
if (result==0)
{
result=1;
for (unsigned int i=0; i<ref.nObjectives(); i++)
{
if (_objectiveVector[i] < ref[i])
{
result=0;
}
}
}
return result;
}
};
#endif /*MOEOGDOMINANCEOBJECTIVEVECTORCOMPARATOR_H_*/

View file

@ -0,0 +1,77 @@
/*
* <moeoObjectiveObjectiveVectorComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOOBJECTIVEOBJECTIVEVECTORCOMPARATOR_H_
#define MOEOOBJECTIVEOBJECTIVEVECTORCOMPARATOR_H_
#include <comparator/moeoObjectiveVectorComparator.h>
/**
* Functor allowing to compare two objective vectors according to their first objective value, then their second, and so on.
*/
template < class ObjectiveVector >
class moeoObjectiveObjectiveVectorComparator : public moeoObjectiveVectorComparator < ObjectiveVector >
{
public:
/**
* Returns true if _objectiveVector1 < _objectiveVector2 on the first objective, then on the second, and so on
* @param _objectiveVector1 the first objective vector
* @param _objectiveVector2 the second objective vector
*/
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{
if ( fabs(_objectiveVector1[i] - _objectiveVector2[i]) > ObjectiveVector::Traits::tolerance() )
{
if (_objectiveVector1[i] < _objectiveVector2[i])
{
return true;
}
else
{
return false;
}
}
}
return false;
}
};
#endif /*MOEOOBJECTIVEOBJECTIVEVECTORCOMPARATOR_H_*/

View file

@ -0,0 +1,52 @@
/*
* <moeoObjectiveVectorComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOOBJECTIVEVECTORCOMPARATOR_H_
#define MOEOOBJECTIVEVECTORCOMPARATOR_H_
#include <math.h>
#include <eoFunctor.h>
/**
* Abstract class allowing to compare 2 objective vectors.
* The template argument ObjectiveVector have to be a moeoObjectiveVector.
*/
template < class ObjectiveVector >
class moeoObjectiveVectorComparator : public eoBF < const ObjectiveVector &, const ObjectiveVector &, const bool >
{};
#endif /*MOEOOBJECTIVEVECTORCOMPARATOR_H_*/

View file

@ -0,0 +1,82 @@
/*
* <moeoOneObjectiveComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOONEOBJECTIVECOMPARATOR_H_
#define MOEOONEOBJECTIVECOMPARATOR_H_
#include <comparator/moeoComparator.h>
/**
* Functor allowing to compare two solutions according to one objective.
*/
template < class MOEOT >
class moeoOneObjectiveComparator : public moeoComparator < MOEOT >
{
public:
/**
* Ctor.
* @param _obj the index of objective
*/
moeoOneObjectiveComparator(unsigned int _obj) : obj(_obj)
{
if (obj > MOEOT::ObjectiveVector::nObjectives())
{
throw std::runtime_error("Problem with the index of objective in moeoOneObjectiveComparator");
}
}
/**
* Returns true if _moeo1 < _moeo2 on the obj objective
* @param _moeo1 the first solution
* @param _moeo2 the second solution
*/
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
return _moeo1.objectiveVector()[obj] < _moeo2.objectiveVector()[obj];
}
private:
/** the index of objective */
unsigned int obj;
};
#endif /*MOEOONEOBJECTIVECOMPARATOR_H_*/

View file

@ -0,0 +1,95 @@
/*
* <moeoParetoObjectiveVectorComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOPARETOOBJECTIVEVECTORCOMPARATOR_H_
#define MOEOPARETOOBJECTIVEVECTORCOMPARATOR_H_
#include <comparator/moeoObjectiveVectorComparator.h>
/**
* This functor class allows to compare 2 objective vectors according to Pareto dominance.
*/
template < class ObjectiveVector >
class moeoParetoObjectiveVectorComparator : public moeoObjectiveVectorComparator < ObjectiveVector >
{
public:
/**
* Returns true if _objectiveVector1 is dominated by _objectiveVector2
* @param _objectiveVector1 the first objective vector
* @param _objectiveVector2 the second objective vector
*/
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{
bool dom = false;
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{
// first, we have to check if the 2 objective values are not equal for the ith objective
if ( fabs(_objectiveVector1[i] - _objectiveVector2[i]) > ObjectiveVector::Traits::tolerance() )
{
// if the ith objective have to be minimized...
if (ObjectiveVector::minimizing(i))
{
if (_objectiveVector1[i] > _objectiveVector2[i])
{
dom = true; //_objectiveVector1[i] is not better than _objectiveVector2[i]
}
else
{
return false; //_objectiveVector2 cannot dominate _objectiveVector1
}
}
// if the ith objective have to be maximized...
else if (ObjectiveVector::maximizing(i))
{
if (_objectiveVector1[i] < _objectiveVector2[i])
{
dom = true; //_objectiveVector1[i] is not better than _objectiveVector2[i]
}
else
{
return false; //_objectiveVector2 cannot dominate _objectiveVector1
}
}
}
}
return dom;
}
};
#endif /*MOEOPARETOOBJECTIVEVECTORCOMPARATOR_H_*/

View file

@ -0,0 +1,59 @@
/***************************************************************************
* Copyright (C) 2008 by Waldo Cancino *
* wcancino@icmc.usp.br *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef MOEOPTRCOMPARATOR_H_
#define MOEOPTRCOMPARATOR_H_
#include <comparator/moeoComparator.h>
/**
* Functor allowing to compare two solutions.referenced by pointers.
* Several MOEO related stuff have to sort populations according some criterion
* Instead to do this, we used a vector whose elements are pointers to true individuals
*/
template < class MOEOT >
class moeoPtrComparator : public eoBF < const MOEOT *, const MOEOT *, const bool >
{
public:
/**
* Ctor with a comparator
* @param _cmp comparator to be employed
*/
moeoPtrComparator( moeoComparator<MOEOT> & _cmp) : cmp(_cmp) {}
/** compare two const individuals */
const bool operator() (const MOEOT *ptr1, const MOEOT *ptr2)
{
return cmp(*ptr1, *ptr2);
}
/** compare two non const individuals */
const bool operator() (MOEOT *ptr1, MOEOT *ptr2)
{
return cmp(*ptr1, *ptr2);
}
private:
moeoComparator<MOEOT> &cmp;
};
#endif /*MOEOPTRCOMPARATOR_H_*/

View file

@ -0,0 +1,85 @@
/*
* <moeoStrictObjectiveVectorComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOSTRICTOBJECTIVEVECTORCOMPARATOR_H_
#define MOEOSTRICTOBJECTIVEVECTORCOMPARATOR_H_
#include <comparator/moeoObjectiveVectorComparator.h>
/**
* This functor class allows to compare 2 objective vectors according to strict dominance.
*/
template < class ObjectiveVector >
class moeoStrictObjectiveVectorComparator : public moeoObjectiveVectorComparator < ObjectiveVector >
{
public:
/**
* Returns true if _objectiveVector1 is strictly dominated by _objectiveVector2
* @param _objectiveVector1 the first objective vector
* @param _objectiveVector2 the second objective vector
*/
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{
// _objectiveVector1[i] == _objectiveVector2[i] ?
if ( fabs(_objectiveVector1[i] - _objectiveVector2[i]) < ObjectiveVector::Traits::tolerance() )
{
return false; // _objectiveVector1[i] is not STRICTLY better than _objectiveVector2[i]
}
else if (ObjectiveVector::minimizing(i))
{
if (_objectiveVector1[i] < _objectiveVector2[i])
{
return false; // _objectiveVector1[i] is not better than _objectiveVector2[i]
}
}
else if (ObjectiveVector::maximizing(i))
{
if (_objectiveVector1[i] > _objectiveVector2[i])
{
return false; // _objectiveVector1[i] is not better than _objectiveVector2[i]
}
}
}
return true;
}
};
#endif /*MOEOSTRICTOBJECTIVEVECTORCOMPARATOR_H_*/

View file

@ -0,0 +1,84 @@
/*
* <moeoWeakObjectiveVectorComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOWEAKOBJECTIVEVECTORCOMPARATOR_H_
#define MOEOWEAKOBJECTIVEVECTORCOMPARATOR_H_
#include <comparator/moeoObjectiveVectorComparator.h>
/**
* This functor class allows to compare 2 objective vectors according to weak dominance.
*/
template < class ObjectiveVector >
class moeoWeakObjectiveVectorComparator : public moeoObjectiveVectorComparator < ObjectiveVector >
{
public:
/**
* Returns true if _objectiveVector1 is weakly dominated by _objectiveVector2
* @param _objectiveVector1 the first objective vector
* @param _objectiveVector2 the second objective vector
*/
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{
// _objectiveVector1[i] == _objectiveVector2[i] ?
if ( fabs(_objectiveVector1[i] - _objectiveVector2[i]) > ObjectiveVector::Traits::tolerance() )
{
if (ObjectiveVector::minimizing(i))
{
if (_objectiveVector1[i] < _objectiveVector2[i])
{
return false; // _objectiveVector1[i] is not better than _objectiveVector2[i]
}
}
else if (ObjectiveVector::maximizing(i))
{
if (_objectiveVector1[i] > _objectiveVector2[i])
{
return false; // _objectiveVector1[i] is not better than _objectiveVector2[i]
}
}
}
}
return true;
}
};
#endif /*MOEOWEAKOBJECTIVEVECTORCOMPARATOR_H_*/

View file

@ -0,0 +1,396 @@
/*
* <MOEO.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEO_H_
#define MOEO_H_
#include <iostream>
#include <stdexcept>
#include <string>
#include <EO.h>
/**
* Base class allowing to represent a solution (an individual) for multi-objective optimization.
* The template argument MOEOObjectiveVector allows to represent the solution in the objective space (it can be a moeoObjectiveVector object).
* The template argument MOEOFitness is an object reflecting the quality of the solution in term of convergence (the fitness of a solution is always to be maximized).
* The template argument MOEODiversity is an object reflecting the quality of the solution in term of diversity (the diversity of a solution is always to be maximized).
* All template arguments must have a void and a copy constructor.
* Using some specific representations, you will have to define a copy constructor if the default one is not what you want.
* In the same cases, you will also have to define the affectation operator (operator=).
* Then, you will explicitly have to call the parent copy constructor and the parent affectation operator at the beginning of the corresponding implementation.
* Besides, note that, contrary to the mono-objective case (and to EO) where the fitness value of a solution is confused with its objective value,
* the fitness value differs of the objectives values in the multi-objective case.
*/
/*
template < typename DataType, typename DataTypeEx > struct Wrapper {
Wrapper() {}
Wrapper( const DataType& data )
: embededData( data ) {}
Wrapper( const Wrapper& wrapper )
: embededData( wrapper.embededData ), embededDataEx( wrapper.embededDataEx ) {}
operator const DataType& () const { return embededData; }
Wrapper& operator= ( const Wrapper& wrapper ) {
embededData = wrapper.embededData;
embededDataEx = wrapper.embededDataEx;
return *this;
}
Wrapper& operator= ( const DataType& data ) {
embededData = data;
return *this;
}
DataType embededData;
DataTypeEx embededDataEx;
};
**/
template < class MOEOObjectiveVector, class MOEOFitness=double, class MOEODiversity=double >
class MOEO : public EO < MOEOObjectiveVector >
{
public:
/** the objective vector type of a solution */
typedef MOEOObjectiveVector ObjectiveVector;
/** the fitness type of a solution */
typedef MOEOFitness Fitness;
// typedef Wrapper< MOEOFitness, MOEOObjectiveVector > Fitness;
/** the diversity type of a solution */
typedef MOEODiversity Diversity;
/**
* Ctor
*/
MOEO()
{
// default values for every parameters
objectiveVectorValue = ObjectiveVector();
fitnessValue = Fitness();
diversityValue = Diversity();
// invalidate all
invalidate();
flagValue=0;
}
/**
* Virtual dtor
*/
virtual ~MOEO()
{};
/**
* Returns the objective vector of the current solution
*/
ObjectiveVector objectiveVector() const
{
if ( invalidObjectiveVector() )
{
throw std::runtime_error("invalid objective vector in MOEO");
}
return objectiveVectorValue;
}
/**
* Sets one dimension of the objective vector
* @param _dim dimension of the objective vector to set
* @param _value the new value of the corresponding objective
*/
void objectiveVector(unsigned int _dim, typename ObjectiveVector::Type _value)
{
objectiveVectorValue[_dim] = _value;
invalidObjectiveVectorValue = false;
}
/**
* Gets one dimension of the objective vector
* @param _dim dimension of the objective vector to set
*/
typename ObjectiveVector::Type objectiveVector(unsigned int _dim)
{
return objectiveVectorValue[_dim];
}
/**
* Sets the objective vector of the current solution
* @param _objectiveVectorValue the new objective vector
*/
void objectiveVector(const ObjectiveVector & _objectiveVectorValue)
{
objectiveVectorValue = _objectiveVectorValue;
invalidObjectiveVectorValue = false;
}
/**
* Sets the objective vector as invalid
*/
void invalidateObjectiveVector()
{
invalidObjectiveVectorValue = true;
}
/**
* Returns true if the objective vector is invalid, false otherwise
*/
bool invalidObjectiveVector() const
{
return invalidObjectiveVectorValue;
}
/**
* Returns the fitness value of the current solution
*/
Fitness fitness() const
{
if ( invalidFitness() )
{
throw std::runtime_error("invalid fitness in MOEO");
}
// const_cast< Fitness& >( fitnessValue ).embededDataEx = objectiveVectorValue;
return fitnessValue;
}
/**
* Sets the fitness value of the current solution
* @param _fitnessValue the new fitness value
*/
void fitness(const Fitness & _fitnessValue)
{
fitnessValue = _fitnessValue;
invalidFitnessValue = false;
}
/**
* Sets the fitness value as invalid
*/
void invalidateFitness()
{
invalidFitnessValue = true;
}
/**
* Returns true if the fitness value is invalid, false otherwise
*/
bool invalidFitness() const
{
return invalidFitnessValue;
}
/**
* Returns the diversity value of the current solution
*/
Diversity diversity() const
{
if ( invalidDiversity() )
{
throw std::runtime_error("invalid diversity in MOEO");
}
return diversityValue;
}
/**
* Sets the diversity value of the current solution
* @param _diversityValue the new diversity value
*/
void diversity(const Diversity & _diversityValue)
{
diversityValue = _diversityValue;
invalidDiversityValue = false;
}
/**
* Sets the diversity value as invalid
*/
void invalidateDiversity()
{
invalidDiversityValue = true;
}
/**
* Returns true if the diversity value is invalid, false otherwise
*/
bool invalidDiversity() const
{
return invalidDiversityValue;
}
/**
* Sets the objective vector, the fitness value and the diversity value as invalid
*/
void invalidate()
{
invalidateObjectiveVector();
invalidateFitness();
invalidateDiversity();
}
/**
* Returns true if the objective values are invalid, false otherwise
*/
bool invalid() const
{
return invalidObjectiveVector();
}
/**
* Returns true if the objective vector of the current solution is smaller than the objective vector of _other on the first objective,
* then on the second, and so on (can be usefull for sorting/printing).
* You should implement another function in the sub-class of MOEO to have another sorting mecanism.
* @param _other the other MOEO object to compare with
*/
bool operator<(const MOEO & _other) const
{
return objectiveVector() < _other.objectiveVector();
}
/**
* Return the class id (the class name as a std::string)
*/
virtual std::string className() const
{
return "MOEO";
}
/**
* Writing object
* @param _os output stream
*/
virtual void printOn(std::ostream & _os) const
{
if ( invalidObjectiveVector() )
{
_os << "INVALID ";
}
else
{
_os << objectiveVectorValue << ' ';
}
}
/**
* Reading object
* @param _is input stream
*/
virtual void readFrom(std::istream & _is)
{
std::string objectiveVector_str;
int pos = _is.tellg();
_is >> objectiveVector_str;
if (objectiveVector_str == "INVALID")
{
invalidateObjectiveVector();
}
else
{
invalidObjectiveVectorValue = false;
_is.seekg(pos); // rewind
_is >> objectiveVectorValue;
}
}
/**
* Setter for "flag"
* @param _flag the flag value
*/
void flag(int _flag){
flagValue=_flag;
}
/**
* Getter for "flag"
* @return the flag value
*/
int flag() const{
return flagValue;
}
private:
/** the objective vector of this solution */
ObjectiveVector objectiveVectorValue;
/** true if the objective vector is invalid */
bool invalidObjectiveVectorValue;
/** the fitness value of this solution */
Fitness fitnessValue;
/** true if the fitness value is invalid */
bool invalidFitnessValue;
/** the diversity value of this solution */
Diversity diversityValue;
/** true if the diversity value is invalid */
bool invalidDiversityValue;
/** A flag which can be used to stock information*/
int flagValue;
};
#endif /*MOEO_H_*/

View file

@ -0,0 +1,108 @@
/*
* <moeoBitVector.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOBITVECTOR_H_
#define MOEOBITVECTOR_H_
#include <core/moeoVector.h>
/**
* This class is an implementationeo of a simple bit-valued moeoVector.
*/
template < class MOEOObjectiveVector, class MOEOFitness=double, class MOEODiversity=double >
class moeoBitVector : public moeoVector < MOEOObjectiveVector, bool, MOEOFitness, MOEODiversity >
{
public:
using moeoVector < MOEOObjectiveVector, bool, MOEOFitness, MOEODiversity > :: begin;
using moeoVector < MOEOObjectiveVector, bool, MOEOFitness, MOEODiversity > :: end;
using moeoVector < MOEOObjectiveVector, bool, MOEOFitness, MOEODiversity > :: resize;
using moeoVector < MOEOObjectiveVector, bool, MOEOFitness, MOEODiversity > :: size;
/**
* Ctor
* @param _size Length of vector (default is 0)
* @param _value Initial value of all elements (default is default value of type GeneType)
*/
moeoBitVector(unsigned int _size = 0, bool _value = false) : moeoVector< MOEOObjectiveVector, bool, MOEOFitness, MOEODiversity >(_size, _value)
{}
/**
* Returns the class name as a std::string
*/
virtual std::string className() const
{
return "moeoBitVector";
}
/**
* Writing object
* @param _os output stream
*/
virtual void printOn(std::ostream & _os) const
{
MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity >::printOn(_os);
_os << ' ';
_os << size() << ' ';
std::copy(begin(), end(), std::ostream_iterator<bool>(_os));
}
/**
* Reading object
* @param _is input stream
*/
virtual void readFrom(std::istream & _is)
{
MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity >::readFrom(_is);
unsigned int s;
_is >> s;
std::string bits;
_is >> bits;
if (_is)
{
resize(bits.size());
std::transform(bits.begin(), bits.end(), begin(), std::bind2nd(std::equal_to<char>(), '1'));
}
}
};
#endif /*MOEOBITVECTOR_H_*/

View file

@ -0,0 +1,50 @@
/*
* <moeoEvalFunc.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOEVALFUNC_H_
#define MOEOEVALFUNC_H_
#include <eoEvalFunc.h>
/*
* Functor that evaluates one MOEO by setting all its objective values.
*/
template < class MOEOT >
class moeoEvalFunc : public eoEvalFunc< MOEOT >
{};
#endif /*MOEOEVALFUNC_H_*/

View file

@ -0,0 +1,71 @@
/*
* <moeoIntVector.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOINTVECTOR_H_
#define MOEOINTVECTOR_H_
#include <core/moeoVector.h>
/**
* This class is an implementation of a simple double-valued moeoVector.
*/
template < class MOEOObjectiveVector, class MOEOFitness=double, class MOEODiversity=double >
class moeoIntVector : public moeoVector < MOEOObjectiveVector, int, MOEOFitness, MOEODiversity >
{
public:
/**
* Ctor
* @param _size Length of vector (default is 0)
* @param _value Initial value of all elements (default is default value of type GeneType)
*/
moeoIntVector(unsigned int _size = 0, int _value = 0) : moeoVector< MOEOObjectiveVector, int, MOEOFitness, MOEODiversity >(_size, _value)
{}
/**
* Returns the class name as a std::string
*/
virtual std::string className() const
{
return "moeoIntVector";
}
};
#endif /*MOEOINTVECTOR_H_*/

View file

@ -0,0 +1,116 @@
/*
* <moeoObjectiveVector.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOOBJECTIVEVECTOR_H_
#define MOEOOBJECTIVEVECTOR_H_
#include <vector>
/**
* Abstract class allowing to represent a solution in the objective space (phenotypic representation).
* The template argument ObjectiveVectorTraits defaults to moeoObjectiveVectorTraits,
* but it can be replaced at will by any other class that implements the static functions defined therein.
* Some static funtions to access to the traits characteristics are re-defined in order not to write a lot of typedef's.
*/
template < class ObjectiveVectorTraits, class ObjectiveVectorType >
class moeoObjectiveVector : public std::vector < ObjectiveVectorType >
{
public:
/** The traits of objective vectors */
typedef ObjectiveVectorTraits Traits;
/** The type of an objective value */
typedef ObjectiveVectorType Type;
/**
* Ctor
*/
moeoObjectiveVector(Type _value = Type()) : std::vector < Type > (ObjectiveVectorTraits::nObjectives(), _value)
{}
/**
* Ctor from a vector of Type
* @param _v the std::vector < Type >
*/
moeoObjectiveVector(std::vector < Type > & _v) : std::vector < Type > (_v)
{}
/**
* Parameters setting (for the objective vector of any solution)
* @param _nObjectives the number of objectives
* @param _bObjectives the min/max vector (true = min / false = max)
*/
static void setup(unsigned int _nObjectives, std::vector < bool > & _bObjectives)
{
ObjectiveVectorTraits::setup(_nObjectives, _bObjectives);
}
/**
* Returns the number of objectives
*/
static unsigned int nObjectives()
{
return ObjectiveVectorTraits::nObjectives();
}
/**
* Returns true if the _ith objective have to be minimized
* @param _i the index
*/
static bool minimizing(unsigned int _i)
{
return ObjectiveVectorTraits::minimizing(_i);
}
/**
* Returns true if the _ith objective have to be maximized
* @param _i the index
*/
static bool maximizing(unsigned int _i)
{
return ObjectiveVectorTraits::maximizing(_i);
}
};
#endif /*MOEOOBJECTIVEVECTOR_H_*/

View file

@ -0,0 +1,42 @@
/*
* <moeoObjectiveVectorTraits.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#include <core/moeoObjectiveVectorTraits.h>
// The static variables of the moeoObjectiveVectorTraits class need to be allocated
unsigned int moeoObjectiveVectorTraits::nObj;
std::vector < bool > moeoObjectiveVectorTraits::bObj;

View file

@ -0,0 +1,130 @@
/*
* <moeoObjectiveVectorTraits.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOOBJECTIVEVECTORTRAITS_H_
#define MOEOOBJECTIVEVECTORTRAITS_H_
#include <iostream>
#include <stdexcept>
#include <vector>
/**
* A traits class for moeoObjectiveVector to specify the number of objectives and which ones have to be minimized or maximized.
*/
class moeoObjectiveVectorTraits
{
public:
/**
* Parameters setting
* @param _nObjectives the number of objectives
* @param _bObjectives the min/max vector (true = min / false = max)
*/
static void setup(unsigned int _nObjectives, std::vector < bool > & _bObjectives)
{
// in case the number of objectives was already set to a different value
if ( nObj && (nObj != _nObjectives) )
{
std::cout << "WARNING\n";
std::cout << "WARNING : the number of objectives are changing\n";
std::cout << "WARNING : Make sure all existing objects are destroyed\n";
std::cout << "WARNING\n";
}
// number of objectives
nObj = _nObjectives;
// min/max vector
bObj = _bObjectives;
// in case the number of objectives and the min/max vector size don't match
if (nObj != bObj.size())
throw std::runtime_error("Number of objectives and min/max size don't match in moeoObjectiveVectorTraits::setup");
}
/**
* Returns the number of objectives
*/
static unsigned int nObjectives()
{
// in case the number of objectives would not be assigned yet
if (! nObj)
throw std::runtime_error("Number of objectives not assigned in moeoObjectiveVectorTraits");
return nObj;
}
/**
* Returns true if the _ith objective have to be minimized
* @param _i the index
*/
static bool minimizing(unsigned int _i)
{
// in case there would be a wrong index
if (_i >= bObj.size())
throw std::runtime_error("Wrong index in moeoObjectiveVectorTraits");
return bObj[_i];
}
/**
* Returns true if the _ith objective have to be maximized
* @param _i the index
*/
static bool maximizing(unsigned int _i)
{
return (! minimizing(_i));
}
/**
* Returns the tolerance value (to compare solutions)
*/
static double tolerance()
{
return 1e-10;
}
private:
/** The number of objectives */
static unsigned int nObj;
/** The min/max vector */
static std::vector < bool > bObj;
};
#endif /*MOEOOBJECTIVEVECTORTRAITS_H_*/

View file

@ -0,0 +1,190 @@
/*
* <moeoRealObjectiveVector.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOREALOBJECTIVEVECTOR_H_
#define MOEOREALOBJECTIVEVECTOR_H_
#include <iostream>
#include <math.h>
#include <comparator/moeoObjectiveObjectiveVectorComparator.h>
#include <comparator/moeoParetoObjectiveVectorComparator.h>
#include <core/moeoObjectiveVector.h>
/**
* This class allows to represent a solution in the objective space (phenotypic representation) by a std::vector of real values,
* i.e. that an objective value is represented using a double, and this for any objective.
*/
template < class ObjectiveVectorTraits >
class moeoRealObjectiveVector : public moeoObjectiveVector < ObjectiveVectorTraits, double >
{
public:
using moeoObjectiveVector < ObjectiveVectorTraits, double >::size;
using moeoObjectiveVector < ObjectiveVectorTraits, double >::operator[];
/**
* Ctor
*/
moeoRealObjectiveVector(double _value = 0.0) : moeoObjectiveVector < ObjectiveVectorTraits, double > (_value)
{}
/**
* Ctor from a vector of doubles
* @param _v the std::vector < double >
*/
moeoRealObjectiveVector(std::vector < double > & _v) : moeoObjectiveVector < ObjectiveVectorTraits, double > (_v)
{}
/**
* Returns true if the current objective vector dominates _other according to the Pareto dominance relation
* (but it's better to use a moeoObjectiveVectorComparator object to compare solutions)
* @param _other the other moeoRealObjectiveVector object to compare with
*/
bool dominates(const moeoRealObjectiveVector < ObjectiveVectorTraits > & _other) const
{
moeoParetoObjectiveVectorComparator < moeoRealObjectiveVector<ObjectiveVectorTraits> > comparator;
return comparator(_other, *this);
}
/**
* Returns true if the current objective vector is equal to _other (according to a tolerance value)
* @param _other the other moeoRealObjectiveVector object to compare with
*/
bool operator==(const moeoRealObjectiveVector < ObjectiveVectorTraits > & _other) const
{
for (unsigned int i=0; i < size(); i++)
{
if ( fabs(operator[](i) - _other[i]) > ObjectiveVectorTraits::tolerance() )
{
return false;
}
}
return true;
}
/**
* Returns true if the current objective vector is different than _other (according to a tolerance value)
* @param _other the other moeoRealObjectiveVector object to compare with
*/
bool operator!=(const moeoRealObjectiveVector < ObjectiveVectorTraits > & _other) const
{
return ! operator==(_other);
}
/**
* Returns true if the current objective vector is smaller than _other on the first objective, then on the second, and so on
* (can be usefull for sorting/printing)
* @param _other the other moeoRealObjectiveVector object to compare with
*/
bool operator<(const moeoRealObjectiveVector < ObjectiveVectorTraits > & _other) const
{
moeoObjectiveObjectiveVectorComparator < moeoRealObjectiveVector < ObjectiveVectorTraits > > cmp;
return cmp(*this, _other);
}
/**
* Returns true if the current objective vector is greater than _other on the first objective, then on the second, and so on
* (can be usefull for sorting/printing)
* @param _other the other moeoRealObjectiveVector object to compare with
*/
bool operator>(const moeoRealObjectiveVector < ObjectiveVectorTraits > & _other) const
{
return _other < *this;
}
/**
* Returns true if the current objective vector is smaller than or equal to _other on the first objective, then on the second, and so on
* (can be usefull for sorting/printing)
* @param _other the other moeoRealObjectiveVector object to compare with
*/
bool operator<=(const moeoRealObjectiveVector < ObjectiveVectorTraits > & _other) const
{
return operator==(_other) || operator<(_other);
}
/**
* Returns true if the current objective vector is greater than or equal to _other on the first objective, then on the second, and so on
* (can be usefull for sorting/printing)
* @param _other the other moeoRealObjectiveVector object to compare with
*/
bool operator>=(const moeoRealObjectiveVector < ObjectiveVectorTraits > & _other) const
{
return operator==(_other) || operator>(_other);
}
};
/**
* Output for a moeoRealObjectiveVector object
* @param _os output stream
* @param _objectiveVector the objective vector to write
*/
template < class ObjectiveVectorTraits >
std::ostream & operator<<(std::ostream & _os, const moeoRealObjectiveVector < ObjectiveVectorTraits > & _objectiveVector)
{
for (unsigned int i=0; i<_objectiveVector.size()-1; i++)
_os << _objectiveVector[i] << " ";
_os << _objectiveVector[_objectiveVector.size()-1];
return _os;
}
/**
* Input for a moeoRealObjectiveVector object
* @param _is input stream
* @param _objectiveVector the objective vector to read
*/
template < class ObjectiveVectorTraits >
std::istream & operator>>(std::istream & _is, moeoRealObjectiveVector < ObjectiveVectorTraits > & _objectiveVector)
{
_objectiveVector = moeoRealObjectiveVector < ObjectiveVectorTraits > ();
for (unsigned int i=0; i<_objectiveVector.size(); i++)
{
_is >> _objectiveVector[i];
}
return _is;
}
#endif /*MOEOREALOBJECTIVEVECTOR_H_*/

View file

@ -0,0 +1,70 @@
/*
* <moeoRealVector.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOREALVECTOR_H_
#define MOEOREALVECTOR_H_
#include <core/moeoVector.h>
/**
* This class is an implementation of a simple double-valued moeoVector.
*/
template < class MOEOObjectiveVector, class MOEOFitness=double, class MOEODiversity=double >
class moeoRealVector : public moeoVector < MOEOObjectiveVector, double, MOEOFitness, MOEODiversity >
{
public:
/**
* Ctor
* @param _size Length of vector (default is 0)
* @param _value Initial value of all elements (default is default value of type GeneType)
*/
moeoRealVector(unsigned int _size = 0, double _value = 0.0) : moeoVector< MOEOObjectiveVector, double, MOEOFitness, MOEODiversity >(_size, _value)
{}
/**
* Returns the class name as a std::string
*/
virtual std::string className() const
{
return "moeoRealVector";
}
};
#endif /*MOEOREALVECTOR_H_*/

View file

@ -0,0 +1,168 @@
/*
* <moeoVector.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOVECTOR_H_
#define MOEOVECTOR_H_
#include <iterator>
#include <vector>
#include <core/MOEO.h>
/**
* Base class for fixed length chromosomes, just derives from MOEO and std::vector and redirects the smaller than operator to MOEO (objective vector based comparison).
* GeneType must have the following methods: void ctor (needed for the std::vector<>), copy ctor.
*/
template < class MOEOObjectiveVector, class GeneType, class MOEOFitness=double, class MOEODiversity=double >
class moeoVector : public MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity >, public std::vector < GeneType >
{
public:
using MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity > :: invalidate;
using std::vector < GeneType > :: operator[];
using std::vector < GeneType > :: begin;
using std::vector < GeneType > :: end;
using std::vector < GeneType > :: resize;
using std::vector < GeneType > :: size;
/** the atomic type */
typedef GeneType AtomType;
/** the container type */
typedef std::vector < GeneType > ContainerType;
/**
* Default ctor.
* @param _size Length of vector (default is 0)
* @param _value Initial value of all elements (default is default value of type GeneType)
*/
moeoVector(unsigned int _size = 0, GeneType _value = GeneType()) :
MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity >(), std::vector<GeneType>(_size, _value)
{}
/**
* We can't have a Ctor from a std::vector as it would create ambiguity with the copy Ctor.
* @param _v a vector of GeneType
*/
void value(const std::vector < GeneType > & _v)
{
if (_v.size() != size()) // safety check
{
if (size()) // NOT an initial empty std::vector
{
std::cout << "Warning: Changing size in moeoVector assignation"<<std::endl;
resize(_v.size());
}
else
{
throw std::runtime_error("Size not initialized in moeoVector");
}
}
std::copy(_v.begin(), _v.end(), begin());
invalidate();
}
/**
* To avoid conflicts between MOEO::operator< and std::vector<GeneType>::operator<
* @param _moeo the object to compare with
*/
bool operator<(const moeoVector< MOEOObjectiveVector, GeneType, MOEOFitness, MOEODiversity> & _moeo) const
{
return MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity >::operator<(_moeo);
}
/**
* Writing object
* @param _os output stream
*/
virtual void printOn(std::ostream & _os) const
{
MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity >::printOn(_os);
_os << ' ';
_os << size() << ' ';
std::copy(begin(), end(), std::ostream_iterator<AtomType>(_os, " "));
}
/**
* Reading object
* @param _is input stream
*/
virtual void readFrom(std::istream & _is)
{
MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity >::readFrom(_is);
unsigned int sz;
_is >> sz;
resize(sz);
unsigned int i;
for (i = 0; i < sz; ++i)
{
AtomType atom;
_is >> atom;
operator[](i) = atom;
}
}
};
/**
* To avoid conflicts between MOEO::operator< and std::vector<double>::operator<
* @param _moeo1 the first object to compare
* @param _moeo2 the second object to compare
*/
template < class MOEOObjectiveVector, class MOEOFitness, class MOEODiversity, class GeneType >
bool operator<(const moeoVector< MOEOObjectiveVector, GeneType, MOEOFitness, MOEODiversity> & _moeo1, const moeoVector< MOEOObjectiveVector, GeneType, MOEOFitness, MOEODiversity > & _moeo2)
{
return _moeo1.operator<(_moeo2);
}
/**
* To avoid conflicts between MOEO::operator> and std::vector<double>::operator>
* @param _moeo1 the first object to compare
* @param _moeo2 the second object to compare
*/
template < class MOEOObjectiveVector, class MOEOFitness, class MOEODiversity, class GeneType >
bool operator>(const moeoVector< MOEOObjectiveVector, GeneType, MOEOFitness, MOEODiversity> & _moeo1, const moeoVector< MOEOObjectiveVector, GeneType, MOEOFitness, MOEODiversity > & _moeo2)
{
return _moeo1.operator>(_moeo2);
}
#endif /*MOEOVECTOR_H_*/

View file

@ -0,0 +1,79 @@
/*
* <moeoDistance.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEODISTANCE_H_
#define MOEODISTANCE_H_
#include <eoFunctor.h>
/**
* The base class for distance computation.
*/
template < class MOEOT , class Type >
class moeoDistance : public eoBF < const MOEOT &, const MOEOT &, const Type >
{
public:
/**
* Nothing to do
* @param _pop the population
*/
virtual void setup(const eoPop < MOEOT > & _pop)
{}
/**
* Nothing to do
* @param _min lower bound
* @param _max upper bound
* @param _obj the objective index
*/
virtual void setup(double _min, double _max, unsigned int _obj)
{}
/**
* Nothing to do
* @param _realInterval the eoRealInterval object
* @param _obj the objective index
*/
virtual void setup(eoRealInterval _realInterval, unsigned int _obj)
{}
};
#endif /*MOEODISTANCE_H_*/

View file

@ -0,0 +1,101 @@
/*
* <moeoDistanceMatrix.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEODISTANCEMATRIX_H_
#define MOEODISTANCEMATRIX_H_
#include <vector>
#include <eoFunctor.h>
#include <distance/moeoDistance.h>
/**
* A matrix to compute distances between every pair of individuals contained in a population.
*/
template < class MOEOT , class Type >
class moeoDistanceMatrix : public eoUF < const eoPop < MOEOT > &, void > , public std::vector< std::vector < Type > >
{
public:
using std::vector< std::vector < Type > > :: size;
using std::vector< std::vector < Type > > :: operator[];
/**
* Ctor
* @param _size size for every dimension of the matrix
* @param _distance the distance to use
*/
moeoDistanceMatrix (unsigned int _size, moeoDistance < MOEOT , Type > & _distance) : distance(_distance)
{
this->resize(_size);
for (unsigned int i=0; i<_size; i++)
{
this->operator[](i).resize(_size);
}
}
/**
* Sets the distance between every pair of individuals contained in the population _pop
* @param _pop the population
*/
void operator()(const eoPop < MOEOT > & _pop)
{
// 1 - setup the bounds (if necessary)
distance.setup(_pop);
// 2 - compute distances
this->operator[](0).operator[](0) = Type();
for (unsigned int i=0; i<size(); i++)
{
this->operator[](i).operator[](i) = Type();
for (unsigned int j=0; j<i; j++)
{
this->operator[](i).operator[](j) = distance(_pop[i], _pop[j]);
this->operator[](j).operator[](i) = this->operator[](i).operator[](j);
}
}
}
private:
/** the distance to use */
moeoDistance < MOEOT , Type > & distance;
};
#endif /*MOEODISTANCEMATRIX_H_*/

View file

@ -0,0 +1,98 @@
/*
* <moeoEuclideanDistance.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
* François Legillon
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOEUCLIDEANDISTANCE_H_
#define MOEOEUCLIDEANDISTANCE_H_
#include <math.h>
#include <distance/moeoObjSpaceDistance.h>
#include <utils/moeoObjectiveVectorNormalizer.h>
/**
* A class allowing to compute an euclidian distance between two solutions in the objective space with normalized objective values (i.e. between 0 and 1).
* A distance value then lies between 0 and sqrt(nObjectives).
*/
template < class MOEOT >
class moeoEuclideanDistance : public moeoObjSpaceDistance < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/** the fitness type of the solutions */
typedef typename MOEOT::Fitness Fitness;
/**
ctr with a normalizer
@param _normalizer the normalizer used for every ObjectiveVector
*/
moeoEuclideanDistance (moeoObjectiveVectorNormalizer<MOEOT> _normalizer):normalizer(_normalizer)
{}
/**
default ctr
*/
moeoEuclideanDistance ():normalizer(defaultNormalizer)
{}
/**
* Returns the euclidian distance between _obj1 and _obj2 in the objective space
* @param _obj1 the first objective vector
* @param _obj2 the second objective vector
*/
const Fitness operator()(const ObjectiveVector & _obj1, const ObjectiveVector & _obj2)
{
Fitness result = 0.0;
Fitness tmp1, tmp2;
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{
tmp1 = normalizer(_obj1)[i];
tmp2 = normalizer(_obj2)[i];
result += (tmp1-tmp2) * (tmp1-tmp2);
}
return sqrt(result);
}
private:
moeoObjectiveVectorNormalizer<MOEOT> defaultNormalizer;
moeoObjectiveVectorNormalizer<MOEOT> &normalizer;
};
#endif /*MOEOEUCLIDEANDISTANCE_H_*/

View file

@ -0,0 +1,98 @@
/*
* <moeoManhattanDistance.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
* Francçois Legillon
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOMANHATTANDISTANCE_H_
#define MOEOMANHATTANDISTANCE_H_
#include <math.h>
#include <distance/moeoObjSpaceDistance.h>
#include <utils/moeoObjectiveVectorNormalizer.h>
/**
* A class allowing to compute the Manhattan distance between two solutions in the objective space normalized objective values (i.e. between 0 and 1).
* A distance value then lies between 0 and nObjectives.
*/
template < class MOEOT >
class moeoManhattanDistance : public moeoObjSpaceDistance < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/** the fitness type of the solutions */
typedef typename MOEOT::Fitness Fitness;
/**
ctr with a normalizer
@param _normalizer the normalizer used for every ObjectiveVector
*/
moeoManhattanDistance (moeoObjectiveVectorNormalizer<MOEOT> &_normalizer):normalizer(_normalizer)
{}
/**
default ctr
*/
moeoManhattanDistance ():normalizer(defaultNormalizer)
{}
/**
* Returns the Manhattan distance between _obj1 and _obj2 in the objective space
* @param _obj1 the first objective vector
* @param _obj2 the second objective vector
*/
const double operator()(const ObjectiveVector & _obj1, const ObjectiveVector & _obj2)
{
double result = 0.0;
double tmp1, tmp2;
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{
tmp1 = normalizer(_obj1)[i];
tmp2 = normalizer(_obj2)[i];
result += fabs(tmp1-tmp2);
}
return result;
}
private:
moeoObjectiveVectorNormalizer<MOEOT> defaultNormalizer;
moeoObjectiveVectorNormalizer<MOEOT> &normalizer;
};
#endif /*MOEOMANHATTANDISTANCE_H_*/

View file

@ -0,0 +1,137 @@
/*
* <moeoNormalizedDistance.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEONORMALIZEDDISTANCE_H_
#define MOEONORMALIZEDDISTANCE_H_
#include <vector>
#include <utils/eoRealBounds.h>
#include <distance/moeoDistance.h>
/**
* The base class for double distance computation with normalized objective values (i.e. between 0 and 1).
*/
template < class MOEOT , class Type = double >
class moeoNormalizedDistance : public moeoDistance < MOEOT , Type >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Default ctr
*/
moeoNormalizedDistance()
{
bounds.resize(ObjectiveVector::Traits::nObjectives());
// initialize bounds in case someone does not want to use them
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
bounds[i] = eoRealInterval(0,1);
}
}
/**
* Returns a very small value that can be used to avoid extreme cases (where the min bound == the max bound)
*/
static double tiny()
{
return 1e-6;
}
/**
* Sets the lower and the upper bounds for every objective using extremes values for solutions contained in the population _pop
* @param _pop the population
*/
virtual void setup(const eoPop < MOEOT > & _pop)
{
double min, max;
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
min = _pop[0].objectiveVector()[i];
max = _pop[0].objectiveVector()[i];
for (unsigned int j=1; j<_pop.size(); j++)
{
min = std::min(min, _pop[j].objectiveVector()[i]);
max = std::max(max, _pop[j].objectiveVector()[i]);
}
// setting of the bounds for the objective i
setup(min, max, i);
}
}
/**
* Sets the lower bound (_min) and the upper bound (_max) for the objective _obj
* @param _min lower bound
* @param _max upper bound
* @param _obj the objective index
*/
virtual void setup(double _min, double _max, unsigned int _obj)
{
if (_min == _max)
{
_min -= tiny();
_max += tiny();
}
bounds[_obj] = eoRealInterval(_min, _max);
}
/**
* Sets the lower bound and the upper bound for the objective _obj using a eoRealInterval object
* @param _realInterval the eoRealInterval object
* @param _obj the objective index
*/
virtual void setup(eoRealInterval _realInterval, unsigned int _obj)
{
bounds[_obj] = _realInterval;
}
protected:
/** the bounds for every objective (bounds[i] = bounds for the objective i) */
std::vector < eoRealInterval > bounds;
};
#endif /*MOEONORMALIZEDDISTANCE_H_*/

View file

@ -0,0 +1,63 @@
/*
* <moeoObjSpaceDistance.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Jeremie Humeau
* Arnaud Liefooghe
* François Legillon
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOOBJDIST_H_
#define MOEOOBJDIST_H_
#include <eo>
#include <moeo>
#include <cmath>
/**
Distances using Objective vectors to evaluate
*/
template < class MOEOT>
class moeoObjSpaceDistance : public moeoDistance < MOEOT, typename MOEOT::Fitness >, public eoBF<const typename MOEOT::ObjectiveVector&,const typename MOEOT::ObjectiveVector&,const typename MOEOT::Fitness>
{
public:
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
typedef typename MOEOT::Fitness Fitness;
virtual const Fitness operator()(const MOEOT &_moeot1,const MOEOT &_moeot2){
return operator()(_moeot1.objectiveVector(),_moeot2.objectiveVector());
}
virtual const Fitness operator()(const ObjectiveVector &_obj1, const ObjectiveVector &_obj2)=0;
};
#endif

View file

@ -0,0 +1,147 @@
/*
* <moeoCrowdingDiversityAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOCROWDINGDIVERSITYASSIGNMENT_H_
#define MOEOCROWDINGDIVERSITYASSIGNMENT_H_
#include <eoPop.h>
#include <comparator/moeoOneObjectiveComparator.h>
#include <diversity/moeoDiversityAssignment.h>
/**
* Diversity assignment sheme based on crowding proposed in:
* K. Deb, A. Pratap, S. Agarwal, T. Meyarivan, "A Fast and Elitist Multi-Objective Genetic Algorithm: NSGA-II", IEEE Transactions on Evolutionary Computation, vol. 6, no. 2 (2002).
*/
template < class MOEOT >
class moeoCrowdingDiversityAssignment : public moeoDiversityAssignment < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Returns a big value (regarded as infinite)
*/
double inf() const
{
return std::numeric_limits<double>::max();
}
/**
* Returns a very small value that can be used to avoid extreme cases (where the min bound == the max bound)
*/
double tiny() const
{
return 1e-6;
}
/**
* Computes diversity values for every solution contained in the population _pop
* @param _pop the population
*/
void operator()(eoPop < MOEOT > & _pop)
{
if (_pop.size() <= 2)
{
for (unsigned int i=0; i<_pop.size(); i++)
{
_pop[i].diversity(inf());
}
}
else
{
setDistances(_pop);
}
}
/**
* @warning NOT IMPLEMENTED, DO NOTHING !
* Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
* @warning NOT IMPLEMENTED, DO NOTHING !
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoCrowdingDiversityAssignment" << std::endl;
}
protected:
/**
* Sets the distance values
* @param _pop the population
*/
virtual void setDistances (eoPop < MOEOT > & _pop)
{
double min, max, distance;
unsigned int nObjectives = MOEOT::ObjectiveVector::nObjectives();
// set diversity to 0
for (unsigned int i=0; i<_pop.size(); i++)
{
_pop[i].diversity(0.0);
}
// for each objective
for (unsigned int obj=0; obj<nObjectives; obj++)
{
// comparator
moeoOneObjectiveComparator < MOEOT > objComp(obj);
// sort
std::sort(_pop.begin(), _pop.end(), objComp);
// min & max
min = _pop[0].objectiveVector()[obj];
max = _pop[_pop.size()-1].objectiveVector()[obj];
// set the diversity value to infiny for min and max
_pop[0].diversity(inf());
_pop[_pop.size()-1].diversity(inf());
for (unsigned int i=1; i<_pop.size()-1; i++)
{
distance = (_pop[i+1].objectiveVector()[obj] - _pop[i-1].objectiveVector()[obj]) / (max-min);
_pop[i].diversity(_pop[i].diversity() + distance);
}
}
}
};
#endif /*MOEOCROWDINGDIVERSITYASSIGNMENT_H_*/

View file

@ -0,0 +1,76 @@
/*
* <moeoDiversityAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEODIVERSITYASSIGNMENT_H_
#define MOEODIVERSITYASSIGNMENT_H_
#include <eoFunctor.h>
#include <eoPop.h>
/**
* Functor that sets the diversity values of a whole population.
*/
template < class MOEOT >
class moeoDiversityAssignment : public eoUF < eoPop < MOEOT > &, void >
{
public:
/** The type for objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
virtual void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) = 0;
/**
* Updates the diversity values of the whole population _pop by taking the deletion of the individual _moeo into account.
* @param _pop the population
* @param _moeo the individual
*/
void updateByDeleting(eoPop < MOEOT > & _pop, MOEOT & _moeo)
{
updateByDeleting(_pop, _moeo.objectiveVector());
}
};
#endif /*MOEODIVERSITYASSIGNMENT_H_*/

View file

@ -0,0 +1,84 @@
/*
* <moeoDummyDiversityAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEODUMMYDIVERSITYASSIGNMENT_H_
#define MOEODUMMYDIVERSITYASSIGNMENT_H_
#include<diversity/moeoDiversityAssignment.h>
/**
* moeoDummyDiversityAssignment is a moeoDiversityAssignment that gives the value '0' as the individual's diversity for a whole population if it is invalid.
*/
template < class MOEOT >
class moeoDummyDiversityAssignment : public moeoDiversityAssignment < MOEOT >
{
public:
/** The type for objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Sets the diversity to '0' for every individuals of the population _pop if it is invalid
* @param _pop the population
*/
void operator () (eoPop < MOEOT > & _pop)
{
for (unsigned int idx = 0; idx<_pop.size (); idx++)
{
if (_pop[idx].invalidDiversity())
{
// set the diversity to 0
_pop[idx].diversity(0.0);
}
}
}
/**
* Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
// nothing to do... ;-)
}
};
#endif /*MOEODUMMYDIVERSITYASSIGNMENT_H_*/

View file

@ -0,0 +1,175 @@
/*
* <moeoFrontByFrontCrowdingDiversityAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2009
* (C) OPAC Team, LIFL, 2002-2009
*
* Arnaud Liefooghe, Waldo Cancino
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOFRONTBYFRONTCROWDINGDIVERSITYASSIGNMENT2_H_
#define MOEOFRONTBYFRONTCROWDINGDIVERSITYASSIGNMENT2_H_
#include <diversity/moeoCrowdingDiversityAssignment.h>
#include <comparator/moeoFitnessThenDiversityComparator.h>
#include <comparator/moeoPtrComparator.h>
/**
* Diversity assignment sheme based on crowding proposed in:
* K. Deb, A. Pratap, S. Agarwal, T. Meyarivan, "A Fast and Elitist Multi-Objective Genetic Algorithm: NSGA-II", IEEE Transactions on Evolutionary Computation, vol. 6, no. 2 (2002).
* Tis strategy assigns diversity values FRONT BY FRONT. It is, for instance, used in NSGA-II.
*/
template < class MOEOT >
class moeoFrontByFrontCrowdingDiversityAssignment : public moeoCrowdingDiversityAssignment < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* @warning NOT IMPLEMENTED, DO NOTHING !
* Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
* @warning NOT IMPLEMENTED, DO NOTHING !
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoFrontByFrontCrowdingDistanceDiversityAssignment" << std::endl;
}
private:
using moeoCrowdingDiversityAssignment < MOEOT >::inf;
using moeoCrowdingDiversityAssignment < MOEOT >::tiny;
/**
* Sets the distance values
* @param _pop the population
*/
void setDistances (eoPop <MOEOT> & _pop)
{
unsigned int a,b;
double min, max, distance;
unsigned int nObjectives = MOEOT::ObjectiveVector::nObjectives();
// set diversity to 0 for every individual
for (unsigned int i=0; i<_pop.size(); i++)
{
_pop[i].diversity(0.0);
}
// sort the whole pop according to fitness values
moeoFitnessThenDiversityComparator < MOEOT > fitnessComparator;
std::vector<MOEOT *> sortedptrpop;
sortedptrpop.resize(_pop.size());
// due to intensive sort operations for this diversity assignment,
// it is more efficient to perform sorts using only pointers to the
// population members in order to avoid copy of individuals
for(unsigned int i=0; i< _pop.size(); i++) sortedptrpop[i] = & (_pop[i]);
//sort the pointers to population members
moeoPtrComparator<MOEOT> cmp2( fitnessComparator);
std::sort(sortedptrpop.begin(), sortedptrpop.end(), cmp2);
// compute the crowding distance values for every individual "front" by "front" (front : from a to b)
a = 0; // the front starts at a
while (a < _pop.size())
{
b = lastIndex(sortedptrpop,a); // the front ends at b
//b = lastIndex(_pop,a); // the front ends at b
// if there is less than 2 individuals in the front...
if ((b-a) < 2)
{
for (unsigned int i=a; i<=b; i++)
{
sortedptrpop[i]->diversity(inf());
//_pop[i].diversity(inf());
}
}
// else...
else
{
// for each objective
for (unsigned int obj=0; obj<nObjectives; obj++)
{
// sort in the descending order using the values of the objective 'obj'
moeoOneObjectiveComparator < MOEOT > objComp(obj);
moeoPtrComparator<MOEOT> cmp2( objComp );
std::sort(sortedptrpop.begin(), sortedptrpop.end(), cmp2);
// min & max
min = (sortedptrpop[b])->objectiveVector()[obj];
max = (sortedptrpop[a])->objectiveVector()[obj];
// avoid extreme case
if (min == max)
{
min -= tiny();
max += tiny();
}
// set the diversity value to infiny for min and max
sortedptrpop[a]->diversity(inf());
sortedptrpop[b]->diversity(inf());
// set the diversity values for the other individuals
for (unsigned int i=a+1; i<b; i++)
{
distance = ( sortedptrpop[i-1]->objectiveVector()[obj] - sortedptrpop[i+1]->objectiveVector()[obj] ) / (max-min);
sortedptrpop[i]->diversity(sortedptrpop[i]->diversity() + distance);
}
}
}
// go to the next front
a = b+1;
}
}
/**
* Returns the index of the last individual having the same fitness value than _pop[_start]
* @param _pop the vector of pointers to population individuals
* @param _start the index to start from
*/
unsigned int lastIndex (std::vector<MOEOT *> & _pop, unsigned int _start)
{
unsigned int i=_start;
while ( (i<_pop.size()-1) && (_pop[i]->fitness()==_pop[i+1]->fitness()) )
{
i++;
}
return i;
}
};
#endif /*MOEOFRONTBYFRONTCROWDINGDIVERSITYASSIGNMENT_H_*/

View file

@ -0,0 +1,130 @@
/*
* <moeoFrontByFrontSharingDiversityAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOFRONTBYFRONTSHARINGDIVERSITYASSIGNMENT_H_
#define MOEOFRONTBYFRONTSHARINGDIVERSITYASSIGNMENT_H_
#include <diversity/moeoSharingDiversityAssignment.h>
/**
* Sharing assignment scheme on the way it is used in NSGA.
*/
template < class MOEOT >
class moeoFrontByFrontSharingDiversityAssignment : public moeoSharingDiversityAssignment < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Ctor
* @param _distance the distance used to compute the neighborhood of solutions (can be related to the decision space or the objective space)
* @param _nicheSize neighborhood size in terms of radius distance (closely related to the way the distances are computed)
* @param _alpha parameter used to regulate the shape of the sharing function
*/
moeoFrontByFrontSharingDiversityAssignment(moeoDistance<MOEOT,double> & _distance, double _nicheSize = 0.5, double _alpha = 2.0) : moeoSharingDiversityAssignment < MOEOT >(_distance, _nicheSize, _alpha)
{}
/**
* Ctor with an euclidean distance (with normalized objective values) in the objective space is used as default
* @param _nicheSize neighborhood size in terms of radius distance (closely related to the way the distances are computed)
* @param _alpha parameter used to regulate the shape of the sharing function
*/
moeoFrontByFrontSharingDiversityAssignment(double _nicheSize = 0.5, double _alpha = 2.0) : moeoSharingDiversityAssignment < MOEOT >(_nicheSize, _alpha)
{}
/**
* @warning NOT IMPLEMENTED, DO NOTHING !
* Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
* @warning NOT IMPLEMENTED, DO NOTHING !
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoSharingDiversityAssignment" << std::endl;
}
private:
using moeoSharingDiversityAssignment < MOEOT >::distance;
using moeoSharingDiversityAssignment < MOEOT >::nicheSize;
using moeoSharingDiversityAssignment < MOEOT >::sh;
/**
* Sets similarities FRONT BY FRONT for every solution contained in the population _pop
* @param _pop the population
*/
void setSimilarities(eoPop < MOEOT > & _pop)
{
// compute distances between every individuals
moeoDistanceMatrix < MOEOT , double > dMatrix (_pop.size(), distance);
dMatrix(_pop);
// sets the distance to bigger than the niche size for every couple of solutions that do not belong to the same front
for (unsigned int i=0; i<_pop.size(); i++)
{
for (unsigned int j=0; j<i; j++)
{
if (_pop[i].fitness() != _pop[j].fitness())
{
dMatrix[i][j] = nicheSize;
dMatrix[j][i] = nicheSize;
}
}
}
// compute similarities
double sum;
for (unsigned int i=0; i<_pop.size(); i++)
{
sum = 0.0;
for (unsigned int j=0; j<_pop.size(); j++)
{
sum += sh(dMatrix[i][j]);
}
_pop[i].diversity(sum);
}
}
};
#endif /*MOEOFRONTBYFRONTSHARINGDIVERSITYASSIGNMENT_H_*/

View file

@ -0,0 +1,173 @@
/*
* <moeoNearestNeighborDiversityAssignment.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
*
*/
//-----------------------------------------------------------------------------
// moeoNearestNeighborDiversityAssignment.h
//-----------------------------------------------------------------------------
#ifndef MOEONEARESTNEIGHBORDIVERSITYASSIGNMENT_H_
#define MOEONEARESTNEIGHBORDIVERSITYASSIGNMENT_H_
#include <list>
#include <diversity/moeoDiversityAssignment.h>
#include <archive/moeoUnboundedArchive.h>
#include <archive/moeoArchive.h>
/**
* moeoNearestNeighborDiversityAssignment is a moeoDiversityAssignment using distance between individuals to assign diversity.
*/
template < class MOEOT >
class moeoNearestNeighborDiversityAssignment : public moeoDiversityAssignment < MOEOT >
{
public:
/** The type for objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Default ctor
* @param _index index for find the k-ieme nearest neighbor, _index correspond to k
*/
moeoNearestNeighborDiversityAssignment(unsigned int _index=1):distance(defaultDistance), archive(defaultArchive), index(_index)
{}
/**
* Ctor where you can choose your own archive
* @param _archive the archive used
* @param _index index for find the k-ieme nearest neighbor, _index correspond to k
*/
moeoNearestNeighborDiversityAssignment(moeoArchive <MOEOT>& _archive, unsigned int _index=1) : distance(defaultDistance), archive(_archive), index(_index)
{}
/**
* Ctor where you can choose your own distance
* @param _dist the distance used
* @param _index index for find the k-ieme nearest neighbor, _index correspond to k
*/
moeoNearestNeighborDiversityAssignment(moeoDistance <MOEOT, double>& _dist, unsigned int _index=1) : distance(_dist), archive(defaultArchive), index(_index)
{}
/**
* Ctor where you can choose your own distance and archive
* @param _dist the distance used
* @param _archive the archive used
* @param _index index for find the k-ieme nearest neighbor, _index correspond to k
*/
moeoNearestNeighborDiversityAssignment(moeoDistance <MOEOT, double>& _dist, moeoArchive <MOEOT>& _archive, unsigned int _index=1) : distance(_dist), archive(_archive), index(_index)
{}
/**
* Affect the diversity to the pop, diversity corresponding to the k-ieme nearest neighbor.
* @param _pop the population
*/
void operator () (eoPop < MOEOT > & _pop)
{
unsigned int i = _pop.size();
unsigned int j = archive.size();
double tmp=0;
std::vector< std::list<double> > matrice(i+j);
if (i+j>0)
{
for (unsigned k=0; k<i+j-1; k++)
{
for (unsigned l=k+1; l<i+j; l++)
{
if ( (k<i) && (l<i) )
tmp=distance(_pop[k], _pop[l]);
else if ( (k<i) && (l>=i) )
tmp=distance(_pop[k], archive[l-i]);
else
tmp=distance(archive[k-i], archive[l-i]);
matrice[k].push_back(tmp);
matrice[l].push_back(tmp);
}
}
}
for (unsigned int k=0; k<i+j; k++)
matrice[k].sort();
for (unsigned int k=0; k<i; k++)
_pop[k].diversity(-1 * 1/(2+getElement(matrice[k])));
for (unsigned int k=i; k<i+j; k++)
archive[k-i].diversity(-1 * 1/(2+getElement(matrice[k])));
}
/**
* @warning NOT IMPLEMENTED, DOES NOTHING !
* Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
* @warning NOT IMPLEMENTED, DOES NOTHING !
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoNearestNeighborDiversityAssignment" << std::endl;
}
private:
/** Distance */
moeoDistance <MOEOT, double> & distance;
/** Default distance */
moeoEuclideanDistance < MOEOT > defaultDistance;
/** Archive */
moeoArchive < MOEOT > & archive;
/** Default archive */
moeoUnboundedArchive < MOEOT > defaultArchive;
/** the index corresponding to k for search the k-ieme nearest neighbor */
unsigned int index;
/**
* Return the index-th element of the list _myList
* @param _myList the list which contains distances
*/
double getElement(std::list<double> _myList)
{
std::list<double>::iterator it= _myList.begin();
for (unsigned int i=1; i< std::min((unsigned int)_myList.size(),index); i++)
it++;
return *it;
}
};
#endif /*MOEONEARESTNEIGHBORDIVERSITYASSIGNEMENT_H_*/

View file

@ -0,0 +1,167 @@
/*
* <moeoSharingDiversityAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOSHARINGDIVERSITYASSIGNMENT_H_
#define MOEOSHARINGDIVERSITYASSIGNMENT_H_
#include <eoPop.h>
#include <comparator/moeoDiversityThenFitnessComparator.h>
#include <distance/moeoDistance.h>
#include <distance/moeoDistanceMatrix.h>
#include <distance/moeoEuclideanDistance.h>
#include <diversity/moeoDiversityAssignment.h>
/**
* Sharing assignment scheme originally porposed by:
* D. E. Goldberg, "Genetic Algorithms in Search, Optimization and Machine Learning", Addision-Wesley, MA, USA (1989).
*/
template < class MOEOT >
class moeoSharingDiversityAssignment : public moeoDiversityAssignment < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Ctor
* @param _distance the distance used to compute the neighborhood of solutions (can be related to the decision space or the objective space)
* @param _nicheSize neighborhood size in terms of radius distance (closely related to the way the distances are computed)
* @param _alpha parameter used to regulate the shape of the sharing function
*/
moeoSharingDiversityAssignment(moeoDistance<MOEOT,double> & _distance, double _nicheSize = 0.5, double _alpha = 1.0) : distance(_distance), nicheSize(_nicheSize), alpha(_alpha)
{}
/**
* Ctor with an euclidean distance (with normalized objective values) in the objective space is used as default
* @param _nicheSize neighborhood size in terms of radius distance (closely related to the way the distances are computed)
* @param _alpha parameter used to regulate the shape of the sharing function
*/
moeoSharingDiversityAssignment(double _nicheSize = 0.5, double _alpha = 1.0) : distance(defaultDistance), nicheSize(_nicheSize), alpha(_alpha)
{}
/**
* Sets diversity values for every solution contained in the population _pop
* @param _pop the population
*/
void operator()(eoPop < MOEOT > & _pop)
{
// 1 - set simuilarities
setSimilarities(_pop);
// 2 - a higher diversity is better, so the values need to be inverted
moeoDiversityThenFitnessComparator < MOEOT > divComparator;
double max = std::max_element(_pop.begin(), _pop.end(), divComparator)->diversity();
for (unsigned int i=0 ; i<_pop.size() ; i++)
{
_pop[i].diversity(max - _pop[i].diversity());
}
}
/**
* @warning NOT IMPLEMENTED, DO NOTHING !
* Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
* @warning NOT IMPLEMENTED, DO NOTHING !
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoSharingDiversityAssignment" << std::endl;
}
protected:
/** the distance used to compute the neighborhood of solutions */
moeoDistance < MOEOT , double > & distance;
/** euclidean distancein the objective space (can be used as default) */
moeoEuclideanDistance < MOEOT > defaultDistance;
/** neighborhood size in terms of radius distance */
double nicheSize;
/** parameter used to regulate the shape of the sharing function */
double alpha;
/**
* Sets similarities for every solution contained in the population _pop
* @param _pop the population
*/
virtual void setSimilarities(eoPop < MOEOT > & _pop)
{
// compute distances between every individuals
moeoDistanceMatrix < MOEOT , double > dMatrix (_pop.size(), distance);
dMatrix(_pop);
// compute similarities
double sum;
for (unsigned int i=0; i<_pop.size(); i++)
{
sum = 0.0;
for (unsigned int j=0; j<_pop.size(); j++)
{
sum += sh(dMatrix[i][j]);
}
_pop[i].diversity(sum);
}
}
/**
* Sharing function
* @param _dist the distance value
*/
double sh(double _dist)
{
double result;
if (_dist < nicheSize)
{
result = 1.0 - pow(_dist / nicheSize, alpha);
}
else
{
result = 0.0;
}
return result;
}
};
#endif /*MOEOSHARINGDIVERSITYASSIGNMENT_H_*/

View file

@ -0,0 +1,203 @@
/*
* <make_checkpoint_moeo.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MAKE_CHECKPOINT_MOEO_H_
#define MAKE_CHECKPOINT_MOEO_H_
#include <limits.h>
#include <stdlib.h>
#include <sstream>
#include <eoContinue.h>
#include <eoEvalFuncCounter.h>
#include <utils/checkpointing>
#include <utils/selectors.h>
#include <utils/eoParser.h>
#include <utils/eoState.h>
#include <metric/moeoContributionMetric.h>
#include <metric/moeoEntropyMetric.h>
#include <utils/moeoArchiveUpdater.h>
#include <utils/moeoArchiveObjectiveVectorSavingUpdater.h>
#include <utils/moeoBinaryMetricSavingUpdater.h>
bool testDirRes(std::string _dirName, bool _erase);
/**
* This functions allows to build an eoCheckPoint for multi-objective optimization from the parser (partly taken from make_checkpoint_pareto.h)
* @param _parser the parser
* @param _state to store allocated objects
* @param _eval the funtions evaluator
* @param _continue the stopping crietria
* @param _pop the population
* @param _archive the archive of non-dominated solutions
*/
template < class MOEOT >
eoCheckPoint < MOEOT > & do_make_checkpoint_moeo (eoParser & _parser, eoState & _state, eoEvalFuncCounter < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoPop < MOEOT > & _pop, moeoArchive < MOEOT > & _archive)
{
eoCheckPoint < MOEOT > & checkpoint = _state.storeFunctor(new eoCheckPoint < MOEOT > (_continue));
/* the objective vector type */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
///////////////////
// Counters
//////////////////
// is nb Eval to be used as counter?
//bool useEval = _parser.getORcreateParam(true, "useEval", "Use nb of eval. as counter (vs nb of gen.)", '\0', "Output").value();
// Create anyway a generation-counter parameter
eoValueParam<unsigned int> *generationCounter = new eoValueParam<unsigned int>(0, "Gen.");
// Create an incrementor (sub-class of eoUpdater).
eoIncrementor<unsigned int> & increment = _state.storeFunctor( new eoIncrementor<unsigned int>(generationCounter->value()) );
// Add it to the checkpoint
checkpoint.add(increment);
// dir for DISK output
std::string & dirName = _parser.getORcreateParam(std::string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output").value();
// shoudl we empty it if exists
eoValueParam<bool>& eraseParam = _parser.getORcreateParam(true, "eraseDir", "erase files in dirName if any", '\0', "Output");
bool dirOK = false; // not tested yet
// Dump of the whole population
//-----------------------------
bool printPop = _parser.getORcreateParam(false, "printPop", "Print sorted pop. every gen.", '\0', "Output").value();
eoSortedPopStat<MOEOT> * popStat;
if ( printPop ) // we do want pop dump
{
popStat = & _state.storeFunctor(new eoSortedPopStat<MOEOT>);
checkpoint.add(*popStat);
}
//////////////////////////////////
// State savers
//////////////////////////////
// feed the state to state savers
// save state every N generation
eoValueParam<unsigned int>& saveFrequencyParam = _parser.createParam((unsigned int)(0), "saveFrequency", "Save every F generation (0 = only final state, absent = never)", '\0', "Persistence" );
if (_parser.isItThere(saveFrequencyParam))
{
// first make sure dirName is OK
if (! dirOK )
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
unsigned int freq = (saveFrequencyParam.value()>0 ? saveFrequencyParam.value() : UINT_MAX );
#ifdef _MSVC
std::string stmp = dirName + "\generations";
#else
std::string stmp = dirName + "/generations";
#endif
eoCountedStateSaver *stateSaver1 = new eoCountedStateSaver(freq, _state, stmp);
_state.storeFunctor(stateSaver1);
checkpoint.add(*stateSaver1);
}
// save state every T seconds
eoValueParam<unsigned int>& saveTimeIntervalParam = _parser.getORcreateParam((unsigned int)(0), "saveTimeInterval", "Save every T seconds (0 or absent = never)", '\0',"Persistence" );
if (_parser.isItThere(saveTimeIntervalParam) && saveTimeIntervalParam.value()>0)
{
// first make sure dirName is OK
if (! dirOK )
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
#ifdef _MSVC
std::string stmp = dirName + "\time";
#else
std::string stmp = dirName + "/time";
#endif
eoTimedStateSaver *stateSaver2 = new eoTimedStateSaver(saveTimeIntervalParam.value(), _state, stmp);
_state.storeFunctor(stateSaver2);
checkpoint.add(*stateSaver2);
}
///////////////////
// Archive
//////////////////
// update the archive every generation
bool updateArch = _parser.getORcreateParam(true, "updateArch", "Update the archive at each gen.", '\0', "Evolution Engine").value();
if (updateArch)
{
moeoArchiveUpdater < MOEOT > * updater = new moeoArchiveUpdater < MOEOT > (_archive, _pop);
_state.storeFunctor(updater);
checkpoint.add(*updater);
}
// store the objective vectors contained in the archive every generation
bool storeArch = _parser.getORcreateParam(false, "storeArch", "Store the archive's objective vectors at each gen.", '\0', "Output").value();
if (storeArch)
{
if (! dirOK )
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
#ifdef _MSVC
std::string stmp = dirName + "\arch";
#else
std::string stmp = dirName + "/arch";
#endif
moeoArchiveObjectiveVectorSavingUpdater < MOEOT > * save_updater = new moeoArchiveObjectiveVectorSavingUpdater < MOEOT > (_archive, stmp);
_state.storeFunctor(save_updater);
checkpoint.add(*save_updater);
}
// store the contribution of the non-dominated solutions
bool cont = _parser.getORcreateParam(false, "contribution", "Store the contribution of the archive at each gen.", '\0', "Output").value();
if (cont)
{
if (! dirOK )
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
#ifdef _MSVC
std::string stmp = dirName + "\contribution";
#else
std::string stmp = dirName + "/contribution";
#endif
moeoContributionMetric < ObjectiveVector > * contribution = new moeoContributionMetric < ObjectiveVector >;
moeoBinaryMetricSavingUpdater < MOEOT > * contribution_updater = new moeoBinaryMetricSavingUpdater < MOEOT > (*contribution, _archive, stmp);
_state.storeFunctor(contribution_updater);
checkpoint.add(*contribution_updater);
}
// store the entropy of the non-dominated solutions
bool ent = _parser.getORcreateParam(false, "entropy", "Store the entropy of the archive at each gen.", '\0', "Output").value();
if (ent)
{
if (! dirOK )
dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
#ifdef _MSVC
std::string stmp = dirName + "\entropy";
#else
std::string stmp = dirName + "/entropy";
#endif
moeoEntropyMetric < ObjectiveVector > * entropy = new moeoEntropyMetric < ObjectiveVector >;
moeoBinaryMetricSavingUpdater < MOEOT > * entropy_updater = new moeoBinaryMetricSavingUpdater < MOEOT > (*entropy, _archive, stmp);
_state.storeFunctor(entropy_updater);
checkpoint.add(*entropy_updater);
}
// and that's it for the (control and) output
return checkpoint;
}
#endif /*MAKE_CHECKPOINT_MOEO_H_*/

View file

@ -0,0 +1,131 @@
/*
* <make_continue_moeo.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MAKE_CONTINUE_MOEO_H_
#define MAKE_CONTINUE_MOEO_H_
#include <eoCombinedContinue.h>
#include <eoGenContinue.h>
#include <eoEvalContinue.h>
#include <eoFitContinue.h>
#include <eoTimeContinue.h>
#ifndef _MSC_VER
#include <eoCtrlCContinue.h>
#endif
#include <utils/eoParser.h>
#include <utils/eoState.h>
/**
* Helper function
* @param _combined the eoCombinedContinue object
* @param _cont the eoContinue to add
*/
template <class MOEOT>
eoCombinedContinue<MOEOT> * make_combinedContinue(eoCombinedContinue<MOEOT> *_combined, eoContinue<MOEOT> *_cont)
{
if (_combined) // already exists
_combined->add(*_cont);
else
_combined = new eoCombinedContinue<MOEOT>(*_cont);
return _combined;
}
/**
* This functions allows to build a eoContinue for multi-objective optimization from the parser (partly taken from make_continue_pareto.h)
* @param _parser the parser
* @param _state to store allocated objects
* @param _eval the funtions evaluator
*/
template <class MOEOT>
eoContinue<MOEOT> & do_make_continue_moeo(eoParser& _parser, eoState& _state, eoEvalFuncCounter<MOEOT> & _eval)
{
// the combined continue - to be filled
eoCombinedContinue<MOEOT> *continuator = NULL;
// First the eoGenContinue - need a default value so you can run blind
// but we also need to be able to avoid it <--> 0
eoValueParam<unsigned int>& maxGenParam = _parser.createParam((unsigned int)(100), "maxGen", "Maximum number of generations (0 = none)",'G',"Stopping criterion");
if (maxGenParam.value()) // positive: -> define and store
{
eoGenContinue<MOEOT> *genCont = new eoGenContinue<MOEOT>(maxGenParam.value());
_state.storeFunctor(genCont);
// and "add" to combined
continuator = make_combinedContinue<MOEOT>(continuator, genCont);
}
// maxEval
eoValueParam<unsigned long>& maxEvalParam = _parser.getORcreateParam((unsigned long)(0), "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion");
if (maxEvalParam.value())
{
eoEvalContinue<MOEOT> *evalCont = new eoEvalContinue<MOEOT>(_eval, maxEvalParam.value());
_state.storeFunctor(evalCont);
// and "add" to combined
continuator = make_combinedContinue<MOEOT>(continuator, evalCont);
}
// maxTime
eoValueParam<unsigned long>& maxTimeParam = _parser.getORcreateParam((unsigned long)(0), "maxTime", "Maximum running time in seconds (0 = none)", 'T', "Stopping criterion");
if (maxTimeParam.value()) // positive: -> define and store
{
eoTimeContinue<MOEOT> *timeCont = new eoTimeContinue<MOEOT>(maxTimeParam.value());
_state.storeFunctor(timeCont);
// and "add" to combined
continuator = make_combinedContinue<MOEOT>(continuator, timeCont);
}
// CtrlC
#ifndef _MSC_VER
// the CtrlC interception (Linux only I'm afraid)
eoCtrlCContinue<MOEOT> *ctrlCCont;
eoValueParam<bool>& ctrlCParam = _parser.createParam(true, "CtrlC", "Terminate current generation upon Ctrl C",'C', "Stopping criterion");
if (ctrlCParam.value())
{
ctrlCCont = new eoCtrlCContinue<MOEOT>;
// store
_state.storeFunctor(ctrlCCont);
// add to combinedContinue
continuator = make_combinedContinue<MOEOT>(continuator, ctrlCCont);
}
#endif
// now check that there is at least one!
if (!continuator)
throw std::runtime_error("You MUST provide a stopping criterion");
// OK, it's there: store in the eoState
_state.storeFunctor(continuator);
// and return
return *continuator;
}
#endif /*MAKE_CONTINUE_MOEO_H_*/

View file

@ -0,0 +1,297 @@
/*
* <make_ea_moeo.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MAKE_EA_MOEO_H_
#define MAKE_EA_MOEO_H_
#include <stdlib.h>
#include <eoContinue.h>
#include <eoEvalFunc.h>
#include <eoGeneralBreeder.h>
#include <eoGenOp.h>
#include <utils/eoParser.h>
#include <utils/eoState.h>
#include <algo/moeoEA.h>
#include <algo/moeoEasyEA.h>
#include <archive/moeoArchive.h>
#include <comparator/moeoAggregativeComparator.h>
#include <comparator/moeoComparator.h>
#include <comparator/moeoDiversityThenFitnessComparator.h>
#include <comparator/moeoFitnessThenDiversityComparator.h>
#include <diversity/moeoDiversityAssignment.h>
#include <diversity/moeoDummyDiversityAssignment.h>
#include <diversity/moeoFrontByFrontCrowdingDiversityAssignment.h>
#include <diversity/moeoFrontByFrontSharingDiversityAssignment.h>
#include <fitness/moeoDummyFitnessAssignment.h>
#include <fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h>
#include <fitness/moeoDominanceDepthFitnessAssignment.h>
#include <fitness/moeoFitnessAssignment.h>
#include <metric/moeoAdditiveEpsilonBinaryMetric.h>
#include <metric/moeoHypervolumeBinaryMetric.h>
#include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
#include <replacement/moeoElitistReplacement.h>
#include <replacement/moeoEnvironmentalReplacement.h>
#include <replacement/moeoGenerationalReplacement.h>
#include <replacement/moeoReplacement.h>
#include <selection/moeoDetTournamentSelect.h>
#include <selection/moeoRandomSelect.h>
#include <selection/moeoStochTournamentSelect.h>
#include <selection/moeoSelectOne.h>
#include <selection/moeoSelectors.h>
/**
* This functions allows to build a moeoEA from the parser
* @param _parser the parser
* @param _state to store allocated objects
* @param _eval the funtions evaluator
* @param _continue the stopping crietria
* @param _op the variation operators
* @param _archive the archive of non-dominated solutions
*/
template < class MOEOT >
moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalFunc < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoGenOp < MOEOT > & _op, moeoArchive < MOEOT > & _archive)
{
/* the objective vector type */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/* the fitness assignment strategy */
std::string & fitnessParam = _parser.createParam(std::string("DomDepth"), "fitness",
"Fitness assignment scheme: Dummy, DomDepth or IndicatorBased", 'F',
"Evolution Engine").value();
std::string & indicatorParam = _parser.createParam(std::string("Epsilon"), "indicator",
"Binary indicator for IndicatorBased: Epsilon, Hypervolume", 'i',
"Evolution Engine").value();
double rho = _parser.createParam(1.1, "rho", "reference point for the hypervolume indicator", '\0',
"Evolution Engine").value();
double kappa = _parser.createParam(0.05, "kappa", "Scaling factor kappa for IndicatorBased", 'k',
"Evolution Engine").value();
moeoFitnessAssignment < MOEOT > * fitnessAssignment;
if (fitnessParam == std::string("Dummy"))
{
fitnessAssignment = new moeoDummyFitnessAssignment < MOEOT> ();
}
else if (fitnessParam == std::string("DomDepth"))
{
fitnessAssignment = new moeoDominanceDepthFitnessAssignment < MOEOT> ();
}
else if (fitnessParam == std::string("IndicatorBased"))
{
// metric
moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > *metric;
if (indicatorParam == std::string("Epsilon"))
{
metric = new moeoAdditiveEpsilonBinaryMetric < ObjectiveVector >;
}
else if (indicatorParam == std::string("Hypervolume"))
{
metric = new moeoHypervolumeBinaryMetric < ObjectiveVector > (rho);
}
else
{
std::string stmp = std::string("Invalid binary quality indicator: ") + indicatorParam;
throw std::runtime_error(stmp.c_str());
}
fitnessAssignment = new moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT > (*metric, kappa);
}
else
{
std::string stmp = std::string("Invalid fitness assignment strategy: ") + fitnessParam;
throw std::runtime_error(stmp.c_str());
}
_state.storeFunctor(fitnessAssignment);
/* the diversity assignment strategy */
eoValueParam<eoParamParamType> & diversityParam = _parser.createParam(eoParamParamType("Dummy"), "diversity",
"Diversity assignment scheme: Dummy, Sharing(nicheSize) or Crowding", 'D', "Evolution Engine");
eoParamParamType & diversityParamValue = diversityParam.value();
moeoDiversityAssignment < MOEOT > * diversityAssignment;
if (diversityParamValue.first == std::string("Dummy"))
{
diversityAssignment = new moeoDummyDiversityAssignment < MOEOT> ();
}
else if (diversityParamValue.first == std::string("Sharing"))
{
double nicheSize;
if (!diversityParamValue.second.size()) // no parameter added
{
std::cerr << "WARNING, no niche size given for Sharing, using 0.5" << std::endl;
nicheSize = 0.5;
diversityParamValue.second.push_back(std::string("0.5"));
}
else
{
nicheSize = atoi(diversityParamValue.second[0].c_str());
}
diversityAssignment = new moeoFrontByFrontSharingDiversityAssignment < MOEOT> (nicheSize);
}
else if (diversityParamValue.first == std::string("Crowding"))
{
diversityAssignment = new moeoFrontByFrontCrowdingDiversityAssignment < MOEOT> ();
}
else
{
std::string stmp = std::string("Invalid diversity assignment strategy: ") + diversityParamValue.first;
throw std::runtime_error(stmp.c_str());
}
_state.storeFunctor(diversityAssignment);
/* the comparator strategy */
std::string & comparatorParam = _parser.createParam(std::string("FitnessThenDiversity"), "comparator",
"Comparator scheme: FitnessThenDiversity, DiversityThenFitness or Aggregative", 'c', "Evolution Engine").value();
moeoComparator < MOEOT > * comparator;
if (comparatorParam == std::string("FitnessThenDiversity"))
{
comparator = new moeoFitnessThenDiversityComparator < MOEOT> ();
}
else if (comparatorParam == std::string("DiversityThenFitness"))
{
comparator = new moeoDiversityThenFitnessComparator < MOEOT> ();
}
else if (comparatorParam == std::string("Aggregative"))
{
comparator = new moeoAggregativeComparator < MOEOT> ();
}
else
{
std::string stmp = std::string("Invalid comparator strategy: ") + comparatorParam;
throw std::runtime_error(stmp.c_str());
}
_state.storeFunctor(comparator);
/* the selection strategy */
eoValueParam < eoParamParamType > & selectionParam = _parser.createParam(eoParamParamType("DetTour(2)"), "selection",
"Selection scheme: DetTour(T), StochTour(t) or Random", 'S', "Evolution Engine");
eoParamParamType & ppSelect = selectionParam.value();
moeoSelectOne < MOEOT > * select;
if (ppSelect.first == std::string("DetTour"))
{
unsigned int tSize;
if (!ppSelect.second.size()) // no parameter added
{
std::cerr << "WARNING, no parameter passed to DetTour, using 2" << std::endl;
tSize = 2;
// put back 2 in parameter for consistency (and status file)
ppSelect.second.push_back(std::string("2"));
}
else // parameter passed by user as DetTour(T)
{
tSize = atoi(ppSelect.second[0].c_str());
}
select = new moeoDetTournamentSelect < MOEOT > (*comparator, tSize);
}
else if (ppSelect.first == std::string("StochTour"))
{
double tRate;
if (!ppSelect.second.size()) // no parameter added
{
std::cerr << "WARNING, no parameter passed to StochTour, using 1" << std::endl;
tRate = 1;
// put back 1 in parameter for consistency (and status file)
ppSelect.second.push_back(std::string("1"));
}
else // parameter passed by user as StochTour(T)
{
tRate = atof(ppSelect.second[0].c_str());
}
select = new moeoStochTournamentSelect < MOEOT > (*comparator, tRate);
}
/*
else if (ppSelect.first == string("Roulette"))
{
// TO DO !
// ...
}
*/
else if (ppSelect.first == std::string("Random"))
{
select = new moeoRandomSelect <MOEOT > ();
}
else
{
std::string stmp = std::string("Invalid selection strategy: ") + ppSelect.first;
throw std::runtime_error(stmp.c_str());
}
_state.storeFunctor(select);
/* the replacement strategy */
std::string & replacementParam = _parser.createParam(std::string("Elitist"), "replacement",
"Replacement scheme: Elitist, Environmental or Generational", 'R', "Evolution Engine").value();
moeoReplacement < MOEOT > * replace;
if (replacementParam == std::string("Elitist"))
{
replace = new moeoElitistReplacement < MOEOT> (*fitnessAssignment, *diversityAssignment, *comparator);
}
else if (replacementParam == std::string("Environmental"))
{
replace = new moeoEnvironmentalReplacement < MOEOT> (*fitnessAssignment, *diversityAssignment, *comparator);
}
else if (replacementParam == std::string("Generational"))
{
replace = new moeoGenerationalReplacement < MOEOT> ();
}
else
{
std::string stmp = std::string("Invalid replacement strategy: ") + replacementParam;
throw std::runtime_error(stmp.c_str());
}
_state.storeFunctor(replace);
/* the number of offspring */
eoValueParam < eoHowMany > & offspringRateParam = _parser.createParam(eoHowMany(1.0), "nbOffspring",
"Number of offspring (percentage or absolute)", 'O', "Evolution Engine");
// the general breeder
eoGeneralBreeder < MOEOT > * breed = new eoGeneralBreeder < MOEOT > (*select, _op, offspringRateParam.value());
_state.storeFunctor(breed);
// the eoEasyEA
moeoEA < MOEOT > * algo = new moeoEasyEA < MOEOT > (_continue, _eval, *breed, *replace, *fitnessAssignment, *diversityAssignment);
_state.storeFunctor(algo);
return *algo;
}
#endif /*MAKE_EA_MOEO_H_*/

View file

@ -0,0 +1,129 @@
/*
* <moeoExhaustiveNeighborhoodExplorer.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEOEXHAUSTIVENEIGHBORHOODEXPLORER_H
#define _MOEOEXHAUSTIVENEIGHBORHOODEXPLORER_H
#include <eoPop.h>
#include <neighborhood/moNeighbor.h>
#include <neighborhood/moNeighborhood.h>
#include <explorer/moeoPopNeighborhoodExplorer.h>
#include <eval/moEval.h>
/**
* Explorer which explore all the neighborhood
*/
template < class Neighbor>
class moeoExhaustiveNeighborhoodExplorer : public moeoPopNeighborhoodExplorer <Neighbor>
{
/** Alias for the type */
typedef typename Neighbor::EOT MOEOT;
/** Alias for the objeciveVector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
public:
/**
* Constructor
* @param _neighborhood a neighborhood
* @param _eval neighbor evaluation function
*/
moeoExhaustiveNeighborhoodExplorer(
moNeighborhood<Neighbor>& _neighborhood,
moEval < Neighbor > & _eval):
neighborhood(_neighborhood), eval(_eval){}
/**
* functor to explore the neighborhood
* @param _src the population to explore
* @param _select contains index of individuals from the population to explore
* @param _dest contains new generated individuals
*/
void operator()(eoPop < MOEOT > & _src, std::vector < unsigned int> _select, eoPop < MOEOT > & _dest)
{
for(unsigned int i=0; i<_select.size(); i++)
explore(_src[_select[i]], _dest);
}
private:
/**
* explorer of one individual
* @param _src the individual to explore
* @param _dest contains new generated individuals
*/
void explore(MOEOT & _src , eoPop < MOEOT > & _dest)
{
//if the neighborhood is not empty
if(neighborhood.hasNeighbor(_src)){
//init the neighborhood
neighborhood.init(_src, neighbor);
//copy the solution (_src) at the end of the destination (_dest)
_dest.push_back(_src);
//eval the neighbor
eval(_dest.back(),neighbor);
//move the copy
neighbor.move(_dest.back());
//affect objective vector to the copy
_dest.back().objectiveVector(neighbor.fitness());
//fix its flag to 0 (unvisited solution)
_dest.back().flag(0);
//repeat all instructions for each neighbor in the neighborhood
while (neighborhood.cont(_src)){
neighborhood.next(_src, neighbor);
_dest.push_back(_src);
eval(_dest.back(),neighbor);
neighbor.move(_dest.back());
_dest.back().objectiveVector(neighbor.fitness());
_dest.back().flag(0);
}
//fix the source flag to 1 (visited solution)
_src.flag(1);
}
}
/** Neighbor */
Neighbor neighbor;
/** Neighborhood */
moNeighborhood<Neighbor>& neighborhood;
/** neighbor evaluation function */
moEval < Neighbor > & eval;
};
#endif /*_MOEOEXHAUSTIVENEIGHBORHOODEXPLORER_H_*/

View file

@ -0,0 +1,124 @@
/*
* <moeoFirstImprovingNeighborhoodExplorer.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEOFIRSTIMPROVINGNEIGHBORHOODEXPLORER_H
#define _MOEOFIRSTIMPROVINGNEIGHBORHOODEXPLORER_H
#include <explorer/moeoSubNeighborhoodExplorer.h>
/**
* Explorer which explore the neighborhood until a improving neighbor is found.
* No dominating neighbor are keeped.
*/
template < class Neighbor >
class moeoFirstImprovingNeighborhoodExplorer : public moeoSubNeighborhoodExplorer < Neighbor >
{
/** Alias for the type */
typedef typename Neighbor::EOT MOEOT;
/** Alias for the objeciveVector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
using moeoSubNeighborhoodExplorer<Neighbor>::neighborhood;
using moeoSubNeighborhoodExplorer<Neighbor>::neighbor;
public:
/**
* Constructor
* @param _neighborhood a neighborhood
* @param _eval neighbor evaluation function
*/
moeoFirstImprovingNeighborhoodExplorer(
moNeighborhood<Neighbor>& _neighborhood,
moEval < Neighbor > & _eval):
moeoSubNeighborhoodExplorer< Neighbor >(_neighborhood, 0), eval(_eval){}
private:
/**
* explorer of one individual
* @param _src the individual to explore
* @param _dest contains new generated individuals
*/
void explore(MOEOT & _src, eoPop < MOEOT > & _dest)
{
//if the neighborhood is not empty
if(neighborhood.hasNeighbor(_src)){
//init the neighborhood
neighborhood.init(_src, neighbor);
//eval the neighbor
cycle(_src, _dest);
//repeat all instructions for each neighbor in the neighborhood until a best neighbor is found
while (!comparator(_src.objectiveVector(), neighbor.fitness()) && neighborhood.cont(_src)){
neighborhood.next(_src, neighbor);
cycle(_src, _dest);
}
//if all neighbors are been visited, fix the source flag to 1 (visited solution)
if(!neighborhood.cont(_src))
_src.flag(1);
}
}
/**
* subfunction of explore
* @param _src the individual to explore
* @param _dest contains new generated individuals
*/
void cycle(MOEOT & _src, eoPop < MOEOT > & _dest){
eval(_src, neighbor);
if(!comparator(neighbor.fitness(), _src.objectiveVector())){
//copy the solution (_src) at the end of the destination (_dest)
_dest.push_back(_src);
//move the copy
neighbor.move(_dest.back());
//affect objective vector to the copy
_dest.back().objectiveVector(neighbor.fitness());
//fix its flag to 0 (unvisited solution)
_dest.back().flag(0);
_dest.back().fitness(0);
}
}
/** Objective Vector Pareto Comparator */
moeoParetoObjectiveVectorComparator<ObjectiveVector> comparator;
/** neighbor evaluation function */
moEval < Neighbor > & eval;
};
#endif /*_MOEOFIRSTIMPROVINGNEIGHBORHOODEXPLORER_H_*/

View file

@ -0,0 +1,112 @@
/*
* <moeoNoDesimprovingNeighborhoodExplorer.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEONODESIMPROVINGNEIGHBORHOODEXPLORER_H
#define _MOEONODESIMPROVINGNEIGHBORHOODEXPLORER_H
#include <explorer/moeoSubNeighborhoodExplorer.h>
/**
* Explorer which explore the neighborhood until a no desimproving neighbor is found.
*/
template < class Neighbor >
class moeoNoDesimprovingNeighborhoodExplorer : public moeoSubNeighborhoodExplorer < Neighbor >
{
/** Alias for the type */
typedef typename Neighbor::EOT MOEOT;
/** Alias for the objeciveVector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
using moeoSubNeighborhoodExplorer<Neighbor>::neighborhood;
using moeoSubNeighborhoodExplorer<Neighbor>::neighbor;
public:
/**
* Constructor
* @param _neighborhood a neighborhood
* @param _eval a neighbor evaluation function
*/
moeoNoDesimprovingNeighborhoodExplorer(
moNeighborhood<Neighbor>& _neighborhood,
moEval < Neighbor > & _eval)
: moeoSubNeighborhoodExplorer< Neighbor >(_neighborhood, 0), eval(_eval){}
private:
/**
* explorer of one individual
* @param _src the individual to explore
* @param _dest contains new generated individuals
*/
void explore(MOEOT & _src, eoPop < MOEOT > & _dest)
{
bool tmp=true;
if(neighborhood.hasNeighbor(_src)){
neighborhood.init(_src, neighbor);
eval(_src,neighbor);
if(!comparator(neighbor.fitness(), _src.objectiveVector())){
_dest.push_back(_src);
neighbor.move(_dest.back());
_dest.back().objectiveVector(neighbor.fitness());
_dest.back().flag(0);
tmp=false;
}
while (neighborhood.cont(_src) && tmp){
neighborhood.next(_src, neighbor);
eval(_src,neighbor);
if(!comparator(neighbor.fitness(), _src.objectiveVector())){
_dest.push_back(_src);
neighbor.move(_dest.back());
_dest.back().objectiveVector(neighbor.fitness());
_dest.back().flag(0);
tmp=false;
}
}
if(!neighborhood.cont(_src))
_src.flag(1);
}
}
/** Objective Vector Pareto Comparator */
moeoParetoObjectiveVectorComparator<ObjectiveVector> comparator;
/** neighbor evaluation function */
moEval < Neighbor > & eval;
};
#endif /*_MOEONODESIMPROVINGNEIGHBORHOODEXPLORER_H_*/

View file

@ -0,0 +1,60 @@
/*
* <moeoPopNeighborhoodExplorer.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEOPOPNEIGHBORHOODEXPLORER_H
#define _MOEOPOPNEIGHBORHOODEXPLORER_H
#include <eoPop.h>
/**
* Abstract class for multi-objective local search neighborhood exploration
*/
template < class Neighbor >
class moeoPopNeighborhoodExplorer: public eoFunctorBase{
public:
typedef typename Neighbor::EOT MOEOT;
/**
* abstract functor which realize exploration
*/
virtual void operator()(eoPop<MOEOT> &, std::vector <unsigned int>, eoPop<MOEOT> &) = 0;
};
#endif /*MOEONEIGHBORHOODEXPLORER_H_*/

View file

@ -0,0 +1,124 @@
/*
* <moeoSubNeighborhoodExplorer.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEOSIMPLESUBNEIGHBORHOODEXPLORER_H
#define _MOEOSIMPLESUBNEIGHBORHOODEXPLORER_H
#include <explorer/moeoSubNeighborhoodExplorer.h>
/**
* Explorer which explore a part of the neighborhood
*/
template < class Neighbor >
class moeoSimpleSubNeighborhoodExplorer : public moeoSubNeighborhoodExplorer < Neighbor >
{
/** Alias for the type */
typedef typename Neighbor::EOT MOEOT;
/** Alias for the objeciveVector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
using moeoSubNeighborhoodExplorer<Neighbor>::neighborhood;
using moeoSubNeighborhoodExplorer<Neighbor>::neighbor;
using moeoSubNeighborhoodExplorer<Neighbor>::number;
public:
/**
* Constructor
* @param _neighborhood a neighborhood
* @param _number number of neighbor to explore
* @param _eval a neighbor evaluation function
*/
moeoSimpleSubNeighborhoodExplorer(
moNeighborhood<Neighbor>& _neighborhood,
unsigned int _number,
moEval < Neighbor > & _eval)
: moeoSubNeighborhoodExplorer<Neighbor>(_neighborhood, _number), eval(_eval){}
private:
/**
* explorer of one individual
* @param _src the individual to explore
* @param _dest contains new generated individuals
*/
void explore(MOEOT & _src, eoPop < MOEOT > & _dest)
{
unsigned int tmp=number;
//if the neighborhood is not empty
if(neighborhood.hasNeighbor(_src) && tmp>0){
//init the neighborhood
neighborhood.init(_src, neighbor);
//eval the neighbor
cycle(_src, _dest);
tmp--;
//repeat all instructions for each neighbor in the neighborhood until a best neighbor is found
while (neighborhood.cont(_src) && tmp>0){
neighborhood.next(_src, neighbor);
cycle(_src, _dest);
tmp--;
}
//if all neighbors are been visited, fix the source flag to 1 (visited solution)
if(!neighborhood.cont(_src))
_src.flag(1);
}
}
/**
* subfunction of explore
* @param _src the individual to explore
* @param _dest contains new generated individuals
*/
void cycle(MOEOT & _src, eoPop < MOEOT > & _dest){
eval(_src, neighbor);
//copy the solution (_src) at the end of the destination (_dest)
_dest.push_back(_src);
//move the copy
neighbor.move(_dest.back());
//affect objective vector to the copy
_dest.back().objectiveVector(neighbor.fitness());
//fix its flag to 0 (unvisited solution)
_dest.back().flag(0);
}
/** Incremental evaluation of a neighbor */
moEval < Neighbor > & eval;
};
#endif /*_MOEOSIMPLESUBNEIGHBORHOODEXPLORER_H_*/

View file

@ -0,0 +1,101 @@
/*
* <moeoSubNeighborhoodExplorer.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEOSUBNEIGHBORHOODEXPLORER_H
#define _MOEOSUBNEIGHBORHOODEXPLORER_H
#include <eoPop.h>
#include <neighborhood/moNeighbor.h>
#include <neighborhood/moNeighborhood.h>
#include <explorer/moeoPopNeighborhoodExplorer.h>
/**
* Explorer which explore a part of the neighborhood
*/
template < class Neighbor >
class moeoSubNeighborhoodExplorer : public moeoPopNeighborhoodExplorer < Neighbor >
{
/** Alias for the type */
typedef typename Neighbor::EOT MOEOT;
/** Alias for the objeciveVector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
public:
/**
* Constructor
* @param _neighborhood a neighborhood
* @param _number the number of neighbor to explore
*/
moeoSubNeighborhoodExplorer(
moNeighborhood<Neighbor>& _neighborhood,
unsigned int _number)
: neighborhood(_neighborhood), number(_number){}
/**
* functor to explore the neighborhood
* @param _src the population to explore
* @param _select contains index of individuals from the population to explore
* @param _dest contains new generated individuals
*/
void operator()(eoPop < MOEOT > & _src, std::vector <unsigned int> _select, eoPop < MOEOT > & _dest)
{
for(unsigned int i=0; i<_select.size(); i++)
explore(_src[_select[i]], _dest);
}
protected:
/**
* explorer of one individual
* @param _src the individual to explore
* @param _dest contains new generated individuals
*/
virtual void explore(MOEOT & _src, eoPop < MOEOT > & _dest) = 0;
/** Neighbor */
Neighbor neighbor;
/** Neighborhood */
moNeighborhood<Neighbor> & neighborhood;
/** number of neighbor to explore for each selected individual*/
unsigned int number;
};
#endif /*_MOEOSUBNEIGHBORHOODEXPLORER_H_*/

View file

@ -0,0 +1,129 @@
/*
* <moeoAggregationFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* François Legillon
*
* 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
*
*/
//-----------------------------------------------------------------------------
// moeoAggregationFitnessAssignment.h
//-----------------------------------------------------------------------------
#ifndef MOEOAGGREGATIONFITNESSASSIGNMENT_H_
#define MOEOAGGREGATIONFITNESSASSIGNMENT_H_
#include <eoPop.h>
#include <eoEvalFunc.h>
#include <fitness/moeoSingleObjectivization.h>
/*
* Fitness assignment scheme which use weight for each objective
*/
template < class MOEOT >
class moeoAggregationFitnessAssignment : public moeoSingleObjectivization < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
typedef typename MOEOT::Fitness Fitness;
/**
* Default ctor
* @param _weight vectors contains all weights.
* @param _eval a eval function, to revalidate the objectiveVector if needed
*/
moeoAggregationFitnessAssignment(std::vector<double> & _weight,eoEvalFunc<MOEOT> &_eval) : weight(_weight),eval(_eval){}
/**
* Ctor with a dummy evaluation function
* @param _weight vectors contains all weights.
*/
moeoAggregationFitnessAssignment(std::vector<double> & _weight) : weight(_weight),eval(defaultEval){}
/**
* Sets the fitness values for _moeot
* @param _moeot the MOEOT
*/
virtual void operator()(MOEOT & _moeot){
if (_moeot.invalidObjectiveVector())
eval(_moeot);
_moeot.fitness(operator()(_moeot.objectiveVector()));
}
/**
* function which calculate the fitness from an objectiveVector (which has troi be valid.)
* @param _mo an valid objectiveVector
* @return the fitness value of _mo
*/
virtual Fitness operator()(const typename MOEOT::ObjectiveVector & _mo){
unsigned int dim=_mo.nObjectives();
Fitness res=0;
if (dim>weight.size()){
std::cout<<"moeoAggregationFitnessAssignmentFitness: Error -> given weight dimension is smaller than MOEOTs"<<std::endl;
return res;
}
for(unsigned int l=0; l<dim; l++){
if (_mo.minimizing(l))
res-=(_mo[l]) * weight[l];
else
res+=(_mo[l]) * weight[l];
}
return res;
}
/**
* Sets the fitness values for every solution contained in the population _pop (and in the archive)
* @param _pop the population
*/
virtual void operator()(eoPop < MOEOT > & _pop){
for (unsigned int k=0; k < _pop.size(); k++)
operator()(_pop[k]);
}
/**
* Warning: no yet implemented: Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec){}
private:
class DummyEval: public eoEvalFunc<MOEOT>{
void operator()(MOEOT &moeo){}
}defaultEval;
//the vector of weight
std::vector<double>& weight;
eoEvalFunc<MOEOT>& eval;
};
#endif /*MOEOAGGREGATIONFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,65 @@
/*
* <moeoBinaryIndicatorBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOBINARYINDICATORBASEDFITNESSASSIGNMENT_H_
#define MOEOBINARYINDICATORBASEDFITNESSASSIGNMENT_H_
#include <fitness/moeoIndicatorBasedFitnessAssignment.h>
/**
* moeoIndicatorBasedFitnessAssignment for binary indicators.
*/
template < class MOEOT >
class moeoBinaryIndicatorBasedFitnessAssignment : public moeoIndicatorBasedFitnessAssignment < MOEOT >
{
public:
/** The type for objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Updates the fitness values of the whole population _pop by taking the new objective vector _objVec into account
* and returns the fitness value of _objVec.
* @param _pop the population
* @param _objVec the objective vector
*/
virtual double updateByAdding(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) = 0;
};
#endif /*MOEOINDICATORBASEDFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,171 @@
/*
* <moeoConstraintFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* François Legillon
*
* 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
*
*/
//-----------------------------------------------------------------------------
// moeoConstraintFitnessAssignment.h
//-----------------------------------------------------------------------------
#ifndef MOEOCONSTRAINTFITNESSASSIGNMENT_H_
#define MOEOCONSTRAINTFITNESSASSIGNMENT_H_
#include <eoPop.h>
#include <fitness/moeoSingleObjectivization.h>
#include <utils/moeoObjectiveVectorNormalizer.h>
/*
* Fitness assignment scheme which give a penalty if MOEOT does not respect constraints
*/
template < class MOEOT >
class moeoConstraintFitnessAssignment : public moeoSingleObjectivization < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/** the fitness type of the solutions */
typedef typename MOEOT::Fitness Fitness;
/** the type of the solutions */
typedef typename ObjectiveVector::Type Type;
/**
* Default ctor
* @param _weight vectors contains all weights to apply for not respecting the contraint in each dimension.
* @param _constraint vector containing the constraints, normalizer is applied to it
* @param _to_optimize dimension in which we ignore the constraint
* @param _normalizer normalizer to apply to each objective
*/
moeoConstraintFitnessAssignment(std::vector<double> & _weight, ObjectiveVector &_constraint, int _to_optimize, moeoObjectiveVectorNormalizer<MOEOT> &_normalizer, eoEvalFunc<MOEOT> &_eval) : weight(_weight),constraint(_constraint),to_optimize(_to_optimize),normalizer(_normalizer),eval(_eval),to_eval(true){}
/**
* Ctor with a dummy eval
* @param _weight vectors contains all weights to apply for not respecting the contraint in each dimension.
* @param _constraint vector containing the constraints, normalizer is applied to it
* @param _to_optimize dimension in which we ignore the constraint
* @param _normalizer normalizer to apply to each objective
*/
moeoConstraintFitnessAssignment(std::vector<double> & _weight, ObjectiveVector &_constraint, int _to_optimize, moeoObjectiveVectorNormalizer<MOEOT> &_normalizer) : weight(_weight), constraint(_constraint), to_optimize(_to_optimize), normalizer(_normalizer), eval(defaultEval), to_eval(false){}
/**
* Sets the fitness values for every solution contained in the population _pop (and in the archive)
* @param _mo the MOEOT
*/
void operator()(MOEOT & _mo){
if (to_eval && _mo.invalidObjectiveVector())
eval(_mo);
_mo.fitness(operator()(_mo.objectiveVector()));
}
/**
* Calculate a fitness from a valid objectiveVector
* @param _mo a valid objectiveVector
* @return the fitness of _mo
*/
Fitness operator()(const typename MOEOT::ObjectiveVector & _mo){
unsigned int dim=_mo.nObjectives();
Fitness res=0;
if (dim>weight.size()){
std::cout<<"moeoAggregationFitnessAssignmentFitness: ouch, given weight dimension is smaller than MOEOTs"<<std::endl;
}
else{
for(unsigned int l=0; l<dim; l++){
if ((int)l==to_optimize)
if (_mo.minimizing(l))
res-=(normalizer(_mo)[l]) * weight[l];
else
res+=(normalizer(_mo)[l]) * weight[l];
else{
if(_mo.minimizing(l)){
if (normalizer(_mo)[l]>normalizer(constraint)[l])
res-=(normalizer(_mo)[l]-normalizer(constraint)[l])*weight[l];
}
else{
if (normalizer(_mo)[l]<normalizer(constraint)[l])
//negative so we add it instead of removing it
res+=(normalizer(_mo)[l]-normalizer(constraint)[l])*weight[l];
}
}
}
}
return res;
}
/**
* Sets the fitness values for every solution contained in the population _pop (and in the archive)
* @param _pop the population
*/
void operator()(eoPop < MOEOT > & _pop)
{
for(unsigned int k=0; k<_pop.size(); k++)
operator()(_pop[k]);
}
/**
* Warning: no yet implemented: Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
//std::cout << "WARNING : updateByDeleting not implemented in moeoAssignmentFitnessAssignment" << std::endl;
}
private:
//dummy evaluation function
class DummyEval: public eoEvalFunc<MOEOT>{
void operator()(MOEOT &moeo){
}
} defaultEval;
//the vector of weight
std::vector<double> weight;
//the vector of constraints
ObjectiveVector constraint;
//index of the objective to optimize
int to_optimize;
//the normalizer
moeoObjectiveVectorNormalizer<MOEOT>& normalizer;
//the evaluation function
eoEvalFunc<MOEOT> &eval;
//true if the evaluation has to be done
bool to_eval;
};
#endif /*MOEOAGGREGATIONFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,50 @@
/*
* <moeoCriterionBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOCRITERIONBASEDFITNESSASSIGNMENT_H_
#define MOEOCRITERIONBASEDFITNESSASSIGNMENT_H_
#include <fitness/moeoFitnessAssignment.h>
/**
* moeoCriterionBasedFitnessAssignment is a moeoFitnessAssignment for criterion-based strategies.
*/
template < class MOEOT >
class moeoCriterionBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT >
{};
#endif /*MOEOCRITERIONBASEDFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,50 @@
/*
* <moeoDominanceBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEODOMINANCEBASEDFITNESSASSIGNMENT_H_
#define MOEODOMINANCEBASEDFITNESSASSIGNMENT_H_
#include <fitness/moeoFitnessAssignment.h>
/**
* moeoDominanceBasedFitnessAssignment is a moeoFitnessAssignment for dominance-based strategies.
*/
template < class MOEOT >
class moeoDominanceBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT >
{};
#endif /*MOEODOMINANCEBASEDFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,143 @@
/*
* <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/moeoDominanceBasedFitnessAssignment.h>
#include <utils/moeoDominanceMatrix.h>
/**
* Fitness assignment sheme that computes how many solutions does each solution dominate.
*/
template < class MOEOT >
class moeoDominanceCountFitnessAssignment : public moeoDominanceBasedFitnessAssignment < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Default ctor
* @param _nocopy boolean to move away clone individuals (default = false)
*/
moeoDominanceCountFitnessAssignment(bool _nocopy=false) : comparator(paretoComparator), archive(defaultArchive), matrix(_nocopy)
{}
/**
* Ctor where you can choose your own archive
* @param _archive an archive to be included in the fitness assignment process
* @param _nocopy boolean to penalize clone individuals (default = false)
*/
moeoDominanceCountFitnessAssignment(moeoArchive < MOEOT > & _archive, bool _nocopy=false) : 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 penalize clone individuals (default = false)
*/
moeoDominanceCountFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _nocopy=false) : 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 an archive to be included in the fitness assignment process
* @param _nocopy boolean to penalize clone individuals (default = false)
*/
moeoDominanceCountFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, moeoArchive < MOEOT > & _archive, bool _nocopy=false) : comparator(_comparator), archive(_archive), matrix(_comparator, _nocopy)
{}
/**
* Sets the fitness values for every solution contained in the population _pop (and in the 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; k++)
archive[k].fitness(matrix.count(k));
for (unsigned int k=i; k<i+j; k++)
_pop[k-i].fitness(matrix.count(k));
}
/**
* Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoDominanceCountFitnessAssignment" << std::endl;
}
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 to be included in the fitness assignment process */
moeoArchive < MOEOT > & archive;
/** Default archive */
moeoUnboundedArchive < MOEOT > defaultArchive;
/** Dominance Matrix */
moeoDominanceMatrix < MOEOT > matrix;
};
#endif /*MOEODOMINANCECOUNTFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,162 @@
/*
* <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/moeoDominanceBasedFitnessAssignment.h>
#include <utils/moeoDominanceMatrix.h>
/**
* Fitness assignment sheme that sum-up the ranks of all solutions dominated by each solution.
* This strategy is used, for instance, in SPEA2.
* E. Zitzler, M. Laumanns, and L. Thiele. SPEA2: Improving the Strength Pareto Evolutionary Algorithm. Technical Report 103,
* Computer Engineering and Networks Laboratory (TIK), ETH Zurich, Zurich, Switzerland, 2001.
*/
template < class MOEOT >
class moeoDominanceCountRankingFitnessAssignment : public moeoDominanceBasedFitnessAssignment < 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 the archive)
* @param _pop the population
*/
void operator()(eoPop < MOEOT > & _pop)
{
unsigned int i= _pop.size();
unsigned int j= archive.size();
matrix(archive,_pop);
for (unsigned int k=0; k<j; k++)
archive[k].fitness(countRanking(k));
for (unsigned int k=j; k<i+j; k++)
_pop[k-j].fitness(countRanking(k));
}
/**
* Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoDominanceCountRankingFitnessAssignment" << std::endl;
}
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 to be included in the fitness assignment process */
moeoArchive < MOEOT > & archive;
/** Default archive */
moeoUnboundedArchive < MOEOT > defaultArchive;
/** Dominance Matrix */
moeoDominanceMatrix <MOEOT> matrix;
/**
* @param _i index of the column
*/
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_*/

View file

@ -0,0 +1,265 @@
/*
* <moeoDominanceDepthFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEODOMINANCEDEPTHFITNESSASSIGNMENT_H_
#define MOEODOMINANCEDEPTHFITNESSASSIGNMENT_H_
#include <vector>
#include <eoPop.h>
#include <comparator/moeoObjectiveObjectiveVectorComparator.h>
#include <comparator/moeoObjectiveVectorComparator.h>
#include <comparator/moeoParetoObjectiveVectorComparator.h>
#include <fitness/moeoDominanceBasedFitnessAssignment.h>
/**
* Fitness assignment sheme based on Pareto-dominance count proposed in:
* N. Srinivas, K. Deb, "Multiobjective Optimization Using Nondominated Sorting in Genetic Algorithms", Evolutionary Computation vol. 2, no. 3, pp. 221-248 (1994)
* and in:
* K. Deb, A. Pratap, S. Agarwal, T. Meyarivan, "A Fast and Elitist Multi-Objective Genetic Algorithm: NSGA-II", IEEE Transactions on Evolutionary Computation, vol. 6, no. 2 (2002).
* This strategy is, for instance, used in NSGA and NSGA-II.
*/
template < class MOEOT >
class moeoDominanceDepthFitnessAssignment : public moeoDominanceBasedFitnessAssignment < MOEOT >
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Default ctor
*/
moeoDominanceDepthFitnessAssignment() : comparator(paretoComparator)
{}
/**
* Ctor where you can choose your own way to compare objective vectors
* @param _comparator the functor used to compare objective vectors
*/
moeoDominanceDepthFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator) : comparator(_comparator)
{}
/**
* Sets the fitness values for every solution contained in the population _pop
* @param _pop the population
*/
void operator()(eoPop < MOEOT > & _pop)
{
// number of objectives for the problem under consideration
unsigned int nObjectives = MOEOT::ObjectiveVector::nObjectives();
if (nObjectives == 1)
{
// one objective
oneObjective(_pop);
}
else if (nObjectives == 2)
{
// two objectives (the two objectives function is still to implement)
mObjectives(_pop);
}
else if (nObjectives > 2)
{
// more than two objectives
mObjectives(_pop);
}
else
{
// problem with the number of objectives
throw std::runtime_error("Problem with the number of objectives in moeoDominanceDepthFitnessAssignment");
}
// a higher fitness is better, so the values need to be inverted
double max = _pop[0].fitness();
for (unsigned int i=1 ; i<_pop.size() ; i++)
{
max = std::max(max, _pop[i].fitness());
}
for (unsigned int i=0 ; i<_pop.size() ; i++)
{
_pop[i].fitness(max - _pop[i].fitness());
}
}
/**
* Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
for (unsigned int i=0; i<_pop.size(); i++)
{
// if _pop[i] is dominated by _objVec
if ( comparator(_pop[i].objectiveVector(), _objVec) )
{
_pop[i].fitness(_pop[i].fitness()+1);
}
}
}
private:
/** Functor to compare two objective vectors */
moeoObjectiveVectorComparator < ObjectiveVector > & comparator;
/** Functor to compare two objective vectors according to Pareto dominance relation */
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
/** Functor allowing to compare two solutions according to their first objective value, then their second, and so on. */
class ObjectiveComparator : public moeoComparator < MOEOT >
{
public:
/**
* Returns true if _moeo1 < _moeo2 on the first objective, then on the second, and so on
* @param _moeo1 the first solution
* @param _moeo2 the second solution
*/
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
return cmp(_moeo1.objectiveVector(), _moeo2.objectiveVector());
}
private:
/** the corresponding comparator for objective vectors */
moeoObjectiveObjectiveVectorComparator < ObjectiveVector > cmp;
}
objComparator;
/**
* Sets the fitness values for mono-objective problems
* @param _pop the population
*/
void oneObjective (eoPop < MOEOT > & _pop)
{
// sorts the population in the ascending order
std::sort(_pop.begin(), _pop.end(), objComparator);
// assign fitness values
unsigned int rank = 1;
_pop[_pop.size()-1].fitness(rank);
for (int i=_pop.size()-2; i>=0; i--)
{
if (_pop[i].objectiveVector() != _pop[i+1].objectiveVector())
{
rank++;
}
_pop[i].fitness(rank);
}
}
/**
* Sets the fitness values for bi-objective problems with a complexity of O(n log n), where n stands for the population size
* @param _pop the population
*/
void twoObjectives (eoPop < MOEOT > & _pop)
{
//... TO DO !
}
/**
* Sets the fitness values for problems with more than two objectives with a complexity of O(n² log n), where n stands for the population size
* @param _pop the population
*/
void mObjectives (eoPop < MOEOT > & _pop)
{
// S[i] = indexes of the individuals dominated by _pop[i]
std::vector < std::vector<unsigned int> > S(_pop.size());
// n[i] = number of individuals that dominate the individual _pop[i]
std::vector < unsigned int > n(_pop.size(), 0);
// fronts: F[i] = indexes of the individuals contained in the ith front
std::vector < std::vector<unsigned int> > F(_pop.size()+2);
// used to store the number of the first front
F[1].reserve(_pop.size());
for (unsigned int p=0; p<_pop.size(); p++)
{
for (unsigned int q=0; q<_pop.size(); q++)
{
// if q is dominated by p
if ( comparator(_pop[q].objectiveVector(), _pop[p].objectiveVector()) )
{
// add q to the set of solutions dominated by p
S[p].push_back(q);
}
// if p is dominated by q
else if ( comparator(_pop[p].objectiveVector(), _pop[q].objectiveVector()) )
{
// increment the domination counter of p
n[p]++;
}
}
// if no individual dominates p
if (n[p] == 0)
{
// p belongs to the first front
_pop[p].fitness(1);
F[1].push_back(p);
}
}
// front counter
unsigned int counter=1;
unsigned int p,q;
while (! F[counter].empty())
{
// used to store the number of the next front
F[counter+1].reserve(_pop.size());
for (unsigned int i=0; i<F[counter].size(); i++)
{
p = F[counter][i];
for (unsigned int j=0; j<S[p].size(); j++)
{
q = S[p][j];
n[q]--;
// if no individual dominates q anymore
if (n[q] == 0)
{
// q belongs to the next front
_pop[q].fitness(counter+1);
F[counter+1].push_back(q);
}
}
}
counter++;
}
}
} ;
#endif /*MOEODOMINANCEDEPTHFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,149 @@
/*
* <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 <archive/moeoUnboundedArchive.h>
#include <comparator/moeoObjectiveVectorComparator.h>
#include <comparator/moeoParetoObjectiveVectorComparator.h>
#include <fitness/moeoDominanceBasedFitnessAssignment.h>
#include <utils/moeoDominanceMatrix.h>
/**
* Fitness assignment sheme that computes how many solutions each solution is dominated by.
*/
template < class MOEOT >
class moeoDominanceRankFitnessAssignment : public moeoDominanceBasedFitnessAssignment < 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 penalize clone individuals (default = false)
*/
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 an archive to be included in the fitness assignment process
* @param _start a start value used to determine the fitness (default _start = 1.0)
* @param _nocopy boolean to penalize clone individuals (default = false)
*/
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 penalize clone individuals (default = false)
*/
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 an archive to be included in the fitness assignment process
* @param _start a start value used to determine the fitness (default _start = 1.0)
* @param _nocopy boolean to penalize clone individuals (default = false)
*/
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 the 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; k++)
archive[k].fitness(-(matrix.rank(k)+start));
for (unsigned int k=i; k<i+j; k++)
_pop[k-i].fitness(-(matrix.rank(k)+start));
}
/**
* Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
std::cout << "WARNING : updateByDeleting not implemented in moeoDominanceRankFitnessAssignment" << std::endl;
}
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 to be included in the fitness assignment process */
moeoArchive < MOEOT > & archive;
/** Default archive */
moeoUnboundedArchive < MOEOT > defaultArchive;
/** Start value */
double start;
/** Dominance Matrix */
moeoDominanceMatrix < MOEOT > matrix;
};
#endif /*MOEODOMINANCERANKFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,84 @@
/*
* <moeoDummyFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEODUMMYFITNESSASSIGNMENT_H_
#define MOEODUMMYFITNESSASSIGNMENT_H_
#include <fitness/moeoFitnessAssignment.h>
/**
* moeoDummyFitnessAssignment is a moeoFitnessAssignment that gives the value '0' as the individual's fitness for a whole population if it is invalid.
*/
template < class MOEOT >
class moeoDummyFitnessAssignment : public moeoFitnessAssignment < MOEOT >
{
public:
/** The type for objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Sets the fitness to '0' for every individuals of the population _pop if it is invalid
* @param _pop the population
*/
void operator () (eoPop < MOEOT > & _pop)
{
for (unsigned int idx = 0; idx<_pop.size (); idx++)
{
if (_pop[idx].invalidFitness())
{
// set the diversity to 0
_pop[idx].fitness(0.0);
}
}
}
/**
* Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
// nothing to do... ;-)
}
};
#endif /*MOEODUMMYFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,227 @@
/*
* <moeoExpBinaryIndicatorBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOEXPBINARYINDICATORBASEDFITNESSASSIGNMENT_H_
#define MOEOEXPBINARYINDICATORBASEDFITNESSASSIGNMENT_H_
#include <math.h>
#include <vector>
#include <eoPop.h>
#include <fitness/moeoBinaryIndicatorBasedFitnessAssignment.h>
#include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
#include <utils/moeoConvertPopToObjectiveVectors.h>
/**
* Fitness assignment sheme based on an indicator proposed in:
* E. Zitzler, S. Künzli, "Indicator-Based Selection in Multiobjective Search", Proc. 8th International Conference on Parallel Problem Solving from Nature (PPSN VIII), pp. 832-842, Birmingham, UK (2004).
* This strategy is, for instance, used in IBEA.
*/
template < class MOEOT >
class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorBasedFitnessAssignment < MOEOT >
{
public:
/** The type of objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Ctor.
* @param _metric the quality indicator
* @param _kappa the scaling factor
*/
moeoExpBinaryIndicatorBasedFitnessAssignment(moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa = 0.05) : metric(_metric), kappa(_kappa)
{}
/**
* Sets the fitness values for every solution contained in the population _pop
* @param _pop the population
*/
void operator()(eoPop < MOEOT > & _pop)
{
// 1 - setting of the bounds
setup(_pop);
// 2 - computing every indicator values
computeValues(_pop);
// 3 - setting fitnesses
setFitnesses(_pop);
}
/**
* Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
std::vector < double > v;
v.resize(_pop.size());
for (unsigned int i=0; i<_pop.size(); i++)
{
v[i] = metric(_objVec, _pop[i].objectiveVector());
}
for (unsigned int i=0; i<_pop.size(); i++)
{
_pop[i].fitness( _pop[i].fitness() + exp(-v[i]/kappa) );
}
}
/**
* Updates the fitness values of the whole population _pop by taking the adding of the objective vector _objVec into account
* and returns the fitness value of _objVec.
* @param _pop the population
* @param _objVec the objective vector
*/
double updateByAdding(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
std::vector < double > v;
// update every fitness values to take the new individual into account
v.resize(_pop.size());
for (unsigned int i=0; i<_pop.size(); i++)
{
v[i] = metric(_objVec, _pop[i].objectiveVector());
}
for (unsigned int i=0; i<_pop.size(); i++)
{
_pop[i].fitness( _pop[i].fitness() - exp(-v[i]/kappa) );
}
// compute the fitness of the new individual
v.clear();
v.resize(_pop.size());
for (unsigned int i=0; i<_pop.size(); i++)
{
v[i] = metric(_pop[i].objectiveVector(), _objVec);
}
double result = 0;
for (unsigned int i=0; i<v.size(); i++)
{
result -= exp(-v[i]/kappa);
}
return result;
}
protected:
/** the quality indicator */
moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & metric;
/** the scaling factor */
double kappa;
/** the computed indicator values */
std::vector < std::vector<double> > values;
/**
* Sets the bounds for every objective using the min and the max value for every objective vector of _pop
* @param _pop the population
*/
void setup(const eoPop < MOEOT > & _pop)
{
double min, max;
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
min = _pop[0].objectiveVector()[i];
max = _pop[0].objectiveVector()[i];
for (unsigned int j=1; j<_pop.size(); j++)
{
min = std::min(min, _pop[j].objectiveVector()[i]);
max = std::max(max, _pop[j].objectiveVector()[i]);
}
// setting of the bounds for the objective i
metric.setup(min, max, i);
}
}
/**
* Compute every indicator value in values (values[i] = I(_v[i], _o))
* @param _pop the population
*/
void computeValues(const eoPop < MOEOT > & _pop)
{
values.clear();
values.resize(_pop.size());
for (unsigned int i=0; i<_pop.size(); i++)
{
values[i].resize(_pop.size());
for (unsigned int j=0; j<_pop.size(); j++)
{
if (i != j)
{
values[i][j] = metric(_pop[i].objectiveVector(), _pop[j].objectiveVector());
}
}
}
}
/**
* Sets the fitness value of the whple population
* @param _pop the population
*/
void setFitnesses(eoPop < MOEOT > & _pop)
{
for (unsigned int i=0; i<_pop.size(); i++)
{
_pop[i].fitness(computeFitness(i));
}
}
/**
* Returns the fitness value of the _idx th individual of the population
* @param _idx the index
*/
double computeFitness(const unsigned int _idx)
{
double result = 0;
for (unsigned int i=0; i<values.size(); i++)
{
if (i != _idx)
{
result -= exp(-values[i][_idx]/kappa);
}
}
return result;
}
};
#endif /*MOEOEXPBINARYINDICATORBASEDFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,76 @@
/*
* <moeoFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOFITNESSASSIGNMENT_H_
#define MOEOFITNESSASSIGNMENT_H_
#include <eoFunctor.h>
#include <eoPop.h>
/**
* Functor that sets the fitness values of a whole population.
*/
template < class MOEOT >
class moeoFitnessAssignment : public eoUF < eoPop < MOEOT > &, void >
{
public:
/** The type for objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
virtual void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) = 0;
/**
* Updates the fitness values of the whole population _pop by taking the deletion of the individual _moeo into account.
* @param _pop the population
* @param _moeo the individual
*/
void updateByDeleting(eoPop < MOEOT > & _pop, MOEOT & _moeo)
{
updateByDeleting(_pop, _moeo.objectiveVector());
}
};
#endif /*MOEOFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,50 @@
/*
* <moeoIndicatorBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOINDICATORBASEDFITNESSASSIGNMENT_H_
#define MOEOINDICATORBASEDFITNESSASSIGNMENT_H_
#include <fitness/moeoFitnessAssignment.h>
/**
* moeoIndicatorBasedFitnessAssignment is a moeoFitnessAssignment for Indicator-based strategies.
*/
template < class MOEOT >
class moeoIndicatorBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT >
{};
#endif /*MOEOINDICATORBASEDFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,134 @@
/*
* <moeoReferencePointIndicatorBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOREFERENCEPOINTINDICATORBASEDFITNESSASSIGNMENT_H_
#define MOEOREFERENCEPOINTINDICATORBASEDFITNESSASSIGNMENT_H_
#include <math.h>
#include <eoPop.h>
#include <fitness/moeoFitnessAssignment.h>
#include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
/**
* Fitness assignment sheme based a Reference Point and a Quality Indicator.
*/
template < class MOEOT >
class moeoReferencePointIndicatorBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT >
{
public:
/** The type of objective vector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
/**
* Ctor
* @param _refPoint the reference point
* @param _metric the quality indicator
*/
moeoReferencePointIndicatorBasedFitnessAssignment (ObjectiveVector & _refPoint, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric) :
refPoint(_refPoint), metric(_metric)
{}
/**
* Sets the fitness values for every solution contained in the population _pop
* @param _pop the population
*/
void operator()(eoPop < MOEOT > & _pop)
{
// 1 - setting of the bounds
setup(_pop);
// 2 - setting fitnesses
setFitnesses(_pop);
}
/**
* Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
* @param _pop the population
* @param _objVec the objective vector
*/
void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
{
// nothing to do ;-)
}
protected:
/** the reference point */
ObjectiveVector & refPoint;
/** the quality indicator */
moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & metric;
/**
* Sets the bounds for every objective using the min and the max value for every objective vector of _pop (and the reference point)
* @param _pop the population
*/
void setup(const eoPop < MOEOT > & _pop)
{
double min, max;
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
min = refPoint[i];
max = refPoint[i];
for (unsigned int j=0; j<_pop.size(); j++)
{
min = std::min(min, _pop[j].objectiveVector()[i]);
max = std::max(max, _pop[j].objectiveVector()[i]);
}
// setting of the bounds for the objective i
metric.setup(min, max, i);
}
}
/**
* Sets the fitness of every individual contained in the population _pop
* @param _pop the population
*/
void setFitnesses(eoPop < MOEOT > & _pop)
{
for (unsigned int i=0; i<_pop.size(); i++)
{
_pop[i].fitness(- metric(_pop[i].objectiveVector(), refPoint) );
}
}
};
#endif /*MOEOREFERENCEPOINTINDICATORBASEDFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,50 @@
/*
* <moeoScalarFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOSCALARFITNESSASSIGNMENT_H_
#define MOEOSCALARFITNESSASSIGNMENT_H_
#include <fitness/moeoFitnessAssignment.h>
/**
* moeoScalarFitnessAssignment is a moeoFitnessAssignment for scalar strategies.
*/
template < class MOEOT >
class moeoScalarFitnessAssignment : public moeoFitnessAssignment < MOEOT >
{};
#endif /*MOEOSCALARFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,67 @@
/*
* <moeoSingleObjectivization.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2009
* (C) OPAC Team, LIFL, 2002-2007
*
* François Legillon
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOSINGLEOBJECTIVIZATION_H_
#define MOEOSINGLEOBJECTIVIZATION_H_
#include <fitness/moeoFitnessAssignment.h>
#include <eoEvalFunc.h>
/**
* Class to adapt multiobjective problems to single objective algorithms
*/
template < class MOEOT >
class moeoSingleObjectivization : public moeoFitnessAssignment < MOEOT > , public eoEvalFunc < MOEOT >
{
public:
/**
* herited from moeoFitnessAssignment
* @param _pop the population
*/
virtual void operator () (eoPop < MOEOT > & _pop)=0;
/**
herited from eoEvalFunc
@param _moeot
*/
virtual void operator() (MOEOT & _moeot)=0;
virtual typename MOEOT::Fitness operator() (const typename MOEOT::ObjectiveVector & _obj)=0;
};
#endif /*MOEOSINGLEOBJECTIVIZATION_H_*/

View file

@ -0,0 +1,50 @@
/*
* <moeoUnaryIndicatorBasedFitnessAssignment.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOUNARYINDICATORBASEDFITNESSASSIGNMENT_H_
#define MOEOUNARYINDICATORBASEDFITNESSASSIGNMENT_H_
#include <fitness/moeoIndicatorBasedFitnessAssignment.h>
/**
* moeoIndicatorBasedFitnessAssignment for unary indicators.
*/
template < class MOEOT >
class moeoUnaryIndicatorBasedFitnessAssignment : public moeoIndicatorBasedFitnessAssignment < MOEOT >
{};
#endif /*MOEOINDICATORBASEDFITNESSASSIGNMENT_H_*/

View file

@ -0,0 +1,150 @@
/*
* <moeoDMLSGenUpdater.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEODMLSGENUPDATER_H
#define _MOEODMLSGENUPDATER_H
#include <eoGenContinue.h>
#include <eoEvalFunc.h>
#include <archive/moeoArchive.h>
#include <archive/moeoUnboundedArchive.h>
#include <explorer/moeoPopNeighborhoodExplorer.h>
#include <selection/moeoUnvisitedSelect.h>
#include <algo/moeoUnifiedDominanceBasedLS.h>
/** updater allowing hybridization with a dmls at checkpointing*/
template < class Neighbor >
class moeoDMLSGenUpdater : public eoUpdater
{
typedef typename Neighbor::EOT MOEOT;
public :
/** Ctor with a dmls.
* @param _dmls the dmls use for the hybridization (!!! Special care is needed when choosing the continuator of the dmls !!!)
* @param _dmlsArchive an archive (used to instantiate the dmls)
* @param _globalArchive the same archive used in the other algorithm
* @param _continuator is a Generational Continuator which allow to run dmls on the global archive each X generation(s)
* @param _verbose verbose mode
*/
moeoDMLSGenUpdater(moeoUnifiedDominanceBasedLS <Neighbor> & _dmls,
moeoArchive < MOEOT > & _dmlsArchive,
moeoArchive < MOEOT > & _globalArchive,
eoGenContinue < MOEOT > & _continuator,
bool _verbose = true):
defaultContinuator(0), dmlsArchive(_dmlsArchive), dmls(_dmls), globalArchive(_globalArchive), continuator(_continuator), verbose(_verbose){}
/** Ctor with a dmls.
* @param _eval a evaluation function (used to instantiate the dmls)
* @param _explorer a neighborhood explorer (used to instantiate the dmls)
* @param _select a selector of unvisited individuals of a population (used to instantiate the dmls)
* @param _globalArchive the same archive used in the other algorithm
* @param _continuator is a Generational Continuator which allow to run dmls on the global archive each X generation(s)
* @param _step (default=1) is the number of Generation of dmls (used to instantiate the defaultContinuator for the dmls)
* @param _verbose verbose mode
*/
moeoDMLSGenUpdater(eoEvalFunc < MOEOT > & _eval,
moeoPopNeighborhoodExplorer < Neighbor > & _explorer,
moeoUnvisitedSelect < MOEOT > & _select,
moeoArchive < MOEOT > & _globalArchive,
eoGenContinue < MOEOT > & _continuator,
unsigned int _step=1,
bool _verbose = true):
defaultContinuator(_step), dmlsArchive(defaultArchive), dmls(defaultContinuator, _eval, defaultArchive, _explorer, _select), globalArchive(_globalArchive), continuator(_continuator), verbose(_verbose){}
/** Ctor with a dmls.
* @param _eval a evaluation function (used to instantiate the dmls)
* @param _dmlsArchive an archive (used to instantiate the dmls)
* @param _explorer a neighborhood explorer (used to instantiate the dmls)
* @param _select a selector of unvisited individuals of a population (used to instantiate the dmls)
* @param _globalArchive the same archive used in the other algorithm
* @param _continuator is a Generational Continuator which allow to run dmls on the global archive each X generation(s)
* @param _step (default=1) is the number of Generation of dmls (used to instantiate the defaultContinuator for the dmls)
* @param _verbose verbose mode
*/
moeoDMLSGenUpdater(eoEvalFunc < MOEOT > & _eval,
moeoArchive < MOEOT > & _dmlsArchive,
moeoPopNeighborhoodExplorer < Neighbor > & _explorer,
moeoUnvisitedSelect < MOEOT > & _select,
moeoArchive < MOEOT > & _globalArchive,
eoGenContinue < MOEOT > & _continuator,
unsigned int _step=1,
bool _verbose = true):
defaultContinuator(_step), dmlsArchive(_dmlsArchive), dmls(defaultContinuator, _eval, _dmlsArchive, _explorer, _select), globalArchive(_globalArchive), continuator(_continuator), verbose(_verbose){}
/** functor which allow to run the dmls*/
virtual void operator()()
{
if(!continuator(globalArchive)){
if(verbose)
std::cout << std::endl << "moeoDMLSGenUpdater: dmls start" << std::endl;
dmls(globalArchive);
globalArchive(dmlsArchive);
if(verbose)
std::cout << "moeoDMLSGenUpdater: dmls stop" << std::endl;
defaultContinuator.totalGenerations(defaultContinuator.totalGenerations());
if(verbose)
std::cout << "the other algorithm restart for " << continuator.totalGenerations() << " generation(s)" << std::endl << std::endl;
continuator.totalGenerations(continuator.totalGenerations());
}
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moeoDMLSGenUpdater"; }
private:
/** defaultContinuator used for the dmls */
eoGenContinue < MOEOT > defaultContinuator;
/** dmls archive */
moeoArchive < MOEOT > & dmlsArchive;
/** default archive used for the dmls */
moeoUnboundedArchive < MOEOT > defaultArchive;
/** the dmls */
moeoUnifiedDominanceBasedLS <Neighbor> dmls;
/** the global archive */
moeoArchive < MOEOT > & globalArchive;
/** continuator used to run the dmls each X generation(s) */
eoGenContinue < MOEOT > & continuator;
/** verbose mode */
bool verbose;
};
#endif /*_MOEODMLSGENUPDATER_H_*/

View file

@ -0,0 +1,134 @@
/*
* <moeoDMLSMonOp.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEODMLSMONOP_H
#define _MOEODMLSMONOP_H
#include <eoGenContinue.h>
#include <utils/eoRNG.h>
#include <eoEvalFunc.h>
#include <archive/moeoArchive.h>
#include <archive/moeoUnboundedArchive.h>
#include <explorer/moeoPopNeighborhoodExplorer.h>
#include <selection/moeoUnvisitedSelect.h>
#include <algo/moeoUnifiedDominanceBasedLS.h>
/** eoMonOp allowing hybridization with a dmls at mutation */
template < class Neighbor >
class moeoDMLSMonOp : public eoMonOp < typename Neighbor::EOT >
{
typedef typename Neighbor::EOT MOEOT;
public :
/** Ctor with a dmls.
* @param _dmls the dmls use for the hybridization (!!! Special care is needed when choosing the continuator of the dmls !!!)
* @param _dmlsArchive an archive (used to instantiate the dmls)
* @param _verbose verbose mode
*/
moeoDMLSMonOp(moeoUnifiedDominanceBasedLS <Neighbor> & _dmls,
moeoArchive < MOEOT > & _dmlsArchive,
bool _verbose = true):
defaultContinuator(0), dmlsArchive(_dmlsArchive), dmls(_dmls), verbose(_verbose) {}
/** Ctor with a dmls.
* @param _eval a evaluation function (used to instantiate the dmls)
* @param _explorer a neighborhood explorer (used to instantiate the dmls)
* @param _select a selector of unvisited individuals of a population (used to instantiate the dmls)
* @param _step (default=1) is the number of Generation of dmls (used to instantiate the defaultContinuator for the dmls)
* @param _verbose verbose mode
*/
moeoDMLSMonOp(eoEvalFunc < MOEOT > & _eval,
moeoPopNeighborhoodExplorer < Neighbor > & _explorer,
moeoUnvisitedSelect < MOEOT > & _select,
unsigned int _step=1,
bool _verbose = true):
defaultContinuator(_step), dmlsArchive(defaultArchive), dmls(defaultContinuator, _eval, defaultArchive, _explorer, _select), verbose(_verbose){}
/** Ctor with a dmls.
* @param _eval a evaluation function (used to instantiate the dmls)
* @param _dmlsArchive an archive (used to instantiate the dmls)
* @param _explorer a neighborhood explorer (used to instantiate the dmls)
* @param _select a selector of unvisited individuals of a population (used to instantiate the dmls)
* @param _step (default=1) is the number of Generation of dmls (used to instantiate the defaultContinuator for the dmls)
* @param _verbose verbose mode
*/
moeoDMLSMonOp(eoEvalFunc < MOEOT > & _eval,
moeoArchive < MOEOT > & _dmlsArchive,
moeoPopNeighborhoodExplorer < Neighbor > & _explorer,
moeoUnvisitedSelect < MOEOT > & _select,
unsigned int _step=1,
bool _verbose = true):
defaultContinuator(_step), dmlsArchive(_dmlsArchive), dmls(defaultContinuator, _eval, _dmlsArchive, _explorer, _select), verbose(_verbose){}
/** functor which allow to run the dmls on a MOEOT and return one of the resulting archive*/
bool operator()( MOEOT & _moeo)
{
if(verbose)
std::cout << std::endl << "moeoDMLSMonOp: dmls start" << std::endl;
unsigned int tmp;
eoPop < MOEOT> pop;
pop.push_back(_moeo);
dmls(pop);
tmp = rng.random(dmlsArchive.size());
_moeo = dmlsArchive[tmp];
defaultContinuator.totalGenerations(defaultContinuator.totalGenerations());
if(verbose)
std::cout << "moeoDMLSMonOp: dmls stop" << std::endl << std::endl;
return false;
}
/**
* @return the class name
*/
virtual std::string className(void) const { return "moeoDMLSMonOp"; }
private:
/** defaultContinuator used for the dmls */
eoGenContinue < MOEOT > defaultContinuator;
/** dmls archive */
moeoArchive < MOEOT > & dmlsArchive;
/** default archive used for the dmls */
moeoUnboundedArchive < MOEOT > defaultArchive;
/** the dmls */
moeoUnifiedDominanceBasedLS <Neighbor> dmls;
/** verbose mode */
bool verbose;
};
#endif /*_MOEODMLSMONOP_H_*/

View file

@ -0,0 +1,109 @@
/*
* <moeoAdditiveEpsilonBinaryMetric.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOADDITIVEEPSILONBINARYMETRIC_H_
#define MOEOADDITIVEEPSILONBINARYMETRIC_H_
#include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
/**
* Additive epsilon binary metric allowing to compare two objective vectors as proposed in
* Zitzler E., Thiele L., Laumanns M., Fonseca C. M., Grunert da Fonseca V.:
* Performance Assessment of Multiobjective Optimizers: An Analysis and Review. IEEE Transactions on Evolutionary Computation 7(2), pp.117132 (2003).
*/
template < class ObjectiveVector >
class moeoAdditiveEpsilonBinaryMetric : public moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double >
{
public:
/**
* Returns the minimal distance by which the objective vector _o1 must be translated in all objectives
* so that it weakly dominates the objective vector _o2
* @warning don't forget to set the bounds for every objective before the call of this function
* @param _o1 the first objective vector
* @param _o2 the second objective vector
*/
double operator()(const ObjectiveVector & _o1, const ObjectiveVector & _o2)
{
// computation of the epsilon value for the first objective
double result = epsilon(_o1, _o2, 0);
// computation of the epsilon value for the other objectives
double tmp;
for (unsigned int i=1; i<ObjectiveVector::Traits::nObjectives(); i++)
{
tmp = epsilon(_o1, _o2, i);
result = std::max(result, tmp);
}
// returns the maximum epsilon value
return result;
}
private:
/** the bounds for every objective */
using moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > :: bounds;
/**
* Returns the epsilon value by which the objective vector _o1 must be translated in the objective _obj
* so that it dominates the objective vector _o2
* @param _o1 the first objective vector
* @param _o2 the second objective vector
* @param _obj the index of the objective
*/
double epsilon(const ObjectiveVector & _o1, const ObjectiveVector & _o2, const unsigned int _obj)
{
double result;
// if the objective _obj have to be minimized
if (ObjectiveVector::Traits::minimizing(_obj))
{
// _o1[_obj] - _o2[_obj]
result = ( (_o1[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() ) - ( (_o2[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() );
}
// if the objective _obj have to be maximized
else
{
// _o2[_obj] - _o1[_obj]
result = ( (_o2[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() ) - ( (_o1[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() );
}
return result;
}
};
#endif /*MOEOADDITIVEEPSILONBINARYMETRIC_H_*/

View file

@ -0,0 +1,138 @@
/*
* <moeoContributionMetric.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOCONTRIBUTIONMETRIC_H_
#define MOEOCONTRIBUTIONMETRIC_H_
#include <comparator/moeoParetoObjectiveVectorComparator.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 ObjectiveVector >
class moeoContributionMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double >
{
public:
/**
* 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 std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
{
unsigned int c = card_C(_set1, _set2);
unsigned int w1 = card_W(_set1, _set2);
unsigned int n1 = card_N(_set1, _set2);
unsigned int w2 = card_W(_set2, _set1);
unsigned int n2 = card_N(_set2, _set1);
return (double) (c / 2.0 + w1 + n1) / (c + w1 + n1 + w2 + n2);
}
private:
/** Functor to compare two objective vectors according to Pareto dominance relation */
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
/**
* Returns the number of solutions both in '_set1' and '_set2'
* @param _set1 the first Pareto set
* @param _set2 the second Pareto set
*/
unsigned int card_C (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
{
unsigned int c=0;
for (unsigned int i=0; i<_set1.size(); i++)
for (unsigned int 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 int card_W (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
{
unsigned int w=0;
for (unsigned int i=0; i<_set1.size(); i++)
for (unsigned int j=0; j<_set2.size(); j++)
if (paretoComparator(_set2[j], _set1[i]))
{
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 int card_N (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
{
unsigned int n=0;
for (unsigned int i=0; i<_set1.size(); i++)
{
bool domin_rel = false;
for (unsigned int j=0; j<_set2.size(); j++)
if ( (paretoComparator(_set2[j], _set1[i])) || (paretoComparator(_set1[i], _set2[j])) )
{
domin_rel = true;
break;
}
if (! domin_rel)
n++;
}
return n;
}
};
#endif /*MOEOCONTRIBUTIONMETRIC_H_*/

View file

@ -0,0 +1,86 @@
/*
* <moeoDistanceMetric.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Jeremie Humeau
* Arnaud Liefooghe
* François Legillon
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEODISTANCEMETRIC_H_
#define MOEODISTANCEMETRIC_H_
#include <cmath>
#include <distance/moeoObjSpaceDistance.h>
/**
Adapter to use Distances as a metric
*/
template < class MOEOT>
class moeoDistanceMetric : public moeoUnaryMetric < typename MOEOT::ObjectiveVector , typename MOEOT::Fitness >
{
public:
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
typedef typename MOEOT::Fitness Fitness;
/**
constructor with a normalizer
@param _distance the distance
@param _referencePoint the point from which we evaluate the distance
@param _normalizer the normalizer
*/
moeoDistanceMetric(moeoObjSpaceDistance<MOEOT> &_distance, const ObjectiveVector &_referencePoint,moeoObjectiveVectorNormalizer<MOEOT>& _normalizer): distance(_distance), reference(_referencePoint),normalizer(_normalizer){}
/**
constructor with a dummy normalizer
@param _distance the distance
@param _referencePoint the point from which we evaluate the distance
*/
moeoDistanceMetric(moeoObjSpaceDistance<MOEOT> &_distance, const ObjectiveVector &_referencePoint): distance(_distance), reference(_referencePoint),normalizer(defaultNormalizer){}
/**
fonction which apply the metric to calculate a fitness
@param _obj the point to evaluate
@return the fitness conrresponding to the distance
*/
Fitness operator()(ObjectiveVector _obj){
return distance(normalizer(reference), normalizer(_obj));
}
private:
moeoObjSpaceDistance<MOEOT>& distance;
const ObjectiveVector& reference;
moeoObjectiveVectorNormalizer<MOEOT> defaultNormalizer;
moeoObjectiveVectorNormalizer<MOEOT>& normalizer;
};
#endif

View file

@ -0,0 +1,223 @@
/*
* <moeoEntropyMetric.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOENTROPYMETRIC_H_
#define MOEOENTROPYMETRIC_H_
#include <vector>
#include <comparator/moeoParetoObjectiveVectorComparator.h>
#include <metric/moeoMetric.h>
/**
* The entropy gives an idea of the diversity of a Pareto set relatively to another
* (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 ObjectiveVector >
class moeoEntropyMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double >
{
public:
/**
* 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 int C = union_set1_star.size();
float omega=0;
float entropy=0;
for (unsigned int i=0 ; i<C ; i++)
{
unsigned int N_i = howManyInNicheOf (union_set1_star, union_set1_star[i], star.size());
unsigned int 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:
/** vector of min values */
std::vector<double> vect_min_val;
/** vector of max values */
std::vector<double> vect_max_val;
/** Functor to compare two objective vectors according to Pareto dominance relation */
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
/**
* Removes the dominated individuals contained in _f
* @param _f a Pareto set
*/
void removeDominated(std::vector < ObjectiveVector > & _f)
{
for (unsigned int i=0 ; i<_f.size(); i++)
{
bool dom = false;
for (unsigned int j=0; j<_f.size(); j++)
if (i != j && paretoComparator(_f[i],_f[j]))
{
dom = true;
break;
}
if (dom)
{
_f[i] = _f.back();
_f.pop_back();
i--;
}
}
}
/**
* Prenormalization
* @param _f a Pareto set
*/
void prenormalize (const std::vector< ObjectiveVector > & _f)
{
vect_min_val.clear();
vect_max_val.clear();
for (unsigned int i=0 ; i<ObjectiveVector::nObjectives(); i++)
{
float min_val = _f.front()[i], max_val = min_val;
for (unsigned int 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);
}
}
/**
* Normalization
* @param _f a Pareto set
*/
void normalize (std::vector< ObjectiveVector > & _f)
{
for (unsigned int i=0 ; i<ObjectiveVector::nObjectives(); i++)
for (unsigned int j=0; j<_f.size(); j++)
_f[j][i] = (_f[j][i] - vect_min_val[i]) / (vect_max_val[i] - vect_min_val[i]);
}
/**
* Computation of the union of _f1 and _f2 in _f
* @param _f1 the first Pareto set
* @param _f2 the second Pareto set
* @param _f the final Pareto set
*/
void computeUnion(const std::vector< ObjectiveVector > & _f1, const std::vector< ObjectiveVector > & _f2, std::vector< ObjectiveVector > & _f)
{
_f = _f1 ;
for (unsigned int i=0; i<_f2.size(); i++)
{
bool b = false;
for (unsigned int j=0; j<_f1.size(); j ++)
if (_f1[j] == _f2[i])
{
b = true;
break;
}
if (! b)
_f.push_back(_f2[i]);
}
}
/**
* How many in niche
*/
unsigned int howManyInNicheOf (const std::vector< ObjectiveVector > & _f, const ObjectiveVector & _s, unsigned int _size)
{
unsigned int n=0;
for (unsigned int i=0 ; i<_f.size(); i++)
{
if (euclidianDistance(_f[i], _s) < (_s.size() / (double) _size))
n++;
}
return n;
}
/**
* Euclidian distance
*/
double euclidianDistance (const ObjectiveVector & _set1, const ObjectiveVector & _to, unsigned int _deg = 2)
{
double dist=0;
for (unsigned int i=0; i<_set1.size(); i++)
dist += pow(fabs(_set1[i] - _to[i]), (int)_deg);
return pow(dist, 1.0 / _deg);
}
};
#endif /*MOEOENTROPYMETRIC_H_*/

View file

@ -0,0 +1,176 @@
/*
* <moeoHyperVolumeDifferenceMetric.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Jeremie Humeau
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOHYPERVOLUMEDIFFERENCEMETRIC_H_
#define MOEOHYPERVOLUMEDIFFERENCEMETRIC_H_
#include <metric/moeoMetric.h>
#include <metric/moeoHyperVolumeMetric.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 ObjectiveVector >
class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double >
{
public:
/**
* Constructor with a coefficient (rho)
* @param _normalize allow to normalize data (default true)
* @param _rho coefficient to determine the reference point.
*/
moeoHyperVolumeDifferenceMetric(bool _normalize=true, double _rho=1.1): normalize(_normalize), rho(_rho), ref_point(NULL){
bounds.resize(ObjectiveVector::Traits::nObjectives());
// initialize bounds in case someone does not want to use them
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
bounds[i] = eoRealInterval(0,1);
}
}
/**
* Constructor with a reference point
* @param _normalize allow to normalize data (default true)
* @param _ref_point the reference point
*/
moeoHyperVolumeDifferenceMetric(bool _normalize=true, ObjectiveVector& _ref_point=NULL): normalize(_normalize), rho(0.0), ref_point(_ref_point){
bounds.resize(ObjectiveVector::Traits::nObjectives());
// initialize bounds in case someone does not want to use them
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
bounds[i] = eoRealInterval(0,1);
}
}
/**
* calculates and returns the HyperVolume value of a pareto front
* @param _set1 the vector contains all objective Vector of the first pareto front
* @param _set2 the vector contains all objective Vector of the second pareto front
*/
double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
{
double hypervolume_set1;
double hypervolume_set2;
if(rho >= 1.0){
//determine bounds
setup(_set1, _set2);
//determine reference point
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++){
if(normalize){
if (ObjectiveVector::Traits::minimizing(i))
ref_point[i]= rho;
else
ref_point[i]= 1-rho;
}
else{
if (ObjectiveVector::Traits::minimizing(i))
ref_point[i]= bounds[i].maximum() * rho;
else
ref_point[i]= bounds[i].maximum() * (1-rho);
}
}
//if no normalization, reinit bounds to O..1 for
if(!normalize)
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
bounds[i] = eoRealInterval(0,1);
}
else if(normalize)
setup(_set1, _set2);
moeoHyperVolumeMetric <ObjectiveVector> unaryMetric(ref_point, bounds);
hypervolume_set1 = unaryMetric(_set1);
hypervolume_set2 = unaryMetric(_set2);
return hypervolume_set1 - hypervolume_set2;
}
/**
* getter on bounds
* @return bounds
*/
std::vector < eoRealInterval > getBounds(){
return bounds;
}
/**
* method caclulate bounds for the normalization
* @param _set1 the vector contains all objective Vector of the first pareto front
* @param _set2 the vector contains all objective Vector of the second pareto front
*/
void setup(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2){
if(_set1.size() < 1 || _set2.size() < 1)
throw("Error in moeoHyperVolumeUnaryMetric::setup -> argument1: vector<ObjectiveVector> size must be greater than 0");
else{
double min, max;
unsigned int nbObj=ObjectiveVector::Traits::nObjectives();
bounds.resize(nbObj);
for (unsigned int i=0; i<nbObj; i++){
min = _set1[0][i];
max = _set1[0][i];
for (unsigned int j=1; j<_set1.size(); j++){
min = std::min(min, _set1[j][i]);
max = std::max(max, _set1[j][i]);
}
for (unsigned int j=0; j<_set2.size(); j++){
min = std::min(min, _set2[j][i]);
max = std::max(max, _set2[j][i]);
}
bounds[i] = eoRealInterval(min, max);
}
}
}
private:
/*boolean indicates if data must be normalized or not*/
bool normalize;
double rho;
/*vectors contains bounds for normalization*/
std::vector < eoRealInterval > bounds;
ObjectiveVector ref_point;
};
#endif /*MOEOHYPERVOLUMEMETRIC_H_*/

View file

@ -0,0 +1,359 @@
/*
* <moeoHyperVolumeMetric.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Jeremie Humeau
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOHYPERVOLUMEMETRIC_H_
#define MOEOHYPERVOLUMEMETRIC_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 ObjectiveVector >
class moeoHyperVolumeMetric : public moeoVectorUnaryMetric < ObjectiveVector , double >
{
public:
/**
* Constructor with a coefficient (rho)
* @param _normalize allow to normalize data (default true)
* @param _rho coefficient to determine the reference point.
*/
moeoHyperVolumeMetric(bool _normalize=true, double _rho=1.1): normalize(_normalize), rho(_rho), ref_point(NULL){
bounds.resize(ObjectiveVector::Traits::nObjectives());
// initialize bounds in case someone does not want to use them
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
bounds[i] = eoRealInterval(0,1);
}
}
/**
* Constructor with a reference point
* @param _normalize allow to normalize data (default true)
* @param _ref_point the reference point
*/
moeoHyperVolumeMetric(bool _normalize=true, ObjectiveVector& _ref_point=NULL): normalize(_normalize), rho(0.0), ref_point(_ref_point){
bounds.resize(ObjectiveVector::Traits::nObjectives());
// initialize bounds in case someone does not want to use them
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
bounds[i] = eoRealInterval(0,1);
}
}
/**
* Constructor with a reference point
* @param _ref_point the reference point
* @param _bounds bounds value
*/
moeoHyperVolumeMetric(ObjectiveVector& _ref_point=NULL, std::vector < eoRealInterval >& _bounds=NULL): normalize(false), rho(0.0), ref_point(_ref_point), bounds(_bounds){}
/**
* calculates and returns the HyperVolume value of a pareto front
* @param _set the vector contains all objective Vector of pareto front
*/
double operator()(const std::vector < ObjectiveVector > & _set)
{
std::vector < std::vector<double> > front;
//determine the reference point if a coefficient is passed in paremeter
if(rho >= 1.0){
//determine bounds
setup(_set);
//determine reference point
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++){
if(normalize){
if (ObjectiveVector::Traits::minimizing(i))
ref_point[i]= rho;
else
ref_point[i]= 1-rho;
}
else{
if (ObjectiveVector::Traits::minimizing(i))
ref_point[i]= bounds[i].maximum() * rho;
else
ref_point[i]= bounds[i].maximum() * (1-rho);
}
}
//if no normalization, reinit bounds to O..1 for
if(!normalize)
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
bounds[i] = eoRealInterval(0,1);
}
else if(normalize)
setup(_set);
front.resize(_set.size());
for(unsigned int i=0; i < _set.size(); i++){
front[i].resize(ObjectiveVector::Traits::nObjectives());
for (unsigned int j=0; j<ObjectiveVector::Traits::nObjectives(); j++){
if (ObjectiveVector::Traits::minimizing(j)){
front[i][j]=ref_point[j] - ((_set[i][j] - bounds[j].minimum()) /bounds[j].range());
}
else{
front[i][j]=((_set[i][j] - bounds[j].minimum()) /bounds[j].range()) - ref_point[j];
}
}
}
return calc_hypervolume(front, front.size(),ObjectiveVector::Traits::nObjectives());
}
/**
* getter on bounds
* @return bounds
*/
std::vector < eoRealInterval > getBounds(){
return bounds;
}
/**
* method caclulate bounds for the normalization
* @param _set the vector of objective vectors
*/
void setup(const std::vector < ObjectiveVector > & _set){
if(_set.size() < 1)
throw("Error in moeoHyperVolumeUnaryMetric::setup -> argument1: vector<ObjectiveVector> size must be greater than 0");
else{
double min, max;
unsigned int nbObj=ObjectiveVector::Traits::nObjectives();
bounds.resize(nbObj);
for (unsigned int i=0; i<nbObj; i++){
min = _set[0][i];
max = _set[0][i];
for (unsigned int j=1; j<_set.size(); j++){
min = std::min(min, _set[j][i]);
max = std::max(max, _set[j][i]);
}
bounds[i] = eoRealInterval(min, max);
}
}
}
/**
* method calculate if a point dominates another one regarding the x first objective
* @param _point1 a vector of distances
* @param _point2 a vector of distances
* @param _no_objectives a number of objectives
* @return true if '_point1' dominates '_point2' with respect to the first 'no_objectives' objectives
*/
bool dominates(std::vector<double>& _point1, std::vector<double>& _point2, unsigned int _no_objectives){
unsigned int i;
bool better_in_any_objective = false;
bool worse_in_any_objective = false;
for(i=0; i < _no_objectives && !worse_in_any_objective; i++){
if(_point1[i] > _point2[i])
better_in_any_objective = true;
else if(_point1[i] < _point2[i])
worse_in_any_objective = true;
}
//_point1 dominates _point2 if it is better than _point2 on a objective and if it is never worse in any other objectives
return(!worse_in_any_objective && better_in_any_objective);
}
/**
* swap two elements of a vector
* @param _front the vector
* @param _i index of the first element to swap
* @param _j index of the second element to swap
*/
void swap(std::vector< std::vector<double> >& _front, unsigned int _i, unsigned int _j){
std::vector<double> tmp;
tmp=_front[_i];
_front[_i]=_front[_j];
_front[_j]=tmp;
//another way (don't work on visual studio)
// _front.push_back(_front[_i]);
// _front[_i]= _front[_j];
// _front[_j]=_front.back();
// _front.pop_back();
}
/**
* collect all nondominated points regarding the first '_no_objectives' objectives (dominated points are stored at the end of _front)
* @param _front the front
* @param _no_points the number of points of the front to consider (index 0 to _no_points are considered)
* @param _no_objectives the number of objective to consider
* @return the index of the last nondominated point
*/
unsigned int filter_nondominated_set( std::vector < std::vector< double > >& _front, unsigned int _no_points, unsigned int _no_objectives){
unsigned int i,j,n;
n=_no_points;
i=0;
while(i < n){
j=i+1;
while(j < n){
//if a point 'A' (index i) dominates another one 'B' (index j), swap 'B' with the point of index n-1
if( dominates(_front[i], _front[j], _no_objectives)){
n--;
swap(_front, j, n);
}
//if a point 'B'(index j) dominates another one 'A' (index i), swap 'A' with the point of index n-1
else if( dominates(_front[j], _front[i], _no_objectives)){
n--;
swap(_front, i, n);
i--;
break;
}
else
j++;
}
i++;
}
return n;
}
/**
* find a minimum value
* @param _front the front
* @param _no_points the number of points of the front to consider (index 0 to _no_points are considered)
* @param _objective the objective to consider
* @return the minimum value regarding dimension '_objective' consider points O to _no_points in '_front'
*/
double surface_unchanged_to(std::vector < std::vector< double > >& _front, unsigned int _no_points, unsigned int _objective){
unsigned int i;
double min, value;
if(_no_points < 1)
throw("Error in moeoHyperVolumeUnaryMetric::surface_unchanged_to -> argument2: _no_points must be greater than 0");
min = _front[0][_objective];
for(i=1; i < _no_points; i++){
value = _front[i][_objective];
if(value < min)
min = value;
}
return min;
}
/**
* remove all points having a value <= 'threshold' regarding the dimension 'objective', only points of index 0 to _no_points are considered.
* points removed are swap at the end of the front.
* @param _front the front
* @param _no_points the number of points of the front to consider (index 0 to _no_points are considered)
* @param _objective the objective to consider
* @param _threshold the threshold
* @return index of the last points of '_front' greater than the threshold
*/
unsigned int reduce_nondominated_set(std::vector < std::vector< double > >& _front, unsigned int _no_points, unsigned int _objective, double _threshold){
unsigned int i,n ;
n=_no_points;
for(i=0; i < n ; i++)
if(_front[i][_objective] <= _threshold){
n--;
swap(_front, i, n);
i--; //ATTENTION I had this to reconsider the point copied to index i (it can be useless verify algorythimic in calc_hypervolume)
}
return n;
}
/**
* calculate hypervolume of the front (data are redrafted before)
* @param _front the front
* @param _no_points the number of points of the front to consider (index 0 to _no_points are considered)
* @param _no_objectives the number of objective to consider
* @return the hypervolume of the front
*/
double calc_hypervolume(std::vector < std::vector< double > >& _front, unsigned int _no_points, unsigned int _no_objectives){
unsigned int n;
double volume, distance;
volume=0;
distance=0;
n=_no_points;
while(n > 0){
unsigned int no_nondominated_points;
double temp_vol, temp_dist;
//get back the index of non dominated points of the front regarding the first "_nb_objectives - 1" objectives
//So one dimension is not determinante for the dominance
no_nondominated_points = filter_nondominated_set(_front, n, _no_objectives - 1);
temp_vol=0;
//if there are less than 3 objectifs take the fisrt objectif of the first point of front to begin computation of hypervolume
if(_no_objectives < 3){
if(_no_objectives < 1)
throw("Error in moeoHyperVolumeUnaryMetric::calc_hypervolume -> argument3: _no_objectives must be greater than 0");
temp_vol=_front[0][0];
}
//else if there at least 3 objectives, a recursive computation of hypervolume starts with _no_objectives -1 on the filter_nondominated_set calculating previously.
else
temp_vol= calc_hypervolume(_front, no_nondominated_points, _no_objectives - 1);
//search the next minimum distance on the dimension _no_objectives -1
temp_dist = surface_unchanged_to(_front, n, _no_objectives - 1);
//calculate the area
volume+= temp_vol * (temp_dist - distance);
//change distance to have the good lenght on next step
distance= temp_dist;
//remove all points <= distance on dimension _no_objectives
n=reduce_nondominated_set(_front, n , _no_objectives - 1, distance);
}
return volume;
}
private:
/*boolean indicates if data must be normalized or not*/
bool normalize;
double rho;
ObjectiveVector ref_point;
/*vectors contains bounds for normalization*/
std::vector < eoRealInterval > bounds;
};
#endif /*MOEOHYPERVOLUMEMETRIC_H_*/

View file

@ -0,0 +1,166 @@
/*
* <moeoHypervolumeBinaryMetric.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOHYPERVOLUMEBINARYMETRIC_H_
#define MOEOHYPERVOLUMEBINARYMETRIC_H_
#include <stdexcept>
#include <comparator/moeoParetoObjectiveVectorComparator.h>
#include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
/**
* Hypervolume binary metric allowing to compare two objective vectors as proposed in
* Zitzler E., Künzli S.: Indicator-Based Selection in Multiobjective Search. In Parallel Problem Solving from Nature (PPSN VIII).
* Lecture Notes in Computer Science 3242, Springer, Birmingham, UK pp.832842 (2004).
* This indicator is based on the hypervolume concept introduced in
* Zitzler, E., Thiele, L.: Multiobjective Optimization Using Evolutionary Algorithms - A Comparative Case Study.
* Parallel Problem Solving from Nature (PPSN-V), pp.292-301 (1998).
*/
template < class ObjectiveVector >
class moeoHypervolumeBinaryMetric : public moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double >
{
public:
/**
* Ctor
* @param _rho value used to compute the reference point from the worst values for each objective (default : 1.1)
*/
moeoHypervolumeBinaryMetric(double _rho = 1.1) : rho(_rho)
{
// not-a-maximization problem check
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
if (ObjectiveVector::Traits::maximizing(i))
{
throw std::runtime_error("Hypervolume binary metric not yet implemented for a maximization problem in moeoHypervolumeBinaryMetric");
}
}
// consistency check
if (rho < 1)
{
std::cout << "Warning, value used to compute the reference point rho for the hypervolume calculation must not be smaller than 1" << std::endl;
std::cout << "Adjusted to 1" << std::endl;
rho = 1;
}
}
/**
* Returns the volume of the space that is dominated by _o2 but not by _o1 with respect to a reference point computed using rho.
* @warning don't forget to set the bounds for every objective before the call of this function
* @param _o1 the first objective vector
* @param _o2 the second objective vector
*/
double operator()(const ObjectiveVector & _o1, const ObjectiveVector & _o2)
{
double result;
// if _o2 is dominated by _o1
if ( paretoComparator(_o2,_o1) )
{
result = - hypervolume(_o1, _o2, ObjectiveVector::Traits::nObjectives()-1);
}
else
{
result = hypervolume(_o2, _o1, ObjectiveVector::Traits::nObjectives()-1);
}
return result;
}
private:
/** value used to compute the reference point from the worst values for each objective */
double rho;
/** the bounds for every objective */
using moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > :: bounds;
/** Functor to compare two objective vectors according to Pareto dominance relation */
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
/**
* Returns the volume of the space that is dominated by _o2 but not by _o1 with respect to a reference point computed using rho for the objective _obj.
* @param _o1 the first objective vector
* @param _o2 the second objective vector
* @param _obj the objective index
* @param _flag used for iteration, if _flag=true _o2 is not talen into account (default : false)
*/
double hypervolume(const ObjectiveVector & _o1, const ObjectiveVector & _o2, const unsigned int _obj, const bool _flag = false)
{
double result;
double range = rho * bounds[_obj].range();
double max = bounds[_obj].minimum() + range;
// value of _1 for the objective _obj
double v1 = _o1[_obj];
// value of _2 for the objective _obj (if _flag=true, v2=max)
double v2;
if (_flag)
{
v2 = max;
}
else
{
v2 = _o2[_obj];
}
// computation of the volume
if (_obj == 0)
{
if (v1 < v2)
{
result = (v2 - v1) / range;
}
else
{
result = 0;
}
}
else
{
if (v1 < v2)
{
result = ( hypervolume(_o1, _o2, _obj-1, true) * (v2 - v1) / range ) + ( hypervolume(_o1, _o2, _obj-1) * (max - v2) / range );
}
else
{
result = hypervolume(_o1, _o2, _obj-1) * (max - v2) / range;
}
}
return result;
}
};
#endif /*MOEOHYPERVOLUMEBINARYMETRIC_H_*/

View file

@ -0,0 +1,99 @@
/*
* <moeoMetric.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOMETRIC_H_
#define MOEOMETRIC_H_
#include <vector>
#include <eoFunctor.h>
/**
* Base class for performance metrics (also known as 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 objective vector.
*/
template < class ObjectiveVector, class R >
class moeoSolutionUnaryMetric : public moeoUnaryMetric < const ObjectiveVector &, R >
{};
/**
* Base class for unary metrics dedicated to the performance evaluation of a Pareto set (a vector of objective vectors)
*/
template < class ObjectiveVector, class R >
class moeoVectorUnaryMetric : public moeoUnaryMetric < const std::vector < ObjectiveVector > &, R >
{};
/**
* Base class for binary metrics dedicated to the performance comparison between two solutions's objective vectors.
*/
template < class ObjectiveVector, class R >
class moeoSolutionVsSolutionBinaryMetric : public moeoBinaryMetric < const ObjectiveVector &, const ObjectiveVector &, R >
{};
/**
* Base class for binary metrics dedicated to the performance comparison between two Pareto sets (two vectors of objective vectors)
*/
template < class ObjectiveVector, class R >
class moeoVectorVsVectorBinaryMetric : public moeoBinaryMetric < const std::vector < ObjectiveVector > &, const std::vector < ObjectiveVector > &, R >
{};
#endif /*MOEOMETRIC_H_*/

View file

@ -0,0 +1,113 @@
/*
* <moeoNormalizedSolutionVsSolutionBinaryMetric.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEONORMALIZEDSOLUTIONVSSOLUTIONBINARYMETRIC_H_
#define MOEONORMALIZEDSOLUTIONVSSOLUTIONBINARYMETRIC_H_
#include <vector>
#include <utils/eoRealBounds.h>
#include <metric/moeoMetric.h>
/**
* Base class for binary metrics dedicated to the performance comparison between two solutions's objective vectors using normalized values.
* Then, indicator values lie in the interval [-1,1].
* Note that you have to set the bounds for every objective before using the operator().
*/
template < class ObjectiveVector, class R >
class moeoNormalizedSolutionVsSolutionBinaryMetric : public moeoSolutionVsSolutionBinaryMetric < ObjectiveVector, R >
{
public:
/**
* Default ctr for any moeoNormalizedSolutionVsSolutionBinaryMetric object
*/
moeoNormalizedSolutionVsSolutionBinaryMetric()
{
bounds.resize(ObjectiveVector::Traits::nObjectives());
// initialize bounds in case someone does not want to use them
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
bounds[i] = eoRealInterval(0,1);
}
}
/**
* Sets the lower bound (_min) and the upper bound (_max) for the objective _obj
* @param _min lower bound
* @param _max upper bound
* @param _obj the objective index
*/
void setup(double _min, double _max, unsigned int _obj)
{
if (_min == _max)
{
_min -= tiny();
_max += tiny();
}
bounds[_obj] = eoRealInterval(_min, _max);
}
/**
* Sets the lower bound and the upper bound for the objective _obj using a eoRealInterval object
* @param _realInterval the eoRealInterval object
* @param _obj the objective index
*/
virtual void setup(eoRealInterval _realInterval, unsigned int _obj)
{
bounds[_obj] = _realInterval;
}
/**
* Returns a very small value that can be used to avoid extreme cases (where the min bound == the max bound)
*/
static double tiny()
{
return 1e-6;
}
protected:
/** the bounds for every objective (bounds[i] = bounds for the objective i) */
std::vector < eoRealInterval > bounds;
};
#endif /*MOEONORMALIZEDSOLUTIONVSSOLUTIONBINARYMETRIC_H_*/

View file

@ -0,0 +1,93 @@
/*
* <moeoVecVsVecAdditiveEpsilonBinaryMetric.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Jeremie Humeau
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOVECVSVECADDITIVEEPSILONBINARYMETRIC_H_
#define MOEOVECVSVECADDITIVEEPSILONBINARYMETRIC_H_
#include <comparator/moeoParetoObjectiveVectorComparator.h>
#include <metric/moeoMetric.h>
#include <metric/moeoVecVsVecEpsilonBinaryMetric.h>
/**
* moeoVecVsVecAdditiveEpsilonBinaryMetric is the implementation of moeoVecVsVecEpsilonBinaryMetric whose calculate an additive epsilon indicator
*/
template < class ObjectiveVector >
class moeoVecVsVecAdditiveEpsilonBinaryMetric : public moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >
{
public:
/**
* Default Constructor: inherit of moeoVecVsVecEpsilonBinaryMetric
*/
moeoVecVsVecAdditiveEpsilonBinaryMetric(bool _normalize=true): moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >(_normalize){}
private:
/**
* compute the additive epsilon indicator. Ieps+(A,B) equals the minimum factor eps such that any objective vector in B is eps-dominated by at least one objective vector in A.
* a vector z1 is said to eps+-dominate another vector z2, if we can add each objective value in z2 by eps and the resulting objective vector is still weakly dominates by z1.
* @param _o1 the first objective vector (correspond to A, must not have dominated elements)
* @param _o2 the second objective vector (correspond to B, must not have dominated elements)
* @param _obj the objective in consideration
* @return the additive epsilon indicator between the two objective vector _o1 and _o2
*/
double epsilon(const ObjectiveVector & _o1, const ObjectiveVector & _o2, const unsigned int _obj){
double result;
// if the objective _obj have to be minimized
if (ObjectiveVector::Traits::minimizing(_obj))
{
// _o1[_obj] - _o2[_obj]
result = ( (_o1[_obj] - moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].minimum()) / moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].range() ) - ( (_o2[_obj] - moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].minimum()) / moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].range() );
}
// if the objective _obj have to be maximized
else
{
// _o2[_obj] - _o1[_obj]
result = ( (_o2[_obj] - moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].minimum()) / moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].range() ) - ( (_o1[_obj] - moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].minimum()) / moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].range() );
}
return result;
}
};
#endif /*MOEOVECVSVECEPSILONBINARYMETRIC_H_*/

Some files were not shown because too many files have changed in this diff Show more