git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1400 331e1502-861f-0410-8da2-ba01fb791d7f

This commit is contained in:
jhumeau 2009-02-05 13:08:33 +00:00
commit 5ba0f15724
10 changed files with 391 additions and 8 deletions

View file

@ -0,0 +1,55 @@
###############################################################################
##
## CMakeLists file for ParadisEO-MOEO/test
##
###############################################################################
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${PARADISEO_MO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${PARADISEO_MOEO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${SOURCES_DIR})
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries
######################################################################################
LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib ${PARADISEO_MOEO_BIN_DIR}/lib)
######################################################################################
######################################################################################
### 3) Define your targets and link the librairies
######################################################################################
SET (TEST_LIST
t-moeoUnifiedDominanceBasedLS
)
FOREACH (test ${TEST_LIST})
SET ("T_${test}_SOURCES" "${test}.cpp")
ENDFOREACH (test)
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} eoutils eo moeo)
ENDFOREACH (test)
######################################################################################

View file

@ -0,0 +1,71 @@
#include <eo>
#include <moeo>
#include <moeoPopNeighborhoodExplorer.h>
#include <moeoPopLS.h>
#include <moeoUnifiedDominanceBasedLS.h>
#include <moMove.h>
class ObjectiveVectorTraits : public moeoObjectiveVectorTraits
{
public:
static bool minimizing (int i)
{
return true;
}
static bool maximizing (int i)
{
return false;
}
static unsigned int nObjectives ()
{
return 2;
}
};
typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector;
class Solution : public moeoRealVector < ObjectiveVector, double, double >
{
public:
Solution() : moeoRealVector < ObjectiveVector, double, double > (1) {}
};
class dummyMove : public moMove < Solution >
{
public :
void operator () (Solution & _solution){}
} ;
int main()
{
// 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;
// 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
eoTimeContinue < Solution > continuator(5);
moeoUnifiedDominanceBasedLS < dummyMove > algo(continuator);
algo(pop);
std::cout << "OK c'est bon" << std::endl;
return EXIT_SUCCESS;
}