Migration from SVN
This commit is contained in:
parent
d7d6c3a217
commit
8cd56f37db
29069 changed files with 0 additions and 4096888 deletions
86
moeo/test/CMakeLists.txt
Normal file
86
moeo/test/CMakeLists.txt
Normal 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
158
moeo/test/moeoTestClass.h
Normal 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
81
moeo/test/t-moeo.cpp
Normal 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;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
195
moeo/test/t-moeo2DMinHypervolumeArchive.cpp
Normal file
195
moeo/test/t-moeo2DMinHypervolumeArchive.cpp
Normal 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
122
moeo/test/t-moeoASEEA.cpp
Normal 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
128
moeo/test/t-moeoASFAMetric.cpp
Executable 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
129
moeo/test/t-moeoASFAOrMetric.cpp
Executable 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
147
moeo/test/t-moeoAchievementFitnessAssignment.cpp
Normal file
147
moeo/test/t-moeoAchievementFitnessAssignment.cpp
Normal 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
114
moeo/test/t-moeoAggregationFitnessAssignment.cpp
Executable file
114
moeo/test/t-moeoAggregationFitnessAssignment.cpp
Executable 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
81
moeo/test/t-moeoAggregativeComparator.cpp
Normal file
81
moeo/test/t-moeoAggregativeComparator.cpp
Normal 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
115
moeo/test/t-moeoAggregativeFitnessAssignment.cpp
Normal file
115
moeo/test/t-moeoAggregativeFitnessAssignment.cpp
Normal 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
81
moeo/test/t-moeoBitVector.cpp
Normal file
81
moeo/test/t-moeoBitVector.cpp
Normal 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;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
136
moeo/test/t-moeoBoundedArchive.cpp
Normal file
136
moeo/test/t-moeoBoundedArchive.cpp
Normal 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
128
moeo/test/t-moeoChebyshevMetric.cpp
Executable file
128
moeo/test/t-moeoChebyshevMetric.cpp
Executable 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
128
moeo/test/t-moeoChebyshevOrientedMetric.cpp
Executable file
128
moeo/test/t-moeoChebyshevOrientedMetric.cpp
Executable 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
122
moeo/test/t-moeoConstraintFitnessAssignment.cpp
Executable file
122
moeo/test/t-moeoConstraintFitnessAssignment.cpp
Executable 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
124
moeo/test/t-moeoCrowdingDiversityAssignment.cpp
Normal file
124
moeo/test/t-moeoCrowdingDiversityAssignment.cpp
Normal 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
107
moeo/test/t-moeoDMLSGenUpdater.cpp
Normal file
107
moeo/test/t-moeoDMLSGenUpdater.cpp
Normal 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;
|
||||
}
|
||||
|
||||
95
moeo/test/t-moeoDMLSMonOp.cpp
Normal file
95
moeo/test/t-moeoDMLSMonOp.cpp
Normal 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;
|
||||
}
|
||||
|
||||
133
moeo/test/t-moeoDetArchiveSelect.cpp
Normal file
133
moeo/test/t-moeoDetArchiveSelect.cpp
Normal 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;
|
||||
}
|
||||
81
moeo/test/t-moeoDiversityThenFitnessComparator.cpp
Normal file
81
moeo/test/t-moeoDiversityThenFitnessComparator.cpp
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* <t-moeoDiversityThenFitnessComparator.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-moeoDiversityThenFitnessComparator.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo>
|
||||
#include <moeo>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef MOEO < double, double, double > Solution;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoDiversityThenFitnessComparator]\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
|
||||
moeoDiversityThenFitnessComparator < Solution > comparator;
|
||||
|
||||
// sol1 better than sol2?
|
||||
if (comparator(sol1, sol2))
|
||||
{
|
||||
std::cout << "ERROR (sol2 must be better)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
183
moeo/test/t-moeoDominanceCountFitnessAssignment.cpp
Normal file
183
moeo/test/t-moeoDominanceCountFitnessAssignment.cpp
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
/*
|
||||
* <t-moeoDominanceCountFitnessAssignment.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-moeoDominanceCountFitnessAssignment.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 test(const eoPop < Solution >& _pop, const moeoUnboundedArchive < Solution >& _archive, int _pop0, int _pop1, int _pop2, int _pop3, int _arch0, int _arch1, int _arch2) {
|
||||
// pop[0]
|
||||
if (_pop[0].fitness() != _pop0)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[0])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[1]
|
||||
if (_pop[1].fitness() != _pop1)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[1])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[2]
|
||||
if (_pop[2].fitness() != _pop2)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[2])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[3]
|
||||
if (_pop[3].fitness() != _pop3)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[3]) " << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// archive[0]
|
||||
if ((_arch0 >= 0 ) && (_archive[0].fitness() != _arch0))
|
||||
{
|
||||
std::cout << "ERROR (bad fitness archive[0])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// archive[1]
|
||||
if ((_arch1 >= 0 ) && (_archive[1].fitness() != _arch1))
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for archive[1])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// archive[2]
|
||||
if ((_arch2 >= 0) && (_archive[2].fitness() != _arch2))
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for archive[2])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int res=EXIT_SUCCESS;
|
||||
|
||||
std::cout << "[moeoDominanceCountFitnessAssignment]\n\n";
|
||||
|
||||
// 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] = 3;
|
||||
obj6[0] = 4;
|
||||
obj6[1] = 4;
|
||||
|
||||
// population
|
||||
eoPop < Solution > pop;
|
||||
pop.resize(4);
|
||||
pop[0].objectiveVector(obj0); // class 1
|
||||
pop[1].objectiveVector(obj1); // class 1
|
||||
pop[2].objectiveVector(obj2); // class 1
|
||||
pop[3].objectiveVector(obj3); // class 3
|
||||
|
||||
moeoUnboundedArchive < Solution > archive;
|
||||
archive.resize(3);
|
||||
archive[0].objectiveVector(obj4);
|
||||
archive[1].objectiveVector(obj5);
|
||||
archive[2].objectiveVector(obj6);
|
||||
|
||||
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
|
||||
|
||||
// fitness assignment
|
||||
|
||||
moeoDominanceCountFitnessAssignment< Solution > fitnessAssignment(false);
|
||||
|
||||
moeoDominanceCountFitnessAssignment< Solution > fitnessAssignment2(archive,false);
|
||||
|
||||
moeoDominanceCountFitnessAssignment< Solution > fitnessAssignment3(paretoComparator);
|
||||
|
||||
moeoDominanceCountFitnessAssignment< Solution > fitnessAssignment4(paretoComparator, archive);
|
||||
|
||||
std::cout << "Constructor without parameter => ";
|
||||
fitnessAssignment(pop);
|
||||
|
||||
if (test(pop, archive, 1, 1, 1, 0, -1, -1, -1) == 0)
|
||||
std::cout << "OK" << std::endl;
|
||||
else
|
||||
res=EXIT_FAILURE;
|
||||
|
||||
std::cout << "Constructor with archive passed in parameter => ";
|
||||
fitnessAssignment2(pop);
|
||||
|
||||
if (test(pop, archive, 1, 2, 3, 0, 1, 2, 1) == 0)
|
||||
std::cout << "OK" << std::endl;
|
||||
else
|
||||
res=EXIT_FAILURE;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
185
moeo/test/t-moeoDominanceCountRankingFitnessAssignment.cpp
Normal file
185
moeo/test/t-moeoDominanceCountRankingFitnessAssignment.cpp
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
/*
|
||||
* <t-moeoDominanceCountRankingFitnessAssignment.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-moeoDominanceCountRankingFitnessAssignment.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 test(const eoPop < Solution >& _pop, const moeoUnboundedArchive < Solution >& _archive, double _pop0, double _pop1, double _pop2, double _pop3, double _arch0, double _arch1, double _arch2) {
|
||||
// pop[0]
|
||||
if (_pop[0].fitness() != _pop0)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[0])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[1]
|
||||
if (_pop[1].fitness() != _pop1)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[1])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[2]
|
||||
if (_pop[2].fitness() != _pop2)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[2])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[3]
|
||||
if (_pop[3].fitness() != _pop3)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[3]) " << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// archive[0]
|
||||
if ((_arch0 <= 0 ) && (_archive[0].fitness() != _arch0))
|
||||
{
|
||||
std::cout << "ERROR (bad fitness archive[0])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// archive[1]
|
||||
if ((_arch1 <= 0 ) && (_archive[1].fitness() != _arch1))
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for archive[1])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// archive[2]
|
||||
if ((_arch2 <= 0) && (_archive[2].fitness() != _arch2))
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for archive[2])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int res=EXIT_SUCCESS;
|
||||
std::cout << "[moeoDominanceCountRankingFitnessAssignment]\n";
|
||||
|
||||
// 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] = 3;
|
||||
obj6[0] = 4;
|
||||
obj6[1] = 4;
|
||||
|
||||
// population
|
||||
eoPop < Solution > pop;
|
||||
pop.resize(4);
|
||||
pop[0].objectiveVector(obj0); // class 1
|
||||
pop[1].objectiveVector(obj1); // class 1
|
||||
pop[2].objectiveVector(obj2); // class 1
|
||||
pop[3].objectiveVector(obj3); // class 3
|
||||
|
||||
moeoUnboundedArchive < Solution > archive;
|
||||
archive.resize(3);
|
||||
archive[0].objectiveVector(obj4);
|
||||
archive[1].objectiveVector(obj5);
|
||||
archive[2].objectiveVector(obj6);
|
||||
|
||||
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
|
||||
|
||||
// fitness assignment
|
||||
|
||||
moeoDominanceCountRankingFitnessAssignment <Solution> fitnessAssignment;
|
||||
|
||||
moeoDominanceCountRankingFitnessAssignment <Solution> fitnessAssignment2(archive);
|
||||
|
||||
moeoDominanceCountRankingFitnessAssignment <Solution> fitnessAssignment3(paretoComparator,false);
|
||||
|
||||
moeoDominanceCountRankingFitnessAssignment <Solution> fitnessAssignment4(paretoComparator, archive,false);
|
||||
|
||||
std::cout << "Constructor without parameter => ";
|
||||
fitnessAssignment(pop);
|
||||
if (test(pop, archive, 0, 0, 0, -3, 1, 1, 1) == 0)
|
||||
std::cout << "OK" << std::endl;
|
||||
else
|
||||
res=EXIT_FAILURE;
|
||||
|
||||
std::cout << "Constructor with archive passed in parameter => ";
|
||||
fitnessAssignment2(pop);
|
||||
for (unsigned int k=0; k<pop.size();k++)
|
||||
std::cout << "pop " << k << " : " << pop[k].fitness() << "\n";
|
||||
for (unsigned int k=0; k<archive.size();k++)
|
||||
std::cout << "archive " << k << " : " << archive[k].fitness() << "\n";
|
||||
|
||||
if (test(pop, archive, 0, -14, 0, -13, -4, 0, -7) == 0)
|
||||
std::cout << "OK" << std::endl;
|
||||
else
|
||||
res=EXIT_FAILURE;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
142
moeo/test/t-moeoDominanceDepthFitnessAssignment.cpp
Normal file
142
moeo/test/t-moeoDominanceDepthFitnessAssignment.cpp
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
* <t-moeoDominanceDepthFitnessAssignment.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moeoDominanceDepthFitnessAssignment.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 << "[moeoDominanceDepthFitnessAssignment]\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); // class 1
|
||||
pop[1].objectiveVector(obj1); // class 1
|
||||
pop[2].objectiveVector(obj2); // class 1
|
||||
pop[3].objectiveVector(obj3); // class 3
|
||||
pop[4].objectiveVector(obj4); // class 2
|
||||
pop[5].objectiveVector(obj5); // class 1
|
||||
|
||||
// fitness assignment
|
||||
moeoDominanceDepthFitnessAssignment< Solution > fitnessAssignment;
|
||||
fitnessAssignment(pop);
|
||||
|
||||
// pop[0]
|
||||
if (pop[0].fitness() != 2.0)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[0])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[1]
|
||||
if (pop[1].fitness() != 2.0)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[1])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[2]
|
||||
if (pop[2].fitness() != 2.0)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[2])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[3]
|
||||
if (pop[3].fitness() != 0.0)
|
||||
{
|
||||
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() != 2.0)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[5])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
210
moeo/test/t-moeoDominanceMatrix.cpp
Normal file
210
moeo/test/t-moeoDominanceMatrix.cpp
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
* <t-moeoDominanceMatrix.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-moeoDominanceMatrix.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo>
|
||||
#include <moeo>
|
||||
#include <assert.h>
|
||||
#include <set>
|
||||
#include <iostream>
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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 << "[moeoDominanceMatrix]\n\n";
|
||||
|
||||
// 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] = 3;
|
||||
obj6[0] = 4;
|
||||
obj6[1] = 4;
|
||||
|
||||
// population
|
||||
eoPop < Solution > pop;
|
||||
pop.resize(4);
|
||||
pop[0].objectiveVector(obj0); // class 1
|
||||
pop[1].objectiveVector(obj1); // class 1
|
||||
pop[2].objectiveVector(obj2); // class 1
|
||||
pop[3].objectiveVector(obj3); // class 3
|
||||
|
||||
moeoUnboundedArchive < Solution > archive;
|
||||
archive.resize(3);
|
||||
archive[0].objectiveVector(obj4);
|
||||
archive[1].objectiveVector(obj5);
|
||||
archive[2].objectiveVector(obj6);
|
||||
|
||||
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
|
||||
|
||||
// fitness assignment
|
||||
|
||||
moeoDominanceMatrix< Solution > matrix(true);
|
||||
|
||||
moeoDominanceMatrix< Solution > matrix2(paretoComparator, false);
|
||||
|
||||
//test operator() with 2 parameters
|
||||
matrix(pop,archive);
|
||||
|
||||
//test result of matrix
|
||||
for (unsigned int i=0; i<7; i++)
|
||||
for (unsigned int j=0; j<3; j++)
|
||||
assert(!matrix[i][j]);
|
||||
assert(matrix[0][3]);
|
||||
assert(matrix[0][5]);
|
||||
assert(matrix[1][3]);
|
||||
assert(matrix[1][5]);
|
||||
assert(matrix[1][6]);
|
||||
assert(matrix[2][3]);
|
||||
assert(matrix[2][4]);
|
||||
assert(matrix[2][5]);
|
||||
assert(matrix[2][6]);
|
||||
assert(matrix[3][5]);
|
||||
assert(matrix[4][3]);
|
||||
assert(matrix[4][5]);
|
||||
assert(matrix[6][3]);
|
||||
assert(matrix[6][5]);
|
||||
assert(!matrix[0][4]);
|
||||
assert(!matrix[0][6]);
|
||||
assert(!matrix[1][4]);
|
||||
assert(!matrix[3][3]);
|
||||
assert(!matrix[3][4]);
|
||||
assert(!matrix[3][6]);
|
||||
assert(!matrix[4][4]);
|
||||
assert(!matrix[4][6]);
|
||||
assert(!matrix[5][3]);
|
||||
assert(!matrix[5][4]);
|
||||
assert(!matrix[5][5]);
|
||||
assert(!matrix[5][6]);
|
||||
assert(!matrix[6][4]);
|
||||
assert(!matrix[6][6]);
|
||||
|
||||
//test methode count
|
||||
assert(matrix.count(0)==2);
|
||||
assert(matrix.count(1)==3);
|
||||
assert(matrix.count(2)==4);
|
||||
assert(matrix.count(3)==1);
|
||||
assert(matrix.count(4)==2);
|
||||
assert(matrix.count(5)==0);
|
||||
assert(matrix.count(6)==2);
|
||||
|
||||
//test methode rank
|
||||
assert(matrix.rank(0)==0);
|
||||
assert(matrix.rank(1)==0);
|
||||
assert(matrix.rank(2)==0);
|
||||
assert(matrix.rank(3)==5);
|
||||
assert(matrix.rank(4)==1);
|
||||
assert(matrix.rank(5)==6);
|
||||
assert(matrix.rank(6)==2);
|
||||
|
||||
//test operator() with one parameter
|
||||
matrix2(archive);
|
||||
|
||||
assert(!matrix2[0][0]);
|
||||
assert(!matrix2[0][1]);
|
||||
assert(!matrix2[0][2]);
|
||||
assert(!matrix2[1][0]);
|
||||
assert(!matrix2[1][1]);
|
||||
assert(matrix2[1][2]);
|
||||
assert(!matrix2[2][0]);
|
||||
assert(!matrix2[2][1]);
|
||||
assert(!matrix2[2][2]);
|
||||
|
||||
assert(matrix2.count(0)==0);
|
||||
assert(matrix2.count(1)==1);
|
||||
assert(matrix2.count(2)==0);
|
||||
|
||||
assert(matrix2.rank(0)==0);
|
||||
assert(matrix2.rank(1)==0);
|
||||
assert(matrix2.rank(2)==1);
|
||||
|
||||
std::set<int> hop;
|
||||
hop.insert(2);
|
||||
hop.insert(2);
|
||||
hop.insert(10);
|
||||
hop.insert(3);
|
||||
hop.insert(45);
|
||||
hop.insert(45);
|
||||
hop.insert(45);
|
||||
|
||||
std::set<int>::iterator it=hop.begin();
|
||||
while (it!=hop.end()) {
|
||||
std::cout << *it << "\n";
|
||||
it++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::cout << "OK";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
179
moeo/test/t-moeoDominanceRankFitnessAssignment.cpp
Normal file
179
moeo/test/t-moeoDominanceRankFitnessAssignment.cpp
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* <t-moeoDominanceRankFitnessAssignment.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-moeoDominanceRankFitnessAssignment.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 test(const eoPop < Solution >& _pop, const moeoUnboundedArchive < Solution >& _archive, int _pop0, int _pop1, int _pop2, int _pop3, int _arch0, int _arch1, int _arch2) {
|
||||
// pop[0]
|
||||
if (_pop[0].fitness() != _pop0)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[0])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[1]
|
||||
if (_pop[1].fitness() != _pop1)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[1])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[2]
|
||||
if (_pop[2].fitness() != _pop2)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[2])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[3]
|
||||
if (_pop[3].fitness() != _pop3)
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[3]) " << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// archive[0]
|
||||
if ((_arch0 <= 0 ) && (_archive[0].fitness() != _arch0))
|
||||
{
|
||||
std::cout << "ERROR (bad fitness archive[0])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// archive[1]
|
||||
if ((_arch1 <= 0 ) && (_archive[1].fitness() != _arch1))
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for archive[1])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// archive[2]
|
||||
if ((_arch2 <= 0) && (_archive[2].fitness() != _arch2))
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for archive[2])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int res=EXIT_SUCCESS;
|
||||
std::cout << "[moeoDominanceRankFitnessAssignment]\n";
|
||||
|
||||
// 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] = 3;
|
||||
obj6[0] = 4;
|
||||
obj6[1] = 4;
|
||||
|
||||
// population
|
||||
eoPop < Solution > pop;
|
||||
pop.resize(4);
|
||||
pop[0].objectiveVector(obj0); // class 1
|
||||
pop[1].objectiveVector(obj1); // class 1
|
||||
pop[2].objectiveVector(obj2); // class 1
|
||||
pop[3].objectiveVector(obj3); // class 3
|
||||
|
||||
moeoUnboundedArchive < Solution > archive;
|
||||
archive.resize(3);
|
||||
archive[0].objectiveVector(obj4);
|
||||
archive[1].objectiveVector(obj5);
|
||||
archive[2].objectiveVector(obj6);
|
||||
|
||||
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
|
||||
|
||||
// fitness assignment
|
||||
moeoDominanceRankFitnessAssignment< Solution > fitnessAssignment;
|
||||
|
||||
moeoDominanceRankFitnessAssignment< Solution > fitnessAssignment2(archive, 2.0,true);
|
||||
|
||||
moeoDominanceRankFitnessAssignment< Solution > fitnessAssignment3(paretoComparator, 3.0);
|
||||
|
||||
moeoDominanceRankFitnessAssignment< Solution > fitnessAssignment4(paretoComparator, archive);
|
||||
|
||||
std::cout << "Constructor without parameter => ";
|
||||
fitnessAssignment(pop);
|
||||
if (test(pop, archive, -1, -1, -1, -4, 1, 1, 1) == 0)
|
||||
std::cout << "OK" << std::endl;
|
||||
else
|
||||
res=EXIT_FAILURE;
|
||||
|
||||
std::cout << "Constructor with archive passed in parameter => ";
|
||||
fitnessAssignment2(pop);
|
||||
if (test(pop, archive, -2, -8, -2, -7, -3, -2, -4) == 0)
|
||||
std::cout << "OK" << std::endl;
|
||||
else
|
||||
res=EXIT_FAILURE;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
128
moeo/test/t-moeoEasyEA.cpp
Normal file
128
moeo/test/t-moeoEasyEA.cpp
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* <t-moeoEasyEA.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moeoEasyEA.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo>
|
||||
#include <es/eoRealInitBounded.h>
|
||||
#include <es/eoRealOp.h>
|
||||
#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;
|
||||
|
||||
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];
|
||||
_sol.objectiveVector(objVec);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoEasyEA]" << std::endl;
|
||||
|
||||
TestEval eval;
|
||||
eoPopLoopEval <Solution> loopEval(eval);
|
||||
eoPopEvalFunc <Solution> & popEval(loopEval);
|
||||
eoQuadCloneOp < Solution > xover;
|
||||
eoUniformMutation < Solution > mutation(0.05);
|
||||
eoSequentialOp < Solution > op;
|
||||
op.add(xover, 1.0);
|
||||
op.add(mutation, 1.0);
|
||||
eoSGATransform < Solution > transform(xover, 1.0, mutation, 1.0);
|
||||
eoRealVectorBounds bounds(1, 1.0, 2.0);
|
||||
eoRealInitBounded < Solution > init(bounds);
|
||||
eoPop < Solution > pop(20, init);
|
||||
eoGenContinue < Solution > term(20);
|
||||
moeoDominanceDepthFitnessAssignment < Solution > fitnessAssignment;
|
||||
moeoFrontByFrontCrowdingDiversityAssignment < Solution > diversityAssignment;
|
||||
moeoFitnessThenDiversityComparator < Solution > comparator;
|
||||
moeoDetTournamentSelect < Solution > selectOne(comparator, 2);
|
||||
moeoElitistReplacement < Solution > replace(fitnessAssignment, diversityAssignment, comparator);
|
||||
eoGeneralBreeder < Solution > breed(selectOne, op);
|
||||
eoSelectMany < Solution > select(selectOne, 1.0);
|
||||
|
||||
// build EA
|
||||
moeoEasyEA < Solution > algo1 (term, eval, breed, replace, fitnessAssignment, diversityAssignment);
|
||||
moeoEasyEA < Solution > algo2 (term, popEval, breed, replace, fitnessAssignment, diversityAssignment);
|
||||
moeoEasyEA < Solution > algo3 (term, eval, select, transform, replace, fitnessAssignment, diversityAssignment);
|
||||
moeoEasyEA < Solution > algo4 (term, popEval, select, transform, replace, fitnessAssignment, diversityAssignment);
|
||||
|
||||
// run the algo
|
||||
algo4(pop);
|
||||
|
||||
// final pop
|
||||
std::cout << "Final population" << std::endl;
|
||||
std::cout << pop << std::endl;
|
||||
|
||||
std::cout << "[moeoEasyEA] OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
161
moeo/test/t-moeoEpsilonHyperboxArchive.cpp
Normal file
161
moeo/test/t-moeoEpsilonHyperboxArchive.cpp
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* <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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
137
moeo/test/t-moeoEpsilonObjectiveVectorComparator.cpp
Normal file
137
moeo/test/t-moeoEpsilonObjectiveVectorComparator.cpp
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* <t-moeoEpsilonObjectiveVectorComparator.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moeoEpsilonObjectiveVectorComparator.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 > Solution;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoEpsilonObjectiveVectorComparator]\t=>\t";
|
||||
|
||||
// objective vectors
|
||||
ObjectiveVector obj1;
|
||||
obj1[0] = 2.0;
|
||||
obj1[1] = 5.0;
|
||||
ObjectiveVector obj2;
|
||||
obj2[0] = 2.2;
|
||||
obj2[1] = 5.5;
|
||||
ObjectiveVector obj3;
|
||||
obj3[0] = 3.0;
|
||||
obj3[1] = 5.0;
|
||||
ObjectiveVector obj4;
|
||||
obj4[0] = 3.0;
|
||||
obj4[1] = 6.0;
|
||||
|
||||
// epsilon
|
||||
double epsilon = 1.1;
|
||||
// comparator
|
||||
moeoEpsilonObjectiveVectorComparator< ObjectiveVector > comparator(epsilon);
|
||||
|
||||
// obj1 dominated by obj2? NO
|
||||
if (comparator(obj1, obj2))
|
||||
{
|
||||
std::cout << "ERROR (obj1 dominated by obj2)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj2 dominated by obj1? YES
|
||||
if (! comparator(obj2, obj1))
|
||||
{
|
||||
std::cout << "ERROR (obj2 notdominated by obj1)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj1 dominated by obj3? NO
|
||||
if (comparator(obj1, obj3))
|
||||
{
|
||||
std::cout << "ERROR (obj1 dominated by obj3)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj3 dominated by obj1? NO
|
||||
if (comparator(obj3, obj1))
|
||||
{
|
||||
std::cout << "ERROR (obj3 dominated by obj1)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj1 dominated by obj4? NO
|
||||
if (comparator(obj1, obj4))
|
||||
{
|
||||
std::cout << "ERROR (obj1 dominated by obj4)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj4 dominated by obj1? YES
|
||||
if (! comparator(obj4, obj1))
|
||||
{
|
||||
std::cout << "ERROR (obj4 not dominated by obj1)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
115
moeo/test/t-moeoExhaustiveNeighborhoodExplorer.cpp
Normal file
115
moeo/test/t-moeoExhaustiveNeighborhoodExplorer.cpp
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
<t-moeoExhaustiveNeighborhoodExplorer.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
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 <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moeoExhaustiveNeighborhoodExplorer] => START" << std::endl;
|
||||
|
||||
//init all components
|
||||
Solution s;
|
||||
evalSolution eval(8);
|
||||
ObjectiveVector o;
|
||||
SolNeighbor n;
|
||||
SolNeighborhood nh(8);
|
||||
moeoExhaustiveNeighborhoodExplorer<SolNeighbor> explorer(nh, eval);
|
||||
|
||||
//create source and destination population
|
||||
eoPop<Solution> src;
|
||||
eoPop<Solution> dest;
|
||||
|
||||
//create a vector for selection
|
||||
std::vector<unsigned int> v;
|
||||
v.push_back(0);
|
||||
|
||||
//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);
|
||||
|
||||
// aplly a move on th solution
|
||||
n.index(3);
|
||||
eval(s,n);
|
||||
n.move(s);
|
||||
s.objectiveVector(n.fitness());
|
||||
|
||||
//print initial sol
|
||||
std::cout << "solution:" << std::endl;
|
||||
std::cout << s << std::endl;
|
||||
|
||||
//copy the solution in the source population
|
||||
src.push_back(s);
|
||||
|
||||
//test the explorer
|
||||
explorer(src, v, dest);
|
||||
|
||||
//verify the destination population
|
||||
assert(dest.size()==8);
|
||||
|
||||
assert(dest[0].objectiveVector()[0]==6);
|
||||
assert(dest[1].objectiveVector()[0]==6);
|
||||
assert(dest[2].objectiveVector()[0]==6);
|
||||
assert(dest[3].objectiveVector()[0]==8);
|
||||
assert(dest[4].objectiveVector()[0]==6);
|
||||
assert(dest[5].objectiveVector()[0]==6);
|
||||
assert(dest[6].objectiveVector()[0]==6);
|
||||
assert(dest[7].objectiveVector()[0]==6);
|
||||
|
||||
assert(dest[0].objectiveVector()[1]==2);
|
||||
assert(dest[1].objectiveVector()[1]==2);
|
||||
assert(dest[2].objectiveVector()[1]==2);
|
||||
assert(dest[3].objectiveVector()[1]==0);
|
||||
assert(dest[4].objectiveVector()[1]==2);
|
||||
assert(dest[5].objectiveVector()[1]==2);
|
||||
assert(dest[6].objectiveVector()[1]==2);
|
||||
assert(dest[7].objectiveVector()[1]==2);
|
||||
|
||||
std::cout << "destination:" << std::endl;
|
||||
for(unsigned int i=0; i<dest.size(); i++)
|
||||
std::cout << dest[i] << std::endl;
|
||||
|
||||
std::cout << "[t-moeoExhaustiveNeighborhoodExplorer] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
64
moeo/test/t-moeoExhaustiveUnvisitedSelect.cpp
Normal file
64
moeo/test/t-moeoExhaustiveUnvisitedSelect.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
<t-moeoExhaustiveUnvisitedSelect.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 <selection/moeoExhaustiveUnvisitedSelect.h>
|
||||
#include <moeoTestClass.h>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moeoExhaustiveUnvisitedSelect] => START" << std::endl;
|
||||
|
||||
// objective vectors
|
||||
eoPop < Solution > pop;
|
||||
pop.resize(5);
|
||||
pop[0].flag(1);
|
||||
pop[1].flag(0);
|
||||
pop[2].flag(0);
|
||||
pop[3].flag(1);
|
||||
pop[4].flag(0);
|
||||
|
||||
moeoExhaustiveUnvisitedSelect < Solution > select;
|
||||
|
||||
std::vector <unsigned int> res;
|
||||
|
||||
res=select(pop);
|
||||
assert(res.size()==3);
|
||||
assert(res[0]==1);
|
||||
assert(res[1]==2);
|
||||
assert(res[2]==4);
|
||||
|
||||
std::cout << "[t-moeoExhaustiveUnvisitedSelect] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
145
moeo/test/t-moeoExpBinaryIndicatorBasedFitnessAssignment.cpp
Normal file
145
moeo/test/t-moeoExpBinaryIndicatorBasedFitnessAssignment.cpp
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* <t-moeoExpBinaryIndicatorBasedFitnessAssignment.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-moeoExpBinaryIndicatorBasedFitnessAssignment.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 << "[moeoExpBinaryIndicatorBasedFitnessAssignment]\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);
|
||||
|
||||
// indicator
|
||||
moeoAdditiveEpsilonBinaryMetric < ObjectiveVector > indicator;
|
||||
|
||||
// fitness assignment
|
||||
moeoExpBinaryIndicatorBasedFitnessAssignment< Solution > fitnessAssignment(indicator, 0.5);
|
||||
fitnessAssignment(pop);
|
||||
|
||||
// pop[0]
|
||||
if ( (pop[0].fitness() > -1.56) || (pop[0].fitness() < -1.57) )
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[0])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[1]
|
||||
if ( (pop[1].fitness() > -2.40) || (pop[1].fitness() < -2.41) )
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[1])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[2]
|
||||
if ( (pop[2].fitness() > -1.51) || (pop[2].fitness() < -1.52) )
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[2])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[3]
|
||||
if ( (pop[3].fitness() > -9.38) || (pop[3].fitness() < -9.39) )
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[3]) " << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[4]
|
||||
if ( (pop[4].fitness() > -2.00) || (pop[4].fitness() < -2.01) )
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[4])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[5]
|
||||
if ( (pop[5].fitness() > -2.40) || (pop[5].fitness() < -2.41) )
|
||||
{
|
||||
std::cout << "ERROR (bad fitness for pop[5])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
132
moeo/test/t-moeoFirstImprovingNeighborhoodExplorer.cpp
Normal file
132
moeo/test/t-moeoFirstImprovingNeighborhoodExplorer.cpp
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
<t-moeoFirstImprovingNeighborhoodExplorer.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
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 <explorer/moeoFirstImprovingNeighborhoodExplorer.h>
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moeoFirstImprovingNeighborhoodExplorer] => START" << std::endl;
|
||||
|
||||
//init all components
|
||||
Solution s;
|
||||
evalSolution eval(8);
|
||||
evalSolution eval2(8, 0);
|
||||
ObjectiveVector o;
|
||||
SolNeighbor n;
|
||||
SolNeighborhood nh(8);
|
||||
moeoFirstImprovingNeighborhoodExplorer<SolNeighbor> explorer(nh, eval);
|
||||
moeoFirstImprovingNeighborhoodExplorer<SolNeighbor> explorer2(nh, eval2);
|
||||
|
||||
//create source and destination population
|
||||
eoPop<Solution> src;
|
||||
eoPop<Solution> dest;
|
||||
|
||||
//create a vector for selection
|
||||
std::vector<unsigned int> v;
|
||||
v.push_back(0);
|
||||
|
||||
//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);
|
||||
|
||||
// aplly a move on th solution
|
||||
n.index(3);
|
||||
eval(s,n);
|
||||
n.move(s);
|
||||
s.objectiveVector(n.fitness());
|
||||
|
||||
//print initial sol
|
||||
std::cout << "solution:" << std::endl;
|
||||
std::cout << s << std::endl;
|
||||
|
||||
//copy the solution in the source population
|
||||
src.push_back(s);
|
||||
|
||||
//test the explorer
|
||||
explorer(src, v, dest);
|
||||
|
||||
assert(dest.size()==8);
|
||||
assert(dest[0].objectiveVector()[0]==6);
|
||||
assert(dest[1].objectiveVector()[0]==6);
|
||||
assert(dest[2].objectiveVector()[0]==6);
|
||||
assert(dest[3].objectiveVector()[0]==8);
|
||||
assert(dest[4].objectiveVector()[0]==6);
|
||||
assert(dest[5].objectiveVector()[0]==6);
|
||||
assert(dest[6].objectiveVector()[0]==6);
|
||||
assert(dest[7].objectiveVector()[0]==6);
|
||||
|
||||
assert(dest[0].objectiveVector()[1]==2);
|
||||
assert(dest[1].objectiveVector()[1]==2);
|
||||
assert(dest[2].objectiveVector()[1]==2);
|
||||
assert(dest[3].objectiveVector()[1]==0);
|
||||
assert(dest[4].objectiveVector()[1]==2);
|
||||
assert(dest[5].objectiveVector()[1]==2);
|
||||
assert(dest[6].objectiveVector()[1]==2);
|
||||
assert(dest[7].objectiveVector()[1]==2);
|
||||
|
||||
std::cout << "destination:" << std::endl;
|
||||
for(unsigned int i=0; i<dest.size(); i++)
|
||||
std::cout << dest[i] << std::endl;
|
||||
|
||||
//test explorer2 (eval function is changed to have solutions dominates other ones
|
||||
explorer2(dest, v, src);
|
||||
|
||||
assert(src.size()==3);
|
||||
|
||||
assert(src[1].objectiveVector()[0]==7);
|
||||
assert(src[2].objectiveVector()[0]==5);
|
||||
|
||||
assert(src[1].objectiveVector()[1]==1);
|
||||
assert(src[2].objectiveVector()[1]==1);
|
||||
|
||||
std::cout << "source: (after an exploration dest -> src)" << std::endl;
|
||||
for(unsigned int i=0; i<src.size(); i++)
|
||||
std::cout << src[i] << std::endl;
|
||||
|
||||
|
||||
std::cout << "[t-moeoFirstImprovingNeighborhoodExplorer] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
136
moeo/test/t-moeoFitDivBoundedArchive.cpp
Normal file
136
moeo/test/t-moeoFitDivBoundedArchive.cpp
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* <t-moeoFitDivBoundedArchive.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-moeoFitDivBoundedArchive.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 << "[moeoFitDivBoundedArchive]\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
|
||||
moeoFitDivBoundedArchive< Solution > arch(indiComparator, comparator, fitness, diversity, 50);
|
||||
moeoFitDivBoundedArchive< 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
81
moeo/test/t-moeoFitnessThenDiversityComparator.cpp
Normal file
81
moeo/test/t-moeoFitnessThenDiversityComparator.cpp
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* <t-moeoFitnessThenDiversityComparator.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-moeoFitnessThenDiversityComparator.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo>
|
||||
#include <moeo>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef MOEO < double, double, double > Solution;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoFitnessThenDiversityComparator]\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
|
||||
moeoFitnessThenDiversityComparator < 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
173
moeo/test/t-moeoHyperVolumeDifferenceMetric.cpp
Normal file
173
moeo/test/t-moeoHyperVolumeDifferenceMetric.cpp
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
/*
|
||||
* <t-moeoHyperVolumeDifferenceMetric.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-moeoHyperVolumeDifferenceMetric.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo>
|
||||
#include <moeo>
|
||||
#include <assert.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 ObjectiveVectorTraits2 : 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 < ObjectiveVectorTraits2 > ObjectiveVector2;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoHyperVolumeDifferenceMetric] => \n";
|
||||
|
||||
// objective vectors
|
||||
std::vector < ObjectiveVector > set1;
|
||||
std::vector < ObjectiveVector > set2;
|
||||
|
||||
//test normalisation
|
||||
set1.resize(3);
|
||||
set2.resize(3);
|
||||
|
||||
//test case
|
||||
set1[0][0] = 5;
|
||||
set1[0][1] = 1;
|
||||
|
||||
set1[1][0] = 2;
|
||||
set1[1][1] = 4;
|
||||
|
||||
set1[2][0] = 1;
|
||||
set1[2][1] = 5;
|
||||
|
||||
set2[0][0] = 4;
|
||||
set2[0][1] = 2;
|
||||
|
||||
set2[1][0] = 3;
|
||||
set2[1][1] = 3;
|
||||
|
||||
set2[2][0] = 1;
|
||||
set2[2][1] = 6;
|
||||
|
||||
moeoHyperVolumeDifferenceMetric < ObjectiveVector> metric(true, 2);
|
||||
|
||||
std::vector < eoRealInterval > bounds;
|
||||
|
||||
metric.setup(set1, set2);
|
||||
bounds = metric.getBounds();
|
||||
|
||||
std::cout << "\t>test normalization =>";
|
||||
assert(bounds[0].minimum()==1.0);
|
||||
assert(bounds[0].maximum()==5.0);
|
||||
assert(bounds[0].range()==4.0);
|
||||
|
||||
assert(bounds[1].minimum()==1.0);
|
||||
assert(bounds[1].maximum()==6.0);
|
||||
assert(bounds[1].range()==5.0);
|
||||
|
||||
std::cout << " OK\n";
|
||||
|
||||
//test calculation of difference hypervolume
|
||||
moeoHyperVolumeDifferenceMetric < ObjectiveVector> metric2(false, 2);
|
||||
std::cout << "\t>test difference without normalization and a coefficient rho=>";
|
||||
double difference=metric2(set1,set2);
|
||||
assert(difference==5.0);
|
||||
std::cout << " OK\n";
|
||||
|
||||
moeoHyperVolumeDifferenceMetric < ObjectiveVector> metric3(true, 1.1);
|
||||
double tolerance = 1e-10;
|
||||
std::cout << "\t>test difference with normalization and coefficient rho=>";
|
||||
difference=metric3(set1,set2);
|
||||
assert( (difference < (0.02 + tolerance)) && (difference > (0.02 - tolerance)));
|
||||
std::cout << " OK\n";
|
||||
|
||||
ObjectiveVector ref_point;
|
||||
ref_point[0]= 10;
|
||||
ref_point[1]= 12;
|
||||
moeoHyperVolumeDifferenceMetric < ObjectiveVector> metric4(false, ref_point);
|
||||
std::cout << "\t>test difference without normalization and a ref_point=>";
|
||||
difference=metric4(set1,set2);
|
||||
assert(difference==5.0);
|
||||
std::cout << " OK\n";
|
||||
|
||||
ref_point[0]= 1.1;
|
||||
ref_point[1]= 1.1;
|
||||
moeoHyperVolumeDifferenceMetric < ObjectiveVector> metric5(true, ref_point);
|
||||
std::cout << "\t>test difference with normalization and a ref_point=>";
|
||||
difference=metric5(set1,set2);
|
||||
assert( (difference < (0.02 + tolerance)) && (difference > (0.02 - tolerance)));
|
||||
std::cout << " OK\n";
|
||||
|
||||
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
344
moeo/test/t-moeoHyperVolumeMetric.cpp
Normal file
344
moeo/test/t-moeoHyperVolumeMetric.cpp
Normal file
|
|
@ -0,0 +1,344 @@
|
|||
/*
|
||||
* <t-moeoHyperVolumeMetric.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-moeoHyperVolumeMetric.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo>
|
||||
#include <moeo>
|
||||
#include <assert.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 ObjectiveVectorTraits2 : 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 < ObjectiveVectorTraits2 > ObjectiveVector2;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoHyperVolumeMetric] => \n";
|
||||
|
||||
// objective vectors
|
||||
std::vector < ObjectiveVector > set1;
|
||||
|
||||
//test normalisation
|
||||
set1.resize(4);
|
||||
|
||||
//test case
|
||||
set1[0][0] = 1;
|
||||
set1[0][1] = 3;
|
||||
|
||||
set1[1][0] = 5;
|
||||
set1[1][1] = 4;
|
||||
|
||||
set1[2][0] = 4;
|
||||
set1[2][1] = 5;
|
||||
|
||||
set1[3][0] = 2;
|
||||
set1[3][1] = 12;
|
||||
|
||||
|
||||
moeoHyperVolumeMetric < ObjectiveVector > metric(true, 1.1);
|
||||
|
||||
std::vector < eoRealInterval > bounds;
|
||||
|
||||
metric.setup(set1);
|
||||
bounds = metric.getBounds();
|
||||
|
||||
std::cout << "\t>test normalization =>";
|
||||
assert(bounds[0].minimum()==1.0);
|
||||
assert(bounds[0].maximum()==5.0);
|
||||
assert(bounds[0].range()==4.0);
|
||||
|
||||
assert(bounds[1].minimum()==3.0);
|
||||
assert(bounds[1].maximum()==12.0);
|
||||
assert(bounds[1].range()==9.0);
|
||||
std::cout << "OK\n";
|
||||
|
||||
set1.resize(0);
|
||||
std::cout << "\t>test bad param in method setup =>";
|
||||
try{
|
||||
metric.setup(set1);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (char const* e){
|
||||
std::cout << "Ok\n";
|
||||
}
|
||||
|
||||
//test method dominates
|
||||
std::vector <double> a;
|
||||
std::vector <double> b;
|
||||
|
||||
a.resize(3);
|
||||
b.resize(3);
|
||||
|
||||
a[0]=10.0;
|
||||
a[1]=10.0;
|
||||
a[2]=2.0;
|
||||
|
||||
b[0]= 3.0;
|
||||
b[1]= 10.0;
|
||||
b[2]= 4.0;
|
||||
|
||||
std::cout << "\t>test method dominates =>";
|
||||
assert(metric.dominates(a, b, 2));
|
||||
assert(!metric.dominates(a, b, 3));
|
||||
std::cout << "Ok\n";
|
||||
|
||||
//test method swap
|
||||
std::vector < std::vector <double> > front;
|
||||
front.resize(5);
|
||||
front[0]=a;
|
||||
front[1]=a;
|
||||
front[2]=a;
|
||||
front[3]=b;
|
||||
front[4]=a;
|
||||
|
||||
std::cout << "\t>test method swap =>";
|
||||
metric.swap(front, 1, 3);
|
||||
assert(front.size()== 5);
|
||||
for(unsigned int i=0; i<5; i++){
|
||||
if(i == 1){
|
||||
assert(front[i][0]==3.0);
|
||||
assert(front[i][1]==10.0);
|
||||
assert(front[i][2]==4.0);
|
||||
}
|
||||
else{
|
||||
assert(front[i][0]==10.0);
|
||||
assert(front[i][1]==10.0);
|
||||
assert(front[i][2]==2.0);
|
||||
}
|
||||
}
|
||||
std::cout << "Ok\n";
|
||||
|
||||
|
||||
//test method filter_nondominated_set
|
||||
std::vector< double > c;
|
||||
std::vector< double > d;
|
||||
std::vector< double > e;
|
||||
|
||||
c.resize(3);
|
||||
d.resize(3);
|
||||
e.resize(3);
|
||||
|
||||
c[0]=11.0;
|
||||
c[1]=9.0;
|
||||
c[2]=5.0;
|
||||
|
||||
d[0]=7.0;
|
||||
d[1]=7.0;
|
||||
d[2]=7.0;
|
||||
|
||||
e[0]=9.0;
|
||||
e[1]=10.5;
|
||||
e[2]=14.0;
|
||||
|
||||
front[0]=a;
|
||||
front[1]=b;
|
||||
front[2]=c;
|
||||
front[3]=d;
|
||||
front[4]=e;
|
||||
|
||||
std::cout << "\t>test method filter_nondominated_set =>";
|
||||
unsigned int res = metric.filter_nondominated_set(front, 5, 2);
|
||||
|
||||
assert(res == 3);
|
||||
|
||||
assert(front[0] == a);
|
||||
assert(front[1]== e);
|
||||
assert(front[2]== c);
|
||||
assert(front[3]== d);
|
||||
assert(front[4]== b);
|
||||
|
||||
std::cout << "Ok\n";
|
||||
|
||||
//test method surface_unchanged_to
|
||||
std::cout << "\t>test method surface_unchanged_set =>";
|
||||
|
||||
front[4]= a;
|
||||
front[0]= c;
|
||||
front[2]= b;
|
||||
|
||||
double min = metric.surface_unchanged_to(front, 4, 2);
|
||||
|
||||
assert(min == 4.0);
|
||||
|
||||
try{
|
||||
metric.surface_unchanged_to(front, 0, 2);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (char const* e){
|
||||
std::cout << "Ok\n";
|
||||
}
|
||||
|
||||
// test method reduce_nondominated_set
|
||||
|
||||
std::cout << "\t>test method reduce_nondominated_set=>";
|
||||
|
||||
res=metric.reduce_nondominated_set(front, 3, 1, 9.5);
|
||||
assert(res==2);
|
||||
|
||||
std::cout << "Ok\n";
|
||||
|
||||
//test method calc_hypervolume
|
||||
std::cout << "\t>test method calc_hypervolume=>";
|
||||
|
||||
a.resize(2);
|
||||
b.resize(2);
|
||||
c.resize(2);
|
||||
front.resize(3);
|
||||
|
||||
a[0]=1;
|
||||
a[1]=3;
|
||||
b[0]=2;
|
||||
b[1]=2;
|
||||
c[0]=3;
|
||||
c[1]=1;
|
||||
|
||||
front[0]=a;
|
||||
front[1]=b;
|
||||
front[2]=c;
|
||||
|
||||
double hyp=metric.calc_hypervolume(front, 3, 2);
|
||||
assert (hyp==6.0);
|
||||
|
||||
a.resize(3);
|
||||
b.resize(3);
|
||||
c.resize(3);
|
||||
|
||||
a[2]=1;
|
||||
b[2]=2;
|
||||
c[2]=3;
|
||||
|
||||
front[0]=c;
|
||||
front[1]=a;
|
||||
front[2]=b;
|
||||
|
||||
hyp=metric.calc_hypervolume(front, 3, 3);
|
||||
assert(hyp==14.0);
|
||||
|
||||
std::cout << "Ok\n";
|
||||
|
||||
//test de l'hyperVolume
|
||||
std::cout << "\t>test operator()=>\n";
|
||||
std::vector <ObjectiveVector2> solution;
|
||||
solution.resize(3);
|
||||
solution[0][0]=3.0;
|
||||
solution[0][1]=1.0;
|
||||
solution[0][2]=3.0;
|
||||
solution[1][0]=2.0;
|
||||
solution[1][1]=2.0;
|
||||
solution[1][2]=2.0;
|
||||
solution[2][0]=1.0;
|
||||
solution[2][1]=3.0;
|
||||
solution[2][2]=1.0;
|
||||
|
||||
ObjectiveVector2 ref_point;
|
||||
ref_point.resize(3);
|
||||
ref_point[0]=4.0;
|
||||
ref_point[1]=4.0;
|
||||
ref_point[2]=4.0;
|
||||
|
||||
std::cout << "\t\t-without normalization and ref_point =>";
|
||||
moeoHyperVolumeMetric < ObjectiveVector2 > metric2(false, ref_point);
|
||||
hyp=metric2(solution);
|
||||
assert(hyp==14.0);
|
||||
std::cout << " Ok\n";
|
||||
|
||||
std::cout << "\t\t-with normalization and ref_point =>";
|
||||
ref_point[0]=1.5;
|
||||
ref_point[1]=1.5;
|
||||
ref_point[2]=1.5;
|
||||
moeoHyperVolumeMetric < ObjectiveVector2 > metric3(true, ref_point);
|
||||
hyp=metric3(solution);
|
||||
assert(hyp==1.75);
|
||||
std::cout << " Ok\n";
|
||||
|
||||
std::cout << "\t\t-without normalization and a coefficent rho =>";
|
||||
hyp=0.0;
|
||||
moeoHyperVolumeMetric < ObjectiveVector2 > metric4(false, 2);
|
||||
hyp=metric4(solution);
|
||||
assert(hyp==100.0);
|
||||
std::cout << " Ok\n";
|
||||
|
||||
std::cout << "\t\t-with normalization and a coefficent rho =>";
|
||||
hyp=0.0;
|
||||
moeoHyperVolumeMetric < ObjectiveVector2 > metric5(true, 1.5);
|
||||
hyp=metric5(solution);
|
||||
assert(hyp==1.75);
|
||||
std::cout << " Ok\n";
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
123
moeo/test/t-moeoIBEA.cpp
Normal file
123
moeo/test/t-moeoIBEA.cpp
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* <t-moeoIBEA.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-moeoIBEA.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo>
|
||||
#include <es/eoRealInitBounded.h>
|
||||
#include <es/eoRealOp.h>
|
||||
#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;
|
||||
|
||||
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];
|
||||
_sol.objectiveVector(objVec);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoIBEA]" << std::endl;
|
||||
|
||||
TestEval eval;
|
||||
eoPopLoopEval <Solution> popEval(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);
|
||||
eoQuadGenOp <Solution> genOp(xover);
|
||||
eoSGATransform < Solution > transform(xover, 0.1, mutation, 0.1);
|
||||
eoGenContinue <Solution > continuator(10);
|
||||
|
||||
// indicator
|
||||
moeoAdditiveEpsilonBinaryMetric < ObjectiveVector > indicator;
|
||||
|
||||
// build IBEA
|
||||
moeoIBEA < Solution > algo(20, eval, xover, 1.0, mutation, 1.0, indicator);
|
||||
moeoIBEA < Solution > algo2(continuator, eval, genOp, indicator);
|
||||
moeoIBEA < Solution > algo3(continuator, popEval, genOp, indicator);
|
||||
moeoIBEA < Solution > algo4(continuator, eval, transform, indicator);
|
||||
moeoIBEA < Solution > algo5(continuator, popEval, transform, indicator);
|
||||
|
||||
// run the algo
|
||||
algo(pop);
|
||||
|
||||
// final pop
|
||||
std::cout << "Final population" << std::endl;
|
||||
std::cout << pop << std::endl;
|
||||
|
||||
std::cout << "[moeoIBEA] OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
158
moeo/test/t-moeoImprOnlyBoundedArchive.cpp
Normal file
158
moeo/test/t-moeoImprOnlyBoundedArchive.cpp
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
* <t-moeoImprOnlyBoundedArchive.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-moeoImprOnlyBoundedArchive.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 << "[moeoImprOnlyBoundedArchive]\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
|
||||
moeoImprOnlyBoundedArchive< Solution > arch(comparator, 50);
|
||||
moeoImprOnlyBoundedArchive< Solution > arch2(2, false);
|
||||
|
||||
//test archive
|
||||
arch(pop);
|
||||
assert(arch.size()==3);
|
||||
assert(arch[0].flag()==0);
|
||||
assert(arch[1].flag()==0);
|
||||
assert(arch[2].flag()==0);
|
||||
|
||||
arch2(pop);
|
||||
assert(arch2.size()==2);
|
||||
assert(arch[0].flag()==0);
|
||||
assert(arch[1].flag()==0);
|
||||
assert(arch[0].objectiveVector()[0]==2);
|
||||
assert(arch[0].objectiveVector()[1]==5);
|
||||
assert(arch[1].objectiveVector()[0]==3);
|
||||
assert(arch[1].objectiveVector()[1]==3);
|
||||
|
||||
obj0[0]=0;
|
||||
obj0[1]=1;
|
||||
pop[0].objectiveVector(obj0);
|
||||
|
||||
arch(pop[0]);
|
||||
assert(arch.size()==1);
|
||||
assert(arch[0].flag()==0);
|
||||
|
||||
pop[0].flag(1);
|
||||
arch(pop[0]);
|
||||
assert(arch.size()==1);
|
||||
assert(arch[0].flag()==1);
|
||||
|
||||
pop[0].flag(0);
|
||||
arch2(pop[0]);
|
||||
assert(arch2.size()==1);
|
||||
assert(arch2[0].flag()==0);
|
||||
|
||||
pop[0].flag(1);
|
||||
arch2(pop[0]);
|
||||
assert(arch2.size()==1);
|
||||
assert(arch2[0].flag()==0);
|
||||
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
82
moeo/test/t-moeoIntVector.cpp
Normal file
82
moeo/test/t-moeoIntVector.cpp
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* <t-moeoIntVector.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-moeoIntVector.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 moeoIntVector < ObjectiveVector > Solution;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
std::cout << "[moeoIntVector]\t=>\t";
|
||||
|
||||
// solutions
|
||||
Solution sol;
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
120
moeo/test/t-moeoMOGA.cpp
Normal file
120
moeo/test/t-moeoMOGA.cpp
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* <t-moeoMOGA.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-moeoMOGA.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo>
|
||||
#include <es/eoRealInitBounded.h>
|
||||
#include <es/eoRealOp.h>
|
||||
#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;
|
||||
|
||||
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];
|
||||
_sol.objectiveVector(objVec);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoMOGA]" << std::endl;
|
||||
|
||||
TestEval eval;
|
||||
eoPopLoopEval <Solution> popEval(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);
|
||||
eoQuadGenOp <Solution> genOp(xover);
|
||||
eoSGATransform < Solution > transform(xover, 0.1, mutation, 0.1);
|
||||
eoGenContinue <Solution > continuator(10);
|
||||
|
||||
// build MOGA
|
||||
moeoMOGA < Solution > algo(20, eval, xover, 1.0, mutation, 1.0);
|
||||
moeoMOGA < Solution > algo2(continuator, eval, genOp);
|
||||
moeoMOGA < Solution > algo3(continuator, popEval, genOp);
|
||||
moeoMOGA < Solution > algo4(continuator, eval, transform);
|
||||
moeoMOGA < Solution > algo5(continuator, popEval, transform);
|
||||
|
||||
// run the algo
|
||||
algo(pop);
|
||||
|
||||
// final pop
|
||||
std::cout << "Final population" << std::endl;
|
||||
std::cout << pop << std::endl;
|
||||
|
||||
std::cout << "[moeoMOGA] OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
113
moeo/test/t-moeoMax3Obj.cpp
Normal file
113
moeo/test/t-moeoMax3Obj.cpp
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* <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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
120
moeo/test/t-moeoNSGA.cpp
Normal file
120
moeo/test/t-moeoNSGA.cpp
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* <t-moeoNSGA.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-moeoNSGA.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo>
|
||||
#include <es/eoRealInitBounded.h>
|
||||
#include <es/eoRealOp.h>
|
||||
#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;
|
||||
|
||||
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];
|
||||
_sol.objectiveVector(objVec);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoNSGA]" << std::endl;
|
||||
|
||||
TestEval eval;
|
||||
eoPopLoopEval <Solution> popEval(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);
|
||||
eoQuadGenOp <Solution> genOp(xover);
|
||||
eoSGATransform < Solution > transform(xover, 0.1, mutation, 0.1);
|
||||
eoGenContinue <Solution > continuator(10);
|
||||
|
||||
// build NSGA
|
||||
moeoNSGA < Solution > algo(20, eval, xover, 1.0, mutation, 1.0);
|
||||
moeoNSGA < Solution > algo2(continuator, eval, genOp);
|
||||
moeoNSGA < Solution > algo3(continuator, popEval, genOp);
|
||||
moeoNSGA < Solution > algo4(continuator, eval, transform);
|
||||
moeoNSGA < Solution > algo5(continuator, popEval, transform);
|
||||
|
||||
// run the algo
|
||||
algo(pop);
|
||||
|
||||
// final pop
|
||||
std::cout << "Final population" << std::endl;
|
||||
std::cout << pop << std::endl;
|
||||
|
||||
std::cout << "[moeoNSGA] OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
120
moeo/test/t-moeoNSGAII.cpp
Normal file
120
moeo/test/t-moeoNSGAII.cpp
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* <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 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] = _sol[0] * _sol[0];
|
||||
_sol.objectiveVector(objVec);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoNSGAII]" << std::endl;
|
||||
|
||||
TestEval eval;
|
||||
eoPopLoopEval <Solution> popEval(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);
|
||||
eoQuadGenOp <Solution> genOp(xover);
|
||||
eoSGATransform < Solution > transform(xover, 0.1, mutation, 0.1);
|
||||
eoGenContinue <Solution > continuator(10);
|
||||
|
||||
// build NSGA-II
|
||||
moeoNSGAII < Solution > algo(20, eval, xover, 1.0, mutation, 1.0);
|
||||
moeoNSGAII < Solution > algo2(continuator, eval, genOp);
|
||||
moeoNSGAII < Solution > algo3(continuator, popEval, genOp);
|
||||
moeoNSGAII < Solution > algo4(continuator, eval, transform);
|
||||
moeoNSGAII < Solution > algo5(continuator, popEval, transform);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
225
moeo/test/t-moeoNearestNeighborDiversityAssignment.cpp
Normal file
225
moeo/test/t-moeoNearestNeighborDiversityAssignment.cpp
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
/*
|
||||
* <t-moeoNearestNeighborDiversityAssignment.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-moeoNearestNeighborDiversityAssignment.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 << "[moeoNearestNeighborDiversityAssignment]\n";
|
||||
|
||||
// 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] = 3;
|
||||
obj6[0] = 4;
|
||||
obj6[1] = 4;
|
||||
|
||||
// population
|
||||
eoPop < Solution > pop;
|
||||
pop.resize(4);
|
||||
pop[0].objectiveVector(obj0); // class 1
|
||||
pop[1].objectiveVector(obj1); // class 1
|
||||
pop[2].objectiveVector(obj2); // class 1
|
||||
pop[3].objectiveVector(obj3); // class 3
|
||||
|
||||
//archive
|
||||
moeoUnboundedArchive < Solution > archive;
|
||||
archive.resize(3);
|
||||
archive[0].objectiveVector(obj4);
|
||||
archive[1].objectiveVector(obj5);
|
||||
archive[2].objectiveVector(obj6);
|
||||
|
||||
//distance
|
||||
moeoEuclideanDistance<Solution> dist;
|
||||
|
||||
// diversity assignment
|
||||
moeoNearestNeighborDiversityAssignment<Solution> diversityAssignment;
|
||||
|
||||
moeoNearestNeighborDiversityAssignment<Solution> diversityAssignment2(archive, 2);
|
||||
|
||||
moeoNearestNeighborDiversityAssignment<Solution> diversityAssignment3(dist);
|
||||
|
||||
moeoNearestNeighborDiversityAssignment<Solution> diversityAssignment4(dist,archive, 2);
|
||||
|
||||
int res=EXIT_SUCCESS;
|
||||
|
||||
for (unsigned int i=0; i<2; i++) {
|
||||
float tmp1=0;
|
||||
float tmp2=0;
|
||||
|
||||
if (i==0) {
|
||||
diversityAssignment(pop);
|
||||
// pop[0]
|
||||
tmp1=pop[0].diversity();
|
||||
tmp2=-1/(2+sqrt(5.0));
|
||||
if (tmp1 != tmp2)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for pop[0])" << std::endl;
|
||||
res=EXIT_FAILURE;
|
||||
}
|
||||
// pop[1]
|
||||
tmp1=pop[1].diversity();
|
||||
tmp2=-1/(2+sqrt(5.0));
|
||||
if (tmp1 != tmp2)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for pop[1])" << std::endl;
|
||||
res=EXIT_FAILURE;
|
||||
}
|
||||
// pop[2]
|
||||
tmp1=pop[2].diversity();
|
||||
tmp2=-1/(2+sqrt(5.0));
|
||||
if (tmp1 != tmp2)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for pop[2])" << std::endl;
|
||||
res=EXIT_FAILURE;
|
||||
}
|
||||
// pop[3]
|
||||
tmp1=pop[3].diversity();
|
||||
tmp2=-1/(2+sqrt(8.0));
|
||||
if (tmp1 != tmp2)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for pop[3]) " << std::endl;
|
||||
res=EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
diversityAssignment4(pop);
|
||||
// pop[0]
|
||||
tmp1=pop[0].diversity();
|
||||
tmp2=-1/(2+sqrt(5.0));
|
||||
if (tmp1 != tmp2)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for pop[0])" << std::endl;
|
||||
res=EXIT_FAILURE;
|
||||
}
|
||||
// pop[1]
|
||||
tmp1=pop[1].diversity();
|
||||
tmp2=-1/(2+sqrt(2.0));
|
||||
if (tmp1 != tmp2)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for pop[1])" << std::endl;
|
||||
res=EXIT_FAILURE;
|
||||
}
|
||||
// pop[2]
|
||||
tmp1=pop[2].diversity();
|
||||
tmp2=-1/(2+sqrt(5.0));
|
||||
if (tmp1 != tmp2)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for pop[2])" << std::endl;
|
||||
res=EXIT_FAILURE;
|
||||
}
|
||||
// pop[3]
|
||||
tmp1=pop[3].diversity();
|
||||
tmp2=-1/(2+sqrt(8.0));
|
||||
if (tmp1 != tmp2)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for pop[3]) " << std::endl;
|
||||
res=EXIT_FAILURE;
|
||||
}
|
||||
// archive[0]
|
||||
tmp1=archive[0].diversity();
|
||||
tmp2=-1/(2+sqrt(8.0));
|
||||
if (tmp1 != tmp2)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity archive[0])" << std::endl;
|
||||
res=EXIT_FAILURE;
|
||||
}
|
||||
// archive[1]
|
||||
tmp1=archive[1].diversity();
|
||||
tmp2=-1/(2+sqrt(2.0));
|
||||
if (tmp1 != tmp2)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for archive[1])" << std::endl;
|
||||
res=EXIT_FAILURE;
|
||||
}
|
||||
// archive[2]
|
||||
tmp1=archive[2].diversity();
|
||||
tmp2=-1/(2+sqrt(2.0));
|
||||
if (tmp1 != tmp2)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for archive[2])" << std::endl;
|
||||
res=EXIT_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return res;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
101
moeo/test/t-moeoNoDesimprovingNeighborhoodExplorer.cpp
Normal file
101
moeo/test/t-moeoNoDesimprovingNeighborhoodExplorer.cpp
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
<t-moeoNoDesimprovingNeighborhoodExplorer.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
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 <explorer/moeoNoDesimprovingNeighborhoodExplorer.h>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moeoNoDesimprovingNeighborhoodExplorer] => START" << std::endl;
|
||||
|
||||
//init all components
|
||||
Solution s;
|
||||
evalSolution eval(8, -1);
|
||||
ObjectiveVector o;
|
||||
SolNeighbor n;
|
||||
SolNeighborhood nh(8);
|
||||
moeoNoDesimprovingNeighborhoodExplorer<SolNeighbor> explorer(nh, eval);
|
||||
|
||||
//create source and destination population
|
||||
eoPop<Solution> src;
|
||||
eoPop<Solution> dest;
|
||||
|
||||
//create a vector for selection
|
||||
std::vector<unsigned int> v;
|
||||
v.push_back(0);
|
||||
|
||||
//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);
|
||||
|
||||
// aplly a move on th solution
|
||||
n.index(3);
|
||||
eval(s,n);
|
||||
n.move(s);
|
||||
s.objectiveVector(n.fitness());
|
||||
|
||||
//print initial sol
|
||||
std::cout << "solution:" << std::endl;
|
||||
std::cout << s << std::endl;
|
||||
|
||||
//copy the solution in the source population
|
||||
src.push_back(s);
|
||||
|
||||
//test explorer, the evaluation function is adapt to test this explorer
|
||||
explorer(src, v, dest);
|
||||
|
||||
//verify destination population
|
||||
assert(dest.size()==1);
|
||||
assert(dest[0].objectiveVector()[0]==10);
|
||||
assert(dest[0].objectiveVector()[1]==0);
|
||||
|
||||
std::cout << "destination:" << std::endl;
|
||||
for(unsigned int i=0; i<dest.size(); i++)
|
||||
std::cout << dest[i] << std::endl;
|
||||
|
||||
std::cout << "[t-moeoNoDesimprovingNeighborhoodExplorer] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
83
moeo/test/t-moeoNumberUnvisitedSelect.cpp
Normal file
83
moeo/test/t-moeoNumberUnvisitedSelect.cpp
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
<t-moeoNumberUnvisitedSelect.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 <selection/moeoNumberUnvisitedSelect.h>
|
||||
#include <moeoTestClass.h>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moeoNumberUnvisitedSelect] => START" << std::endl;
|
||||
|
||||
// objective vectors
|
||||
eoPop < Solution > pop;
|
||||
pop.resize(5);
|
||||
pop[0].flag(1);
|
||||
pop[1].flag(0);
|
||||
pop[2].flag(0);
|
||||
pop[3].flag(1);
|
||||
pop[4].flag(0);
|
||||
|
||||
moeoNumberUnvisitedSelect < Solution > select(2);
|
||||
|
||||
std::vector <unsigned int> res;
|
||||
|
||||
//test general
|
||||
res=select(pop);
|
||||
assert(res.size()==2);
|
||||
assert(res[0]==1 || res[0]==2 || res[0]==4);
|
||||
assert(res[1]==1 || res[1]==2 || res[1]==4);
|
||||
assert(res[0] != res[1]);
|
||||
|
||||
//test au bornes
|
||||
moeoNumberUnvisitedSelect < Solution > select2(6);
|
||||
res.resize(0);
|
||||
res=select2(pop);
|
||||
assert(res.size()==3);
|
||||
assert(res[0]==1 || res[0]==2 || res[0]==4);
|
||||
assert(res[1]==1 || res[1]==2 || res[1]==4);
|
||||
assert(res[2]==1 || res[2]==2 || res[2]==4);
|
||||
assert(res[0] != res[1]);
|
||||
assert(res[0] != res[2]);
|
||||
assert(res[1] != res[2]);
|
||||
|
||||
moeoNumberUnvisitedSelect < Solution > select3(0);
|
||||
res.resize(0);
|
||||
res=select3(pop);
|
||||
assert(res.size()==0);
|
||||
|
||||
|
||||
std::cout << "[t-moeoNumberUnvisitedSelect] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
119
moeo/test/t-moeoPLS1.cpp
Normal file
119
moeo/test/t-moeoPLS1.cpp
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
<t-moeoPLS1.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
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>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moeoPLS1] => 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> test(cont, fullEval, arch, nh, eval);
|
||||
|
||||
//create source population
|
||||
eoPop<Solution> src;
|
||||
|
||||
//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);
|
||||
|
||||
//apply a move on the solution and compute new objective vector
|
||||
n.index(3);
|
||||
eval(s,n);
|
||||
n.move(s);
|
||||
s.objectiveVector(n.fitness());
|
||||
|
||||
//copy the solution in the source population
|
||||
src.push_back(s);
|
||||
|
||||
//test PLS1
|
||||
test(src);
|
||||
|
||||
//verify all objective vector was found.
|
||||
assert(arch.size()==9);
|
||||
assert(arch[0].objectiveVector()[0]==7);
|
||||
assert(arch[1].objectiveVector()[0]==6);
|
||||
assert(arch[2].objectiveVector()[0]==8);
|
||||
assert(arch[3].objectiveVector()[0]==5);
|
||||
assert(arch[4].objectiveVector()[0]==4);
|
||||
assert(arch[5].objectiveVector()[0]==3);
|
||||
assert(arch[6].objectiveVector()[0]==2);
|
||||
assert(arch[7].objectiveVector()[0]==1);
|
||||
assert(arch[8].objectiveVector()[0]==0);
|
||||
|
||||
assert(arch[0].objectiveVector()[1]==1);
|
||||
assert(arch[1].objectiveVector()[1]==2);
|
||||
assert(arch[2].objectiveVector()[1]==0);
|
||||
assert(arch[3].objectiveVector()[1]==3);
|
||||
assert(arch[4].objectiveVector()[1]==4);
|
||||
assert(arch[5].objectiveVector()[1]==5);
|
||||
assert(arch[6].objectiveVector()[1]==6);
|
||||
assert(arch[7].objectiveVector()[1]==7);
|
||||
assert(arch[8].objectiveVector()[1]==8);
|
||||
|
||||
//Print
|
||||
std::cout << "source:" << std::endl;
|
||||
std::cout << src << std::endl;
|
||||
|
||||
std::cout << "archive:" << std::endl;
|
||||
for(unsigned int i=0; i<arch.size(); i++)
|
||||
std::cout << arch[i] << std::endl;
|
||||
|
||||
std::cout << "[t-moeoPLS1] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
120
moeo/test/t-moeoPLS2.cpp
Normal file
120
moeo/test/t-moeoPLS2.cpp
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
<t-moeoPLS2.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
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/moeoPLS2.h>
|
||||
#include <eoTimeContinue.h>
|
||||
#include <archive/moeoUnboundedArchive.h>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moeoPLS2] => 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);
|
||||
moeoPLS2<SolNeighbor> test(cont, fullEval, arch, nh, eval);
|
||||
|
||||
//create source population
|
||||
eoPop<Solution> src;
|
||||
|
||||
//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);
|
||||
|
||||
//apply a move on the solution and compute new objective vector
|
||||
n.index(3);
|
||||
eval(s,n);
|
||||
n.move(s);
|
||||
s.objectiveVector(n.fitness());
|
||||
|
||||
//copy the solution in the source population
|
||||
src.push_back(s);
|
||||
|
||||
//test PLS2
|
||||
test(src);
|
||||
|
||||
//verify all objective vector was found.
|
||||
assert(arch.size()==9);
|
||||
assert(arch[0].objectiveVector()[0]==7);
|
||||
assert(arch[1].objectiveVector()[0]==6);
|
||||
assert(arch[2].objectiveVector()[0]==8);
|
||||
assert(arch[3].objectiveVector()[0]==5);
|
||||
assert(arch[4].objectiveVector()[0]==4);
|
||||
assert(arch[5].objectiveVector()[0]==3);
|
||||
assert(arch[6].objectiveVector()[0]==2);
|
||||
assert(arch[7].objectiveVector()[0]==1);
|
||||
assert(arch[8].objectiveVector()[0]==0);
|
||||
|
||||
assert(arch[0].objectiveVector()[1]==1);
|
||||
assert(arch[1].objectiveVector()[1]==2);
|
||||
assert(arch[2].objectiveVector()[1]==0);
|
||||
assert(arch[3].objectiveVector()[1]==3);
|
||||
assert(arch[4].objectiveVector()[1]==4);
|
||||
assert(arch[5].objectiveVector()[1]==5);
|
||||
assert(arch[6].objectiveVector()[1]==6);
|
||||
assert(arch[7].objectiveVector()[1]==7);
|
||||
assert(arch[8].objectiveVector()[1]==8);
|
||||
|
||||
//Print
|
||||
std::cout << "source:" << std::endl;
|
||||
std::cout << src << std::endl;
|
||||
|
||||
std::cout << "archive:" << std::endl;
|
||||
for(unsigned int i=0; i<arch.size(); i++)
|
||||
std::cout << arch[i] << std::endl;
|
||||
|
||||
|
||||
std::cout << "[t-moeoPLS2] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
95
moeo/test/t-moeoParetoObjectiveVectorComparator.cpp
Normal file
95
moeo/test/t-moeoParetoObjectiveVectorComparator.cpp
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* <t-moeoParetoObjectiveVectorComparator.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-moeoParetoObjectiveVectorComparator.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 << "[moeoParetoObjectiveVectorComparator]\t=>\t";
|
||||
|
||||
// objective vectors
|
||||
ObjectiveVector obj1;
|
||||
obj1[0] = 2;
|
||||
obj1[1] = 5;
|
||||
ObjectiveVector obj2;
|
||||
obj2[0] = 3;
|
||||
obj2[1] = 5;
|
||||
|
||||
// comparator
|
||||
moeoParetoObjectiveVectorComparator< ObjectiveVector > comparator;
|
||||
|
||||
|
||||
// obj1 dominated by obj2?
|
||||
if (comparator(obj1, obj2))
|
||||
{
|
||||
std::cout << "ERROR (obj1 must be better)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
186
moeo/test/t-moeoQuadTreeArchive.cpp
Normal file
186
moeo/test/t-moeoQuadTreeArchive.cpp
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
* <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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
332
moeo/test/t-moeoQuadTreeIndex.cpp
Executable file
332
moeo/test/t-moeoQuadTreeIndex.cpp
Executable file
|
|
@ -0,0 +1,332 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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;
|
||||
}
|
||||
|
||||
180
moeo/test/t-moeoQuickUnboundedArchiveIndex.cpp
Executable file
180
moeo/test/t-moeoQuickUnboundedArchiveIndex.cpp
Executable file
|
|
@ -0,0 +1,180 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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;
|
||||
}
|
||||
|
||||
81
moeo/test/t-moeoRealVector.cpp
Normal file
81
moeo/test/t-moeoRealVector.cpp
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* <t-moeoRealVector.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-moeoRealVector.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 moeoRealVector < ObjectiveVector, double, double > Solution;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
std::cout << "[moeoRealVector]\t=>\t";
|
||||
|
||||
// solutions
|
||||
Solution sol1, sol2;
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
124
moeo/test/t-moeoSEEA.cpp
Normal file
124
moeo/test/t-moeoSEEA.cpp
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* <t-moeoSEEA.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moeoSEEA.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo>
|
||||
#include <es/eoRealInitBounded.h>
|
||||
#include <es/eoRealOp.h>
|
||||
#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;
|
||||
|
||||
class Solution : public moeoRealVector < ObjectiveVector, double, double >
|
||||
{
|
||||
public:
|
||||
Solution() : moeoRealVector < ObjectiveVector, double, double > (2) {}
|
||||
};
|
||||
|
||||
class TestEval : public moeoEvalFunc < Solution >
|
||||
{
|
||||
public:
|
||||
void operator () (Solution & _sol)
|
||||
{
|
||||
ObjectiveVector objVec;
|
||||
objVec[0] = _sol[0];
|
||||
objVec[1] = _sol[1];
|
||||
_sol.objectiveVector(objVec);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoSEEA]" << std::endl;
|
||||
|
||||
TestEval eval;
|
||||
eoQuadCloneOp < Solution > xover;
|
||||
eoUniformMutation < Solution > mutation(0.05);
|
||||
|
||||
eoRealVectorBounds bounds(2, 1.0, 2.0);
|
||||
eoRealInitBounded < Solution > init(bounds);
|
||||
eoPop < Solution > pop(20, init);
|
||||
eoQuadGenOp <Solution> genOp(xover);
|
||||
eoSGATransform < Solution > transform(xover, 0.1, mutation, 0.1);
|
||||
eoGenContinue <Solution > continuator(20);
|
||||
moeoUnboundedArchive < Solution > archive;
|
||||
|
||||
eoPopLoopEval <Solution> loopEval(eval);
|
||||
eoPopEvalFunc <Solution>& popEval(loopEval);
|
||||
|
||||
// build SEEA
|
||||
moeoSEEA < Solution > algo1(20, eval, xover, 1.0, mutation, 1.0, archive);
|
||||
moeoSEEA < Solution > algo2(continuator, eval, genOp, archive);
|
||||
moeoSEEA < Solution > algo3(continuator, popEval, genOp, archive);
|
||||
moeoSEEA < Solution > algo4(continuator, eval, transform, archive);
|
||||
moeoSEEA < Solution > algo5(continuator, popEval, transform, archive);
|
||||
|
||||
// run the algo
|
||||
algo5(pop);
|
||||
|
||||
// final archive
|
||||
std::cout << "Final archive" << std::endl;
|
||||
std::cout << archive << std::endl;
|
||||
|
||||
std::cout << "[moeoSEEA] OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
128
moeo/test/t-moeoSPEA2.cpp
Normal file
128
moeo/test/t-moeoSPEA2.cpp
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* <t-moeoSPEA2.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-moeoSPEA2.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo>
|
||||
#include <es/eoRealInitBounded.h>
|
||||
#include <es/eoRealOp.h>
|
||||
#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;
|
||||
|
||||
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];
|
||||
_sol.objectiveVector(objVec);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoSPEA2]" << 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);
|
||||
eoQuadGenOp <Solution> genOp(xover);
|
||||
eoSGATransform < Solution > transform(xover, 0.1, mutation, 0.1);
|
||||
eoGenContinue <Solution > continuator(10);
|
||||
moeoSPEA2Archive < Solution > archive(3);
|
||||
|
||||
eoPopLoopEval <Solution> loopEval(eval);
|
||||
eoPopEvalFunc <Solution>& popEval(loopEval);
|
||||
|
||||
// build NSGA-II
|
||||
moeoSPEA2 < Solution > algo(20, eval, xover, 1.0, mutation, 1.0,archive);
|
||||
moeoSPEA2 < Solution > algo2(continuator, eval, xover, 1.0, mutation, 1.0,archive);
|
||||
moeoSPEA2 < Solution > algo3(continuator, popEval, xover, 1.0, mutation, 1.0,archive);
|
||||
moeoSPEA2 < Solution > algo4(continuator, eval, genOp, archive);
|
||||
moeoSPEA2 < Solution > algo5(continuator, popEval, genOp, archive);
|
||||
moeoSPEA2 < Solution > algo6(continuator, eval, transform, archive);
|
||||
moeoSPEA2 < Solution > algo7(continuator, popEval, transform, archive);
|
||||
|
||||
|
||||
// run the algo
|
||||
algo7(pop);
|
||||
|
||||
// final pop
|
||||
std::cout << "Final population" << std::endl;
|
||||
std::cout << pop << std::endl;
|
||||
|
||||
std::cout << "[moeoSPEA2] OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
252
moeo/test/t-moeoSPEA2Archive.cpp
Normal file
252
moeo/test/t-moeoSPEA2Archive.cpp
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
/*
|
||||
* <t-moeoSPEA2Archive.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-moeoSPEA2Archive.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 << "[moeoSPEA2Archive] => ";
|
||||
|
||||
float tmp1=0;
|
||||
float tmp2=0;
|
||||
|
||||
// objective vectors
|
||||
ObjectiveVector obj0, obj1, obj2, obj3;
|
||||
obj0[0] = 2;
|
||||
obj0[1] = 1;
|
||||
obj1[0] = 1;
|
||||
obj1[1] = 2;
|
||||
obj2[0] = 0;
|
||||
obj2[1] = 4;
|
||||
obj3[0] = 5;
|
||||
obj3[1] = 0;
|
||||
|
||||
// population
|
||||
eoPop < Solution > pop;
|
||||
pop.resize(4);
|
||||
pop[0].objectiveVector(obj0);
|
||||
pop[1].objectiveVector(obj1);
|
||||
pop[2].objectiveVector(obj2);
|
||||
pop[3].objectiveVector(obj3);
|
||||
|
||||
//distance
|
||||
moeoEuclideanDistance<Solution> dist;
|
||||
|
||||
//objective vector comparator
|
||||
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
|
||||
|
||||
//comparator
|
||||
moeoFitnessThenDiversityComparator < Solution > indiComparator;
|
||||
|
||||
//archive
|
||||
moeoSPEA2Archive<Solution> archive(dist,3);
|
||||
|
||||
moeoSPEA2Archive<Solution> archive2;
|
||||
|
||||
moeoSPEA2Archive<Solution> archive3(indiComparator,1);
|
||||
|
||||
moeoSPEA2Archive<Solution> archive4(paretoComparator);
|
||||
|
||||
moeoSPEA2Archive<Solution> archive5(indiComparator, dist, paretoComparator, 3);
|
||||
|
||||
// diversity assignment
|
||||
moeoNearestNeighborDiversityAssignment<Solution> diversityassignement(dist,archive, 2);
|
||||
diversityassignement(pop);
|
||||
|
||||
// fitness assignment
|
||||
moeoDominanceCountRankingFitnessAssignment <Solution> fitnessassignement(archive,false);
|
||||
fitnessassignement(pop);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//first test archive: the archive is empty -> the best element of the pop must be copy in the archive.
|
||||
|
||||
|
||||
archive(pop);
|
||||
|
||||
//archive[0]
|
||||
tmp1=archive[0].diversity();
|
||||
tmp2=-1/(2+sqrt(20.0));
|
||||
if ( (tmp1 != tmp2) || (archive[0].fitness() != 0.0) )
|
||||
{
|
||||
std::cout << "ERROR (Test 1: bad result for archive[0])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
//archive[1]
|
||||
tmp1=archive[1].diversity();
|
||||
tmp2=-1/(2+sqrt(13.0));
|
||||
if ( (tmp1 != tmp2) || (archive[1].fitness() != 0.0) )
|
||||
{
|
||||
std::cout << "ERROR (Test 1: bad result for archive[1])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
//archive[2]
|
||||
tmp1=archive[2].diversity();
|
||||
tmp2=-1/(2+sqrt(10.0));
|
||||
if ( (tmp1 != tmp2) || (archive[2].fitness() != 0.0) )
|
||||
{
|
||||
std::cout << "ERROR (Test 1: bad result for archive[2])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
obj0[0] = 3;
|
||||
obj0[1] = 1;
|
||||
obj1[0] = 2;
|
||||
obj1[1] = 2;
|
||||
obj3[0] = 1;
|
||||
obj3[1] = 3;
|
||||
pop[0].objectiveVector(obj0);
|
||||
pop[1].objectiveVector(obj1);
|
||||
pop[3].objectiveVector(obj3);
|
||||
|
||||
diversityassignement(pop);
|
||||
fitnessassignement(pop);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//second test archive : (there are more elements with fitness=0 than the size of the archive)
|
||||
//depends of the good result of the first test
|
||||
archive(pop);
|
||||
//archive[0]
|
||||
tmp1=archive[0].diversity();
|
||||
tmp2=-1/3.0;
|
||||
if ( (tmp1 != tmp2) || (archive[0].fitness() != 0.0) )
|
||||
{
|
||||
std::cout << "ERROR (Test 2: bad result for archive[0])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
//archive[1]
|
||||
tmp1=archive[1].diversity();
|
||||
tmp2=-1/(2+sqrt(2.0));
|
||||
if ( (tmp1 != tmp2) || (archive[1].fitness() != 0.0) )
|
||||
{
|
||||
std::cout << "ERROR (Test 2: bad result for archive[1])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
//archive[2]
|
||||
tmp1=archive[2].diversity();
|
||||
tmp2=-1/(2+sqrt(10.0));
|
||||
if ( (tmp1 != tmp2) || (archive[2].fitness() != 0.0) )
|
||||
{
|
||||
std::cout << "ERROR (Test 2: bad result for archive[2])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
obj0[0] = 5;
|
||||
obj0[1] = 5;
|
||||
obj1[0] = 4;
|
||||
obj1[1] = 4;
|
||||
obj2[0] = 4;
|
||||
obj2[1] = 5;
|
||||
obj3[0] = 4;
|
||||
obj3[1] = 0;
|
||||
|
||||
pop[0].objectiveVector(obj0);
|
||||
pop[1].objectiveVector(obj1);
|
||||
pop[2].objectiveVector(obj2);
|
||||
pop[3].objectiveVector(obj3);
|
||||
|
||||
diversityassignement(pop);
|
||||
fitnessassignement(pop);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//third test archive : a pop element with fitness=0 replace a worst archive element
|
||||
//depends of the good result of the two first tests
|
||||
|
||||
archive(pop);
|
||||
|
||||
//archive[0]
|
||||
tmp1=archive[0].diversity();
|
||||
tmp2=-1/(2+sqrt(16.0));
|
||||
if ( (tmp1 != tmp2) || (archive[0].fitness() != 0.0) )
|
||||
{
|
||||
std::cout << "ERROR (Test 3: bad result for archive[0])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
//archive[1]
|
||||
tmp1=archive[1].diversity();
|
||||
tmp2=-1/(2+sqrt(10.0));
|
||||
if ( (tmp1 != tmp2) || (archive[1].fitness() != -0.0) )
|
||||
{
|
||||
std::cout << "ERROR (Test 3: bad result for archive[1])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
//archive[2]
|
||||
tmp1=archive[2].diversity();
|
||||
tmp2=-1/(2+sqrt(5.0));
|
||||
if ( (tmp1 != tmp2) || (archive[2].fitness() != 0.0) )
|
||||
{
|
||||
std::cout << "ERROR (Test 3: bad result for archive[2])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
archive(pop[0]);
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
126
moeo/test/t-moeoSharingDiversityAssignment.cpp
Normal file
126
moeo/test/t-moeoSharingDiversityAssignment.cpp
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* <t-moeoSharingDiversityAssignment.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-moeoSharingDiversityAssignment.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 << "[moeoSharingDiversityAssignment]\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);
|
||||
|
||||
// fitness & diversity assignment
|
||||
moeoDummyFitnessAssignment< Solution > fitnessAssignment;
|
||||
fitnessAssignment(pop);
|
||||
moeoSharingDiversityAssignment< Solution > diversityAssignment;
|
||||
diversityAssignment(pop);
|
||||
|
||||
// pop[0]
|
||||
if (pop[0].diversity() != 1.0)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for pop[0])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[1]
|
||||
if (pop[1].diversity() != 0.0)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for pop[1])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[2]
|
||||
if (pop[2].diversity() != 0.0)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for pop[2])" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// pop[3]
|
||||
if (pop[3].diversity() != 1.0)
|
||||
{
|
||||
std::cout << "ERROR (bad diversity for pop[3]) " << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
109
moeo/test/t-moeoSimpleSubNeighborhoodExplorer.cpp
Normal file
109
moeo/test/t-moeoSimpleSubNeighborhoodExplorer.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
<t-moeoSimpleSubNeighborhoodExplorer.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
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 <explorer/moeoSimpleSubNeighborhoodExplorer.h>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moeoSimpleSubNeighborhoodExplorer] => START" << std::endl;
|
||||
|
||||
//init all components
|
||||
Solution s;
|
||||
evalSolution eval(8);
|
||||
ObjectiveVector o;
|
||||
SolNeighbor n;
|
||||
SolNeighborhood nh(8);
|
||||
moeoSimpleSubNeighborhoodExplorer<SolNeighbor> explorer(nh, 4, eval);
|
||||
|
||||
//create source and destination population
|
||||
eoPop<Solution> src;
|
||||
eoPop<Solution> dest;
|
||||
|
||||
//create a vector for selection
|
||||
std::vector<unsigned int> v;
|
||||
v.push_back(0);
|
||||
|
||||
//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);
|
||||
|
||||
// aplly a move on th solution
|
||||
n.index(3);
|
||||
eval(s,n);
|
||||
n.move(s);
|
||||
s.objectiveVector(n.fitness());
|
||||
|
||||
//print initial sol
|
||||
std::cout << "solution:" << std::endl;
|
||||
std::cout << s << std::endl;
|
||||
|
||||
//copy the solution in the source population
|
||||
src.push_back(s);
|
||||
|
||||
//test the explorer (only 4 neighbors are visited)
|
||||
explorer(src, v, dest);
|
||||
|
||||
//verify the destination population
|
||||
assert(dest.size()==4);
|
||||
|
||||
assert(dest[0].objectiveVector()[0]==6);
|
||||
assert(dest[1].objectiveVector()[0]==6);
|
||||
assert(dest[2].objectiveVector()[0]==6);
|
||||
assert(dest[3].objectiveVector()[0]==8);
|
||||
|
||||
assert(dest[0].objectiveVector()[1]==2);
|
||||
assert(dest[1].objectiveVector()[1]==2);
|
||||
assert(dest[2].objectiveVector()[1]==2);
|
||||
assert(dest[3].objectiveVector()[1]==0);
|
||||
|
||||
std::cout << "destination:" << std::endl;
|
||||
for(unsigned int i=0; i<dest.size(); i++)
|
||||
std::cout << dest[i] << std::endl;
|
||||
|
||||
std::cout << "[t-moeoSimpleSubNeighborhoodExplorer] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
132
moeo/test/t-moeoStrictObjectiveVectorComparator.cpp
Normal file
132
moeo/test/t-moeoStrictObjectiveVectorComparator.cpp
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* <t-moeoStrictObjectiveVectorComparator.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moeoStrictObjectiveVectorComparator.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 > Solution;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoStrictObjectiveVectorComparator]\t=>\t";
|
||||
|
||||
// objective vectors
|
||||
ObjectiveVector obj1;
|
||||
obj1[0] = 2.0;
|
||||
obj1[1] = 5.0;
|
||||
ObjectiveVector obj2;
|
||||
obj2[0] = 3.0;
|
||||
obj2[1] = 5.0;
|
||||
ObjectiveVector obj3;
|
||||
obj3[0] = 3.0;
|
||||
obj3[1] = 7.0;
|
||||
|
||||
// comparator
|
||||
moeoStrictObjectiveVectorComparator< ObjectiveVector > comparator;
|
||||
|
||||
// obj1 dominated by obj2? NO
|
||||
if (comparator(obj1, obj2))
|
||||
{
|
||||
std::cout << "ERROR (obj1 dominated by obj2)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj2 dominated by obj1? NO
|
||||
if (comparator(obj2, obj1))
|
||||
{
|
||||
std::cout << "ERROR (obj2 dominated by obj1)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj1 dominated by obj3? NO
|
||||
if (comparator(obj1, obj3))
|
||||
{
|
||||
std::cout << "ERROR (obj1 dominated by obj3)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj3 dominated by obj1? YES
|
||||
if (! comparator(obj3, obj1))
|
||||
{
|
||||
std::cout << "ERROR (obj3 not dominated by obj1)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj2 dominated by obj3? NO
|
||||
if (comparator(obj2, obj3))
|
||||
{
|
||||
std::cout << "ERROR (obj2 dominated by obj3)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj3 dominated by obj2? NO
|
||||
if (comparator(obj3, obj2))
|
||||
{
|
||||
std::cout << "ERROR (obj3 dominated by obj2)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
148
moeo/test/t-moeoUnboundedArchive.cpp
Normal file
148
moeo/test/t-moeoUnboundedArchive.cpp
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* <t-moeoUnboundedArchive.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-moeoUnboundedArchive.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 << "[moeoUnboundedArchive]\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);
|
||||
|
||||
// archive
|
||||
moeoUnboundedArchive< Solution > arch;
|
||||
arch(pop);
|
||||
|
||||
// size
|
||||
if (arch.size() != 3)
|
||||
{
|
||||
std::cout << "ERROR (too much solutions)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// obj0 must be in
|
||||
if (! arch.contains(obj0))
|
||||
{
|
||||
std::cout << "ERROR (obj0 not in)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// obj1 must be in
|
||||
if (! arch.contains(obj1))
|
||||
{
|
||||
std::cout << "ERROR (obj1 not in)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// obj2 must be in
|
||||
if (! arch.contains(obj2))
|
||||
{
|
||||
std::cout << "ERROR (obj2 not in)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// obj3 must be out
|
||||
if (arch.contains(obj3))
|
||||
{
|
||||
std::cout << "ERROR (obj3 in)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// obj4 must be out
|
||||
if (arch.contains(obj4))
|
||||
{
|
||||
std::cout << "ERROR (obj4 in)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// obj5 must be in
|
||||
if (! arch.contains(obj5))
|
||||
{
|
||||
std::cout << "ERROR (obj5 not in)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
244
moeo/test/t-moeoVecVsVecAdditiveEpsilonBinaryMetric.cpp
Normal file
244
moeo/test/t-moeoVecVsVecAdditiveEpsilonBinaryMetric.cpp
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
/*
|
||||
* <t-moeoVecVsVecAdditiveEpsilonBinaryMetric.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-moeoVecVsVecAdditiveEpsilonBinaryMetric.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo>
|
||||
#include <moeo>
|
||||
#include <assert.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 ObjectiveVectorTraits2 : public moeoObjectiveVectorTraits
|
||||
{
|
||||
public:
|
||||
static bool minimizing (int i)
|
||||
{
|
||||
if (i==0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
static bool maximizing (int i)
|
||||
{
|
||||
if (i==0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
|
||||
}
|
||||
static unsigned int nObjectives ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
typedef moeoRealObjectiveVector < ObjectiveVectorTraits2 > ObjectiveVector2;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoVecVsVecAdditiveEpsilonBinaryMetric] => \n";
|
||||
|
||||
double eps;
|
||||
|
||||
// objective vectors
|
||||
std::vector < ObjectiveVector > set1;
|
||||
std::vector < ObjectiveVector > set2;
|
||||
|
||||
//test 1: set2 dominates set1
|
||||
set1.resize(4);
|
||||
set2.resize(4);
|
||||
|
||||
set1[0][0] = 6;
|
||||
set1[0][1] = 3;
|
||||
|
||||
set1[1][0] = 5;
|
||||
set1[1][1] = 4;
|
||||
|
||||
set1[2][0] = 4;
|
||||
set1[2][1] = 5;
|
||||
|
||||
set1[3][0] = 2;
|
||||
set1[3][1] = 7;
|
||||
|
||||
set2[0][0] = 1;
|
||||
set2[0][1] = 5;
|
||||
|
||||
set2[1][0] = 2;
|
||||
set2[1][1] = 3;
|
||||
|
||||
set2[2][0] = 3;
|
||||
set2[2][1] = 2;
|
||||
|
||||
set2[3][0] = 4;
|
||||
set2[3][1] = 1;
|
||||
|
||||
moeoVecVsVecAdditiveEpsilonBinaryMetric < ObjectiveVector > metric(false);
|
||||
|
||||
eps = metric(set1, set2);
|
||||
assert(eps == 2.0);
|
||||
std::cout << "\t>test1 => OK\n";
|
||||
//end test1
|
||||
|
||||
//test2: set1 dominates set2
|
||||
set2.resize(3);
|
||||
|
||||
set1[0][0] = 0;
|
||||
set1[0][1] = 6;
|
||||
|
||||
set1[1][0] = 1;
|
||||
set1[1][1] = 3;
|
||||
|
||||
set1[2][0] = 3;
|
||||
set1[2][1] = 1;
|
||||
|
||||
set1[3][0] = 6;
|
||||
set1[3][1] = 0;
|
||||
|
||||
set2[0][0] = 1;
|
||||
set2[0][1] = 5;
|
||||
|
||||
set2[1][0] = 3;
|
||||
set2[1][1] = 3;
|
||||
|
||||
set2[2][0] = 5;
|
||||
set2[2][1] = 2;
|
||||
|
||||
eps = metric(set1, set2);
|
||||
assert(eps == 0.0);
|
||||
std::cout << "\t>test2 => OK\n";
|
||||
//end test2
|
||||
|
||||
set2.resize(4);
|
||||
//test3: no dominance
|
||||
set1[0][0] = 7;
|
||||
set1[0][1] = 1;
|
||||
|
||||
set1[1][0] = 6;
|
||||
set1[1][1] = 4;
|
||||
|
||||
set1[2][0] = 3;
|
||||
set1[2][1] = 4;
|
||||
|
||||
set1[3][0] = 2;
|
||||
set1[3][1] = 7;
|
||||
|
||||
set2[0][0] = 8;
|
||||
set2[0][1] = 2;
|
||||
|
||||
set2[1][0] = 5;
|
||||
set2[1][1] = 3;
|
||||
|
||||
set2[2][0] = 4;
|
||||
set2[2][1] = 5;
|
||||
|
||||
set2[3][0] = 1;
|
||||
set2[3][1] = 6;
|
||||
|
||||
eps = metric(set1, set2);
|
||||
assert(eps == 1.0);
|
||||
std::cout << "\t>test3 => OK\n";
|
||||
//end test3
|
||||
|
||||
//test bounds
|
||||
std::vector < eoRealInterval > bounds;
|
||||
|
||||
moeoVecVsVecAdditiveEpsilonBinaryMetric < ObjectiveVector > metric2;
|
||||
metric2.setup(set1, set2);
|
||||
bounds = metric2.getBounds();
|
||||
|
||||
assert(bounds[0].minimum()==1.0);
|
||||
assert(bounds[0].maximum()==8.0);
|
||||
assert(bounds[0].range()==7.0);
|
||||
|
||||
assert(bounds[1].minimum()==1.0);
|
||||
assert(bounds[1].maximum()==7.0);
|
||||
assert(bounds[1].range()==6.0);
|
||||
std::cout << "\t>test normalization => OK\n";
|
||||
//end test bounds
|
||||
|
||||
std::vector < ObjectiveVector2 > set3;
|
||||
std::vector < ObjectiveVector2 > set4;
|
||||
moeoVecVsVecAdditiveEpsilonBinaryMetric < ObjectiveVector2 > metric3(false);
|
||||
|
||||
//test 1: set2 dominates set1
|
||||
set3.resize(2);
|
||||
set4.resize(2);
|
||||
|
||||
set3[0][0] = 6;
|
||||
set3[0][1] = 3;
|
||||
|
||||
set3[1][0] = 5;
|
||||
set3[1][1] = 4;
|
||||
|
||||
set4[0][0] = 1;
|
||||
set4[0][1] = 5;
|
||||
|
||||
set4[1][0] = 2;
|
||||
set4[1][1] = 3;
|
||||
|
||||
std::cout << "\t>test with maximization =>";
|
||||
eps = metric3(set3, set4);
|
||||
assert(eps==4.0);
|
||||
std::cout << "OK\n";
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
286
moeo/test/t-moeoVecVsVecMultiplicativeEpsilonBinaryMetric.cpp
Normal file
286
moeo/test/t-moeoVecVsVecMultiplicativeEpsilonBinaryMetric.cpp
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
/*
|
||||
* <t-moeoVecVsVecMultiplicativeEpsilonBinaryMetric.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-moeoVecVsVecMultiplicativeEpsilonBinaryMetric.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo>
|
||||
#include <moeo>
|
||||
#include <assert.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 ObjectiveVectorTraits2 : public moeoObjectiveVectorTraits
|
||||
{
|
||||
public:
|
||||
static bool minimizing (int i)
|
||||
{
|
||||
if (i==0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
static bool maximizing (int i)
|
||||
{
|
||||
if (i==0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
|
||||
}
|
||||
static unsigned int nObjectives ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
typedef moeoRealObjectiveVector < ObjectiveVectorTraits2 > ObjectiveVector2;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoVecVsVecMultiplicativeEpsilonBinaryMetric] => \n";
|
||||
|
||||
double eps;
|
||||
|
||||
// objective vectors
|
||||
std::vector < ObjectiveVector > set1;
|
||||
std::vector < ObjectiveVector > set2;
|
||||
std::vector < ObjectiveVector > set3;
|
||||
std::vector < ObjectiveVector > set4;
|
||||
|
||||
set1.resize(5);
|
||||
set2.resize(4);
|
||||
set3.resize(5);
|
||||
set4.resize(3);
|
||||
|
||||
set1[0][0] = 4;
|
||||
set1[0][1] = 7;
|
||||
|
||||
set1[1][0] = 5;
|
||||
set1[1][1] = 6;
|
||||
|
||||
set1[2][0] = 7;
|
||||
set1[2][1] = 5;
|
||||
|
||||
set1[3][0] = 8;
|
||||
set1[3][1] = 4;
|
||||
|
||||
set1[4][0] = 9;
|
||||
set1[4][1] = 2;
|
||||
|
||||
set2[0][0] = 4;
|
||||
set2[0][1] = 7;
|
||||
|
||||
set2[1][0] = 5;
|
||||
set2[1][1] = 6;
|
||||
|
||||
set2[2][0] = 7;
|
||||
set2[2][1] = 5;
|
||||
|
||||
set2[3][0] = 8;
|
||||
set2[3][1] = 4;
|
||||
|
||||
set3[0][0] = 10;
|
||||
set3[0][1] = 4;
|
||||
|
||||
set3[1][0] = 9;
|
||||
set3[1][1] = 5;
|
||||
|
||||
set3[2][0] = 8;
|
||||
set3[2][1] = 6;
|
||||
|
||||
set3[3][0] = 7;
|
||||
set3[3][1] = 7;
|
||||
|
||||
set3[4][0] = 6;
|
||||
set3[4][1] = 8;
|
||||
|
||||
set4[0][0] = 3;
|
||||
set4[0][1] = 1;
|
||||
|
||||
set4[1][0] = 2;
|
||||
set4[1][1] = 2;
|
||||
|
||||
set4[2][0] = 1;
|
||||
set4[2][1] = 3;
|
||||
|
||||
|
||||
|
||||
moeoVecVsVecMultiplicativeEpsilonBinaryMetric < ObjectiveVector > metric;
|
||||
|
||||
std::cout << "\t>Ieps(set1, set2) => ";
|
||||
eps = metric(set1, set2);
|
||||
assert(eps == 1.0);
|
||||
std::cout << "OK\n";
|
||||
|
||||
std::cout << "\t>Ieps(set2, set1) => ";
|
||||
eps = metric(set2, set1);
|
||||
assert(eps == 2.0);
|
||||
std::cout << "OK\n";
|
||||
|
||||
std::cout << "\t>Ieps(set1, set3) => ";
|
||||
eps = metric(set1, set3);
|
||||
assert(eps == 0.9);
|
||||
std::cout << "OK\n";
|
||||
|
||||
std::cout << "\t>Ieps(set3, set1) => ";
|
||||
eps = metric(set3, set1);
|
||||
assert(eps == 2.0);
|
||||
std::cout << "OK\n";
|
||||
|
||||
std::cout << "\t>Ieps(set1, set4) => ";
|
||||
eps = metric(set1, set4);
|
||||
assert(eps == 4.0);
|
||||
std::cout << "OK\n";
|
||||
|
||||
std::cout << "\t>Ieps(set4, set1) => ";
|
||||
eps = metric(set4, set1);
|
||||
assert(eps == 0.5);
|
||||
std::cout << "OK\n";
|
||||
|
||||
std::cout << "\t>Ieps(set2, set3) => ";
|
||||
eps = metric(set2, set3);
|
||||
assert(eps == 1.0);
|
||||
std::cout << "OK\n";
|
||||
|
||||
std::cout << "\t>Ieps(set3, set2) => ";
|
||||
eps = metric(set3, set2);
|
||||
assert(eps == 1.5);
|
||||
std::cout << "OK\n";
|
||||
|
||||
std::cout << "\t>Ieps(set2, set4) => ";
|
||||
eps = metric(set2, set4);
|
||||
assert(eps == 4.0);
|
||||
std::cout << "OK\n";
|
||||
|
||||
std::cout << "\t>Ieps(set4, set2) => ";
|
||||
eps = metric(set4, set2);
|
||||
assert(eps == 3.0/7.0);
|
||||
std::cout << "OK\n";
|
||||
|
||||
std::cout << "\t>Ieps(set3, set4) => ";
|
||||
eps = metric(set3, set4);
|
||||
assert(eps == 6.0);
|
||||
std::cout << "OK\n";
|
||||
|
||||
std::cout << "\t>Ieps(set4, set3) => ";
|
||||
eps = metric(set4, set3);
|
||||
assert(eps == 1.0/3.0);
|
||||
std::cout << "OK\n";
|
||||
|
||||
set1[0][0] = 0;
|
||||
set3[0][1] = -1;
|
||||
|
||||
std::cout << "\tError test: elements with a differents sign => ";
|
||||
try{
|
||||
eps = metric(set4, set3);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (char const* e){
|
||||
std::cout << "OK\n";
|
||||
}
|
||||
|
||||
std::cout << "\tError test: an element = 0 => ";
|
||||
try{
|
||||
eps = metric(set1, set2);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (char const* e){
|
||||
std::cout << "Ok\n";
|
||||
}
|
||||
|
||||
//test with maximization
|
||||
moeoVecVsVecMultiplicativeEpsilonBinaryMetric < ObjectiveVector2 > metric2;
|
||||
|
||||
std::vector < ObjectiveVector2 > set5;
|
||||
std::vector < ObjectiveVector2 > set6;
|
||||
|
||||
|
||||
set5.resize(3);
|
||||
set6.resize(4);
|
||||
|
||||
set5[0][0] = 1;
|
||||
set5[0][1] = 3;
|
||||
|
||||
set5[1][0] = 2;
|
||||
set5[1][1] = 2;
|
||||
|
||||
set5[2][0] = 3;
|
||||
set5[2][1] = 1;
|
||||
|
||||
set6[0][0] = 5;
|
||||
set6[0][1] = 2;
|
||||
|
||||
set6[1][0] = 4;
|
||||
set6[1][1] = 3;
|
||||
|
||||
set6[2][0] = 3;
|
||||
set6[2][1] = 4;
|
||||
|
||||
set6[3][0] = 2;
|
||||
set6[3][1] = 5;
|
||||
|
||||
std::cout << "\t1 Maximazing objectif test => ";
|
||||
eps = metric2(set5, set6);
|
||||
assert(eps == 5.0/3.0);
|
||||
std::cout << "Ok\n";
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
135
moeo/test/t-moeoWeakObjectiveVectorComparator.cpp
Normal file
135
moeo/test/t-moeoWeakObjectiveVectorComparator.cpp
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* <t-moeoWeakObjectiveVectorComparator.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moeoWeakObjectiveVectorComparator.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 > Solution;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "[moeoWeakObjectiveVectorComparator]\t=>\t";
|
||||
|
||||
// objective vectors
|
||||
ObjectiveVector obj1;
|
||||
obj1[0] = 2.0;
|
||||
obj1[1] = 5.0;
|
||||
ObjectiveVector obj2;
|
||||
obj2[0] = 2.0;
|
||||
obj2[1] = 5.0;
|
||||
ObjectiveVector obj3;
|
||||
obj3[0] = 3.0;
|
||||
obj3[1] = 5.0;
|
||||
ObjectiveVector obj4;
|
||||
obj4[0] = 3.0;
|
||||
obj4[1] = 6.0;
|
||||
|
||||
// comparator
|
||||
moeoWeakObjectiveVectorComparator< ObjectiveVector > comparator;
|
||||
|
||||
// obj1 dominated by obj2? YES
|
||||
if (! comparator(obj1, obj2))
|
||||
{
|
||||
std::cout << "ERROR (obj1 not dominated by obj2)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj2 dominated by obj1? YES
|
||||
if (! comparator(obj2, obj1))
|
||||
{
|
||||
std::cout << "ERROR (obj2 not dominated by obj1)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj1 dominated by obj3? NO
|
||||
if (comparator(obj1, obj3))
|
||||
{
|
||||
std::cout << "ERROR (obj1 dominated by obj3)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj3 dominated by obj1? YES
|
||||
if (! comparator(obj3, obj1))
|
||||
{
|
||||
std::cout << "ERROR (obj3 not dominated by obj1)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj3 dominated by obj4? NO
|
||||
if (comparator(obj3, obj4))
|
||||
{
|
||||
std::cout << "ERROR (obj3 dominated by obj4)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// obj4 dominated by obj3? YES
|
||||
if (! comparator(obj4, obj3))
|
||||
{
|
||||
std::cout << "ERROR (obj4 not dominated by obj3)" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Loading…
Add table
Add a link
Reference in a new issue