From ddc1e86f62326080db77f39ddd2426b85d3b34ef Mon Sep 17 00:00:00 2001 From: jhumeau Date: Mon, 14 Dec 2009 16:29:06 +0000 Subject: [PATCH] algo VFAS and Weight Strategies added git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1627 331e1502-861f-0410-8da2-ba01fb791d7f --- trunk/paradiseo-moeo/src/algo/moeoVFAS.h | 164 +++++++++++++++++ trunk/paradiseo-moeo/src/moeo | 13 ++ .../src/utils/moeoAnytimeWeightStrategy.h | 101 +++++++++++ .../moeoAugmentedQexploreWeightStrategy.h | 170 ++++++++++++++++++ .../src/utils/moeoDichoWeightStrategy.h | 153 ++++++++++++++++ .../src/utils/moeoDummyRefPointStrategy.h | 51 ++++++ .../src/utils/moeoDummyWeightStrategy.h | 62 +++++++ ...moeoFixedTimeBothDirectionWeightStrategy.h | 87 +++++++++ .../moeoFixedTimeOneDirectionWeightStrategy.h | 80 +++++++++ .../src/utils/moeoQexploreWeightStrategy.h | 114 ++++++++++++ .../src/utils/moeoRandWeightStrategy.h | 83 +++++++++ .../src/utils/moeoVariableRefPointStrategy.h | 51 ++++++ .../src/utils/moeoVariableWeightStrategy.h | 51 ++++++ 13 files changed, 1180 insertions(+) create mode 100644 trunk/paradiseo-moeo/src/algo/moeoVFAS.h create mode 100755 trunk/paradiseo-moeo/src/utils/moeoAnytimeWeightStrategy.h create mode 100755 trunk/paradiseo-moeo/src/utils/moeoAugmentedQexploreWeightStrategy.h create mode 100644 trunk/paradiseo-moeo/src/utils/moeoDichoWeightStrategy.h create mode 100755 trunk/paradiseo-moeo/src/utils/moeoDummyRefPointStrategy.h create mode 100755 trunk/paradiseo-moeo/src/utils/moeoDummyWeightStrategy.h create mode 100755 trunk/paradiseo-moeo/src/utils/moeoFixedTimeBothDirectionWeightStrategy.h create mode 100755 trunk/paradiseo-moeo/src/utils/moeoFixedTimeOneDirectionWeightStrategy.h create mode 100755 trunk/paradiseo-moeo/src/utils/moeoQexploreWeightStrategy.h create mode 100755 trunk/paradiseo-moeo/src/utils/moeoRandWeightStrategy.h create mode 100755 trunk/paradiseo-moeo/src/utils/moeoVariableRefPointStrategy.h create mode 100755 trunk/paradiseo-moeo/src/utils/moeoVariableWeightStrategy.h diff --git a/trunk/paradiseo-moeo/src/algo/moeoVFAS.h b/trunk/paradiseo-moeo/src/algo/moeoVFAS.h new file mode 100644 index 000000000..118ed6c3c --- /dev/null +++ b/trunk/paradiseo-moeo/src/algo/moeoVFAS.h @@ -0,0 +1,164 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 + (C) OPAC Team, LIFL, 2002-2008 + + Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) + François Legillon + + This software is governed by the CeCILL license under French law and + abiding by the rules of distribution of free software. You can use, + modify and/ or redistribute the software under the terms of the CeCILL + license as circulated by CEA, CNRS and INRIA at the following URL + "http://www.cecill.info". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited liability. + + In this respect, the user's attention is drawn to the risks associated + with loading, using, modifying and/or developing or reproducing the + software by the user in light of its specific status of free software, + that may mean that it is complicated to manipulate, and that also + therefore means that it is reserved for developers and experienced + professionals having in-depth computer knowledge. Users are therefore + encouraged to load and test the software's suitability as regards their + requirements in conditions enabling the security of their systems and/or + data to be ensured and, more generally, to use and operate it in the + same conditions as regards security. + The fact that you are presently reading this means that you have had + knowledge of the CeCILL license and that you accept its terms. + + ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr + */ + +#ifndef _moeoVFAS_h +#define _moeoVFAS_h + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +//! Variable fitness assignment search (vfas) +/*! + Search using multiple fitness assignment to search solution to a multi objective problem + */ + +template < class M > +class moeoVFAS:public moeoPopAlgo < typename M::EOType > +{ + + public: + typedef typename M::EOType MOEOT; + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + typedef typename MOEOT::Fitness Fitness; + /*! + constructor using a moAlgo and a vector of weight + take a base vector of weight, and modify it to relaunch the algo with a diferent fitness + use a selectOne to determine which moeot should be the base for the algo launch + use a eoPop to keep result from each iteration + + + @param _algorithm The solution based heuristic to use. It should at least use the fitness value at some point. + @param _continue The stopping criterion. + @param _select a selector to choose on which moeot we use the algorithm + @param _weights a vector containing the base weights, which will be changed at each iteration. + @param _eval The evaluation function. + @param _wstrat the strategy to change weights (should be constructed with the same weights as the fitness) + */ + moeoVFAS (moeoSolAlgo & _algorithm, eoContinue & _continue,moeoSelectOne &_select, + std::vector &_weights, eoEvalFunc< MOEOT > &_eval , moeoVariableWeightStrategy &_wstrat ): + algo(_algorithm),cont(_continue), select(_select), weights(_weights),eval(_eval),wstrat(_wstrat), refPoint(defaultRefPoint),rstrat(defaultRstrat) + {} + + /*! + constructor using a moAlgo an ObjectiveVector and a vector of weight + take a base vector of weight, and modify it to relaunch the algo with a diferent fitness + use a selectOne to determine which moeot should be the base for the algo launch + use a eoPop to keep result from each iteration + + + @param _algorithm The solution based heuristic to use. It should at least use the fitness value at some point. + @param _continue The stopping criterion. + @param _select a selector to choose on which moeot we use the algorithm + @param _weights a vector containing the base weights, which will be changed at each iteration. + @param _refPoint a reference point changed at each iteration + @param _eval The evaluation function. + @param _wstrat the strategy to change weights (should be constructed with the same weights as the fitness) + @param _rstrat the strategy to change the reference point + */ + moeoVFAS (moeoSolAlgo & _algorithm, eoContinue & _continue,moeoSelectOne &_select, + std::vector &_weights, ObjectiveVector &_refPoint, eoEvalFunc< MOEOT > &_eval , moeoVariableWeightStrategy &_wstrat , moeoVariableRefPointStrategy& _rstrat): + algo(_algorithm),cont(_continue), select(_select), weights(_weights),eval(_eval),wstrat(_wstrat), rstrat(_rstrat),refPoint(_refPoint) + {} + + /** + constructor without the weights + @param _algorithm The solution based heuristic to use. It should at least use the fitness value at some point. + @param _continue The stopping criterion. + @param _select a selector to choose on which moeot we use the algorithm + @param _eval The evaluation function. + **/ + moeoVFAS (moeoSolAlgo & _algorithm, eoContinue & _continue,moeoSelectOne &_select, + eoEvalFunc< MOEOT > &_eval, moeoVariableWeightStrategy &_wstrat): + algo(_algorithm),cont(_continue), select(_select), weights(defaultWeights), eval(_eval), wstrat(defaultWstrat), refPoint(defaultRefPoint), rstrat(defaultRstrat) + { + weights.resize(MOEOT::ObjectiveVector::nObjectives(),1.0/MOEOT::ObjectiveVector::nObjectives()); + } + /** + * launch the algorithm + * @param _pop the initial population on which algo will be launched + **/ + virtual void operator()(eoPop &_pop){ + uniform_generator rngGen(0.0,1.0); + for (unsigned int i=0;i<_pop.size();i++){ + if (_pop[i].invalidObjectiveVector()) + eval(_pop[i]); + } + moeoObjectiveVectorNormalizer norm(_pop); + moeoAggregationFitnessAssignment fitness(weights,eval); + bool res=false; + int iteration=0; + fitness(_pop); + MOEOT moeot(select(_pop)); + wstrat(weights,moeot); + rstrat(refPoint,moeot); + + do { + norm.update_by_pop(_pop); + fitness(_pop); + moeot=(select(_pop)); + res=algo(moeot)||res; + _pop.push_back(moeot); + std::cout< &algo; + eoContinue &cont; + moeoSelectOne &select; + std::vector &weights; + std::vector defaultWeights; + ObjectiveVector &refPoint; + ObjectiveVector defaultRefPoint; + eoEvalFunc &eval; + moeoVariableWeightStrategy &wstrat; + moeoVariableRefPointStrategy &rstrat; + moeoDummyRefPointStrategy defaultRstrat; + moeoDummyWeightStrategy defaultWstrat; + + +}; +#endif diff --git a/trunk/paradiseo-moeo/src/moeo b/trunk/paradiseo-moeo/src/moeo index 341e7a04a..7d0683bae 100644 --- a/trunk/paradiseo-moeo/src/moeo +++ b/trunk/paradiseo-moeo/src/moeo @@ -57,6 +57,7 @@ #include #include #include +#include #include @@ -174,6 +175,18 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include diff --git a/trunk/paradiseo-moeo/src/utils/moeoAnytimeWeightStrategy.h b/trunk/paradiseo-moeo/src/utils/moeoAnytimeWeightStrategy.h new file mode 100755 index 000000000..5a86595db --- /dev/null +++ b/trunk/paradiseo-moeo/src/utils/moeoAnytimeWeightStrategy.h @@ -0,0 +1,101 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* François Legillon +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* + */ +//----------------------------------------------------------------------------- + +#ifndef MOEOANYTIMEWEIGHTSTRAT_H_ +#define MOEOANYTIMEWEIGHTSTRAT_H_ +#include +#include +#include +#include + +/** + * Change all weights according to a pattern ressembling to a "double strategy" 2 to 1 then 1 to 2. + * Can only be applied to 2 objectives vector problem + */ +template +class moeoAnytimeWeightStrategy: public moeoVariableWeightStrategy +{ + public: + /** + * default constructor + */ + moeoAnytimeWeightStrategy():random(default_random),depth(0){} + + /** + * constructor with a given random generator, for algorithms wanting to keep the same generator for some reason + * @param _random an uniform random generator + */ + moeoAnytimeWeightStrategy(UF_random_generator &_random):random(_random), depth(0){} + + /** + * + * @param _weights the weights to change + * @param _moeot not used + */ + void operator()(std::vector& _weights, const MOEOT& _moeot){ + if (depth<2){ + if (depth==0) toTest.push_back(0.5); + _weights[0]=depth; + _weights[1]=1-_weights[0]; + depth++; + old1=0; + old2=1; + return; + } + if (!toTest.empty()){ + _weights[0]=toTest.front(); + _weights[1]=1-_weights[0]; + toTest.erase(toTest.begin()); + toTest.push_back((_weights[0]+old1)/2); + toTest.push_back((_weights[0]+old2)/2); + old2=old1; + old1=_weights[0]; + }else{ + std::cout<<"Error: Strange occurence in moeoAnytimeWeightStrategy "< &random; + UF_random_generator default_random; + int depth; + std::list toTest; +}; + +#endif diff --git a/trunk/paradiseo-moeo/src/utils/moeoAugmentedQexploreWeightStrategy.h b/trunk/paradiseo-moeo/src/utils/moeoAugmentedQexploreWeightStrategy.h new file mode 100755 index 000000000..591872e28 --- /dev/null +++ b/trunk/paradiseo-moeo/src/utils/moeoAugmentedQexploreWeightStrategy.h @@ -0,0 +1,170 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* François Legillon +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* + */ +//----------------------------------------------------------------------------- + +#ifndef MOEOAUGMENTEDQEXPLWEIGHTSTRAT_H_ +#define MOEOAUGMENTEDQEXPLWEIGHTSTRAT_H_ +#include +#include +#include +#include + +/** + * Change all weights according to a pattern ressembling to a "double strategy" 2 to 1 then 1 to 2. + * Can only be applied to 2 objectives vector problem + */ +template +class moeoAugmentedQexploreWeightStrategy: public moeoVariableWeightStrategy +{ + public: + /** + * default constructor + */ + moeoAugmentedQexploreWeightStrategy():depth(0),num(0),reset(true){ + nums.resize(1,0); + } + /** + * + * @param _weights the weights to change + * @param moeot a moeot, not used + */ + void operator()(std::vector &_weights,const MOEOT &moeot){ + int dim=moeot.objectiveVector().size(); + bool res=false; + int max=dim-1; + if (depth==0) do_reset(); + while (!res) { + res=translate(dim,_weights); + next_num(dim); + if (nums[0]>max){ + do_reset(); + } + } + } + + private: + + void next_num(int dim){ + int max=dim-1; + int idx=nums.size()-1; + if (depth==0){ + do_reset(); + }else{ + idx=nums.size()-1; + while(idx>0 && nums[idx]==max) idx--; + int to_assign=nums[idx]+1; + for (unsigned int i=idx;i &_weights){ + _weights.clear(); + _weights.resize(dim,0); + int max=dim-1; + for (unsigned int i=0;i1 && _weights[nums[i]]==depth) { + return false; + } + } + + bool accept_pow=false; + bool accept_prim=false; + for (unsigned int i=0;i<_weights.size();i++){ + if (accept_pow || (_weights[i]!=1 && !is2pow(_weights[i]))) { + accept_pow=true; + } + if (accept_prim || (coprim(_weights[i],depth))) + accept_prim=true; + + _weights[i]=(_weights[i]+0.0)/(0.0+depth); + } + return accept_prim && accept_pow; + } + + void do_reset(){ + if (depth==0) depth=1; + else depth=depth*2; + nums.resize(depth); + for (unsigned int i=0;i nums; + int depth,num; + bool reset; + +}; + +#endif diff --git a/trunk/paradiseo-moeo/src/utils/moeoDichoWeightStrategy.h b/trunk/paradiseo-moeo/src/utils/moeoDichoWeightStrategy.h new file mode 100644 index 000000000..703ee4925 --- /dev/null +++ b/trunk/paradiseo-moeo/src/utils/moeoDichoWeightStrategy.h @@ -0,0 +1,153 @@ +/* + * + * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 + * (C) OPAC Team, LIFL, 2002-2007 + * + * Fran<-61><-89>ois Legillon + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + * ParadisEO WebSite : http://paradiseo.gforge.inria.fr + * Contact: paradiseo-help@lists.gforge.inria.fr + * + */ +//----------------------------------------------------------------------------- + +#ifndef MOEODICHOWEIGHTSTRAT_H_ +#define MOEODICHOWEIGHTSTRAT_H_ +#include +#include +#include +#include + +/** + * Change all weights according to a pattern ressembling to a "double strategy" 2 to 1 then 1 to 2. + * Can only be applied to 2 objectives vector problem + */ +template +class moeoDichoWeightStrategy: public moeoVariableWeightStrategy +{ + public: + /** + * default constructor + */ + moeoDichoWeightStrategy():random(default_random),num(0){} + + /** + * constructor with a given random generator, for algorithms wanting to keep the same generator for some reason + * @param _random an uniform random generator + */ + moeoDichoWeightStrategy(UF_random_generator &_random):random(_random),num(0){} + + /** + * + * @param _weights the weights to change + * @param moeot a moeot, will be kept in an archive in order to calculate weights later + */ + void operator()(std::vector &_weights,const MOEOT &moeot){ + std::vector res; + ObjectiveVector tmp; + _weights.resize(moeot.objectiveVector().size()); + if (arch.size()<2){ + //archive too small, we generate starting weights to populate it + //if no better solution is provided, we will toggle between (0,1) and (1,0) + arch(moeot); + if (num==0){ + _weights[0]=0; + _weights[1]=1; + num++; + }else{ + _weights[1]=0; + _weights[0]=1; + num=0; + std::sort(arch.begin(),arch.end(),cmpParetoSort()); + it=arch.begin(); + } + return; + }else{ + if (it!=arch.end()){ + tmp=(*it).objectiveVector(); + it++; + if (it==arch.end()){ + //we were at the last elements, recurse to update the archive + operator()(_weights,moeot); + return; + } + toAdd.push_back(moeot); + res=normal(tmp,(*it).objectiveVector()); + _weights[0]=res[0]; + _weights[1]=res[1]; + }else{ + //we only add new elements to the archive once we have done an entire cycle on it, + //to prevent iterator breaking + //then we reset the iterator, and we recurse to start over + arch(toAdd); + toAdd.clear(); + std::sort(arch.begin(),arch.end(),cmpParetoSort()); + it=arch.begin(); + operator()(_weights,moeot); + return; + } + } + + } + + + + private: + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + std::vector normal(const ObjectiveVector &_obj1, const ObjectiveVector &_obj2){ + std::vector res; + double sum=0; + for (unsigned int i=0;i<_obj1.size();i++){ + if (_obj1[i]>_obj2[i]) + res.push_back(_obj1[i]-_obj2[i]); + else + res.push_back(_obj2[i]-_obj1[i]); + sum+=res[i]; + } + for (unsigned int i=0;i<_obj1.size();i++) res[i]=res[i]/sum; + return res; + } + struct cmpParetoSort + { + //since we apply it to a 2dimension pareto front, we can sort every objectiveVector + // following either objective without problem + bool operator()(const MOEOT & a,const MOEOT & b) const + { + return b.objectiveVector()[0] &random; + UF_random_generator default_random; + int num; + moeoUnboundedArchive arch; + eoPop toAdd; + typename eoPop::iterator it; +}; + +#endif diff --git a/trunk/paradiseo-moeo/src/utils/moeoDummyRefPointStrategy.h b/trunk/paradiseo-moeo/src/utils/moeoDummyRefPointStrategy.h new file mode 100755 index 000000000..a1b0c0e53 --- /dev/null +++ b/trunk/paradiseo-moeo/src/utils/moeoDummyRefPointStrategy.h @@ -0,0 +1,51 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* François Legillon +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ +//----------------------------------------------------------------------------- + +#ifndef MOEODUMMYREFPOINT_H_ +#define MOEODUMMYREFPOINT_H_ + +/** + * dummy class for variable reference point strategies. do nothing + */ +template +class moeoDummyRefPointStrategy : public moeoVariableRefPointStrategy + { + public: + virtual void operator()(typename MOEOT::ObjectiveVector &_obj,const MOEOT &_moeo ){} + }; + +#endif diff --git a/trunk/paradiseo-moeo/src/utils/moeoDummyWeightStrategy.h b/trunk/paradiseo-moeo/src/utils/moeoDummyWeightStrategy.h new file mode 100755 index 000000000..3db57a2e2 --- /dev/null +++ b/trunk/paradiseo-moeo/src/utils/moeoDummyWeightStrategy.h @@ -0,0 +1,62 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* François Legillon +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ +//----------------------------------------------------------------------------- + +#ifndef MOEODUMMYWEIGHTSTRAT_H_ +#define MOEODUMMYWEIGHTSTRAT_H_ +#include + +/** + * Dummy variable weight strategy. Fill the weight with equal values + */ +template +class moeoDummyWeightStrategy: public moeoVariableWeightStrategy + { + public: + /** + * main function + * @param _weights the weights to change + * @param _moeot not used + */ + void operator()(std::vector &_weights,const MOEOT &_moeot){ + double sum=0; + for (unsigned int i=0;i<_weights.size();i++){ + _weights[i]=(1.0/_weights.size()); + } + } + }; + +#endif diff --git a/trunk/paradiseo-moeo/src/utils/moeoFixedTimeBothDirectionWeightStrategy.h b/trunk/paradiseo-moeo/src/utils/moeoFixedTimeBothDirectionWeightStrategy.h new file mode 100755 index 000000000..6b935cac5 --- /dev/null +++ b/trunk/paradiseo-moeo/src/utils/moeoFixedTimeBothDirectionWeightStrategy.h @@ -0,0 +1,87 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* François Legillon +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* + */ +//----------------------------------------------------------------------------- + +#ifndef MOEOFTBDWSWEIGHTSTRAT_H_ +#define MOEOFTBDWSWEIGHTSTRAT_H_ +#include +#include +#include +#include + +/** + * Change all weights according to a "double strategy" pattern 2 to 1 then 1 to 2. + */ +template +class moeoFixedTimeBothDirectionWeightStrategy: public moeoVariableWeightStrategy +{ + public: + /** + * default constructor + * @param _step how much we want the weight to change every iteration + */ + moeoFixedTimeBothDirectionWeightStrategy(double _step):step(_step),current(0),direction(false){} + /** + * + * @param _weights the weights to change + * @param moeot a moeot, not used + */ + void operator()(std::vector &_weights,const MOEOT &moeot){ + double res; + if (current==1){ + res=1; + current=0; + direction=!direction; + }else res=current; + if (current+step>1){ + current=1; + }else current+=step; + if (direction){ + _weights[0]=res; + _weights[1]=1-res; + }else{ + _weights[0]=1-res; + _weights[1]=res; + } + } + + private: + double step; + double current; + bool direction; +}; + +#endif diff --git a/trunk/paradiseo-moeo/src/utils/moeoFixedTimeOneDirectionWeightStrategy.h b/trunk/paradiseo-moeo/src/utils/moeoFixedTimeOneDirectionWeightStrategy.h new file mode 100755 index 000000000..e21c4535d --- /dev/null +++ b/trunk/paradiseo-moeo/src/utils/moeoFixedTimeOneDirectionWeightStrategy.h @@ -0,0 +1,80 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* François Legillon +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* + */ +//----------------------------------------------------------------------------- + +#ifndef MOEOFTODWSWEIGHTSTRAT_H_ +#define MOEOFTODWSWEIGHTSTRAT_H_ +#include +#include +#include +#include + +/** + * Change all weights according to a simple strategy by adding a step every generation + */ +template +class moeoFixedTimeOneDirectionWeightStrategy: public moeoVariableWeightStrategy +{ + public: + /** + * default constructor + * @param _step how much we want the weight to change every iteration + */ + moeoFixedTimeOneDirectionWeightStrategy(double _step):step(_step),current(0){} + /** + * + * @param _weights the weights to change + * @param moeot a moeot, not used + */ + void operator()(std::vector &_weights,const MOEOT &moeot){ + double res; + if (current==1){ + res=1; + current=0; + }else res=current; + if (current+step>1){ + current=1; + }else current+=step; + _weights[0]=res; + _weights[1]=1-res; + } + + private: + double step; + double current; +}; + +#endif diff --git a/trunk/paradiseo-moeo/src/utils/moeoQexploreWeightStrategy.h b/trunk/paradiseo-moeo/src/utils/moeoQexploreWeightStrategy.h new file mode 100755 index 000000000..7fbabe029 --- /dev/null +++ b/trunk/paradiseo-moeo/src/utils/moeoQexploreWeightStrategy.h @@ -0,0 +1,114 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* François Legillon +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* + */ +//----------------------------------------------------------------------------- + +#ifndef MOEOQEXPLWEIGHTSTRAT_H_ +#define MOEOQEXPLWEIGHTSTRAT_H_ +#include +#include +#include +#include +//#include +/** + * Change all weights according to a pattern ressembling to a "double strategy" 2 to 1 then 1 to 2. + * Can only be applied to 2 objectives vector problem + */ +template +class moeoQexploreWeightStrategy: public moeoVariableWeightStrategy +{ + public: + /** + * default constructor + */ + moeoQexploreWeightStrategy():random(default_random),depth(0),num(0){} + + /** + * constructor with a given random generator, for algorithms wanting to keep the same generator for some reason + * @param _random an uniform random generator + */ + moeoQexploreWeightStrategy(UF_random_generator &_random):random(_random),depth(0),num(0){} + /** + * + * @param _weights the weights to change + * @param moeot a moeot, not used + */ + void operator()(std::vector &_weights,const MOEOT &moeot){ + if (depth==0){ + if (num==0){ + num++; + _weights[0]=0; + _weights[1]=1; + }else{ + num=1; + depth=1; + _weights[0]=1; + _weights[1]=0; + } + }else{ + while (num=depth){ + depth++; + num=1; + } + _weights[0]=(num+0.0)/depth; + _weights[1]=1-(num+0.0)/depth; + num++; + } + } + + + private: + + bool coprim(int a, int b){ + if (b==0){ + return a==1; + }else { + return coprim(b,a%b); + } + } + + void next_num(){ + + } + UF_random_generator &random; + UF_random_generator default_random; + int depth,num,idx; + std::list toTest; +}; + +#endif diff --git a/trunk/paradiseo-moeo/src/utils/moeoRandWeightStrategy.h b/trunk/paradiseo-moeo/src/utils/moeoRandWeightStrategy.h new file mode 100755 index 000000000..3c2099a95 --- /dev/null +++ b/trunk/paradiseo-moeo/src/utils/moeoRandWeightStrategy.h @@ -0,0 +1,83 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* François Legillon +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ +//----------------------------------------------------------------------------- + +#ifndef MOEORANDWEIGHTSTRAT_H_ +#define MOEORANDWEIGHTSTRAT_H_ +#include + +/** + * Change all weights randomly. + */ +template +class moeoRandWeightStrategy: public moeoVariableWeightStrategy + { + public: + /** + * default constructor + */ + moeoRandWeightStrategy():random(default_random){} + + /** + * constructor with a given random generator, for algorithms wanting to keep the same generator for some reason + * @param _random an uniform random generator + */ + moeoRandWeightStrategy(UF_random_generator &_random):random(_random){} + + /** + * main function, fill the weight randomly + * @param _weights the weights to change + * @param _moeot not used + */ + void operator()(std::vector &_weights,const MOEOT &_moeot){ + double sum=0; + for (unsigned int i=0;i<_weights.size();i++){ + double rnd=random(100000); + sum+=rnd; + _weights[i]=rnd; + } + //we divide by the sum in order to keep the weight sum equal to 1 + for (unsigned int i=0;i<_weights.size();i++){ + _weights[i]=_weights[i]/sum; + } + } + + private: + UF_random_generator &random; + UF_random_generator default_random; + }; + +#endif diff --git a/trunk/paradiseo-moeo/src/utils/moeoVariableRefPointStrategy.h b/trunk/paradiseo-moeo/src/utils/moeoVariableRefPointStrategy.h new file mode 100755 index 000000000..1eb355d54 --- /dev/null +++ b/trunk/paradiseo-moeo/src/utils/moeoVariableRefPointStrategy.h @@ -0,0 +1,51 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* François Legillon +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ +//----------------------------------------------------------------------------- + +#ifndef MOEOVARREFPOINT_H_ +#define MOEOVARREFPOINT_H_ + +/** + * Abstract class for strategies for changing reference point, in a fitness assignment that use it. + */ +template +class moeoVariableRefPointStrategy + { + public: + virtual void operator()(typename MOEOT::ObjectiveVector &_obj,const MOEOT &_moeo )=0; + }; + +#endif diff --git a/trunk/paradiseo-moeo/src/utils/moeoVariableWeightStrategy.h b/trunk/paradiseo-moeo/src/utils/moeoVariableWeightStrategy.h new file mode 100755 index 000000000..f6a2147b3 --- /dev/null +++ b/trunk/paradiseo-moeo/src/utils/moeoVariableWeightStrategy.h @@ -0,0 +1,51 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* François Legillon +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ +//----------------------------------------------------------------------------- + +#ifndef MOEOVARWEIGHT_H_ +#define MOEOVARWEIGHT_H_ + +/** + * Abstract class for strategies for changing weight, in a aggregative fitness assignment. + */ +template +class moeoVariableWeightStrategy + { + public: + virtual void operator()(std::vector &_weights,const MOEOT &_moeo )=0; + }; + +#endif