Migration from SVN
This commit is contained in:
parent
d7d6c3a217
commit
8cd56f37db
164 changed files with 0 additions and 4096888 deletions
44
moeo/src/CMakeLists.txt
Normal file
44
moeo/src/CMakeLists.txt
Normal 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 local/${LIB} COMPONENT libraries)
|
||||
|
||||
######################################################################################
|
||||
### 3) Look for headers
|
||||
######################################################################################
|
||||
|
||||
file(GLOB HDRS moeo)
|
||||
install(FILES ${HDRS} DESTINATION local/include${INSTALL_SUB_DIR}/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 local/include${INSTALL_SUB_DIR}/moeo
|
||||
COMPONENT headers
|
||||
FILES_MATCHING PATTERN "*.h"
|
||||
)
|
||||
|
||||
208
moeo/src/algo/moeoASEEA.h
Normal file
208
moeo/src/algo/moeoASEEA.h
Normal 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_*/
|
||||
47
moeo/src/algo/moeoAlgo.h
Normal file
47
moeo/src/algo/moeoAlgo.h
Normal 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_*/
|
||||
50
moeo/src/algo/moeoEA.h
Normal file
50
moeo/src/algo/moeoEA.h
Normal 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_*/
|
||||
217
moeo/src/algo/moeoEasyEA.h
Executable file
217
moeo/src/algo/moeoEasyEA.h
Executable 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_*/
|
||||
225
moeo/src/algo/moeoIBEA.h
Normal file
225
moeo/src/algo/moeoIBEA.h
Normal 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_*/
|
||||
213
moeo/src/algo/moeoMOGA.h
Normal file
213
moeo/src/algo/moeoMOGA.h
Normal 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_*/
|
||||
215
moeo/src/algo/moeoNSGA.h
Normal file
215
moeo/src/algo/moeoNSGA.h
Normal 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_*/
|
||||
210
moeo/src/algo/moeoNSGAII.h
Normal file
210
moeo/src/algo/moeoNSGAII.h
Normal 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_*/
|
||||
87
moeo/src/algo/moeoPLS1.h
Normal file
87
moeo/src/algo/moeoPLS1.h
Normal 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 177–199
|
||||
*/
|
||||
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_*/
|
||||
95
moeo/src/algo/moeoPLS2.h
Normal file
95
moeo/src/algo/moeoPLS2.h
Normal 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 416–428
|
||||
*
|
||||
* 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 72–86
|
||||
*
|
||||
* 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 153–176
|
||||
*/
|
||||
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_*/
|
||||
52
moeo/src/algo/moeoPopAlgo.h
Normal file
52
moeo/src/algo/moeoPopAlgo.h
Normal 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_*/
|
||||
50
moeo/src/algo/moeoPopLS.h
Executable file
50
moeo/src/algo/moeoPopLS.h
Executable 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_*/
|
||||
211
moeo/src/algo/moeoSEEA.h
Normal file
211
moeo/src/algo/moeoSEEA.h
Normal 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_*/
|
||||
278
moeo/src/algo/moeoSPEA2.h
Normal file
278
moeo/src/algo/moeoSPEA2.h
Normal 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_*/
|
||||
149
moeo/src/algo/moeoUnifiedDominanceBasedLS.h
Executable file
149
moeo/src/algo/moeoUnifiedDominanceBasedLS.h
Executable 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_*/
|
||||
|
||||
445
moeo/src/archive/moeo2DMinHypervolumeArchive.h
Normal file
445
moeo/src/archive/moeo2DMinHypervolumeArchive.h
Normal 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_ */
|
||||
235
moeo/src/archive/moeoArchive.h
Normal file
235
moeo/src/archive/moeoArchive.h
Normal 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_ */
|
||||
81
moeo/src/archive/moeoBoundedArchive.h
Normal file
81
moeo/src/archive/moeoBoundedArchive.h
Normal 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_*/
|
||||
421
moeo/src/archive/moeoEpsilonHyperboxArchive.h
Normal file
421
moeo/src/archive/moeoEpsilonHyperboxArchive.h
Normal 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_*/
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue