Migration from SVN

This commit is contained in:
quemy 2012-08-30 11:30:11 +02:00
commit 8cd56f37db
64 changed files with 0 additions and 4096888 deletions

86
moeo/test/CMakeLists.txt Normal file
View file

@ -0,0 +1,86 @@
######################################################################################
### 0) Include headers
######################################################################################
include_directories(${EO_SRC_DIR}/src)
include_directories(${MO_SRC_DIR}/src)
include_directories(${MOEO_SRC_DIR}/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
######################################################################################
### 1) Define test list
######################################################################################
set(TEST_LIST
t-moeo
t-moeoBitVector
t-moeoRealVector
t-moeoUnboundedArchive
t-moeoParetoObjectiveVectorComparator
t-moeoStrictObjectiveVectorComparator
t-moeoWeakObjectiveVectorComparator
t-moeoEpsilonObjectiveVectorComparator
#t-moeoAggregativeComparator # TEMPORARLY BYPASSED
#t-moeoDiversityThenFitnessComparator # IDEM.
#t-moeoFitnessThenDiversityComparator # IDEM
t-moeoAchievementFitnessAssignment
t-moeoExpBinaryIndicatorBasedFitnessAssignment
t-moeoCrowdingDiversityAssignment
t-moeoSharingDiversityAssignment
t-moeoIBEA
t-moeoNSGA
t-moeoNSGAII
t-moeoSEEA
t-moeoMax3Obj
t-moeoEasyEA
t-moeoDominanceCountFitnessAssignment
t-moeoDominanceRankFitnessAssignment
t-moeoDominanceCountRankingFitnessAssignment
t-moeoDominanceDepthFitnessAssignment
t-moeoNearestNeighborDiversityAssignment
t-moeoSPEA2Archive
t-moeoSPEA2
t-moeoDominanceMatrix
t-moeoVecVsVecAdditiveEpsilonBinaryMetric
t-moeoVecVsVecMultiplicativeEpsilonBinaryMetric
t-moeoHyperVolumeMetric
t-moeoHyperVolumeDifferenceMetric
t-moeoIntVector
t-moeoImprOnlyBoundedArchive
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-moeoExhaustiveNeighborhoodExplorer
t-moeoFirstImprovingNeighborhoodExplorer
t-moeoSimpleSubNeighborhoodExplorer
t-moeoNoDesimprovingNeighborhoodExplorer
t-moeoPLS1
t-moeoPLS2
t-moeoExhaustiveUnvisitedSelect
t-moeoNumberUnvisitedSelect
t-moeoDMLSMonOp
t-moeoDMLSGenUpdater
t-moeo2DMinHypervolumeArchive
)
######################################################################################
### 3) Create each test
######################################################################################
foreach (test ${TEST_LIST})
set("T_${test}_SOURCES" "${test}.cpp")
add_executable(${test} ${T_${test}_SOURCES})
add_test(${test} ${test})
target_link_libraries(${test} moeo ga es eoutils eo)
install(TARGETS ${test} RUNTIME DESTINATION local/share${INSTALL_SUB_DIR}/moeo/test COMPONENT tests)
endforeach (test)

158
moeo/test/moeoTestClass.h Normal file
View file

@ -0,0 +1,158 @@
/*
<moeoTestClass.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moeoTestClass_h
#define _moeoTestClass_h
#include <moeo>
#include <EO.h>
#include <eoEvalFunc.h>
#include <neighborhood/moNeighbor.h>
#include <neighborhood/moBackableNeighbor.h>
#include <neighborhood/moNeighborhood.h>
#include <neighborhood/moRndNeighborhood.h>
#include <eval/moEval.h>
#include <ga/eoBit.h>
#include <eoScalarFitness.h>
#include <neighborhood/moOrderNeighborhood.h>
#include <problems/bitString/moBitNeighbor.h>
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 moeoBitVector<ObjectiveVector> Solution;
class SolNeighbor : public moIndexNeighbor <Solution, ObjectiveVector>
{
public:
virtual void move(Solution & _solution) {
_solution[key] = !_solution[key];
}
};
typedef moOrderNeighborhood<SolNeighbor> SolNeighborhood;
class evalSolution : public moEval< SolNeighbor >
{
private:
unsigned size;
int flag;
public:
evalSolution(unsigned _size, int _flag=1) : size(_size), flag(_flag) {};
~evalSolution(void) {} ;
void operator() (Solution& _sol, SolNeighbor& _n){
ObjectiveVector objVec=_sol.objectiveVector();
if(flag>0){
if (_sol[_n.index()]){
objVec[0]--;
objVec[1]++;
}
else{
objVec[0]++;
objVec[1]--;
}
_n.fitness(objVec);
}
else if(flag==0){
if (_sol[_n.index()]){
objVec[0]--;
objVec[1]--;
}
else{
objVec[0]++;
objVec[1]--;
}
_n.fitness(objVec);
}
else{
if (_sol[_n.index()]){
objVec[0]++;
objVec[1]++;
}
else{
objVec[0]++;
objVec[1]--;
}
_n.fitness(objVec);
}
}
};
class fullEvalSolution : public eoEvalFunc< Solution >
{
private:
unsigned size;
public:
fullEvalSolution(unsigned _size) : size(_size){};
~fullEvalSolution(void) {} ;
void operator() (Solution& _sol){
ObjectiveVector o;
for(unsigned int i=0; i<size; i++)
if(_sol[i])
o[0]++;
else
o[1]++;
_sol.objectiveVector(o);
}
};
#endif

81
moeo/test/t-moeo.cpp Normal file
View file

@ -0,0 +1,81 @@
/*
* <t-moeo.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-moeo.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 << "[MOEO]\t=>\t";
// solutions
Solution sol1, sol2;
std::cout << "OK" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,195 @@
/*
* <t-moeo2DMinHypervolumeArchive.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-moeo2DMinHypervolumeArchive.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 moeoBitVector < ObjectiveVector > Solution;
//-----------------------------------------------------------------------------
int main()
{
std::cout << "[moeo2DMinHyperVolumeArchive]\t=>\t";
// objective vectors
ObjectiveVector obj;
obj[0] = 7;
obj[1] = 15;
// population
eoPop < Solution > pop;
pop.resize(0);
//Solutions
Solution a;
a.objectiveVector(obj);
// archive
moeo2DMinHypervolumeArchive<Solution> arch(5,1000);
//test archive
pop.push_back(a);
obj[0]=10;
obj[1]=14;
a.objectiveVector(obj);
pop.push_back(a);
obj[0]=8;
obj[1]=14.5;
a.objectiveVector(obj);
pop.push_back(a);
obj[0]=6;
obj[1]=15;
a.objectiveVector(obj);
pop.push_back(a);
obj[0]=14;
obj[1]=13;
a.objectiveVector(obj);
pop.push_back(a);
obj[0]=12;
obj[1]=13.5;
a.objectiveVector(obj);
pop.push_back(a);
obj[0]=14.5;
obj[1]=12.5;
a.objectiveVector(obj);
pop.push_back(a);
obj[0]=14;
obj[1]=13;
a.objectiveVector(obj);
pop.push_back(a);
obj[0]=11.5;
obj[1]=11.5;
a.objectiveVector(obj);
pop.push_back(a);
obj[0]=5.5;
obj[1]=12.5;
a.objectiveVector(obj);
pop.push_back(a);
obj[0]=3.5;
obj[1]=13.5;
a.objectiveVector(obj);
pop.push_back(a);
obj[0]=15;
obj[1]=3.5;
a.objectiveVector(obj);
pop.push_back(a);
obj[0]=13.5;
obj[1]=8;
a.objectiveVector(obj);
pop.push_back(a);
obj[0]=1;
obj[1]=15;
a.objectiveVector(obj);
pop.push_back(a);
for(int i=0; i< pop.size(); i++){
arch(pop[i]);
arch.print();
std::cout << std::endl;
}
moeo2DMinHypervolumeArchive<Solution>::iterator it;
it=arch.begin();
assert(it->objectiveVector()[0]==15);
assert(it->objectiveVector()[1]==3.5);
assert(it->fitness()==1000);
it++;
assert(it->objectiveVector()[0]==13.5);
assert(it->objectiveVector()[1]==8);
assert(it->fitness()==6.75);
it++;
assert(it->objectiveVector()[0]==5.5);
assert(it->objectiveVector()[1]==12.5);
assert(it->fitness()==8);
it++;
assert(it->objectiveVector()[0]==3.5);
assert(it->objectiveVector()[1]==13.5);
assert(it->fitness()==3);
it++;
assert(it->objectiveVector()[0]==1);
assert(it->objectiveVector()[1]==15);
assert(it->fitness()==1000);
std::cout << "OK" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

122
moeo/test/t-moeoASEEA.cpp Normal file
View file

@ -0,0 +1,122 @@
/*
* <t-moeoASEEA.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-moeoASEEA.cpp
//-----------------------------------------------------------------------------
#include <eo>
#include <moeo>
#include <cassert>
#include <es/eoRealInitBounded.h>
#include <es/eoRealOp.h>
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 > (1) {}
};
class TestEval : public moeoEvalFunc < Solution >
{
public:
void operator () (Solution & _sol)
{
ObjectiveVector objVec;
objVec[0] = _sol[0];
objVec[1] = 1 / (_sol[0]+1);
_sol.objectiveVector(objVec);
}
};
int main()
{
std::cout << "[moeoASSEA] => \n";
TestEval eval;
eoQuadCloneOp < Solution > xover;
eoUniformMutation < Solution > mutation(1.0);
eoRealVectorBounds bounds(1, 1.0, 2.0);
eoRealInitBounded < Solution > init(bounds);
eoPop < Solution > pop(20, init);
for(unsigned int i=0; i<pop.size(); i++)
eval(pop[i]);
eoSGATransform < Solution > transform(xover, 0.1, mutation, 0.1);
eoGenContinue <Solution > continuator(10);
moeoUnboundedArchive < Solution > archive;
eoPopLoopEval <Solution> loopEval(eval);
eoPopEvalFunc <Solution>& popEval(loopEval);
// build ASSEA
moeoASEEA <Solution> algo1(10, eval, xover, 0.1, mutation, 0.5, archive, 10);
moeoASEEA <Solution> algo2(continuator, popEval, xover, 0.1, mutation, 1.0, archive, 10);
moeoASEEA <Solution> algo3(continuator, eval, xover, 0.1, mutation, 1.0, archive, 10);
moeoASEEA <Solution> algo4(continuator, popEval, transform, archive, 10);
moeoASEEA <Solution> algo5(continuator, eval, transform, archive, 10);
// run the algo
algo1(pop);
algo2(pop);
algo3(pop);
algo4(pop);
algo5(pop);
std::cout << " OK\n";
return EXIT_SUCCESS;
}

128
moeo/test/t-moeoASFAMetric.cpp Executable file
View file

@ -0,0 +1,128 @@
/*
* <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;
}
//-----------------------------------------------------------------------------

129
moeo/test/t-moeoASFAOrMetric.cpp Executable file
View file

@ -0,0 +1,129 @@
/*
* <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

@ -0,0 +1,147 @@
/*
* <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

@ -0,0 +1,114 @@
/*
* <t-moeoAggregationFitnessAssignment.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;
//-----------------------------------------------------------------------------
int main()
{
std::cout << "[moeoAggregationFitnessAssignment] => ";
// objective vectors
ObjectiveVector obj0, obj1, obj2, obj3;
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);
moeoAggregationFitnessAssignment < 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

@ -0,0 +1,81 @@
/*
* <t-moeoAggregativeComparator.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-moeoAggregativeComparator.cpp
//-----------------------------------------------------------------------------
#include <eo>
#include <moeo>
//-----------------------------------------------------------------------------
typedef MOEO < double, double, double > Solution;
//-----------------------------------------------------------------------------
int main()
{
std::cout << "[moeoAggregativeComparator]\t=>\t";
// fitness & diversity
double fit1 = 1.0;
double div1 = 2.0;
double fit2 = 3.0;
double div2 = 1.0;
// solutions
Solution sol1;
sol1.fitness(fit1);
sol1.diversity(div1);
Solution sol2;
sol2.fitness(fit2);
sol2.diversity(div2);
// comparator
moeoAggregativeComparator < Solution > comparator;
// sol1 not better than sol2?
if (! comparator(sol1, sol2))
{
std::cout << "ERROR (sol1 must be better)" << std::endl;
return EXIT_FAILURE;
}
std::cout << "OK" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,115 @@
/*
* <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

@ -0,0 +1,81 @@
/*
* <t-moeoBitVector.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-moeoBitVector.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 moeoBitVector < ObjectiveVector, double, double > Solution;
//-----------------------------------------------------------------------------
int main()
{
std::cout << "[moeoBitVector]\t=>\t";
// solutions
Solution sol1, sol2;
std::cout << "OK" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,136 @@
/*
* <t-moeoBoundedArchive.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-moeoBoundedArchive.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()
{
std::cout << "[moeoBoundedArchive]\t=>\t";
// 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;
obj4[0] = 5;
obj4[1] = 1;
obj5[0] = 3;
obj5[1] = 8;
obj6[0] = 2.5;
obj6[1] = 3.5;
// 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);
moeoDummyFitnessAssignment < Solution > fitness;
moeoDummyDiversityAssignment < Solution > diversity;
moeoFitnessThenDiversityComparator < Solution > indiComparator;
moeoParetoObjectiveVectorComparator < ObjectiveVector > comparator;
// archive
moeoBoundedArchive< Solution > arch(indiComparator, comparator, fitness, diversity, 50);
moeoBoundedArchive< Solution > arch2(indiComparator, fitness, diversity, 2);
//test archive
arch(pop);
assert(arch.size()==3);
arch2(pop);
assert(arch2.size()==2);
pop.resize(7);
pop[6].objectiveVector(obj6);
arch2(pop[6]);
assert(arch2.size()==2);
obj6[0] = 0;
obj6[1] = 0;
pop[6].objectiveVector(obj6);
arch2(pop[6]);
assert(arch2.size()==1);
std::cout << "OK" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,128 @@
/*
* <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

@ -0,0 +1,128 @@
/*
* <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

@ -0,0 +1,122 @@
/*
* <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

@ -0,0 +1,124 @@
/*
* <t-moeoCrowdingDiversityAssignment.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-moeoCrowdingDiversityAssignment.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 << "[moeoCrowdingDiversityAssignment]\t=>\t";
// objective vectors
ObjectiveVector obj0, obj1, obj2, obj3;
obj0[0] = 1;
obj0[1] = 5;
obj1[0] = 3;
obj1[1] = 3;
obj2[0] = 3;
obj2[1] = 3;
obj3[0] = 5;
obj3[1] = 1;
// population
eoPop < Solution > pop;
pop.resize(4);
pop[0].objectiveVector(obj0);
pop[1].objectiveVector(obj1);
pop[2].objectiveVector(obj2);
pop[3].objectiveVector(obj3);
// diversity assignment
moeoCrowdingDiversityAssignment< Solution > diversityAssignment;
diversityAssignment(pop);
// pop[0]
if (pop[0].diversity() != diversityAssignment.inf())
{
std::cout << "ERROR (bad diversity for pop[0])" << std::endl;
return EXIT_FAILURE;
}
// pop[1]
if (pop[1].diversity() != 1.0)
{
std::cout << "ERROR (bad diversity for pop[1])" << std::endl;
return EXIT_FAILURE;
}
// pop[2]
if (pop[2].diversity() != 1.0)
{
std::cout << "ERROR (bad diversity for pop[2])" << std::endl;
return EXIT_FAILURE;
}
// pop[3]
if (pop[3].diversity() != diversityAssignment.inf())
{
std::cout << "ERROR (bad diversity for pop[3]) " << std::endl;
return EXIT_FAILURE;
}
std::cout << "OK" << std::endl;
return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

View file

@ -0,0 +1,107 @@
/*
<t-moeoDMLSGenUpdater.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, 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 ue,
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".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include "moeoTestClass.h"
#include <algo/moeoPLS1.h>
#include <eoTimeContinue.h>
#include <archive/moeoUnboundedArchive.h>
#include <hybridization/moeoDMLSGenUpdater.h>
#include <selection/moeoExhaustiveUnvisitedSelect.h>
#include <explorer/moeoExhaustiveNeighborhoodExplorer.h>
#include <eoGenContinue.h>
#include <iostream>
#include <cstdlib>
#include <cassert>
int main(){
std::cout << "[t-moeoDMLSGenUpdater] => START" << std::endl;
//init all components
moeoUnboundedArchive<Solution> arch(false);
moeoUnboundedArchive<Solution> globalArch(false);
eoTimeContinue<Solution> cont(1);
fullEvalSolution fullEval(8);
Solution s;
evalSolution eval(8);
ObjectiveVector o;
SolNeighbor n;
SolNeighborhood nh(8);
moeoPLS1<SolNeighbor> pls1(cont, fullEval, arch, nh, eval);
moeoExhaustiveUnvisitedSelect<Solution> select;
moeoExhaustiveNeighborhoodExplorer<SolNeighbor> explorer(nh, eval);
eoGenContinue<Solution> genCont(2);
//Create a solution
s.resize(8);
s[0]=true;
s[1]=true;
s[2]=true;
s[3]=true;
s[4]=true;
s[5]=true;
s[6]=true;
s[7]=true;
//Set its objective Vector
o[0]=8;
o[1]=0;
s.objectiveVector(o);
globalArch(s);
assert(globalArch.size()==1);
//test constructor 1 with a dmls, its archive, a global archive and a generational continuator
moeoDMLSGenUpdater<SolNeighbor> test1(pls1, arch, globalArch, genCont);
//test constructor 2 with a full evaluation function, an explorer, a selector, a global archive and a generational continuator
moeoDMLSGenUpdater<SolNeighbor> test2(fullEval, explorer, select, globalArch, genCont);
//test constructor 3 with a full evaluation function, an explorer, a selector, a global archive and a generational continuator
moeoDMLSGenUpdater<SolNeighbor> test3(fullEval, arch, explorer, select, globalArch, genCont);
std::cout << "initial solution:" << std::endl;
std::cout << s << std::endl;
test1();
assert(globalArch.size()==1);
test1();
assert(globalArch.size()==9);
std::cout << "global arch:" << std::endl;
for(unsigned int i=0; i<globalArch.size(); i++)
std::cout << globalArch[i] << std::endl;
std::cout << "[t-moeoDMLSGenUpdater] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,95 @@
/*
<t-moeoDMLSMonOp.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, 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 ue,
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".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <iostream>
#include <cstdlib>
#include <cassert>
#include "moeoTestClass.h"
#include <algo/moeoPLS1.h>
#include <eoTimeContinue.h>
#include <archive/moeoUnboundedArchive.h>
#include <hybridization/moeoDMLSMonOp.h>
#include <selection/moeoExhaustiveUnvisitedSelect.h>
#include <explorer/moeoExhaustiveNeighborhoodExplorer.h>
int main(){
std::cout << "[t-moeoDMLSMonOp] => START" << std::endl;
//init all components
moeoUnboundedArchive<Solution> arch(false);
eoTimeContinue<Solution> cont(1);
fullEvalSolution fullEval(8);
Solution s;
evalSolution eval(8);
ObjectiveVector o;
SolNeighbor n;
SolNeighborhood nh(8);
moeoPLS1<SolNeighbor> pls1(cont, fullEval, arch, nh, eval);
moeoExhaustiveUnvisitedSelect<Solution> select;
moeoExhaustiveNeighborhoodExplorer<SolNeighbor> explorer(nh, eval);
//Create a solution
s.push_back(true);
s.push_back(true);
s.push_back(true);
s.push_back(true);
s.push_back(true);
s.push_back(true);
s.push_back(true);
s.push_back(true);
//Set its objective Vector
o[0]=8;
o[1]=0;
s.objectiveVector(o);
//test constructor 1 with a dmls and its archive
moeoDMLSMonOp<SolNeighbor> test1(pls1, arch);
//test constructor 2 with an incremental evaluation function, a selector and an explorer
moeoDMLSMonOp<SolNeighbor> test2(fullEval, explorer, select, 2, true);
//test constructor 3 with an incremental evaluation function, a selector and an explorer and the dmls archive
moeoDMLSMonOp<SolNeighbor> test3(fullEval, arch, explorer, select, 2, true);
std::cout << "initial solution:" << std::endl;
std::cout << s << std::endl;
test1(s);
std::cout << "mutate solution:" << std::endl;
std::cout << s << std::endl;
std::cout << "[t-moeoDMLSMonOp] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,133 @@
/*
* <t-moeoDetArchiveSelect.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-moeoDetArchiveSelect..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()
{
std::cout << "[moeoDetArchiveSelect] => \n";
moeoUnboundedArchive <Solution> archive;
Solution sol1, sol2, sol3, sol4, sol5;
ObjectiveVector obj1, obj2, obj3, obj4, obj5;
obj1[0]=10;
obj1[1]=0;
obj2[0]=9;
obj2[1]=1;
obj3[0]=8;
obj3[1]=2;
obj4[0]=7;
obj4[1]=3;
obj5[0]=6;
obj5[1]=4;
sol1.objectiveVector(obj1);
sol2.objectiveVector(obj2);
sol3.objectiveVector(obj3);
sol4.objectiveVector(obj4);
sol5.objectiveVector(obj5);
archive(sol1);
archive(sol2);
archive(sol3);
archive(sol4);
archive(sol5);
assert(archive.size() == 5);
//archive.printOn(std::cout);
eoPop <Solution> source, dest;
// test with max > archive size
moeoDetArchiveSelect <Solution> select1(archive, 10);
select1(source, dest);
for(unsigned int i=0; i< archive.size(); i++){
assert(dest[i].objectiveVector()[0]==archive[i].objectiveVector()[0]);
assert(dest[i].objectiveVector()[1]==archive[i].objectiveVector()[1]);
}
//test with a max < archive size
dest.resize(0);
moeoDetArchiveSelect <Solution> select2(archive, 3);
select2(source, dest);
assert(dest.size()==3);
//test with archive size < min
dest.resize(0);
moeoDetArchiveSelect <Solution> select3(archive, 100, 10);
select3(source, dest);
for(int i=0; i< 10; i++){
assert(dest[i].objectiveVector()[0]==archive[i%archive.size()].objectiveVector()[0]);
assert(dest[i].objectiveVector()[1]==archive[i%archive.size()].objectiveVector()[1]);
}
//test with bad value
dest.resize(0);
moeoDetArchiveSelect <Solution> select4(archive, 10, 11);
select4(source, dest);
assert(dest.size()==0);
std::cout << " OK\n";
return EXIT_SUCCESS;
}

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