modif cmake configuration
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1277 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
1432128e88
commit
350bdfc7de
1261 changed files with 144616 additions and 0 deletions
101
branches/cmakemodif/paradiseo-moeo/test/CMakeLists.txt
Normal file
101
branches/cmakemodif/paradiseo-moeo/test/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
###############################################################################
|
||||
##
|
||||
## CMakeLists file for ParadisEO-MOEO/test
|
||||
##
|
||||
###############################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${ParadisEO-MOEO_SOURCE_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${ParadisEO-MOEO_BINARY_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your targets and link the librairies
|
||||
######################################################################################
|
||||
|
||||
SET (TEST_LIST
|
||||
t-moeo
|
||||
t-moeoBitVector
|
||||
t-moeoRealVector
|
||||
t-moeoUnboundedArchive
|
||||
t-moeoParetoObjectiveVectorComparator
|
||||
t-moeoStrictObjectiveVectorComparator
|
||||
t-moeoWeakObjectiveVectorComparator
|
||||
t-moeoEpsilonObjectiveVectorComparator
|
||||
t-moeoAggregativeComparator
|
||||
t-moeoDiversityThenFitnessComparator
|
||||
t-moeoFitnessThenDiversityComparator
|
||||
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-moeoBoundedArchive
|
||||
)
|
||||
|
||||
FOREACH (test ${TEST_LIST})
|
||||
SET ("T_${test}_SOURCES" "${test}.cpp")
|
||||
ENDFOREACH (test)
|
||||
|
||||
|
||||
|
||||
IF(ENABLE_MINIMAL_CMAKE_TESTING)
|
||||
SET (MIN_TEST_LIST t-moeoEasyEA)
|
||||
FOREACH (mintest ${MIN_TEST_LIST})
|
||||
SET ("T_${mintest}_SOURCES" "${mintest}.cpp")
|
||||
ADD_EXECUTABLE(${mintest} ${T_${mintest}_SOURCES})
|
||||
ADD_TEST(${mintest} ${mintest})
|
||||
TARGET_LINK_LIBRARIES(${mintest} moeo ga es eoutils eo)
|
||||
ENDFOREACH (mintest)
|
||||
|
||||
ELSEIF(ENABLE_CMAKE_TESTING)
|
||||
|
||||
FOREACH (test ${TEST_LIST})
|
||||
ADD_EXECUTABLE(${test} ${T_${test}_SOURCES})
|
||||
ADD_TEST(${test} ${test})
|
||||
ENDFOREACH (test)
|
||||
|
||||
# Link the librairies
|
||||
FOREACH (test ${TEST_LIST})
|
||||
TARGET_LINK_LIBRARIES(${test} moeo ga es eoutils eo)
|
||||
ENDFOREACH (test)
|
||||
|
||||
ENDIF(ENABLE_MINIMAL_CMAKE_TESTING)
|
||||
|
||||
######################################################################################
|
||||
|
||||
81
branches/cmakemodif/paradiseo-moeo/test/t-moeo.cpp
Normal file
81
branches/cmakemodif/paradiseo-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;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
81
branches/cmakemodif/paradiseo-moeo/test/t-moeoBitVector.cpp
Normal file
81
branches/cmakemodif/paradiseo-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
branches/cmakemodif/paradiseo-moeo/test/t-moeoBoundedArchive.cpp
Normal file
136
branches/cmakemodif/paradiseo-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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
* <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>
|
||||
#include <limits>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
const double infinity = std::numeric_limits< double >::infinity();
|
||||
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 (int k=0; k<pop.size();k++)
|
||||
std::cout << "pop " << k << " : " << pop[k].fitness() << "\n";
|
||||
for (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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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
branches/cmakemodif/paradiseo-moeo/test/t-moeoEasyEA.cpp
Normal file
128
branches/cmakemodif/paradiseo-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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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
branches/cmakemodif/paradiseo-moeo/test/t-moeoIBEA.cpp
Normal file
123
branches/cmakemodif/paradiseo-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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
82
branches/cmakemodif/paradiseo-moeo/test/t-moeoIntVector.cpp
Normal file
82
branches/cmakemodif/paradiseo-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;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
113
branches/cmakemodif/paradiseo-moeo/test/t-moeoMax3Obj.cpp
Normal file
113
branches/cmakemodif/paradiseo-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
branches/cmakemodif/paradiseo-moeo/test/t-moeoNSGA.cpp
Normal file
120
branches/cmakemodif/paradiseo-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
branches/cmakemodif/paradiseo-moeo/test/t-moeoNSGAII.cpp
Normal file
120
branches/cmakemodif/paradiseo-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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
81
branches/cmakemodif/paradiseo-moeo/test/t-moeoRealVector.cpp
Normal file
81
branches/cmakemodif/paradiseo-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
branches/cmakemodif/paradiseo-moeo/test/t-moeoSEEA.cpp
Normal file
124
branches/cmakemodif/paradiseo-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
branches/cmakemodif/paradiseo-moeo/test/t-moeoSPEA2.cpp
Normal file
128
branches/cmakemodif/paradiseo-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
branches/cmakemodif/paradiseo-moeo/test/t-moeoSPEA2Archive.cpp
Normal file
252
branches/cmakemodif/paradiseo-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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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 << "[moeoArchive]\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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -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