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;
}
//-----------------------------------------------------------------------------

View file

@ -1,186 +0,0 @@
/*
* <t-moeoquadTreeArchive.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-moeoEpsilonHyperboxArchive.cpp
//-----------------------------------------------------------------------------
#include <eo>
#include <moeo>
#include <cmath>
//-----------------------------------------------------------------------------
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;
typedef MOEO < ObjectiveVector, double, double > Solution;
//-----------------------------------------------------------------------------
int main()
{
std::cout << "[moeoQuadTreeArchive]\t=>\t";
moeoQuadTree<ObjectiveVector> tree;
bool empty= tree.isEmpty();
std::cout <<"empty? " << empty << std::endl;
ObjectiveVector obj1;
obj1[0]=10.0;
obj1[1]=10.0;
obj1[2]=10.0;
ObjectiveVector obj2;
obj2[0]=9.0;
obj2[1]=9.0;
obj2[2]=9.0;
ObjectiveVector obj3;
obj3[0]=2.0;
obj3[1]=11.0;
obj3[2]=11.0;
ObjectiveVector obj4;
obj4[0]=1.0;
obj4[1]=10.0;
obj4[2]=10.0;
ObjectiveVector obj5;
obj5[0]=2.0;
obj5[1]=2.0;
obj5[2]=2.0;
ObjectiveVector obj6;
obj6[0]=26.0;
obj6[1]=0.0;
obj6[2]=5.0;
ObjectiveVector obj7;
obj7[0]=56.0;
obj7[1]=22.0;
obj7[2]=0.0;
ObjectiveVector obj8;
obj8[0]=87.0;
obj8[1]=42.0;
obj8[2]=62.0;
ObjectiveVector obj9;
obj9[0]=90.0;
obj9[1]=69.0;
obj9[2]=83.0;
ObjectiveVector obj10;
obj10[0]=68.0;
obj10[1]=89.0;
obj10[2]=22.0;
// QuadTreeNode<ObjectiveVector> hop(obj1);
// QuadTreeNode<ObjectiveVector> hop2(obj2);
// QuadTreeNode<ObjectiveVector> hop3(obj3);
// QuadTreeNode<ObjectiveVector> hop4(obj4);
// empty = hop.getSubTree().empty();
// std::cout <<"empty? " << empty << std::endl;
// std::vector< QuadTreeNode<ObjectiveVector> > nodes;
// nodes.push_back(hop);
// nodes.push_back(hop2);
// nodes.push_back(hop3);
// std::cout << nodes[1].getVec() << std::endl;
// std::cout << "size: " << nodes.size() << std::endl;
// tree.insert(obj1);
// tree.insert(obj2);
// tree.insert(obj3);
// tree.insert(obj4);
// tree.insert(obj5);
std::cout << "\n\n\n";
// tree.insert(obj6);
// tree.insert(obj7);
// tree.insert(obj8);
// tree.insert(obj9);
// tree.insert(obj10);
moeoUnboundedArchive<Solution> archive(false);
eoPop<Solution> pop;
pop.resize(1000);
int tmp;
for(int i= 0; i<1000 ; i++){
ObjectiveVector obj;
obj[0]=floor(rng.uniform()*100);
obj[1]=floor(rng.uniform()*100);
obj[2]=floor(rng.uniform()*100);
std::cout << obj << std::endl;
pop[i].objectiveVector(obj);
tree.insert(obj);
archive(pop[i]);
tree.printTree();
std::cout << std::endl;
std::cout << std::endl;
std::cout << "archive: " << archive << std::endl;
// std::cin >> tmp;
}
// QuadTreeNode<ObjectiveVector> * a = tree.getRoot();
// QuadTreeNode<ObjectiveVector> * b = a->getSubTree()[1];
// QuadTreeNode<ObjectiveVector> * c = b->getSubTree()[2];
//
// tree.reinsert(a,c);
// std::cout << "achive: " << archive << std::endl;
tree.printTree();
std::cout << "OK" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,332 +0,0 @@
//-----------------------------------------------------------------------------
// t-moeoQuickUnboundedArchive.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;
}
};
class ObjectiveVectorTraits3d : 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;
typedef moeoRealObjectiveVector < ObjectiveVectorTraits3d > ObjectiveVector3d;
typedef MOEO < ObjectiveVector, double, double > Solution;
typedef MOEO < ObjectiveVector3d, double, double > Solution3d;
//-----------------------------------------------------------------------------
int main()
{
std::cout << "[moeoArchive]\t=>\t";
// First test is just to verify behavior of moeoQuickUnboundedArchive
// objective vectors
ObjectiveVector obj0, obj1, obj2, obj3, obj4, obj5,obj10;
obj0[0] = 12226;
obj0[1] = 427894;
obj1[0] = 12170;
obj1[1] = 431736;
obj2[0] = 11965;
obj2[1] = 435193;
obj3[0] = 11893;
obj3[1] = 441839;
obj4[0] = 11870;
obj4[1] = 450770;
obj5[0] = 11769;
obj5[1] = 460005;
obj10[0] = 11769;
obj10[1] = 46005;
// 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);
// archive
moeoQuadTree<Solution> index;
moeoIndexedArchive <Solution> arch(index);
// moeoQuickUnboundedArchive< Solution > arch;
arch(pop);
// arch.printIndex();
// size
if (arch.size() > 6)
{
std::cout << "ERROR1 (too much solutions)" << std::endl;
return EXIT_FAILURE;
}
// obj0 must be in
if (! arch.contains(obj0))
{
std::cout << "ERROR2 (obj0 not in)" << std::endl;
return EXIT_FAILURE;
}
// obj1 must be in
if (! arch.contains(obj1))
{
std::cout << "ERROR3 (obj1 not in)" << std::endl;
return EXIT_FAILURE;
}
// obj2 must be in
if (! arch.contains(obj2))
{
std::cout << "ERROR4 (obj2 not in)" << std::endl;
return EXIT_FAILURE;
}
// obj3 must be in
if (! arch.contains(obj3))
{
std::cout << "ERROR5 (obj3 not in)" << std::endl;
return EXIT_FAILURE;
}
// obj4 must be in
if (!arch.contains(obj4))
{
std::cout << "ERROR6 (obj4 not in)! " << obj4<< std::endl;
// arch.printIndex();
return EXIT_FAILURE;
}
// obj5 must be in
if (! arch.contains(obj5))
{
std::cout << "ERROR7 (obj5 not in)" << std::endl;
return EXIT_FAILURE;
}
// Second test is to verify behavior with negative and comparator
ObjectiveVector obj6, obj7;
obj6[0] = -12170;
obj6[1] = 427894;
obj7[0] = -12226;
obj7[1] = 431736;
eoPop < Solution > pop2;
pop2.resize(2);
pop2[0].objectiveVector(obj6);
pop2[1].objectiveVector(obj7);
moeoQuadTree< Solution > index2;
moeoIndexedArchive< Solution > arch2(index2);
arch2(pop2);
// size
if (arch2.size() != 2)
{
std::cout << "ERROR8 (too much solutions)" << std::endl;
return EXIT_FAILURE;
}
//Third test is with two equals values
ObjectiveVector obj8, obj9;
obj8[0] = 10;
obj8[1] = 10;
obj9[0] = 10;
obj9[1] = 10;
eoPop < Solution > pop3;
pop3.resize(2);
pop3[0].objectiveVector(obj8);
pop3[1].objectiveVector(obj9);
moeoQuadTree< Solution > index3;
moeoIndexedArchive< Solution > arch3(index3);
arch3(pop3);
if (arch3.size() != 1)
{
std::cout << "ERROR9 (too much solutions)" << std::endl;
return EXIT_FAILURE;
}
eoPop < Solution > pop4;
pop4.resize(6);
pop4[0].objectiveVector(obj0);
pop4[1].objectiveVector(obj1);
pop4[2].objectiveVector(obj2);
pop4[3].objectiveVector(obj3);
pop4[4].objectiveVector(obj4);
pop4[5].objectiveVector(obj10);
moeoQuadTree< Solution > index4;
moeoIndexedArchive< Solution > arch4(index4);
arch4(pop4);
if (arch4.size() != 1)
{
std::cout << "ERROR10 (too much solutions)" << std::endl;
return EXIT_FAILURE;
}
std::vector<bool>bobj;
for (unsigned int i=0;i<3;i++){
bobj.push_back(false);
}
ObjectiveVectorTraits3d::setup(3,bobj);
moeoQuadTree < Solution3d> index5;
moeoIndexedArchive < Solution3d> arch5(index5);
eoPop<Solution3d> pop5;
pop5.resize(6);
ObjectiveVector3d obj3d0, obj3d1, obj3d2, obj3d3, obj3d4, obj3d5, obj3d6,obj3d10;
obj3d0[0] = 12226;
obj3d0[1] = 427894;
obj3d0[2] = 10;
obj3d1[0] = 12170;
obj3d1[1] = 431736;
obj3d1[2] = 10;
obj3d2[0] = 11965;
obj3d2[1] = 435193;
obj3d2[2] = 10;
obj3d3[0] = 11893;
obj3d3[1] = 441839;
obj3d3[2] = 10;
obj3d4[0] = 11870;
obj3d4[1] = 450770;
obj3d4[2] = 10;
obj3d5[0] = 11769;
obj3d5[1] = 46005;
obj3d5[2] = 2;
obj3d10[0] = 11769;
obj3d10[1] = 46005;
obj3d10[2] = 10;
obj3d6[0] = 11769;
obj3d6[1] = 460005;
obj3d6[2] = 1;
pop5[0].objectiveVector(obj3d0);
pop5[1].objectiveVector(obj3d1);
pop5[2].objectiveVector(obj3d2);
pop5[3].objectiveVector(obj3d3);
pop5[4].objectiveVector(obj3d4);
pop5[5].objectiveVector(obj3d10);
arch5(pop5);
pop5.resize(7);
pop5[6].objectiveVector(obj3d5);
arch5(pop5[6]);
// index5.printTree();
/* for (unsigned int i=0;i<arch5.size();i++){
std::cout<<i<<" "<<arch5[i].objectiveVector()<<std::endl;
}*/
assert(arch5.size()==1);
pop5.resize(8);
pop5[7].objectiveVector(obj3d6);
arch5(pop5[7]);
assert(arch5.size()==2);
moeoQuadTree < Solution3d> index6;
moeoIndexedArchive < Solution3d> arch6(index6);
eoPop<Solution3d> pop6;
ObjectiveVector3d jojo, jojo1, jojo2, jojo3, jojo4, jojo5, jojo6, jojo7, jojo8, jojo9 ;
jojo[0]=10;
jojo[1]=10;
jojo[2]=10;
jojo1[0]=5;
jojo1[1]=5;
jojo1[2]=23;
jojo2[0]=3;
jojo2[1]=25;
jojo2[2]=16;
jojo3[0]=14;
jojo3[1]=18;
jojo3[2]=6;
jojo4[0]=100;
jojo4[1]=100;
jojo4[2]=100;
jojo5[0]=4;
jojo5[1]=8;
jojo5[2]=12;
jojo6[0]=11;
jojo6[1]=14;
jojo6[2]=9;
jojo7[0]=40;
jojo7[1]=12;
jojo7[2]=3;
jojo8[0]=12;
jojo8[1]=8;
jojo8[2]=4;
jojo9[0]=4;
jojo9[1]=4;
jojo9[2]=22;
pop6.resize(8);
pop6[0].objectiveVector(jojo);
pop6[1].objectiveVector(jojo1);
pop6[2].objectiveVector(jojo2);
pop6[3].objectiveVector(jojo3);
pop6[4].objectiveVector(jojo4);
pop6[5].objectiveVector(jojo5);
pop6[6].objectiveVector(jojo6);
pop6[7].objectiveVector(jojo7);
Solution3d add;
Solution3d add2;
add.objectiveVector(jojo8);
add2.objectiveVector(jojo9);
/* pop[1].objectiveVector(jojo1);
pop[1].objectiveVector(jojo1);
pop[1].objectiveVector(jojo1);*/
arch6(pop6);
assert(arch6.size()==7);
bool res=arch6(add);
assert(res && arch6.size()==7);
res=arch6(add2);
assert(res && arch6.size()==7);
std::cout << "OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -1,180 +0,0 @@
//-----------------------------------------------------------------------------
// t-moeoQuickUnboundedArchive.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 << "[moeoArchive]\t=>\t";
// First test is just to verify behavior of moeoQuickUnboundedArchive
// objective vectors
ObjectiveVector obj0, obj1, obj2, obj3, obj4, obj5,obj10;
obj0[0] = 12226;
obj0[1] = 427894;
obj1[0] = 12170;
obj1[1] = 431736;
obj2[0] = 11965;
obj2[1] = 435193;
obj3[0] = 11893;
obj3[1] = 441839;
obj4[0] = 11870;
obj4[1] = 450770;
obj5[0] = 11769;
obj5[1] = 460005;
obj10[0] = 11769;
obj10[1] = 46005;
// 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);
// archive
moeoQuickUnboundedArchiveIndex< Solution> index;
moeoIndexedArchive <Solution> arch(index);
// moeoQuickUnboundedArchive< Solution > arch;
arch(pop);
// arch.printIndex();
// size
if (arch.size() > 6)
{
std::cout << "ERROR1 (too much solutions)" << std::endl;
return EXIT_FAILURE;
}
// obj0 must be in
if (! arch.contains(obj0))
{
std::cout << "ERROR2 (obj0 not in)" << std::endl;
return EXIT_FAILURE;
}
// obj1 must be in
if (! arch.contains(obj1))
{
std::cout << "ERROR3 (obj1 not in)" << std::endl;
return EXIT_FAILURE;
}
// obj2 must be in
if (! arch.contains(obj2))
{
std::cout << "ERROR4 (obj2 not in)" << std::endl;
return EXIT_FAILURE;
}
// obj3 must be in
if (! arch.contains(obj3))
{
std::cout << "ERROR5 (obj3 not in)" << std::endl;
return EXIT_FAILURE;
}
// obj4 must be in
if (!arch.contains(obj4))
{
std::cout << "ERROR6 (obj4 not in)! " << obj4<< std::endl;
// arch.printIndex();
return EXIT_FAILURE;
}
// obj5 must be in
if (! arch.contains(obj5))
{
std::cout << "ERROR7 (obj5 not in)" << std::endl;
return EXIT_FAILURE;
}
// Second test is to verify behavior with negative and comparator
ObjectiveVector obj6, obj7;
std::cout<<"test neg"<<std::endl;
obj6[0] = -12170;
obj6[1] = 427894;
obj7[0] = -12226;
obj7[1] = 431736;
eoPop < Solution > pop2;
pop2.resize(2);
pop2[0].objectiveVector(obj6);
pop2[1].objectiveVector(obj7);
std::cout<<"archive 2"<<std::endl;
moeoQuickUnboundedArchiveIndex< Solution > index2;
moeoIndexedArchive< Solution > arch2(index2);
arch2(pop2);
// size
if (arch2.size() != 2)
{
std::cout << "ERROR8 (too much solutions)" << std::endl;
return EXIT_FAILURE;
}
//Third test is with two equals values
ObjectiveVector obj8, obj9;
obj8[0] = 10;
obj8[1] = 10;
obj9[0] = 10;
obj9[1] = 10;
eoPop < Solution > pop3;
pop3.resize(2);
pop3[0].objectiveVector(obj8);
pop3[1].objectiveVector(obj9);
std::cout<<"archive 3"<<std::endl;
moeoQuickUnboundedArchiveIndex< Solution > index3;
moeoIndexedArchive< Solution > arch3(index3);
arch3(pop3);
if (arch3.size() != 1)
{
std::cout << "ERROR9 (too much solutions)" << std::endl;
return EXIT_FAILURE;
}
eoPop < Solution > pop4;
pop4.resize(6);
pop4[0].objectiveVector(obj0);
pop4[1].objectiveVector(obj1);
pop4[2].objectiveVector(obj2);
pop4[3].objectiveVector(obj3);
pop4[4].objectiveVector(obj4);
pop4[5].objectiveVector(obj10);
std::cout<<"archive 4"<<std::endl;
moeoQuickUnboundedArchiveIndex< Solution > index4;
moeoIndexedArchive< Solution > arch4(index4);
arch4(pop4);
if (arch4.size() != 1)
{
std::cout << "ERROR10 (too much solutions)" << std::endl;
return EXIT_FAILURE;
}
std::cout << "OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -1,274 +0,0 @@
/*
* <t-moeoTS.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;
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;
moeoIncrEvalSingleObjectivizer<Solution,testMove> sincrEval(singler,incrEval);
moeoTSMoveLoopExpl<testMove> expl(init,next,sincrEval,tabuList,aspirCrit);
moeoTS<testMove> ts(init,next,incrEval,tabuList,aspirCrit,continu,singler);
cout << "[ moeoTS ] ==> ";
ts(solution);
cout << "OK" << endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,314 +0,0 @@
/*
* <t-moVFAS.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()
{
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;
moeoDetTournamentSelect<Solution> selectOne(comparator);
eoPop<Solution> pop;
pop.push_back(solution);
moeoRandWeightStrategy<Solution> strat;
std::vector<double> weights;
weights.push_back(0);
weights.push_back(1);
moeoHC<testMove> hc(init,next,incrEval,select,singler);
moeoVFAS<testMove> vfas(hc,continu,selectOne,eval,strat);
moeoVFAS<testMove> vfas1(hc,continu,selectOne,weights,eval,strat);
cout << "[ moeo_VFAS ] ==> ";
vfas(pop);
std::cout<<"OK"<<std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -1,187 +0,0 @@
/*
* <t-moVNS.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2007-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Salma Mesmoudi (salma.mesmoudi@inria.fr), Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
* Jeremie Humeau (jeremie.humeau@inria.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-moVNS.cpp
//-----------------------------------------------------------------------------
#include <eo> // EO
#include <oldmo> // MO
#include <moeo>
#include <cassert>
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 EO<unsigned int> solution;
typedef moeoRealObjectiveVector<ObjectiveVectorTraits> ObjectiveVector;
typedef eoScalarFitness< float, std::greater<float> > tspFitness ;
typedef moeoRealVector <ObjectiveVector, unsigned int> Route ;
int cpt=0;
int tableau[8]={1.0, 2.0, 8.0, 8.0, 11.0, 11.0, 11.0,30.0};
class testMove : public moMove <solution>
{
public :
void operator () (solution & _solution)
{
solution sol=_solution;
}
} ;
class solutionAlgo : public moAlgo <solution>
{
public :
bool operator () (solution & _solution)
{
solution solution(_solution);
return true;
}
} ;
class Voisinage : public eoMonOp<Route>
{
public :
bool operator () (Route & _solution)
{
_solution.invalidate();
//_solution.fitness();
return true;
}
} ;
class Explorer : public moExpl<Route>
{
public:
Explorer(eoMonOp<Route> & expl): moExpl<Route>( expl)
{
}
};
class solutionEval : public eoEvalFunc <Route>
{
public :
void operator () (Route & _solution)
{
ObjectiveVector obj;
obj[0]=(tableau[0]);
obj[1]=(tableau[cpt]);
_solution.objectiveVector(obj);
_solution.fitness(obj[0]+obj[1]);
cpt++;
}
};
class solutionSingler : public moeoSingleObjectivization<Route>
{
public:
solutionSingler(solutionEval &_eval):eval(_eval){}
void operator () (Route & _solution){
eval(_solution);
_solution.fitness(_solution.objectiveVector()[0]+_solution.objectiveVector()[1]);
}
void operator()(eoPop<Route> &_pop){
}
Route::Fitness operator() (const ObjectiveVector &_obj){
return _obj[0]+_obj[1];
}
void updateByDeleting(eoPop<Route>& pop, ObjectiveVector& obj){}
solutionEval &eval;
} ;
//-----------------------------------------------------------------------------
int
main()
{
std::string test_result;
//solution solution;
Route so ;
Voisinage sol1;
Voisinage sol2;
Explorer explorer(sol1);
explorer.addExplorer(sol2);
solutionEval eval;
std::vector<double> poids;
poids.push_back(1);
poids.push_back(1);
solutionSingler singler(eval);
moeoVNS<Route> vns(explorer, singler);
cout << "[moeoVNS] ==> ";
so.fitness(5.0);
vns(so);
assert(so.fitness()==12.0);
cout << "OK" << endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------