peo : tutorials modified
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@980 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
96e4fb74e8
commit
d96a303853
7 changed files with 8 additions and 131 deletions
|
|
@ -61,19 +61,13 @@ structure:
|
||||||
|
|
|
|
||||||
+-- examples TSP
|
+-- examples TSP
|
||||||
|
|
|
|
||||||
+-- Introduction Technical introduction
|
|
||||||
|
|
|
||||||
+-- Lesson1 Parallel evaluation for EA and PSO
|
+-- Lesson1 Parallel evaluation for EA and PSO
|
||||||
|
|
|
|
||||||
+-- Lesson2 Parallel transformation (crossover + mutation) for EA
|
+-- Lesson2 Parallel transformation (crossover + mutation) for EA
|
||||||
|
|
|
|
||||||
+-- Lesson3 Insular model for PSO and EA
|
+-- Lesson3 Insular model for PSO and EA
|
||||||
|
|
|
|
||||||
+-- Lesson4 PSO and EA completely parallel
|
+-- Lesson4 Hybridization
|
||||||
|
|
|
||||||
+-- Lesson5 Hybridization
|
|
||||||
|
|
|
||||||
+-- Lesson6 Multi-start : several local searches
|
|
||||||
|
|
||||||
===================================================================
|
===================================================================
|
||||||
NOTES
|
NOTES
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,6 @@ SET(FLOWSHOP_BIN_DIR "${MOEO_BIN_DIR}/tutorial/examples/flowshop" CACHE PATH "Fl
|
||||||
### 2) Where must cmake go now ?
|
### 2) Where must cmake go now ?
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
SUBDIRS(examples Lesson1 Lesson2 Lesson3 Lesson4 Lesson5)
|
SUBDIRS(examples Lesson1 Lesson2 Lesson3 Lesson4)
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ SET_TARGET_PROPERTIES(ea PROPERTIES VERSION "${LESSON1_VERSION}")
|
||||||
### 5) Link the librairies
|
### 5) Link the librairies
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(pso ${XML2_LIBS} peo rmc_mpi eo eoutils)
|
TARGET_LINK_LIBRARIES(pso ${XML2_LIBS} peo rmc_mpi eo eoutils peo)
|
||||||
TARGET_LINK_LIBRARIES(ea ${XML2_LIBS} peo rmc_mpi eo eoutils)
|
TARGET_LINK_LIBRARIES(ea ${XML2_LIBS} peo rmc_mpi eo eoutils peo)
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,6 @@ SET_TARGET_PROPERTIES(ea PROPERTIES VERSION "${LESSON2_VERSION}")
|
||||||
### 5) Link the librairies
|
### 5) Link the librairies
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(ea ${XML2_LIBS} peo rmc_mpi eo eoutils)
|
TARGET_LINK_LIBRARIES(ea ${XML2_LIBS} peo rmc_mpi eo eoutils peo)
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,8 @@ SET_TARGET_PROPERTIES(ea PROPERTIES VERSION "${LESSON3_VERSION}")
|
||||||
### 5) Link the librairies
|
### 5) Link the librairies
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(pso ${XML2_LIBS} peo rmc_mpi eo eoutils)
|
TARGET_LINK_LIBRARIES(pso ${XML2_LIBS} peo rmc_mpi eo eoutils peo)
|
||||||
TARGET_LINK_LIBRARIES(ea ${XML2_LIBS} peo rmc_mpi eo eoutils)
|
TARGET_LINK_LIBRARIES(ea ${XML2_LIBS} peo rmc_mpi eo eoutils peo)
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,6 @@ ENDIF(WIN32 AND NOT CYGWIN)
|
||||||
### 3) Define your target(s): just an executable here
|
### 3) Define your target(s): just an executable here
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
ADD_EXECUTABLE(lsea mainLSEA.cpp)
|
|
||||||
ADD_DEPENDENCIES(lsea tsp peo rmc_mpi)
|
|
||||||
ADD_EXECUTABLE(eals mainEALS.cpp)
|
ADD_EXECUTABLE(eals mainEALS.cpp)
|
||||||
ADD_DEPENDENCIES(eals tsp peo rmc_mpi)
|
ADD_DEPENDENCIES(eals tsp peo rmc_mpi)
|
||||||
|
|
||||||
|
|
@ -67,7 +65,6 @@ ADD_DEPENDENCIES(eals tsp peo rmc_mpi)
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
SET(LESSON4_VERSION ${GLOBAL_VERSION})
|
SET(LESSON4_VERSION ${GLOBAL_VERSION})
|
||||||
SET_TARGET_PROPERTIES(lsea PROPERTIES VERSION "${LESSON4_VERSION}")
|
|
||||||
SET_TARGET_PROPERTIES(eals PROPERTIES VERSION "${LESSON4_VERSION}")
|
SET_TARGET_PROPERTIES(eals PROPERTIES VERSION "${LESSON4_VERSION}")
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
@ -77,7 +74,6 @@ SET_TARGET_PROPERTIES(eals PROPERTIES VERSION "${LESSON4_VERSION}")
|
||||||
### 5) Link the librairies
|
### 5) Link the librairies
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(lsea ${XML2_LIBS} tsp peo rmc_mpi eo eoutils)
|
TARGET_LINK_LIBRARIES(eals ${XML2_LIBS} tsp peo rmc_mpi eo eoutils peo)
|
||||||
TARGET_LINK_LIBRARIES(eals ${XML2_LIBS} tsp peo rmc_mpi eo eoutils)
|
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
|
||||||
|
|
@ -1,113 +0,0 @@
|
||||||
/* <main.cpp>
|
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
|
||||||
* (C) OPAC Team, INRIA, 2007
|
|
||||||
*
|
|
||||||
* Clive Canape
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "param.h"
|
|
||||||
#include "route_init.h"
|
|
||||||
#include "route_eval.h"
|
|
||||||
#include "order_xover.h"
|
|
||||||
#include "edge_xover.h"
|
|
||||||
#include "partial_mapped_xover.h"
|
|
||||||
#include "city_swap.h"
|
|
||||||
#include "part_route_eval.h"
|
|
||||||
#include "merge_route_eval.h"
|
|
||||||
#include "two_opt_init.h"
|
|
||||||
#include "two_opt_next.h"
|
|
||||||
#include "two_opt_incr_eval.h"
|
|
||||||
|
|
||||||
#include <peo>
|
|
||||||
|
|
||||||
#define POP_SIZE 10
|
|
||||||
#define NUM_GEN 200
|
|
||||||
#define CROSS_RATE 1.0
|
|
||||||
#define MUT_RATE 0.1
|
|
||||||
|
|
||||||
|
|
||||||
int main (int __argc, char * * __argv)
|
|
||||||
{
|
|
||||||
|
|
||||||
peo :: init (__argc, __argv);
|
|
||||||
loadParameters (__argc, __argv);
|
|
||||||
RouteInit route_init;
|
|
||||||
RouteEval full_eval;
|
|
||||||
OrderXover order_cross;
|
|
||||||
PartialMappedXover pm_cross;
|
|
||||||
EdgeXover edge_cross;
|
|
||||||
CitySwap city_swap_mut;
|
|
||||||
|
|
||||||
// Local search
|
|
||||||
TwoOptInit pmx_two_opt_init;
|
|
||||||
TwoOptNext pmx_two_opt_next;
|
|
||||||
TwoOptIncrEval pmx_two_opt_incr_eval;
|
|
||||||
moBestImprSelect <TwoOpt> pmx_two_opt_move_select;
|
|
||||||
moHC <TwoOpt> hc (pmx_two_opt_init, pmx_two_opt_next, pmx_two_opt_incr_eval, pmx_two_opt_move_select, full_eval);
|
|
||||||
eoPop <Route> pop (POP_SIZE, route_init);
|
|
||||||
peoMultiStart <Route> initParallelHC (hc);
|
|
||||||
peoWrapper parallelHC (initParallelHC, pop);
|
|
||||||
initParallelHC.setOwner(parallelHC);
|
|
||||||
peo :: run( );
|
|
||||||
peo :: finalize( );
|
|
||||||
|
|
||||||
if (getNodeRank()==1)
|
|
||||||
{
|
|
||||||
std :: cout << "\nResult before the EA\n";
|
|
||||||
pop.sort();
|
|
||||||
for (unsigned i=0;i<pop.size();i++)
|
|
||||||
std::cout<<"\n"<<pop[i].fitness();
|
|
||||||
std :: cout << "\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// EA
|
|
||||||
peo :: init (__argc, __argv);
|
|
||||||
eoGenContinue <Route> cont (NUM_GEN);
|
|
||||||
eoCheckPoint <Route> checkpoint (cont);
|
|
||||||
eoEvalFuncCounter< Route > eval(full_eval);
|
|
||||||
eoStochTournamentSelect <Route> select_one;
|
|
||||||
eoSelectNumber <Route> select (select_one, POP_SIZE);
|
|
||||||
eoSGATransform <Route> transform (order_cross, CROSS_RATE, city_swap_mut, MUT_RATE);
|
|
||||||
eoEPReplacement <Route> replace (2);
|
|
||||||
eoEasyEA< Route > eaAlg( checkpoint, eval, select, transform, replace );
|
|
||||||
peoWrapper parallelEA( eaAlg, pop);
|
|
||||||
peo :: run ();
|
|
||||||
peo :: finalize ();
|
|
||||||
|
|
||||||
if (getNodeRank()==1)
|
|
||||||
{
|
|
||||||
std :: cout << "\nResult after the EA\n";
|
|
||||||
pop.sort();
|
|
||||||
for (unsigned i=0;i<pop.size();i++)
|
|
||||||
std::cout<<"\n"<<pop[i].fitness();
|
|
||||||
std :: cout << "\n\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue