test inutiles virés

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1877 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-06-30 13:16:28 +00:00
commit dc83722be4
26 changed files with 0 additions and 5665 deletions

View file

@ -52,7 +52,6 @@ SET (TEST_LIST
t-moeoNSGA
t-moeoNSGAII
t-moeoSEEA
t-moeoMax3Obj
t-moeoEasyEA
t-moeoDominanceCountFitnessAssignment
t-moeoDominanceRankFitnessAssignment
@ -71,28 +70,8 @@ SET (TEST_LIST
t-moeoFitDivBoundedArchive
t-moeoDetArchiveSelect
t-moeoASEEA
t-moeoEpsilonHyperboxArchive
#t-moeoQuadTreeIndex
t-moeoQuickUnboundedArchiveIndex
t-moeoAggregationFitnessAssignment
t-moeoConstraintFitnessAssignment
t-moeoChebyshevMetric
t-moeoChebyshevOrientedMetric
t-moeoASFAMetric
t-moeoASFAOrMetric
t-moeoHC
t-moeoILS_HC
t-moeoILS_SA
t-moeoILS_TS
t-moeoTS
t-moeoVNS
t-moeoVFAS
t-moeoAnytimeWeightStrategy
t-moeoQexploreWeightStrategy
t-moeoAugmentedQexploreWeightStrategy
t-moeoFixedTimeOneDirectionWeightStrategy
t-moeoFixedTimeBothDirectionWeightStrategy
t-moeoDichoWeightStrategy
t-moeoExhaustiveNeighborhoodExplorer
t-moeoFirstImprovingNeighborhoodExplorer
t-moeoSimpleSubNeighborhoodExplorer

View file

@ -1,128 +0,0 @@
/*
* <t-moeoChebyshevMetric.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jeremie Humeau
* Francois 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
*
*/
//-----------------------------------------------------------------------------
// t-moeoAggregationFitnessAssignment.cpp
//-----------------------------------------------------------------------------
#include <eo>
#include <moeo>
#include <cassert>
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
typedef MOEO < ObjectiveVector, double, double > Solution;
class DummyEval: public eoEvalFunc<Solution>{
void operator()(Solution &moeo){
}
} eval;
//-----------------------------------------------------------------------------
int main()
{
std::cout << "[moeoChebyshevMetric] => ";
// objective vectors
ObjectiveVector obj0, obj1, obj2, obj3, obj4, obj5, obj6;
obj0[0] = 3;
obj0[1] = 3;
obj1[0] = 2;
obj1[1] = 2;
obj2[0] = 1;
obj2[1] = 1;
obj4[0] = 0;
obj4[1] = 0;
std::vector<double> poids;
poids.resize(2);
poids[0]=2;
poids[1]=3;
ObjectiveVector obj_poids(poids);
// population
eoPop < Solution > pop;
pop.resize(3);
pop[0].objectiveVector(obj0);
pop[1].objectiveVector(obj1);
pop[2].objectiveVector(obj2);
Solution reference;
reference.objectiveVector(obj4);
unsigned int rho=2;
moeoObjectiveVectorNormalizer<Solution> normalizer(pop,10);
moeoAchievementScalarizingFunctionMetricFitnessAssignment<Solution> fitness(rho,obj4,obj_poids,normalizer);
moeoAchievementScalarizingFunctionMetricFitnessAssignment<Solution> fitness1(rho,obj4,obj_poids,normalizer,eval);
moeoAchievementScalarizingFunctionMetricFitnessAssignment<Solution> fitness2(rho,obj4,obj_poids);
moeoAchievementScalarizingFunctionMetricFitnessAssignment<Solution> fitness3(rho,obj4,obj_poids,eval);
fitness(pop);
fitness(reference);
assert(pop[0].fitness()<pop[1].fitness());
assert(pop[1].fitness()<pop[2].fitness());
std::cout << "Ok" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,129 +0,0 @@
/*
* <t-moeoChebyshevMetric.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jeremie Humeau
* Francois 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
*
*/
//-----------------------------------------------------------------------------
// t-moeoAggregationFitnessAssignment.cpp
//-----------------------------------------------------------------------------
#include <eo>
#include <moeo>
#include <cassert>
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
typedef MOEO < ObjectiveVector, double, double > Solution;
class DummyEval: public eoEvalFunc<Solution>{
void operator()(Solution &moeo){
}
} eval;
//-----------------------------------------------------------------------------
int main()
{
std::cout << "[moeoChebyshevMetric] => ";
// objective vectors
ObjectiveVector obj0, obj1, obj2, obj3, obj4, obj5, obj6;
obj0[0] = 3;
obj0[1] = 3;
obj1[0] = 2;
obj1[1] = 2;
obj2[0] = 1;
obj2[1] = 1;
obj4[0] = 0;
obj4[1] = 0;
std::vector<double> poids;
poids.resize(2);
poids[0]=2;
poids[1]=3;
ObjectiveVector obj_poids(poids);
// population
eoPop < Solution > pop;
pop.resize(3);
pop[0].objectiveVector(obj0);
pop[1].objectiveVector(obj1);
pop[2].objectiveVector(obj2);
Solution reference;
reference.objectiveVector(obj4);
unsigned int rho=2;
moeoObjectiveVectorNormalizer<Solution> normalizer(pop,10);
moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment<Solution> fitness(rho,obj4,obj_poids,normalizer,eval);
moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment<Solution> fitness1(rho,obj4,obj_poids);
moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment<Solution> fitness2(rho,obj4,obj_poids,normalizer);
moeoAugmentedAchievementScalarizingFunctionMetricFitnessAssignment<Solution> fitness3(rho,obj4,obj_poids,eval);
fitness(pop);
fitness(reference);
assert(pop[0].fitness()<pop[1].fitness());
assert(pop[1].fitness()<pop[2].fitness());
std::cout << "Ok" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,147 +0,0 @@
/*
* <t-moeoAchievementFitnessAssignment.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
* Contact: paradiseo-help@lists.gforge.inria.fr
*
*/
//-----------------------------------------------------------------------------
// t-moeoAchievementFitnessAssignment.cpp
//-----------------------------------------------------------------------------
#include <eo>
#include <moeo>
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
typedef MOEO < ObjectiveVector, double, double > Solution;
//-----------------------------------------------------------------------------
int main()
{
std::cout << "[moeoAchievementFitnessAssignment]\t=>\t";
// objective vectors
ObjectiveVector obj0, obj1, obj2, obj3, obj4, obj5;
obj0[0] = 2;
obj0[1] = 5;
obj1[0] = 3;
obj1[1] = 3;
obj2[0] = 4;
obj2[1] = 1;
obj3[0] = 5;
obj3[1] = 5;
obj4[0] = 5;
obj4[1] = 1;
obj5[0] = 3;
obj5[1] = 3;
// population
eoPop < Solution > pop;
pop.resize(6);
pop[0].objectiveVector(obj0);
pop[1].objectiveVector(obj1);
pop[2].objectiveVector(obj2);
pop[3].objectiveVector(obj3);
pop[4].objectiveVector(obj4);
pop[5].objectiveVector(obj5);
// reference point
ObjectiveVector ref;
ref[0] = 3;
ref[1] = 2;
// fitness assignment
moeoAchievementFitnessAssignment< Solution > fitnessAssignment(ref, 0.0);
fitnessAssignment(pop);
// pop[0]
if (pop[0].fitness() != -1.5)
{
std::cout << "ERROR (bad fitness for pop[0])" << std::endl;
return EXIT_FAILURE;
}
// pop[1]
if (pop[1].fitness() != -0.5)
{
std::cout << "ERROR (bad fitness for pop[1])" << std::endl;
return EXIT_FAILURE;
}
// pop[2]
if (pop[2].fitness() != -0.5)
{
std::cout << "ERROR (bad fitness for pop[2])" << std::endl;
return EXIT_FAILURE;
}
// pop[3]
if (pop[3].fitness() != -1.5)
{
std::cout << "ERROR (bad fitness for pop[3]) " << std::endl;
return EXIT_FAILURE;
}
// pop[4]
if (pop[4].fitness() != -1.0)
{
std::cout << "ERROR (bad fitness for pop[4])" << std::endl;
return EXIT_FAILURE;
}
// pop[5]
if (pop[5].fitness() != -0.5)
{
std::cout << "ERROR (bad fitness for pop[5])" << std::endl;
return EXIT_FAILURE;
}
std::cout << "OK" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,115 +0,0 @@
/*
* <t-moeoAggregativeFitnessAssignment.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jeremie Humeau
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
* Contact: paradiseo-help@lists.gforge.inria.fr
*
*/
//-----------------------------------------------------------------------------
// t-moeoAggregativeFitnessAssignment.cpp
//-----------------------------------------------------------------------------
#include <eo>
#include <moeo>
#include <cassert>
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
typedef MOEO < ObjectiveVector, double, double > Solution;
//-----------------------------------------------------------------------------
int main()
{
int res=EXIT_SUCCESS;
std::cout << "[moeoAggregativeFitnessAssignment] => ";
// objective vectors
ObjectiveVector obj0, obj1, obj2, obj3, obj4, obj5, obj6;
obj0[0] = 2;
obj0[1] = 5;
obj1[0] = 3;
obj1[1] = 3;
obj2[0] = 4;
obj2[1] = 1;
obj3[0] = 5;
obj3[1] = 5;
std::vector<double> poids;
poids.resize(2);
poids[0]=2;
poids[1]=3;
// population
eoPop < Solution > pop;
pop.resize(4);
pop[0].objectiveVector(obj0);
pop[1].objectiveVector(obj1);
pop[2].objectiveVector(obj2);
pop[3].objectiveVector(obj3);
moeoAggregativeFitnessAssignment < Solution > fitness(poids);
fitness(pop);
assert(pop[0].fitness() == 19.0);
assert(pop[1].fitness() == 15.0);
assert(pop[2].fitness() == 11.0);
assert(pop[3].fitness() == 25.0);
std::cout << "Ok" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,301 +0,0 @@
/*
* <t-moeoAnytimeWeightStrategy.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2008
*
* Fraéncç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
*
*/
//-----------------------------------------------------------------------------
// t-moeoAnytimeWeightStrategy.cpp
//-----------------------------------------------------------------------------
#include <eo> // EO
#include <oldmo> // MO
#include <moeo>
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
class Solution : public moeoRealVector < ObjectiveVector, double, double >
{
public:
Solution() : moeoRealVector < ObjectiveVector, double, double > (2) {}
};
class solutionEval : public eoEvalFunc < Solution >
{
public:
void operator () (Solution & _sol)
{
ObjectiveVector objVec;
objVec[0] = _sol[0];
objVec[1] = _sol[1];
_sol.objectiveVector(objVec);
}
};
class testMove : public moMove <Solution>
{
public :
void operator () (Solution & _solution)
{
Solution sol=_solution;
}
} ;
class testMoveInit : public moMoveInit <testMove>
{
public :
void operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
}
} ;
class testMoveNext : public moNextMove <testMove>
{
public :
bool operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
return false;
}
} ;
class testMoveIncrEval : public moMoveIncrEval <testMove,ObjectiveVector>
{
public :
ObjectiveVector operator () (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution solution(_solution);
return _solution.objectiveVector();
}
} ;
class testTabuList : public moTabuList<testMove>
{
public:
bool operator() (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
return false;
}
void add(const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
}
void update()
{}
void init()
{}
};
class testAspirCrit : public moAspirCrit<testMove>
{
public:
bool operator() (const testMove & _move, const double & _fitness)
{
double fitness;
const testMove move(_move);
fitness=_fitness;
return false;
}
void init()
{}
};
class solutionContinue : public eoContinue<Solution>
{
public :
solutionContinue(): counter(0)
{}
bool operator () (const eoPop<Solution> & _solution)
{
if(counter==0)
{
counter++;
return true;
}
return false;
}
bool operator () (const Solution & _solution)
{
const Solution sol(_solution);
if(counter==0)
{
counter++;
return true;
}
return false;
}
void init()
{}
private :
unsigned int counter;
} ;
class solutionComparator : public moeoComparator<Solution>
{
public :
const bool operator () (const Solution & _solution1 , const Solution & _solution2)
{
const Solution sol1(_solution1);
const Solution sol2(_solution2);
return sol1.fitness()>sol2.fitness();
}
} ;
class solutionPerturbation : public eoMonOp<Solution>
{
public :
bool operator () (Solution & _solution)
{
ObjectiveVector objVec;
objVec[0] = 1;
objVec[1] = 1;
_solution[1]=1;
_solution[0]=1;
_solution.objectiveVector(objVec);
_solution.fitness(2);
return true;
}
} ;
class solutionSingler : public moeoSingleObjectivization<Solution>
{
void operator () (Solution & _solution){
ObjectiveVector objVec;
objVec[0] = _solution[0];
objVec[1] = _solution[1];
_solution.objectiveVector(objVec);
_solution.fitness(_solution.objectiveVector()[0]+_solution.objectiveVector()[1]);
}
void operator()(eoPop<Solution> &_pop){
}
double operator() (const ObjectiveVector &_obj){
return _obj[0]+_obj[1];
}
void updateByDeleting(eoPop<Solution>& pop, ObjectiveVector& obj){}
} ;
class selectMove: public moMoveSelect<testMove>
{
public:
void init(const double &d){
max_fit=d;
}
bool update(const testMove &move,const double &fitness){
if (fitness>max_fit){
max_fit=fitness;
best_move=move;
return false;
}else
return true;
}
void operator()(testMove &move,double &fitness){
move=best_move;
fitness=max_fit;
}
private:
double max_fit;
testMove best_move;
};
//-----------------------------------------------------------------------------
int main()
{
Solution solution;
moeoAnytimeWeightStrategy<Solution> strat;
std::vector<double> weight;
weight.resize(2);
cout << "[ moeoAnytimeWeightStrategy ] ==> ";
strat(weight,solution);
assert(weight[0]==0 && weight[1]==1);
strat(weight,solution);
assert(weight[0]==1 && weight[1]==0);
strat(weight,solution);
assert(weight[0]==0.5 && weight[1]==0.5);
strat(weight,solution);
assert(weight[0]==0.25 && weight[1]==0.75);
strat(weight,solution);
assert(weight[0]==0.75 && weight[1]==0.25);
std::cout<<"OK"<<std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,300 +0,0 @@
/*
* <t-moeoAugmentedQexploreWeightStrategy.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2008
*
* Fraéncç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
*
*/
//-----------------------------------------------------------------------------
// t-moeoAugmentedQexploreWeightStrategy.cpp
//-----------------------------------------------------------------------------
#include <eo> // EO
#include <oldmo> // MO
#include <moeo>
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 3;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
class Solution : public moeoRealVector < ObjectiveVector, double, double >
{
public:
Solution() : moeoRealVector < ObjectiveVector, double, double > (3) {}
};
class solutionEval : public eoEvalFunc < Solution >
{
public:
void operator () (Solution & _sol)
{
ObjectiveVector objVec;
objVec[0] = _sol[0];
objVec[1] = _sol[1];
objVec[2] = _sol[2];
_sol.objectiveVector(objVec);
}
};
class testMove : public moMove <Solution>
{
public :
void operator () (Solution & _solution)
{
Solution sol=_solution;
}
} ;
class testMoveInit : public moMoveInit <testMove>
{
public :
void operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
}
} ;
class testMoveNext : public moNextMove <testMove>
{
public :
bool operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
return false;
}
} ;
class testMoveIncrEval : public moMoveIncrEval <testMove,ObjectiveVector>
{
public :
ObjectiveVector operator () (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution solution(_solution);
return _solution.objectiveVector();
}
} ;
class testTabuList : public moTabuList<testMove>
{
public:
bool operator() (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
return false;
}
void add(const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
}
void update()
{}
void init()
{}
};
class testAspirCrit : public moAspirCrit<testMove>
{
public:
bool operator() (const testMove & _move, const double & _fitness)
{
double fitness;
const testMove move(_move);
fitness=_fitness;
return false;
}
void init()
{}
};
class solutionContinue : public eoContinue<Solution>
{
public :
solutionContinue(): counter(0)
{}
bool operator () (const eoPop<Solution> & _solution)
{
if(counter==0)
{
counter++;
return true;
}
return false;
}
bool operator () (const Solution & _solution)
{
const Solution sol(_solution);
if(counter==0)
{
counter++;
return true;
}
return false;
}
void init()
{}
private :
unsigned int counter;
} ;
class solutionComparator : public moeoComparator<Solution>
{
public :
const bool operator () (const Solution & _solution1 , const Solution & _solution2)
{
const Solution sol1(_solution1);
const Solution sol2(_solution2);
return sol1.fitness()>sol2.fitness();
}
} ;
class solutionPerturbation : public eoMonOp<Solution>
{
public :
bool operator () (Solution & _solution)
{
ObjectiveVector objVec;
objVec[0] = 1;
objVec[1] = 1;
objVec[2] = 1;
_solution[1]=1;
_solution[0]=1;
_solution[2]=1;
_solution.objectiveVector(objVec);
_solution.fitness(2);
return true;
}
} ;
class solutionSingler : public moeoSingleObjectivization<Solution>
{
void operator () (Solution & _solution){
ObjectiveVector objVec;
objVec[0] = _solution[0];
objVec[1] = _solution[1];
objVec[2] = _solution[2];
_solution.objectiveVector(objVec);
_solution.fitness(_solution.objectiveVector()[0]+_solution.objectiveVector()[1]);
}
void operator()(eoPop<Solution> &_pop){
}
double operator() (const ObjectiveVector &_obj){
return _obj[0]+_obj[1];
}
void updateByDeleting(eoPop<Solution>& pop, ObjectiveVector& obj){}
} ;
class selectMove: public moMoveSelect<testMove>
{
public:
void init(const double &d){
max_fit=d;
}
bool update(const testMove &move,const double &fitness){
if (fitness>max_fit){
max_fit=fitness;
best_move=move;
return false;
}else
return true;
}
void operator()(testMove &move,double &fitness){
move=best_move;
fitness=max_fit;
}
private:
double max_fit;
testMove best_move;
};
//-----------------------------------------------------------------------------
int main()
{
Solution solution;
solutionEval eval;
std::vector<double> weight;
weight.resize(3);
cout << "[moeoAugmentedQexploreWeightStrategy] ==> ";
moeoAugmentedQexploreWeightStrategy<Solution> strat;
for (unsigned int i=0;i<6000;i++){
eval(solution);
strat(weight,solution);
// std::cout<<weight[0]<<" "<<weight[1]<<" "<<weight[2]<<" "/*<<weight[3]*/<<std::endl;
}
std::cout<<"OK"<<std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,128 +0,0 @@
/*
* <t-moeoChebyshevMetric.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jeremie Humeau
* Francois 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
*
*/
//-----------------------------------------------------------------------------
// t-moeoAggregationFitnessAssignment.cpp
//-----------------------------------------------------------------------------
#include <eo>
#include <moeo>
#include <cassert>
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return false;
}
static bool maximizing (int i)
{
return true;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
typedef MOEO < ObjectiveVector, double, double > Solution;
class DummyEval: public eoEvalFunc<Solution>{
void operator()(Solution &moeo){
}
} eval;
//-----------------------------------------------------------------------------
int main()
{
std::cout << "[moeoChebyshevMetric] => ";
// objective vectors
ObjectiveVector obj0, obj1, obj2, obj3, obj4, obj5, obj6;
obj0[0] = 3;
obj0[1] = 3;
obj1[0] = 2;
obj1[1] = 2;
obj2[0] = 1;
obj2[1] = 1;
obj4[0] = 0;
obj4[1] = 0;
std::vector<double> poids;
poids.resize(2);
poids[0]=2;
poids[1]=3;
ObjectiveVector obj_poids(poids);
// population
eoPop < Solution > pop;
pop.resize(3);
pop[0].objectiveVector(obj0);
pop[1].objectiveVector(obj1);
pop[2].objectiveVector(obj2);
Solution reference;
reference.objectiveVector(obj4);
unsigned int rho=2;
moeoObjectiveVectorNormalizer<Solution> normalizer(pop,10);
moeoWeightedChebychevMetricFitnessAssignment<Solution> fitness(rho,obj4,obj_poids,normalizer);
moeoWeightedChebychevMetricFitnessAssignment<Solution> fitness2(rho,obj4,obj_poids);
moeoWeightedChebychevMetricFitnessAssignment<Solution> fitness3(rho,obj4,obj_poids,eval);
moeoWeightedChebychevMetricFitnessAssignment<Solution> fitness4(rho,obj4,obj_poids,normalizer,eval);
fitness(pop);
fitness(reference);
assert(pop[0].fitness()<pop[1].fitness());
assert(pop[1].fitness()<pop[2].fitness());
std::cout << "Ok" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,128 +0,0 @@
/*
* <t-moeoChebyshevOrientedMetric.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jeremie Humeau
* Francois 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
*
*/
//-----------------------------------------------------------------------------
// t-moeoAggregationFitnessAssignment.cpp
//-----------------------------------------------------------------------------
#include <eo>
#include <moeo>
#include <cassert>
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
typedef MOEO < ObjectiveVector, double, double > Solution;
class DummyEval: public eoEvalFunc<Solution>{
void operator()(Solution &moeo){
}
} eval;
//-----------------------------------------------------------------------------
int main()
{
std::cout << "[moeoChebyshevMetric] => ";
// objective vectors
ObjectiveVector obj0, obj1, obj2, obj3, obj4, obj5, obj6;
obj0[0] = 3;
obj0[1] = 3;
obj1[0] = 2;
obj1[1] = 2;
obj2[0] = 1;
obj2[1] = 1;
obj4[0] = 0;
obj4[1] = 0;
std::vector<double> poids;
poids.resize(2);
poids[0]=2;
poids[1]=3;
ObjectiveVector obj_poids(poids);
// population
eoPop < Solution > pop;
pop.resize(3);
pop[0].objectiveVector(obj0);
pop[1].objectiveVector(obj1);
pop[2].objectiveVector(obj2);
Solution reference;
reference.objectiveVector(obj4);
unsigned int rho=2;
moeoObjectiveVectorNormalizer<Solution> normalizer(pop,10);
moeoAugmentedWeightedChebychevMetricFitnessAssignment<Solution> fitness(rho,obj4,obj_poids,normalizer,eval);
moeoAugmentedWeightedChebychevMetricFitnessAssignment<Solution> fitness1(rho,obj4,obj_poids,normalizer);
moeoAugmentedWeightedChebychevMetricFitnessAssignment<Solution> fitness2(rho,obj4,obj_poids,eval);
moeoAugmentedWeightedChebychevMetricFitnessAssignment<Solution> fitness3(rho,obj4,obj_poids);
fitness(pop);
fitness(reference);
assert(pop[0].fitness()<pop[1].fitness());
assert(pop[1].fitness()<pop[2].fitness());
std::cout << "Ok" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,122 +0,0 @@
/*
* <t-moeoConstraintFitnessAssignment.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jeremie Humeau
* Francois 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
*
*/
//-----------------------------------------------------------------------------
// t-moeoAggregationFitnessAssignment.cpp
//-----------------------------------------------------------------------------
#include <eo>
#include <moeo>
#include <cassert>
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
typedef MOEO < ObjectiveVector, double, double > Solution;
class DummyEval: public eoEvalFunc<Solution>{
void operator()(Solution &moeo){
}
} defaultEval;
//-----------------------------------------------------------------------------
int main()
{
std::cout << "[moeoAggregationFitnessAssignment] => ";
// objective vectors
ObjectiveVector obj0, obj1, obj2, obj3, obj4, obj5, obj6;
obj0[0] = 0;
obj0[1] = 2;
obj1[0] = 2;
obj1[1] = 0;
obj2[0] = 4;
obj2[1] = 2;
obj4[0] = 3;
obj4[1] = 0;
std::vector<double> poids;
poids.resize(2);
poids[0]=2;
poids[1]=1;
// population
eoPop < Solution > pop;
pop.resize(3);
pop[0].objectiveVector(obj0);
pop[1].objectiveVector(obj1);
pop[2].objectiveVector(obj2);
moeoObjectiveVectorNormalizer<Solution> normalizer;
moeoConstraintFitnessAssignment < Solution > fitness(poids,obj4,1,normalizer);
moeoConstraintFitnessAssignment < Solution > fitness2(poids,obj4,1,normalizer,defaultEval);
fitness(pop);
assert(pop[0].fitness()==-2);
assert(pop[1].fitness()==0);
assert(pop[2].fitness()==-4);
std::cout << "Ok" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,305 +0,0 @@
/*
* <t-moeoDichoWeightStrategy.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2008
*
* François Legillon
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
* Contact: paradiseo-help@lists.gforge.inria.fr
*
*/
//-----------------------------------------------------------------------------
// t-moILS_HC.cpp
//-----------------------------------------------------------------------------
#include <eo> // EO
#include <oldmo> // MO
#include <moeo>
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
class Solution : public moeoRealVector < ObjectiveVector, double, double >
{
public:
Solution() : moeoRealVector < ObjectiveVector, double, double > (2) {}
};
class solutionEval : public eoEvalFunc < Solution >
{
public:
void operator () (Solution & _sol)
{
ObjectiveVector objVec;
objVec[0] = _sol[0];
objVec[1] = _sol[1];
_sol.objectiveVector(objVec);
}
};
class testMove : public moMove <Solution>
{
public :
void operator () (Solution & _solution)
{
Solution sol=_solution;
}
} ;
class testMoveInit : public moMoveInit <testMove>
{
public :
void operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
}
} ;
class testMoveNext : public moNextMove <testMove>
{
public :
bool operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
return false;
}
} ;
class testMoveIncrEval : public moMoveIncrEval <testMove,ObjectiveVector>
{
public :
ObjectiveVector operator () (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution solution(_solution);
return _solution.objectiveVector();
}
} ;
class testTabuList : public moTabuList<testMove>
{
public:
bool operator() (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
return false;
}
void add(const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
}
void update()
{}
void init()
{}
};
class testAspirCrit : public moAspirCrit<testMove>
{
public:
bool operator() (const testMove & _move, const double & _fitness)
{
double fitness;
const testMove move(_move);
fitness=_fitness;
return false;
}
void init()
{}
};
class solutionContinue : public eoContinue<Solution>
{
public :
solutionContinue(): counter(0)
{}
bool operator () (const eoPop<Solution> & _solution)
{
if(counter==0)
{
counter++;
return true;
}
return false;
}
bool operator () (const Solution & _solution)
{
const Solution sol(_solution);
if(counter==0)
{
counter++;
return true;
}
return false;
}
void init()
{}
private :
unsigned int counter;
} ;
class solutionComparator : public moeoComparator<Solution>
{
public :
const bool operator () (const Solution & _solution1 , const Solution & _solution2)
{
const Solution sol1(_solution1);
const Solution sol2(_solution2);
return sol1.fitness()>sol2.fitness();
}
} ;
class solutionPerturbation : public eoMonOp<Solution>
{
public :
bool operator () (Solution & _solution)
{
ObjectiveVector objVec;
objVec[0] = 1;
objVec[1] = 1;
_solution[1]=1;
_solution[0]=1;
_solution.objectiveVector(objVec);
_solution.fitness(2);
return true;
}
} ;
class solutionSingler : public moeoSingleObjectivization<Solution>
{
void operator () (Solution & _solution){
ObjectiveVector objVec;
objVec[0] = _solution[0];
objVec[1] = _solution[1];
_solution.objectiveVector(objVec);
_solution.fitness(_solution.objectiveVector()[0]+_solution.objectiveVector()[1]);
}
void operator()(eoPop<Solution> &_pop){
}
double operator() (const ObjectiveVector &_obj){
return _obj[0]+_obj[1];
}
void updateByDeleting(eoPop<Solution>& pop, ObjectiveVector& obj){}
} ;
class selectMove: public moMoveSelect<testMove>
{
public:
void init(const double &d){
max_fit=d;
}
bool update(const testMove &move,const double &fitness){
if (fitness>max_fit){
max_fit=fitness;
best_move=move;
return false;
}else
return true;
}
void operator()(testMove &move,double &fitness){
move=best_move;
fitness=max_fit;
}
private:
double max_fit;
testMove best_move;
};
//-----------------------------------------------------------------------------
int main()
{
Solution solution;
moeoDichoWeightStrategy<Solution> strat;
solutionEval eval;
std::vector<double> weight;
cout << "[moeoDichoWeightStrategy] ==> ";
weight.resize(2);
ObjectiveVector obj;
obj[0]=1;
obj[1]=0;
solution.objectiveVector(obj);
strat(weight,solution);
assert(weight[0]==0 && weight[1]==1);
obj[0]=0;
obj[1]=1;
solution.objectiveVector(obj);
strat(weight,solution);
assert(weight[0]==1 && weight[1]==0);
strat(weight,solution);
assert(weight[0]==0.5 && weight[1]==0.5);
std::cout<<"OK"<<std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,161 +0,0 @@
/*
* <t-moeoEpsilonHyperboxArchive.cpp>
* 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
*
*/
//-----------------------------------------------------------------------------
// t-moeoEpsilonHyperboxArchive.cpp
//-----------------------------------------------------------------------------
#include <eo>
#include <moeo>
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
typedef MOEO < ObjectiveVector, double, double > Solution;
//-----------------------------------------------------------------------------
int main()
{
//!!!!!!!!!!!!VRAI TEST A FAIRE!!!!!!!!!!!!!!
std::cout << "[moeoEpsilonHyperboxArchive]\t=>\t";
std::cout << std::endl;
// objective vectors
ObjectiveVector obj;
// population
eoPop < Solution > pop;
pop.resize(100);
unsigned int o1=50;
unsigned int o2=50;
unsigned int o3=50;
unsigned int o4=50;
for(int i=0; i< pop.size()/2; i++){
// tmp=rng.uniform()*100;
obj[0]=o1;
obj[1]=o2;
// obj[0]=tmp;
// obj[1]=100-tmp;
pop[2*i].objectiveVector(obj);
obj[0]=o3;
obj[1]=o4;
// tmp=rng.uniform()*100;
// obj[0]=tmp;
// obj[1]=100-tmp;
pop[2*i + 1].objectiveVector(obj);
o1++;
o2--;
o3--;
o4++;
}
// pop.resize(4);
// obj[0]=0;
// obj[1]=100;
// pop[0].objectiveVector(obj);
// obj[0]=100;
// obj[1]=0;
// pop[1].objectiveVector(obj);
// obj[0]=50;
// obj[1]=50;
// pop[2].objectiveVector(obj);
// obj[0]=49;
// obj[1]=50.5;
// pop[3].objectiveVector(obj);
std::vector < double > epsilon;
epsilon.push_back(0.05);
epsilon.push_back(0.05);
// archive
moeoEpsilonHyperboxArchive< Solution > arch(epsilon);
ObjectiveVector nadir = arch.getNadir();
ObjectiveVector ideal = arch.getIdeal();
std::cout << "nadir: " << nadir << std::endl;
std::cout << "ideal: " << ideal << std::endl;
for(int i=0; i<pop.size() ; i++)
std::cout << pop[i].objectiveVector() << std::endl;
for(int i=0; i<pop.size() ; i++){
arch(pop[i]);
// nadir = arch.getNadir();
// ideal = arch.getIdeal();
// std::cout << "nadir: " << nadir << std::endl;
// std::cout << "ideal: " << ideal << std::endl;
// std::cout << "archive size: " << arch.size() << std::endl;
}
arch.filtre();
std::cout << "archive size: " << arch.size() << std::endl;
for (unsigned int i=0; i< arch.size(); i++)
std::cout << arch[i].objectiveVector() << std::endl;
std::cout << "nadir: " << nadir << std::endl;
std::cout << "ideal: " << ideal << std::endl;
//arch(pop);
std::cout << "OK" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,295 +0,0 @@
/*
* <t-moeoFixedTimeBothDirectionWeightStrategy.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2008
*
* Fraéncç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
*
*/
//-----------------------------------------------------------------------------
// t-moILS_HC.cpp
//-----------------------------------------------------------------------------
#include <eo> // EO
#include <oldmo> // MO
#include <moeo>
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
class Solution : public moeoRealVector < ObjectiveVector, double, double >
{
public:
Solution() : moeoRealVector < ObjectiveVector, double, double > (2) {}
};
class solutionEval : public eoEvalFunc < Solution >
{
public:
void operator () (Solution & _sol)
{
ObjectiveVector objVec;
objVec[0] = _sol[0];
objVec[1] = _sol[1];
_sol.objectiveVector(objVec);
}
};
class testMove : public moMove <Solution>
{
public :
void operator () (Solution & _solution)
{
Solution sol=_solution;
}
} ;
class testMoveInit : public moMoveInit <testMove>
{
public :
void operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
}
} ;
class testMoveNext : public moNextMove <testMove>
{
public :
bool operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
return false;
}
} ;
class testMoveIncrEval : public moMoveIncrEval <testMove,ObjectiveVector>
{
public :
ObjectiveVector operator () (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution solution(_solution);
return _solution.objectiveVector();
}
} ;
class testTabuList : public moTabuList<testMove>
{
public:
bool operator() (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
return false;
}
void add(const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
}
void update()
{}
void init()
{}
};
class testAspirCrit : public moAspirCrit<testMove>
{
public:
bool operator() (const testMove & _move, const double & _fitness)
{
double fitness;
const testMove move(_move);
fitness=_fitness;
return false;
}
void init()
{}
};
class solutionContinue : public eoContinue<Solution>
{
public :
solutionContinue(): counter(0)
{}
bool operator () (const eoPop<Solution> & _solution)
{
if(counter==0)
{
counter++;
return true;
}
return false;
}
bool operator () (const Solution & _solution)
{
const Solution sol(_solution);
if(counter==0)
{
counter++;
return true;
}
return false;
}
void init()
{}
private :
unsigned int counter;
} ;
class solutionComparator : public moeoComparator<Solution>
{
public :
const bool operator () (const Solution & _solution1 , const Solution & _solution2)
{
const Solution sol1(_solution1);
const Solution sol2(_solution2);
return sol1.fitness()>sol2.fitness();
}
} ;
class solutionPerturbation : public eoMonOp<Solution>
{
public :
bool operator () (Solution & _solution)
{
ObjectiveVector objVec;
objVec[0] = 1;
objVec[1] = 1;
_solution[1]=1;
_solution[0]=1;
_solution.objectiveVector(objVec);
_solution.fitness(2);
return true;
}
} ;
class solutionSingler : public moeoSingleObjectivization<Solution>
{
void operator () (Solution & _solution){
ObjectiveVector objVec;
objVec[0] = _solution[0];
objVec[1] = _solution[1];
_solution.objectiveVector(objVec);
_solution.fitness(_solution.objectiveVector()[0]+_solution.objectiveVector()[1]);
}
void operator()(eoPop<Solution> &_pop){
}
double operator() (const ObjectiveVector &_obj){
return _obj[0]+_obj[1];
}
void updateByDeleting(eoPop<Solution>& pop, ObjectiveVector& obj){}
} ;
class selectMove: public moMoveSelect<testMove>
{
public:
void init(const double &d){
max_fit=d;
}
bool update(const testMove &move,const double &fitness){
if (fitness>max_fit){
max_fit=fitness;
best_move=move;
return false;
}else
return true;
}
void operator()(testMove &move,double &fitness){
move=best_move;
fitness=max_fit;
}
private:
double max_fit;
testMove best_move;
};
//-----------------------------------------------------------------------------
int main()
{
Solution solution;
moeoFixedTimeBothDirectionWeightStrategy<Solution> strat(0.1);
std::vector<double> weight;
weight.resize(2);
for (unsigned int i=0;i<20;i++){
strat(weight,solution);
std::cout<<weight[0]<<" "<<weight[1]<<std::endl;
}
cout << "[ moeo_weight2direction ] ==> ";
std::cout<<"OK"<<std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,295 +0,0 @@
/*
* <t-moeoFixedTimeOneDirectionWeightStrategy.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2008
*
* Fraéncç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
*
*/
//-----------------------------------------------------------------------------
// t-moILS_HC.cpp
//-----------------------------------------------------------------------------
#include <eo> // EO
#include <oldmo> // MO
#include <moeo>
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
class Solution : public moeoRealVector < ObjectiveVector, double, double >
{
public:
Solution() : moeoRealVector < ObjectiveVector, double, double > (2) {}
};
class solutionEval : public eoEvalFunc < Solution >
{
public:
void operator () (Solution & _sol)
{
ObjectiveVector objVec;
objVec[0] = _sol[0];
objVec[1] = _sol[1];
_sol.objectiveVector(objVec);
}
};
class testMove : public moMove <Solution>
{
public :
void operator () (Solution & _solution)
{
Solution sol=_solution;
}
} ;
class testMoveInit : public moMoveInit <testMove>
{
public :
void operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
}
} ;
class testMoveNext : public moNextMove <testMove>
{
public :
bool operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
return false;
}
} ;
class testMoveIncrEval : public moMoveIncrEval <testMove,ObjectiveVector>
{
public :
ObjectiveVector operator () (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution solution(_solution);
return _solution.objectiveVector();
}
} ;
class testTabuList : public moTabuList<testMove>
{
public:
bool operator() (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
return false;
}
void add(const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
}
void update()
{}
void init()
{}
};
class testAspirCrit : public moAspirCrit<testMove>
{
public:
bool operator() (const testMove & _move, const double & _fitness)
{
double fitness;
const testMove move(_move);
fitness=_fitness;
return false;
}
void init()
{}
};
class solutionContinue : public eoContinue<Solution>
{
public :
solutionContinue(): counter(0)
{}
bool operator () (const eoPop<Solution> & _solution)
{
if(counter==0)
{
counter++;
return true;
}
return false;
}
bool operator () (const Solution & _solution)
{
const Solution sol(_solution);
if(counter==0)
{
counter++;
return true;
}
return false;
}
void init()
{}
private :
unsigned int counter;
} ;
class solutionComparator : public moeoComparator<Solution>
{
public :
const bool operator () (const Solution & _solution1 , const Solution & _solution2)
{
const Solution sol1(_solution1);
const Solution sol2(_solution2);
return sol1.fitness()>sol2.fitness();
}
} ;
class solutionPerturbation : public eoMonOp<Solution>
{
public :
bool operator () (Solution & _solution)
{
ObjectiveVector objVec;
objVec[0] = 1;
objVec[1] = 1;
_solution[1]=1;
_solution[0]=1;
_solution.objectiveVector(objVec);
_solution.fitness(2);
return true;
}
} ;
class solutionSingler : public moeoSingleObjectivization<Solution>
{
void operator () (Solution & _solution){
ObjectiveVector objVec;
objVec[0] = _solution[0];
objVec[1] = _solution[1];
_solution.objectiveVector(objVec);
_solution.fitness(_solution.objectiveVector()[0]+_solution.objectiveVector()[1]);
}
void operator()(eoPop<Solution> &_pop){
}
double operator() (const ObjectiveVector &_obj){
return _obj[0]+_obj[1];
}
void updateByDeleting(eoPop<Solution>& pop, ObjectiveVector& obj){}
} ;
class selectMove: public moMoveSelect<testMove>
{
public:
void init(const double &d){
max_fit=d;
}
bool update(const testMove &move,const double &fitness){
if (fitness>max_fit){
max_fit=fitness;
best_move=move;
return false;
}else
return true;
}
void operator()(testMove &move,double &fitness){
move=best_move;
fitness=max_fit;
}
private:
double max_fit;
testMove best_move;
};
//-----------------------------------------------------------------------------
int main()
{
Solution solution;
moeoFixedTimeOneDirectionWeightStrategy<Solution> strat(0.1);
std::vector<double> weight;
weight.resize(2);
for (unsigned int i=0;i<20;i++){
strat(weight,solution);
std::cout<<weight[0]<<" "<<weight[1]<<std::endl;
}
cout << "[ moeo_weight1direction ] ==> ";
std::cout<<"OK"<<std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,296 +0,0 @@
/*
* <t-moILS_HC.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2008
*
* S<-61><-87>bastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
*
* 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
*
*/
//-----------------------------------------------------------------------------
// t-moILS_HC.cpp
//-----------------------------------------------------------------------------
#include <eo> // EO
#include <oldmo> // MO
#include <moeo>
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
class Solution : public moeoRealVector < ObjectiveVector, double, double >
{
public:
Solution() : moeoRealVector < ObjectiveVector, double, double > (2) {}
};
class solutionEval : public moeoEvalFunc < Solution >
{
public:
void operator () (Solution & _sol)
{
ObjectiveVector objVec;
objVec[0] = _sol[0];
objVec[1] = _sol[1];
_sol.objectiveVector(objVec);
}
};
class testMove : public moMove <Solution>
{
public :
void operator () (Solution & _solution)
{
Solution sol=_solution;
}
} ;
class testMoveInit : public moMoveInit <testMove>
{
public :
void operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
}
} ;
class testMoveNext : public moNextMove <testMove>
{
public :
bool operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
return false;
}
} ;
class testMoveIncrEval : public moMoveIncrEval <testMove,ObjectiveVector>
{
public :
ObjectiveVector operator () (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution solution(_solution);
return _solution.objectiveVector();
}
} ;
class testTabuList : public moTabuList<testMove>
{
public:
bool operator() (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
return false;
}
void add(const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
}
void update()
{}
void init()
{}
};
class testAspirCrit : public moAspirCrit<testMove>
{
public:
bool operator() (const testMove & _move, const double & _fitness)
{
double fitness;
const testMove move(_move);
fitness=_fitness;
return false;
}
void init()
{}
};
class solutionContinue : public moSolContinue<Solution>
{
public :
solutionContinue(): counter(0)
{}
bool operator () (const Solution & _solution)
{
const Solution sol(_solution);
if(counter==0)
{
counter++;
return true;
}
return false;
}
void init()
{}
private :
unsigned int counter;
} ;
class solutionComparator : public moComparator<Solution>
{
public :
bool operator () (const Solution & _solution1 , const Solution & _solution2)
{
const Solution sol1(_solution1);
const Solution sol2(_solution2);
return sol1.fitness()>sol2.fitness();
}
} ;
class solutionPerturbation : public eoMonOp<Solution>
{
public :
bool operator () (Solution & _solution)
{
ObjectiveVector objVec;
objVec[0] = 1;
objVec[1] = 1;
_solution[1]=1;
_solution[0]=1;
_solution.objectiveVector(objVec);
_solution.fitness(2);
return true;
}
} ;
class solutionSingler : public moeoSingleObjectivization<Solution>
{
void operator () (Solution & _solution){
ObjectiveVector objVec;
objVec[0] = _solution[0];
objVec[1] = _solution[1];
_solution.objectiveVector(objVec);
_solution.fitness(_solution.objectiveVector()[0]+_solution.objectiveVector()[1]);
}
void operator()(eoPop<Solution> &_pop){
}
double operator() (const ObjectiveVector &_obj){
return _obj[0]+_obj[1];
}
void updateByDeleting(eoPop<Solution>& pop, ObjectiveVector& obj){}
} ;
class selectMove: public moMoveSelect<testMove>
{
public:
void init(const double &d){
max_fit=d;
}
bool update(const testMove &move,const double &fitness){
if (fitness>max_fit){
max_fit=fitness;
best_move=move;
return false;
}else
return true;
}
void operator()(testMove &move,double &fitness){
move=best_move;
fitness=max_fit;
}
private:
double max_fit;
testMove best_move;
};
//-----------------------------------------------------------------------------
int main()
{
std::string test_result;
Solution solution;
testMoveInit init;
testMoveNext next;
testMoveIncrEval incrEval;
testTabuList tabuList;
testAspirCrit aspirCrit;
solutionEval eval;
solutionContinue continu;
solutionContinue continu_2;
solutionComparator comparator;
solutionPerturbation perturbation;
solutionSingler singler;
selectMove select;
moeoHC<testMove> hc(init, next, incrEval, select, singler);
cout << "[ moeoHC ] ==> ";
hc(solution);
cout << "OK" << endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,300 +0,0 @@
/*
* <t-moILS_HC.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2008
*
* S<-61><-87>bastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
*
* 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
*
*/
//-----------------------------------------------------------------------------
// t-moILS_HC.cpp
//-----------------------------------------------------------------------------
#include <eo> // EO
#include <oldmo> // MO
#include <moeo>
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
class Solution : public moeoRealVector < ObjectiveVector, double, double >
{
public:
Solution() : moeoRealVector < ObjectiveVector, double, double > (2) {}
};
class solutionEval : public moeoEvalFunc < Solution >
{
public:
void operator () (Solution & _sol)
{
ObjectiveVector objVec;
objVec[0] = _sol[0];
objVec[1] = _sol[1];
_sol.objectiveVector(objVec);
}
};
class testMove : public moMove <Solution>
{
public :
void operator () (Solution & _solution)
{
Solution sol=_solution;
}
} ;
class testMoveInit : public moMoveInit <testMove>
{
public :
void operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
}
} ;
class testMoveNext : public moNextMove <testMove>
{
public :
bool operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
return false;
}
} ;
class testMoveIncrEval : public moMoveIncrEval <testMove,ObjectiveVector>
{
public :
ObjectiveVector operator () (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution solution(_solution);
return _solution.objectiveVector();
}
} ;
class testTabuList : public moTabuList<testMove>
{
public:
bool operator() (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
return false;
}
void add(const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
}
void update()
{}
void init()
{}
};
class testAspirCrit : public moAspirCrit<testMove>
{
public:
bool operator() (const testMove & _move, const double & _fitness)
{
double fitness;
const testMove move(_move);
fitness=_fitness;
return false;
}
void init()
{}
};
class solutionContinue : public moSolContinue<Solution>
{
public :
solutionContinue(): counter(0)
{}
bool operator () (const Solution & _solution)
{
const Solution sol(_solution);
if(counter==0)
{
counter++;
return true;
}
return false;
}
void init()
{}
private :
unsigned int counter;
} ;
class solutionComparator : public moComparator<Solution>
{
public :
bool operator () (const Solution & _solution1 , const Solution & _solution2)
{
const Solution sol1(_solution1);
const Solution sol2(_solution2);
return sol1.fitness()>sol2.fitness();
}
} ;
class solutionPerturbation : public eoMonOp<Solution>
{
public :
bool operator () (Solution & _solution)
{
ObjectiveVector objVec;
objVec[0] = 1;
objVec[1] = 1;
_solution[1]=1;
_solution[0]=1;
_solution.objectiveVector(objVec);
_solution.fitness(2);
return true;
}
} ;
class solutionSingler : public moeoSingleObjectivization<Solution>
{
void operator () (Solution & _solution){
ObjectiveVector objVec;
objVec[0] = _solution[0];
objVec[1] = _solution[1];
_solution.objectiveVector(objVec);
_solution.fitness(_solution.objectiveVector()[0]+_solution.objectiveVector()[1]);
}
void operator()(eoPop<Solution> &_pop){
}
double operator() (const ObjectiveVector &_obj){
return _obj[0]+_obj[1];
}
void updateByDeleting(eoPop<Solution>& pop, ObjectiveVector& obj){}
} ;
class selectMove: public moMoveSelect<testMove>
{
public:
void init(const double &d){
max_fit=d;
}
bool update(const testMove &move,const double &fitness){
if (fitness>max_fit){
max_fit=fitness;
best_move=move;
return false;
}else
return true;
}
void operator()(testMove &move,double &fitness){
move=best_move;
fitness=max_fit;
}
private:
double max_fit;
testMove best_move;
};
//-----------------------------------------------------------------------------
int main()
{
std::string test_result;
int return_value;
Solution solution;
testMoveInit init;
testMoveNext next;
testMoveIncrEval incrEval;
testTabuList tabuList;
testAspirCrit aspirCrit;
solutionEval eval;
solutionContinue continu;
solutionContinue continu_2;
solutionComparator comparator;
solutionPerturbation perturbation;
solutionSingler singler;
selectMove select;
moeoILS<testMove> ils(init, next, incrEval, singler, select, continu, comparator, perturbation);
cout << "[ moILS_HC ] ==> ";
ils(solution);
test_result=((solution.fitness()!=2)?"KO":"OK");
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
cout << test_result << endl;
return return_value;
}
//-----------------------------------------------------------------------------

View file

@ -1,325 +0,0 @@
/*
* <t-moILS_HC.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2008
*
* S<-61><-87>bastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
* Legillon François
*
* 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
*
*/
//-----------------------------------------------------------------------------
// t-moILS_HC.cpp
//-----------------------------------------------------------------------------
#include <eo> // EO
#include <oldmo> // MO
#include <moeo>
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
class Solution : public moeoRealVector < ObjectiveVector, double, double >
{
public:
Solution() : moeoRealVector < ObjectiveVector, double, double > (2) {}
};
class solutionEval : public moeoEvalFunc < Solution >
{
public:
void operator () (Solution & _sol)
{
ObjectiveVector objVec;
objVec[0] = _sol[0];
objVec[1] = _sol[1];
_sol.objectiveVector(objVec);
}
};
class testMove : public moMove <Solution>
{
public :
void operator () (Solution & _solution)
{
Solution sol=_solution;
}
} ;
class testMoveInit : public moMoveInit <testMove>
{
public :
void operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
}
} ;
class testMoveNext : public moNextMove <testMove>
{
public :
bool operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
return false;
}
} ;
class testMoveIncrEval : public moMoveIncrEval <testMove,ObjectiveVector>
{
public :
ObjectiveVector operator () (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution solution(_solution);
return _solution.objectiveVector();
}
} ;
class testTabuList : public moTabuList<testMove>
{
public:
bool operator() (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
return false;
}
void add(const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
}
void update()
{}
void init()
{}
};
class testAspirCrit : public moAspirCrit<testMove>
{
public:
bool operator() (const testMove & _move, const double & _fitness)
{
double fitness;
const testMove move(_move);
fitness=_fitness;
return false;
}
void init()
{}
};
class solutionContinue : public moSolContinue<Solution>
{
public :
solutionContinue(): counter(0)
{}
bool operator () (const Solution & _solution)
{
const Solution sol(_solution);
if(counter==0)
{
counter++;
return true;
}
return false;
}
void init()
{}
private :
unsigned int counter;
} ;
class solutionComparator : public moComparator<Solution>
{
public :
bool operator () (const Solution & _solution1 , const Solution & _solution2)
{
const Solution sol1(_solution1);
const Solution sol2(_solution2);
return sol1.fitness()>sol2.fitness();
}
} ;
class solutionPerturbation : public eoMonOp<Solution>
{
public :
bool operator () (Solution & _solution)
{
ObjectiveVector objVec;
objVec[0] = 1;
objVec[1] = 1;
_solution[1]=1;
_solution[0]=1;
_solution.objectiveVector(objVec);
_solution.fitness(2);
return true;
}
} ;
class solutionSingler : public moeoSingleObjectivization<Solution>
{
void operator () (Solution & _solution){
ObjectiveVector objVec;
objVec[0] = _solution[0];
objVec[1] = _solution[1];
_solution.objectiveVector(objVec);
_solution.fitness(_solution.objectiveVector()[0]+_solution.objectiveVector()[1]);
}
void operator()(eoPop<Solution> &_pop){
}
double operator() (const ObjectiveVector &_obj){
return _obj[0]+_obj[1];
}
void updateByDeleting(eoPop<Solution>& pop, ObjectiveVector& obj){}
} ;
class selectMove: public moMoveSelect<testMove>
{
public:
void init(const double &d){
max_fit=d;
}
bool update(const testMove &move,const double &fitness){
if (fitness>max_fit){
max_fit=fitness;
best_move=move;
return false;
}else
return true;
}
void operator()(testMove &move,double &fitness){
move=best_move;
fitness=max_fit;
}
private:
double max_fit;
testMove best_move;
};
class testCooling : public moCoolingSchedule
{
public :
bool operator () (double & _temperature)
{
double temperature;
temperature=_temperature;
return false;
}
};
class testRandMove : public moRandMove<testMove>
{
public :
void operator () (testMove & _move)
{
_move=_move;
}
};
//-----------------------------------------------------------------------------
int main()
{
std::string test_result;
int return_value;
Solution solution;
testMoveInit init;
testMoveNext next;
testMoveIncrEval incrEval;
testTabuList tabuList;
testAspirCrit aspirCrit;
solutionEval eval;
solutionContinue continu;
solutionContinue continu_2;
solutionComparator comparator;
solutionPerturbation perturbation;
solutionSingler singler;
selectMove select;
testRandMove rand;
testCooling cooling;
// moeoILS<testMove> ils(init, next, incrEval, singler, select, continu, comparator, perturbation, eval);
moeoILS<testMove> ils(rand, incrEval,singler, continu, 10.0, cooling, continu_2, comparator, perturbation);
cout << "[ moILS_HC ] ==> ";
ils(solution);
test_result=((solution.fitness()!=2)?"KO":"OK");
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
cout << test_result << endl;
return return_value;
}
//-----------------------------------------------------------------------------

View file

@ -1,277 +0,0 @@
/*
* <t-moILS_TS.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2008
*
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
*
* 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
*
*/
//-----------------------------------------------------------------------------
// t-moILS_TS.cpp
//-----------------------------------------------------------------------------
#include <eo> // EO
#include <oldmo> // MO
#include <moeo>
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
class Solution : public moeoRealVector < ObjectiveVector, double, double >
{
public:
Solution() : moeoRealVector < ObjectiveVector, double, double > (2) {}
};
class solutionEval : public moeoEvalFunc < Solution >
{
public:
void operator () (Solution & _sol)
{
ObjectiveVector objVec;
objVec[0] = _sol[0];
objVec[1] = _sol[1];
_sol.objectiveVector(objVec);
// _sol.fitness(_sol[1]+_sol[2]);
}
};
class testMove : public moMove <Solution>
{
public :
void operator () (Solution & _solution)
{
Solution sol=_solution;
}
} ;
class testMoveInit : public moMoveInit <testMove>
{
public :
void operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
}
} ;
class testMoveNext : public moNextMove <testMove>
{
public :
bool operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
return false;
}
} ;
class testMoveIncrEval : public moMoveIncrEval <testMove,ObjectiveVector>
{
public :
ObjectiveVector operator () (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution solution(_solution);
return _solution.objectiveVector();
}
} ;
class testTabuList : public moTabuList<testMove>
{
public:
bool operator() (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
return false;
}
void add(const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
}
void update()
{}
void init()
{}
};
class testAspirCrit : public moAspirCrit<testMove>
{
public:
bool operator() (const testMove & _move, const double & _fitness)
{
double fitness;
const testMove move(_move);
fitness=_fitness;
return false;
}
void init()
{}
};
class solutionContinue : public moSolContinue<Solution>
{
public :
solutionContinue(): counter(0)
{}
bool operator () (const Solution & _solution)
{
const Solution sol(_solution);
if(counter==0)
{
counter++;
return true;
}
return false;
}
void init()
{}
private :
unsigned int counter;
} ;
class solutionComparator : public moComparator<Solution>
{
public :
bool operator () (const Solution & _solution1 , const Solution & _solution2)
{
const Solution sol1(_solution1);
const Solution sol2(_solution2);
return sol1.fitness()>sol2.fitness();
}
} ;
class solutionPerturbation : public eoMonOp<Solution>
{
public :
bool operator () (Solution & _solution)
{
ObjectiveVector objVec;
objVec[0] = 1;
objVec[1] = 1;
_solution[1]=1;
_solution[0]=1;
_solution.objectiveVector(objVec);
_solution.fitness(2);
_solution.invalidate();
return true;
}
} ;
class solutionSingler : public moeoSingleObjectivization<Solution>
{
void operator () (Solution & _solution){
ObjectiveVector objVec;
objVec[0] = _solution[0];
objVec[1] = _solution[1];
_solution.objectiveVector(objVec);
_solution.fitness(_solution.objectiveVector()[0]+_solution.objectiveVector()[1]);
}
void operator()(eoPop<Solution> &_pop){
}
double operator() (const ObjectiveVector &_obj){
return _obj[0]+_obj[1];
}
void updateByDeleting(eoPop<Solution>& pop, ObjectiveVector& obj){}
} ;
//-----------------------------------------------------------------------------
int main()
{
std::string test_result;
int return_value;
Solution solution;
testMoveInit init;
testMoveNext next;
testMoveIncrEval incrEval;
testTabuList tabuList;
testAspirCrit aspirCrit;
solutionEval eval;
solutionContinue continu;
solutionContinue continu_2;
solutionComparator comparator;
solutionPerturbation perturbation;
solutionSingler singler;
moeoILS<testMove> ils(init, next, incrEval, singler, tabuList, aspirCrit, continu, continu_2, comparator, perturbation);
cout << "[ moILS_TS ] ==> ";
ils(solution);
test_result=((solution.fitness()!=2)?"KO":"OK");
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
cout << test_result << endl;
return return_value;
}
//-----------------------------------------------------------------------------

View file

@ -1,113 +0,0 @@
/*
* <t-moeoNSGAII.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
* Contact: paradiseo-help@lists.gforge.inria.fr
*
*/
//-----------------------------------------------------------------------------
// t-moeoNSGAII.cpp
//-----------------------------------------------------------------------------
#include <eo>
#include <es/eoRealInitBounded.h>
#include <es/eoRealOp.h>
#include <moeo>
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return false;
}
static bool maximizing (int i)
{
return true;
}
static unsigned int nObjectives ()
{
return 3;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
class Solution : public moeoRealVector < ObjectiveVector, double, double >
{
public:
Solution() : moeoRealVector < ObjectiveVector, double, double > (1) {}
};
class TestEval : public moeoEvalFunc < Solution >
{
public:
void operator () (Solution & _sol)
{
ObjectiveVector objVec;
objVec[0] = _sol[0];
objVec[1] = _sol[0] * _sol[0];
objVec[2] = _sol[0] + (_sol[0] * _sol[0]);
_sol.objectiveVector(objVec);
}
};
//-----------------------------------------------------------------------------
int main()
{
std::cout << "[moeoNSGAII]" << std::endl;
TestEval eval;
eoQuadCloneOp < Solution > xover;
eoUniformMutation < Solution > mutation(0.05);
eoRealVectorBounds bounds(1, 1.0, 2.0);
eoRealInitBounded < Solution > init(bounds);
eoPop < Solution > pop(20, init);
// build NSGA-II
moeoNSGAII < Solution > algo(20, eval, xover, 1.0, mutation, 1.0);
// run the algo
algo(pop);
// final pop
std::cout << "Final population" << std::endl;
std::cout << pop << std::endl;
std::cout << "[moeoNSGAII] OK" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,306 +0,0 @@
/*
* <t-moeoQexploreWeightStrategy.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2008
*
* Fraéncç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
*
*/
//-----------------------------------------------------------------------------
// t-moeoQexploreWeightStrategy.cpp
//-----------------------------------------------------------------------------
#include <eo> // EO
#include <oldmo> // MO
#include <moeo>
using std::cout;
using std::endl;
//-----------------------------------------------------------------------------
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
class Solution : public moeoRealVector < ObjectiveVector, double, double >
{
public:
Solution() : moeoRealVector < ObjectiveVector, double, double > (2) {}
};
class solutionEval : public eoEvalFunc < Solution >
{
public:
void operator () (Solution & _sol)
{
ObjectiveVector objVec;
objVec[0] = _sol[0];
objVec[1] = _sol[1];
_sol.objectiveVector(objVec);
}
};
class testMove : public moMove <Solution>
{
public :
void operator () (Solution & _solution)
{
Solution sol=_solution;
}
} ;
class testMoveInit : public moMoveInit <testMove>
{
public :
void operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
}
} ;
class testMoveNext : public moNextMove <testMove>
{
public :
bool operator () (testMove & _move, const Solution & _solution)
{
testMove move=_move;
const Solution sol(_solution);
return false;
}
} ;
class testMoveIncrEval : public moMoveIncrEval <testMove,ObjectiveVector>
{
public :
ObjectiveVector operator () (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution solution(_solution);
return _solution.objectiveVector();
}
} ;
class testTabuList : public moTabuList<testMove>
{
public:
bool operator() (const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
return false;
}
void add(const testMove & _move, const Solution & _solution)
{
const testMove move(_move);
const Solution sol(_solution);
}
void update()
{}
void init()
{}
};
class testAspirCrit : public moAspirCrit<testMove>
{
public:
bool operator() (const testMove & _move, const double & _fitness)
{
double fitness;
const testMove move(_move);
fitness=_fitness;
return false;
}
void init()
{}
};
class solutionContinue : public eoContinue<Solution>
{
public :
solutionContinue(): counter(0)
{}
bool operator () (const eoPop<Solution> & _solution)
{
if(counter==0)
{
counter++;
return true;
}
return false;
}
bool operator () (const Solution & _solution)
{
const Solution sol(_solution);
if(counter==0)
{
counter++;
return true;
}
return false;
}
void init()
{}
private :
unsigned int counter;
} ;
class solutionComparator : public moeoComparator<Solution>
{
public :
const bool operator () (const Solution & _solution1 , const Solution & _solution2)
{
const Solution sol1(_solution1);
const Solution sol2(_solution2);
return sol1.fitness()>sol2.fitness();
}
} ;
class solutionPerturbation : public eoMonOp<Solution>
{
public :
bool operator () (Solution & _solution)
{
ObjectiveVector objVec;
objVec[0] = 1;
objVec[1] = 1;
_solution[1]=1;
_solution[0]=1;
_solution.objectiveVector(objVec);
_solution.fitness(2);
return true;
}
} ;
class solutionSingler : public moeoSingleObjectivization<Solution>
{
void operator () (Solution & _solution){
ObjectiveVector objVec;
objVec[0] = _solution[0];
objVec[1] = _solution[1];
_solution.objectiveVector(objVec);
_solution.fitness(_solution.objectiveVector()[0]+_solution.objectiveVector()[1]);
}
void operator()(eoPop<Solution> &_pop){
}
double operator() (const ObjectiveVector &_obj){
return _obj[0]+_obj[1];
}
void updateByDeleting(eoPop<Solution>& pop, ObjectiveVector& obj){}
} ;
class selectMove: public moMoveSelect<testMove>
{
public:
void init(const double &d){
max_fit=d;
}
bool update(const testMove &move,const double &fitness){
if (fitness>max_fit){
max_fit=fitness;
best_move=move;
return false;
}else
return true;
}
void operator()(testMove &move,double &fitness){
move=best_move;
fitness=max_fit;
}
private:
double max_fit;
testMove best_move;
};
//-----------------------------------------------------------------------------
int main()
{
Solution solution;
moeoQexploreWeightStrategy<Solution> strat;
cout << "[ moeoQexploreWeightStrategy ] ==> ";
std::vector<double> weight;
weight.resize(2);
strat(weight,solution);
assert(weight[0]==0 && weight[1]==1);
strat(weight,solution);
assert(weight[0]==1 && weight[1]==0);
strat(weight,solution);
assert(weight[0]==0.5 && weight[1]==0.5);
strat(weight,solution);
assert(weight[0]==1.0/3.0 && weight[1]==2.0/3.0);
strat(weight,solution);
assert(weight[0]==2.0/3.0 && weight[1]==1.0/3.0);
strat(weight,solution);
assert(weight[0]==1.0/4.0 && weight[1]==3.0/4.0);
strat(weight,solution);
assert(weight[0]==3.0/4.0 && weight[1]==1.0/4.0);
std::cout<<"OK"<<std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

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