From 1100fbdb90b458e7efe71c0a02ecd10c5f09c49a Mon Sep 17 00:00:00 2001 From: canape Date: Mon, 12 Nov 2007 08:48:41 +0000 Subject: [PATCH] New lesson git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@782 331e1502-861f-0410-8da2-ba01fb791d7f --- .../tutorial/examples/CMakeLists.txt | 11 + .../tutorial/examples/tsp/CMakeLists.txt | 110 ++++++++ .../examples/tsp/benchs/eil101.opt.tour | 108 ++++++++ .../tutorial/examples/tsp/benchs/eil101.tsp | 108 ++++++++ .../examples/tsp/benchs/eil101.tsp.hc | 102 ++++++++ .../tutorial/examples/tsp/city_swap.cpp | 49 ++++ .../tutorial/examples/tsp/city_swap.h | 54 ++++ .../tutorial/examples/tsp/data.cpp | 126 +++++++++ .../tutorial/examples/tsp/data.h | 46 ++++ .../tutorial/examples/tsp/display.cpp | 145 +++++++++++ .../tutorial/examples/tsp/display.h | 44 ++++ .../examples/tsp/display_best_route.cpp | 50 ++++ .../examples/tsp/display_best_route.h | 60 +++++ .../tutorial/examples/tsp/edge_xover.cpp | 146 +++++++++++ .../tutorial/examples/tsp/edge_xover.h | 71 ++++++ .../examples/tsp/merge_route_eval.cpp | 45 ++++ .../tutorial/examples/tsp/merge_route_eval.h | 52 ++++ .../paradiseo-peo/tutorial/examples/tsp/mix.h | 52 ++++ .../tutorial/examples/tsp/node.cpp | 105 ++++++++ .../tutorial/examples/tsp/node.h | 54 ++++ .../tutorial/examples/tsp/opt_route.cpp | 135 ++++++++++ .../tutorial/examples/tsp/opt_route.h | 51 ++++ .../tutorial/examples/tsp/order_xover.cpp | 92 +++++++ .../tutorial/examples/tsp/order_xover.h | 56 ++++ .../tsp/paradiseo-peo-lsn-shared.doxyfile | 240 ++++++++++++++++++ .../tutorial/examples/tsp/param.cpp | 51 ++++ .../tutorial/examples/tsp/param.h | 42 +++ .../tutorial/examples/tsp/part_route_eval.cpp | 58 +++++ .../tutorial/examples/tsp/part_route_eval.h | 61 +++++ .../examples/tsp/partial_mapped_xover.cpp | 89 +++++++ .../examples/tsp/partial_mapped_xover.h | 56 ++++ .../tutorial/examples/tsp/route.cpp | 49 ++++ .../tutorial/examples/tsp/route.h | 48 ++++ .../tutorial/examples/tsp/route_eval.cpp | 41 +++ .../tutorial/examples/tsp/route_eval.h | 51 ++++ .../tutorial/examples/tsp/route_init.cpp | 51 ++++ .../tutorial/examples/tsp/route_init.h | 51 ++++ .../tutorial/examples/tsp/two_opt.cpp | 48 ++++ .../tutorial/examples/tsp/two_opt.h | 53 ++++ .../examples/tsp/two_opt_incr_eval.cpp | 52 ++++ .../tutorial/examples/tsp/two_opt_incr_eval.h | 51 ++++ .../tutorial/examples/tsp/two_opt_init.cpp | 42 +++ .../tutorial/examples/tsp/two_opt_init.h | 52 ++++ .../tutorial/examples/tsp/two_opt_next.cpp | 55 ++++ .../tutorial/examples/tsp/two_opt_next.h | 52 ++++ .../tutorial/examples/tsp/two_opt_rand.cpp | 49 ++++ .../tutorial/examples/tsp/two_opt_rand.h | 52 ++++ 47 files changed, 3266 insertions(+) create mode 100644 trunk/paradiseo-peo/tutorial/examples/CMakeLists.txt create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/CMakeLists.txt create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.opt.tour create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.tsp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.tsp.hc create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/city_swap.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/city_swap.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/data.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/data.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/display.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/display.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/display_best_route.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/display_best_route.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/edge_xover.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/edge_xover.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/merge_route_eval.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/merge_route_eval.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/mix.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/node.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/node.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/opt_route.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/opt_route.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/order_xover.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/order_xover.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/paradiseo-peo-lsn-shared.doxyfile create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/param.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/param.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/part_route_eval.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/part_route_eval.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/partial_mapped_xover.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/partial_mapped_xover.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/route.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/route.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/route_eval.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/route_eval.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/route_init.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/route_init.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/two_opt.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/two_opt.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_incr_eval.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_incr_eval.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_init.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_init.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_next.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_next.h create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_rand.cpp create mode 100644 trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_rand.h diff --git a/trunk/paradiseo-peo/tutorial/examples/CMakeLists.txt b/trunk/paradiseo-peo/tutorial/examples/CMakeLists.txt new file mode 100644 index 000000000..7d024ee3a --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/CMakeLists.txt @@ -0,0 +1,11 @@ + + +###################################################################################### +### 1) Where must cmake go now ? +###################################################################################### + +SUBDIRS(tsp) + +###################################################################################### + + diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/CMakeLists.txt b/trunk/paradiseo-peo/tutorial/examples/tsp/CMakeLists.txt new file mode 100644 index 000000000..b22a7fe63 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/CMakeLists.txt @@ -0,0 +1,110 @@ + +###################################################################################### +### 0) Copy the "benchs" directory in the build directory to easily run the lessons +###################################################################################### + +ADD_CUSTOM_TARGET(install DEPENDS ${ParadisEO-PEO_SOURCE_DIR}/tutorial/examples/tsp/benchs) +ADD_CUSTOM_COMMAND( + TARGET install + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_directory + ${ParadisEO-PEO_SOURCE_DIR}/tutorial/examples/tsp/benchs + ${ParadisEO-PEO_BINARY_DIR}/tutorial/examples/tsp/benchs) + +###################################################################################### + + +###################################################################################### +### 1) Include the sources +###################################################################################### + +INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src) +INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src) +INCLUDE_DIRECTORIES(${ParadisEO-PEO_SOURCE_DIR}/src) + +###################################################################################### + + +###################################################################################### +### 2) Define your target(s): just the tsp lib here +###################################################################################### + +SET(TSP_LIB_OUTPUT_PATH ${TSP_BINARY_DIR}/lib) +SET(LIBRARY_OUTPUT_PATH ${TSP_LIB_OUTPUT_PATH}) + +SET (TSP_SOURCES data.h + data.cpp + opt_route.h + opt_route.cpp + param.h + param.cpp + node.h + node.cpp + route.h + route.cpp + route_init.h + route_init.cpp + route_eval.h + route_eval.cpp + two_opt.h + two_opt.cpp + two_opt_init.h + two_opt_init.cpp + two_opt_incr_eval.h + two_opt_incr_eval.cpp + two_opt_next.h + two_opt_next.cpp + order_xover.h + order_xover.cpp + partial_mapped_xover.h + partial_mapped_xover.cpp + edge_xover.h + edge_xover.cpp + city_swap.h + city_swap.cpp + part_route_eval.h + part_route_eval.cpp + merge_route_eval.h + merge_route_eval.cpp) + +ADD_LIBRARY(tsp STATIC ${TSP_SOURCES}) +###################################################################################### + + +###################################################################################### +### 3) Optionnal: define your lib's version +###################################################################################### + +SET(TSP_VERSION ${GLOBAL_VERSION}) +SET_TARGET_PROPERTIES(tsp PROPERTIES VERSION "${TSP_VERSION}") +###################################################################################### + + +###################################################################################### +### 4) Windows advanced config - especially for Microsoft Visual Studio 8 +###################################################################################### + + IF(CMAKE_CXX_COMPILER MATCHES cl) + IF(NOT WITH_SHARED_LIBS) + IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005") + SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy") + SET(CMAKE_CXX_FLAGS_DEBUG "/MTd /Z7 /Od") + SET(CMAKE_CXX_FLAGS_RELEASE "/MT /O2") + SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O2") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MTd /Z7 /Od") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") + + ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005") + ENDIF(NOT WITH_SHARED_LIBS) + ENDIF(CMAKE_CXX_COMPILER MATCHES cl) +###################################################################################### + + +###################################################################################### +### 5) Where must cmake go now ? +###################################################################################### + +# nothing to be compiled in the subdirs + +###################################################################################### diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.opt.tour b/trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.opt.tour new file mode 100644 index 000000000..1d3fece5a --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.opt.tour @@ -0,0 +1,108 @@ +NAME : eil101.opt.tour +COMMENT : Optimum tour for eil101.tsp (Length 629) +TYPE : TOUR +DIMENSION : 101 +TOUR_SECTION +1 +69 +27 +101 +53 +28 +26 +12 +80 +68 +29 +24 +54 +55 +25 +4 +39 +67 +23 +56 +75 +41 +22 +74 +72 +73 +21 +40 +58 +13 +94 +95 +97 +87 +2 +57 +15 +43 +42 +14 +44 +38 +86 +16 +61 +85 +91 +100 +98 +37 +92 +59 +93 +99 +96 +6 +89 +52 +18 +83 +60 +5 +84 +17 +45 +8 +46 +47 +36 +49 +64 +63 +90 +32 +10 +62 +11 +19 +48 +82 +7 +88 +31 +70 +30 +20 +66 +71 +65 +35 +34 +78 +81 +9 +51 +33 +79 +3 +77 +76 +50 +-1 +EOF diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.tsp b/trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.tsp new file mode 100644 index 000000000..9672f849e --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.tsp @@ -0,0 +1,108 @@ +NAME : eil101 +COMMENT : 101-city problem (Christofides/Eilon) +TYPE : TSP +DIMENSION : 101 +EDGE_WEIGHT_TYPE : EUC_2D +NODE_COORD_SECTION +1 41 49 +2 35 17 +3 55 45 +4 55 20 +5 15 30 +6 25 30 +7 20 50 +8 10 43 +9 55 60 +10 30 60 +11 20 65 +12 50 35 +13 30 25 +14 15 10 +15 30 5 +16 10 20 +17 5 30 +18 20 40 +19 15 60 +20 45 65 +21 45 20 +22 45 10 +23 55 5 +24 65 35 +25 65 20 +26 45 30 +27 35 40 +28 41 37 +29 64 42 +30 40 60 +31 31 52 +32 35 69 +33 53 52 +34 65 55 +35 63 65 +36 2 60 +37 20 20 +38 5 5 +39 60 12 +40 40 25 +41 42 7 +42 24 12 +43 23 3 +44 11 14 +45 6 38 +46 2 48 +47 8 56 +48 13 52 +49 6 68 +50 47 47 +51 49 58 +52 27 43 +53 37 31 +54 57 29 +55 63 23 +56 53 12 +57 32 12 +58 36 26 +59 21 24 +60 17 34 +61 12 24 +62 24 58 +63 27 69 +64 15 77 +65 62 77 +66 49 73 +67 67 5 +68 56 39 +69 37 47 +70 37 56 +71 57 68 +72 47 16 +73 44 17 +74 46 13 +75 49 11 +76 49 42 +77 53 43 +78 61 52 +79 57 48 +80 56 37 +81 55 54 +82 15 47 +83 14 37 +84 11 31 +85 16 22 +86 4 18 +87 28 18 +88 26 52 +89 26 35 +90 31 67 +91 15 19 +92 22 22 +93 18 24 +94 26 27 +95 25 24 +96 22 27 +97 25 21 +98 19 21 +99 20 26 +100 18 18 +101 35 35 +EOF diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.tsp.hc b/trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.tsp.hc new file mode 100644 index 000000000..f12903349 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.tsp.hc @@ -0,0 +1,102 @@ +101 +41 49 +35 17 +55 45 +55 20 +15 30 +25 30 +20 50 +10 43 +55 60 +30 60 +20 65 +50 35 +30 25 +15 10 +30 5 +10 20 +5 30 +20 40 +15 60 +45 65 +45 20 +45 10 +55 5 +65 35 +65 20 +45 30 +35 40 +41 37 +64 42 +40 60 +31 52 +35 69 +53 52 +65 55 +63 65 +2 60 +20 20 +5 5 +60 12 +40 25 +42 7 +24 12 +23 3 +11 14 +6 38 +2 48 +8 56 +13 52 +6 68 +47 47 +49 58 +27 43 +37 31 +57 29 +63 23 +53 12 +32 12 +36 26 +21 24 +17 34 +12 24 +24 58 +27 69 +15 77 +62 77 +49 73 +67 5 +56 39 +37 47 +37 56 +57 68 +47 16 +44 17 +46 13 +49 11 +49 42 +53 43 +61 52 +57 48 +56 37 +55 54 +15 47 +14 37 +11 31 +16 22 +4 18 +28 18 +26 52 +26 35 +31 67 +15 19 +22 22 +18 24 +26 27 +25 24 +22 27 +25 21 +19 21 +20 26 +18 18 +35 35 diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/city_swap.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/city_swap.cpp new file mode 100644 index 000000000..4cf961da5 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/city_swap.cpp @@ -0,0 +1,49 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 + +#include "city_swap.h" + +bool CitySwap :: operator () (Route & __route) { + + std :: swap (__route [rng.random (__route.size ())], + __route [rng.random (__route.size ())]) ; + + __route.invalidate () ; + + return true ; +} diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/city_swap.h b/trunk/paradiseo-peo/tutorial/examples/tsp/city_swap.h new file mode 100644 index 000000000..8a0756968 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/city_swap.h @@ -0,0 +1,54 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef city_swap_h +#define city_swap_h + +#include + +#include "route.h" + +/** Its swaps two vertices + randomly choosen */ +class CitySwap : public eoMonOp { + +public : + + bool operator () (Route & __route) ; + +} ; + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/data.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/data.cpp new file mode 100644 index 000000000..4bbdd1a96 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/data.cpp @@ -0,0 +1,126 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 +#include +#include +#include + +#include + +#include "data.h" +#include "node.h" + +#define MAX_TRASH_LENGTH 1000 +#define MAX_FIELD_LENGTH 1000 +#define MAX_LINE_LENGTH 1000 + +static void getNextField (FILE * __f, char * __buff) { + + char trash [MAX_TRASH_LENGTH]; + + fscanf (__f, "%[ \t:\n]", trash); /* Discarding sep. */ + fscanf (__f, "%[^:\n]", __buff); /* Reading the field */ + fgetc (__f); +} + +static void getLine (FILE * __f, char * __buff) { + + char trash [MAX_TRASH_LENGTH]; + + fscanf (__f, "%[ \t:\n]", trash); /* Discarding sep. */ + fscanf (__f, "%[^\n]", __buff); /* Reading the line */ +} + +void loadData (const char * __filename) { + + FILE * f = fopen (__filename, "r"); + + if (f) { + + printf ("Loading '%s'.\n", __filename); + + char field [MAX_FIELD_LENGTH]; + + getNextField (f, field); /* Name */ + assert (strstr (field, "NAME")); + getNextField (f, field); + printf ("NAME: %s.\n", field); + + getNextField (f, field); /* Comment */ + assert (strstr (field, "COMMENT")); + getLine (f, field); + printf ("COMMENT: %s.\n", field); + + getNextField (f, field); /* Type */ + assert (strstr (field, "TYPE")); + getNextField (f, field); + printf ("TYPE: %s.\n", field); + + getNextField (f, field); /* Dimension */ + assert (strstr (field, "DIMENSION")); + getNextField (f, field); + printf ("DIMENSION: %s.\n", field); + numNodes = atoi (field); + + getNextField (f, field); /* Edge weight type */ + assert (strstr (field, "EDGE_WEIGHT_TYPE")); + getNextField (f, field); + printf ("EDGE_WEIGHT_TYPE: %s.\n", field); + + getNextField (f, field); /* Node coord section */ + assert (strstr (field, "NODE_COORD_SECTION")); + loadNodes (f); + + getNextField (f, field); /* End of file */ + assert (strstr (field, "EOF")); + printf ("EOF.\n"); + } + else { + + fprintf (stderr, "Can't open '%s'.\n", __filename); + exit (1); + } +} + +void loadData (eoParser & __parser) { + + /* Getting the path of the instance */ + + eoValueParam param ("", "inst", "Path of the instance") ; + __parser.processParam (param) ; + loadData (param.value ().c_str ()); +} diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/data.h b/trunk/paradiseo-peo/tutorial/examples/tsp/data.h new file mode 100644 index 000000000..2ec56fdd4 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/data.h @@ -0,0 +1,46 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __data_h +#define __data_h + +#include + +extern void loadData (const char * __filename); + +extern void loadData (eoParser & __parser); + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/display.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/display.cpp new file mode 100644 index 000000000..69ebfaf9d --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/display.cpp @@ -0,0 +1,145 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 +#include + +#include + +#include "display.h" +#include "node.h" +#include "opt_route.h" + +#define BORDER 20 +#define RATIO 0.5 + +#define screen_width 1024 +#define screen_height 768 + +static const char * filename; + +/* Computed coordinates */ +static unsigned * X_new_coord, * Y_new_coord ; + +/* this variable will contain the handle to the returned graphics context. */ +static GC gc; + +/* this variable will contain the pointer to the Display structure */ +static Display* disp; + +/* this variable will store the ID of the newly created window. */ +static Window win; + +static int screen; + +/* Create a new backing pixmap of the appropriate size */ + + /* Best tour */ + /* + gdk_gc_set_line_attributes (gc, 2, GDK_LINE_ON_OFF_DASH, GDK_CAP_NOT_LAST, GDK_JOIN_MITER) ; + + gdk_gc_set_foreground (gc, & color_green) ; + + for (int i = 0 ; i < (int) numNodes ; i ++) { + + gdk_draw_line (pixmap, gc, + X_new_coord [opt_route [i]], + Y_new_coord [opt_route [i]], + X_new_coord [opt_route [(i + 1) % numNodes]], + Y_new_coord [opt_route [(i + 1) % numNodes]]); + + }*/ + +void openMainWindow (const char * __filename) { + + filename = __filename; + + /* Map */ + int map_width = (int) (X_max - X_min); + int map_height = (int) (Y_max - Y_min); + int map_side = std :: max (map_width, map_height); + + /* Calculate the window's width and height. */ + int win_width = (int) (screen_width * RATIO * map_width / map_side); + int win_height = (int) (screen_height * RATIO * map_height / map_side); + + /* Computing the coordinates */ + X_new_coord = new unsigned [numNodes]; + Y_new_coord = new unsigned [numNodes]; + + for (unsigned i = 0; i < numNodes; i ++) { + X_new_coord [i] = (unsigned) (win_width * (1.0 - (X_coord [i] - X_min) / map_width) + BORDER); + Y_new_coord [i] = (unsigned) (win_height * (1.0 - (Y_coord [i] - Y_min) / map_height) + BORDER); + } + + /* Initialisation */ + XGCValues val ; + + disp = XOpenDisplay (NULL) ; + screen = DefaultScreen (disp) ; + win = XCreateSimpleWindow (disp, RootWindow (disp, screen), 0, 0, win_width + 2 * BORDER, win_height + 2 * BORDER, 2, BlackPixel (disp, screen), WhitePixel (disp, screen)) ; + val.foreground = BlackPixel(disp, screen) ; + val.background = WhitePixel(disp, screen) ; + gc = XCreateGC (disp, win, GCForeground | GCBackground, & val) ; + + XMapWindow (disp, win) ; + XFlush (disp) ; + + while (true) { + XClearWindow (disp, win) ; + + /* Vertices as circles */ + for (unsigned i = 1 ; i < numNodes ; i ++) + XDrawArc (disp, win, gc, X_new_coord [i] - 1, Y_new_coord [i] - 1, 3, 3, 0, 364 * 64) ; + + /* New tour */ + std :: ifstream f (filename); + if (f) { + Route route; + f >> route; + f.close (); + + for (int i = 0; i < (int) numNodes; i ++) + XDrawLine (disp, win, gc, + X_new_coord [route [i]], + Y_new_coord [route [i]], + X_new_coord [route [(i + 1) % numNodes]], + Y_new_coord [route [(i + 1) % numNodes]]); + } + XFlush (disp) ; + sleep (1) ; + } +} diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/display.h b/trunk/paradiseo-peo/tutorial/examples/tsp/display.h new file mode 100644 index 000000000..b39c307ca --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/display.h @@ -0,0 +1,44 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __display_h +#define __display_h + +#include "route.h" + +extern void openMainWindow (const char * __filename); + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/display_best_route.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/display_best_route.cpp new file mode 100644 index 000000000..6bbe6630d --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/display_best_route.cpp @@ -0,0 +1,50 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 "display_best_route.h" +#include "display.h" + +DisplayBestRoute :: DisplayBestRoute (eoPop & __pop + ) : pop (__pop) { + + +} + +void DisplayBestRoute :: operator () () { + + displayRoute (pop.best_element ()); +} + diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/display_best_route.h b/trunk/paradiseo-peo/tutorial/examples/tsp/display_best_route.h new file mode 100644 index 000000000..734f8a855 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/display_best_route.h @@ -0,0 +1,60 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __display_best_route_h +#define __display_best_route_h + +#include + +#include + +#include "route.h" + +class DisplayBestRoute : public eoUpdater { + +public : + + DisplayBestRoute (eoPop & __pop); + + void operator () (); + +private : + + eoPop & pop; + +}; + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/edge_xover.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/edge_xover.cpp new file mode 100644 index 000000000..a2dac3a9a --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/edge_xover.cpp @@ -0,0 +1,146 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 +#include + +#include + +#include "edge_xover.h" + +void EdgeXover :: build_map (const Route & __par1, const Route & __par2) { + + unsigned len = __par1.size () ; + + /* Initialization */ + _map.clear () ; + _map.resize (len) ; + + for (unsigned i = 0 ; i < len ; i ++) { + _map [__par1 [i]].insert (__par1 [(i + 1) % len]) ; + _map [__par2 [i]].insert (__par2 [(i + 1) % len]) ; + _map [__par1 [i]].insert (__par1 [(i - 1 + len) % len]) ; + _map [__par2 [i]].insert (__par2 [(i - 1 + len) % len]) ; + } + + visited.clear () ; + visited.resize (len, false) ; +} + +void EdgeXover :: remove_entry (unsigned __vertex, std :: vector > & __map) { + + std :: set & neigh = __map [__vertex] ; + + for (std :: set :: iterator it = neigh.begin () ; + it != neigh.end () ; + it ++) + __map [* it].erase (__vertex) ; + +} + +void EdgeXover :: add_vertex (unsigned __vertex, Route & __child) { + + visited [__vertex] = true ; + __child.push_back (__vertex) ; + remove_entry (__vertex, _map) ; /* Removing entries */ +} + +void EdgeXover :: cross (const Route & __par1, const Route & __par2, Route & __child) { + + build_map (__par1, __par2) ; + + unsigned len = __par1.size () ; + + /* Go ! */ + __child.clear () ; + + unsigned cur_vertex = rng.random (len) ; + + add_vertex (cur_vertex, __child) ; + + for (unsigned i = 1 ; i < len ; i ++) { + + unsigned len_min_entry = MAXINT ; + + std :: set & neigh = _map [cur_vertex] ; + + for (std :: set :: iterator it = neigh.begin () ; + it != neigh.end () ; + it ++) { + unsigned l = _map [* it].size () ; + if (len_min_entry > l) + len_min_entry = l ; + } + + std :: vector cand ; /* Candidates */ + + for (std :: set :: iterator it = neigh.begin () ; + it != neigh.end () ; + it ++) { + unsigned l = _map [* it].size () ; + if (len_min_entry == l) + cand.push_back (* it) ; + } + + if (! cand.size ()) { + + /* Oh no ! Implicit mutation */ + for (unsigned j = 0 ; j < len ; j ++) + if (! visited [j]) + cand.push_back (j) ; + } + + cur_vertex = cand [rng.random (cand.size ())] ; + + add_vertex (cur_vertex, __child) ; + } +} + +bool EdgeXover :: operator () (Route & __route1, Route & __route2) { + + // Init. copy + Route par [2] ; + par [0] = __route1 ; + par [1] = __route2 ; + + cross (par [0], par [1], __route1) ; + cross (par [1], par [0], __route2) ; + + __route1.invalidate () ; + __route2.invalidate () ; + + return true ; +} diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/edge_xover.h b/trunk/paradiseo-peo/tutorial/examples/tsp/edge_xover.h new file mode 100644 index 000000000..75d91a22e --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/edge_xover.h @@ -0,0 +1,71 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef edge_xover_h +#define edge_xover_h + +#include +#include + +#include + +#include "route.h" + +/** Edge Crossover */ +class EdgeXover : public eoQuadOp { + +public : + + bool operator () (Route & __route1, Route & __route2) ; + +private : + + void cross (const Route & __par1, const Route & __par2, Route & __child) ; /* Binary */ + + void remove_entry (unsigned __vertex, std :: vector > & __map) ; + /* Updating the map of entries */ + + void build_map (const Route & __par1, const Route & __par2) ; + + void add_vertex (unsigned __vertex, Route & __child) ; + + std :: vector > _map ; /* The handled map */ + + std :: vector visited ; /* Vertices that are already visited */ + +} ; + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/merge_route_eval.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/merge_route_eval.cpp new file mode 100644 index 000000000..dc005214b --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/merge_route_eval.cpp @@ -0,0 +1,45 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 "merge_route_eval.h" + +void MergeRouteEval :: operator () (Route & __route, const int & __part_fit) { + + int len = __route.fitness (); + len += __part_fit; + __route.fitness (len); +} + diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/merge_route_eval.h b/trunk/paradiseo-peo/tutorial/examples/tsp/merge_route_eval.h new file mode 100644 index 000000000..78c7b8a65 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/merge_route_eval.h @@ -0,0 +1,52 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __merge_route_eval_h +#define __merge_route_eval_h + +#include + +#include "route.h" + +class MergeRouteEval : public peoAggEvalFunc { + +public : + + void operator () (Route & __route, const int & __part_fit) ; + +}; + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/mix.h b/trunk/paradiseo-peo/tutorial/examples/tsp/mix.h new file mode 100644 index 000000000..ce6e31a26 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/mix.h @@ -0,0 +1,52 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __mix_h +#define __mix_h + +#include + +#include + +template void mix (std :: vector & __v) { + + unsigned len = __v.size () ; + + for (unsigned i = 0 ; i < len ; i ++) + std :: swap (__v [i], __v [rng.random (len)]) ; +} + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/node.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/node.cpp new file mode 100644 index 000000000..48f76484d --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/node.cpp @@ -0,0 +1,105 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 +#include + +#include "node.h" + +unsigned numNodes; /* Number of nodes */ + +//static unsigned * * dist; /* Square matrix of distances */ + +double * X_coord, * Y_coord; + +double X_min = MAXDOUBLE, X_max = MINDOUBLE, Y_min = MAXDOUBLE, Y_max = MINDOUBLE; + +void loadNodes (FILE * __f) { + + /* Coord */ + + X_coord = new double [numNodes]; + + Y_coord = new double [numNodes]; + + unsigned num; + + for (unsigned i = 0; i < numNodes; i ++) { + + fscanf (__f, "%u%lf%lf", & num, X_coord + i, Y_coord + i); + + if (X_coord [i] < X_min) + X_min = X_coord [i]; + if (X_coord [i] > X_max) + X_max = X_coord [i]; + if (Y_coord [i] < Y_min) + Y_min = Y_coord [i]; + if (Y_coord [i] > Y_max) + Y_max = Y_coord [i]; + } + + /* Allocation */ + /* + dist = new unsigned * [numNodes]; + + for (unsigned i = 0; i < numNodes; i ++) + dist [i] = new unsigned [numNodes]; + */ + /* Computation of the distances */ + + /* + for (unsigned i = 0; i < numNodes; i ++) { + + dist [i] [i] = 0; + + for (unsigned j = 0; j < numNodes; j ++) { + + double dx = X_coord [i] - X_coord [j], dy = Y_coord [i] - Y_coord [j]; + + dist [i] [j] = dist [j] [i] = (unsigned) (sqrt (dx * dx + dy * dy) + 0.5) ; + } + }*/ +} + +unsigned distance (Node __from, Node __to) { + + // return dist [__from] [__to]; + + double dx = X_coord [__from] - X_coord [__to], dy = Y_coord [__from] - Y_coord [__to]; + + return (unsigned) (sqrt (dx * dx + dy * dy) + 0.5) ; +} + diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/node.h b/trunk/paradiseo-peo/tutorial/examples/tsp/node.h new file mode 100644 index 000000000..bbc68c7f6 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/node.h @@ -0,0 +1,54 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __node_h +#define __node_h + +#include + +typedef unsigned Node; + +extern double X_min, X_max, Y_min, Y_max; + +extern double * X_coord, * Y_coord; + +extern unsigned numNodes; /* Number of nodes */ + +extern void loadNodes (FILE * __f); + +extern unsigned distance (Node __from, Node __to); + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/opt_route.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/opt_route.cpp new file mode 100644 index 000000000..a8f85e3a1 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/opt_route.cpp @@ -0,0 +1,135 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 "opt_route.h" + +#define MAX_TRASH_LENGTH 1000 +#define MAX_FIELD_LENGTH 1000 +#define MAX_LINE_LENGTH 1000 + +static void getNextField (FILE * __f, char * __buff) { + + char trash [MAX_TRASH_LENGTH]; + + fscanf (__f, "%[ \t:\n]", trash); /* Discarding sep. */ + fscanf (__f, "%[^:\n]", __buff); /* Reading the field */ + fgetc (__f); +} + +static void getLine (FILE * __f, char * __buff) { + + char trash [MAX_TRASH_LENGTH]; + + fscanf (__f, "%[ \t:\n]", trash); /* Discarding sep. */ + fscanf (__f, "%[^\n]", __buff); /* Reading the line */ +} + +static void loadBestRoute (FILE * __f) { + + opt_route.clear (); + + for (unsigned i = 0; i < numNodes; i ++) { + Node node; + fscanf (__f, "%u", & node); + opt_route.push_back (node - 1); + } + int d; /* -1 ! */ + fscanf (__f, "%d", & d); +} + +void loadOptimumRoute (const char * __filename) { + + FILE * f = fopen (__filename, "r"); + + if (f) { + + printf ("Loading '%s'.\n", __filename); + + char field [MAX_FIELD_LENGTH]; + + getNextField (f, field); /* Name */ + assert (strstr (field, "NAME")); + getNextField (f, field); + //printf ("NAME: %s.\n", field); + + getNextField (f, field); /* Comment */ + assert (strstr (field, "COMMENT")); + getLine (f, field); + // printf ("COMMENT: %s.\n", field); + + getNextField (f, field); /* Type */ + assert (strstr (field, "TYPE")); + getNextField (f, field); + //printf ("TYPE: %s.\n", field); + + getNextField (f, field); /* Dimension */ + assert (strstr (field, "DIMENSION")); + getNextField (f, field); + // printf ("DIMENSION: %s.\n", field); + numNodes = atoi (field); + + getNextField (f, field); /* Tour section */ + assert (strstr (field, "TOUR_SECTION")); + loadBestRoute (f); + + getNextField (f, field); /* End of file */ + assert (strstr (field, "EOF")); + //printf ("EOF.\n"); + + printf ("The length of the best route is %u.\n", length (opt_route)); + } + else { + + fprintf (stderr, "Can't open '%s'.\n", __filename); + exit (1); + } +} + +void loadOptimumRoute (eoParser & __parser) { + + /* Getting the path of the instance */ + + eoValueParam param ("", "optimumTour", "Optimum tour") ; + __parser.processParam (param) ; + if (strlen (param.value ().c_str ())) + loadOptimumRoute (param.value ().c_str ()); + else + opt_route.fitness (0); +} + +Route opt_route; /* Optimum route */ + + diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/opt_route.h b/trunk/paradiseo-peo/tutorial/examples/tsp/opt_route.h new file mode 100644 index 000000000..8a5767285 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/opt_route.h @@ -0,0 +1,51 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __opt_route_h +#define __opt_route_h + +#include +#include + +#include "route.h" + +extern void loadOptimumRoute (const char * __filename); + +extern void loadOptimumRoute (eoParser & __parser); + +extern Route opt_route; /* Optimum route */ + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/order_xover.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/order_xover.cpp new file mode 100644 index 000000000..f69eaff30 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/order_xover.cpp @@ -0,0 +1,92 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 + +#include + +#include "order_xover.h" + +void OrderXover :: cross (const Route & __par1, const Route & __par2, Route & __child) { + + unsigned cut2 = 1 + rng.random (numNodes) ; + unsigned cut1 = rng.random (cut2); + unsigned l = 0; + + /* To store vertices that have already been crossed */ + std :: vector v (numNodes, false); + + /* Copy of the left partial route of the first parent */ + for (unsigned i = cut1 ; i < cut2 ; i ++) { + __child [l ++] = __par1 [i] ; + v [__par1 [i]] = true ; + } + + /* Searching the vertex of the second path, that ended the previous first one */ + unsigned from = 0 ; + for (unsigned i = 0; i < numNodes; i ++) + if (__par2 [i] == __child [cut2 - 1]) { + from = i ; + break ; + } + + /* Selecting a direction (Left or Right) */ + char direct = rng.flip () ? 1 : -1 ; + + for (unsigned i = 0; i < numNodes + 1; i ++) { + unsigned bidule = (direct * i + from + numNodes) % numNodes; + if (! v [__par2 [bidule]]) { + __child [l ++] = __par2 [bidule] ; + v [__par2 [bidule]] = true ; + } + } +} + +bool OrderXover :: operator () (Route & __route1, Route & __route2) { + + // Init. copy + Route par [2] ; + par [0] = __route1 ; + par [1] = __route2 ; + + cross (par [0], par [1], __route1) ; + cross (par [1], par [0], __route2) ; + + __route1.invalidate () ; + __route2.invalidate () ; + + return true ; +} diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/order_xover.h b/trunk/paradiseo-peo/tutorial/examples/tsp/order_xover.h new file mode 100644 index 000000000..bd14f5a50 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/order_xover.h @@ -0,0 +1,56 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef order_xover_h +#define order_xover_h + +#include + +#include "route.h" + +/** Order Crossover */ +class OrderXover : public eoQuadOp { + +public : + + bool operator () (Route & __route1, Route & __route2) ; + +private : + + void cross (const Route & __par1, const Route & __par2, Route & __child) ; +} ; + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/paradiseo-peo-lsn-shared.doxyfile b/trunk/paradiseo-peo/tutorial/examples/tsp/paradiseo-peo-lsn-shared.doxyfile new file mode 100644 index 000000000..5acf7de0b --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/paradiseo-peo-lsn-shared.doxyfile @@ -0,0 +1,240 @@ +# Doxyfile 1.4.7 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = "@PACKAGE_NAME@ - Lessons" +PROJECT_NUMBER = @PACKAGE_VERSION@ +OUTPUT_DIRECTORY = @CMAKE_BINARY_DIR@/doc/html/lsnshared +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = @CMAKE_SOURCE_DIR@ +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = YES +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +BUILTIN_STL_SUPPORT = NO +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = NO +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = YES +HIDE_UNDOC_CLASSES = YES +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = NO +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = NO +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = YES +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = YES +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = @CMAKE_CURRENT_SOURCE_DIR@ +FILE_PATTERNS = *.cpp \ + *.h \ + NEWS \ + README +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 3 +IGNORE_PREFIX = peo +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = YES +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = YES +USE_PDFLATEX = YES +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = YES +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = @EO_BIN_DIR@/doc/eo.doxytag=http://eodev.sourceforge.net/eo/doc/html \ + @MO_BIN_DIR@/doc/mo.doxytag=@MO_BIN_DIR@/doc/html \ + @ParadisEO-PEO_BINARY_DIR@/doc/peo.doxytag=@ParadisEO-PEO_BINARY_DIR@/doc/html +GENERATE_TAGFILE = @CMAKE_BINARY_DIR@/doc/paradiseo-peo-lsn-shared.doxytag +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = YES diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/param.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/param.cpp new file mode 100644 index 000000000..92dc5f256 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/param.cpp @@ -0,0 +1,51 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 + +#include "data.h" +#include "opt_route.h" + +void loadParameters (int __argc, char * * __argv) { + + eoParser parser (__argc, __argv); + + loadData (parser); + + loadOptimumRoute (parser); +} + + diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/param.h b/trunk/paradiseo-peo/tutorial/examples/tsp/param.h new file mode 100644 index 000000000..25b981696 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/param.h @@ -0,0 +1,42 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __param_h +#define __param_h + +extern void loadParameters (int __argc, char * * __argv); + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/part_route_eval.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/part_route_eval.cpp new file mode 100644 index 000000000..d78c6c6e7 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/part_route_eval.cpp @@ -0,0 +1,58 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 "part_route_eval.h" +#include "node.h" + +PartRouteEval :: PartRouteEval (float __from, + float __to + ) : from (__from), + to (__to) { + +} + +void PartRouteEval :: operator () (Route & __route) { + + + unsigned len = 0 ; + + for (unsigned i = (unsigned) (__route.size () * from) ; + i < (unsigned) (__route.size () * to) ; + i ++) + len += distance (__route [i], __route [(i + 1) % numNodes]) ; + + __route.fitness (- (int) len) ; +} diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/part_route_eval.h b/trunk/paradiseo-peo/tutorial/examples/tsp/part_route_eval.h new file mode 100644 index 000000000..8d144555d --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/part_route_eval.h @@ -0,0 +1,61 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __part_route_eval_h +#define __part_route_eval_h + +#include + +#include "route.h" + +/** Route Evaluator */ +class PartRouteEval : public eoEvalFunc { + +public : + + /** Constructor */ + PartRouteEval (float __from, float __to) ; + + void operator () (Route & __route) ; + +private : + + float from, to ; + +} ; + + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/partial_mapped_xover.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/partial_mapped_xover.cpp new file mode 100644 index 000000000..8c37ad6a0 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/partial_mapped_xover.cpp @@ -0,0 +1,89 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 + +#include + +#include "partial_mapped_xover.h" +#include "mix.h" + +void PartialMappedXover :: repair (Route & __route, unsigned __cut1, unsigned __cut2) { + + unsigned v [__route.size ()] ; // Number of times a cities are visited ... + + for (unsigned i = 0 ; i < __route.size () ; i ++) + v [i] = 0 ; + + for (unsigned i = 0 ; i < __route.size () ; i ++) + v [__route [i]] ++ ; + + std :: vector vert ; + + for (unsigned i = 0 ; i < __route.size () ; i ++) + if (! v [i]) + vert.push_back (i) ; + + mix (vert) ; + + for (unsigned i = 0 ; i < __route.size () ; i ++) + if (i < __cut1 || i >= __cut2) + if (v [__route [i]] > 1) { + __route [i] = vert.back () ; + vert.pop_back () ; + } +} + +bool PartialMappedXover :: operator () (Route & __route1, Route & __route2) { + + unsigned cut1 = rng.random (__route1.size ()), cut2 = rng.random (__route2.size ()) ; + + if (cut2 < cut1) + std :: swap (cut1, cut2) ; + + // Between the cuts + for (unsigned i = cut1 ; i < cut2 ; i ++) + std :: swap (__route1 [i], __route2 [i]) ; + + // Outside the cuts + repair (__route1, cut1, cut2) ; + repair (__route2, cut1, cut2) ; + + __route1.invalidate () ; + __route2.invalidate () ; + + return true ; +} diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/partial_mapped_xover.h b/trunk/paradiseo-peo/tutorial/examples/tsp/partial_mapped_xover.h new file mode 100644 index 000000000..e3ff29ad7 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/partial_mapped_xover.h @@ -0,0 +1,56 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef partial_mapped_xover_h +#define partial_mapped_xover_h + +#include + +#include "route.h" + +/** Partial Mapped Crossover */ +class PartialMappedXover : public eoQuadOp { + +public : + + bool operator () (Route & __route1, Route & __route2) ; + +private : + + void repair (Route & __route, unsigned __cut1, unsigned __cut2) ; +} ; + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/route.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/route.cpp new file mode 100644 index 000000000..73a035539 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/route.cpp @@ -0,0 +1,49 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 "route.h" + +unsigned length (const Route & __route) { + + unsigned len = 0 ; + + for (unsigned i = 0; i < numNodes; i ++) + len += distance (__route [i], __route [(i + 1) % numNodes]) ; + + return len; +} + + diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/route.h b/trunk/paradiseo-peo/tutorial/examples/tsp/route.h new file mode 100644 index 000000000..13071e2ec --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/route.h @@ -0,0 +1,48 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __route_h +#define __route_h + +#include + +#include "node.h" + +typedef eoVector Route; + +unsigned length (const Route & __route); + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/route_eval.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/route_eval.cpp new file mode 100644 index 000000000..d16c15ed4 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/route_eval.cpp @@ -0,0 +1,41 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 "route_eval.h" + +void RouteEval :: operator () (Route & __route) { + __route.fitness (- (int) length (__route)); +} diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/route_eval.h b/trunk/paradiseo-peo/tutorial/examples/tsp/route_eval.h new file mode 100644 index 000000000..5e79b7b9f --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/route_eval.h @@ -0,0 +1,51 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __route_eval_h +#define __route_eval_h + +#include + +#include "route.h" + +class RouteEval : public eoEvalFunc { + +public : + + void operator () (Route & __route) ; +} ; + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/route_init.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/route_init.cpp new file mode 100644 index 000000000..6e611d76e --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/route_init.cpp @@ -0,0 +1,51 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 + +#include "route_init.h" +#include "node.h" + +void RouteInit :: operator () (Route & __route) { + + __route.clear (); + + for (unsigned i = 0 ; i < numNodes ; i ++) + __route.push_back (i); + + for (unsigned i = 0 ; i < numNodes ; i ++) + std :: swap (__route [i], __route [rng.random (numNodes)]); +} diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/route_init.h b/trunk/paradiseo-peo/tutorial/examples/tsp/route_init.h new file mode 100644 index 000000000..b5311b1f7 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/route_init.h @@ -0,0 +1,51 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __route_init_h +#define __route_init_h + +#include + +#include "route.h" + +class RouteInit : public eoInit { + +public : + + void operator () (Route & __route); +} ; + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt.cpp new file mode 100644 index 000000000..f149b6de1 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt.cpp @@ -0,0 +1,48 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 "two_opt.h" + +void TwoOpt :: operator () (Route & __route) { + + unsigned i = 0; + + while ((2 * i) < (second - first)) { + + std :: swap (__route [first + i], __route [second - i]); + i ++; + } +} diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt.h b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt.h new file mode 100644 index 000000000..5c9e985ea --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt.h @@ -0,0 +1,53 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __two_opt_h +#define __two_opt_h + +#include +#include + +#include "route.h" + +class TwoOpt : public moMove , public std :: pair { + +public : + + void operator () (Route & __route); + +} ; + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_incr_eval.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_incr_eval.cpp new file mode 100644 index 000000000..60be43d9f --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_incr_eval.cpp @@ -0,0 +1,52 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 "two_opt_incr_eval.h" +#include "node.h" + +int TwoOptIncrEval :: operator () (const TwoOpt & __move, const Route & __route) { + + /* From */ + Node v1 = __route [__move.first], v1_left = __route [(__move.first - 1 + numNodes) % numNodes]; + + /* To */ + Node v2 = __route [__move.second], v2_right = __route [(__move.second + 1) % numNodes]; + + if (v1 == v2 || v2_right == v1) + return __route.fitness (); + else + return __route.fitness () - distance (v1_left, v2) - distance (v1, v2_right) + distance (v1_left, v1) + distance (v2, v2_right); +} diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_incr_eval.h b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_incr_eval.h new file mode 100644 index 000000000..7cce92aa7 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_incr_eval.h @@ -0,0 +1,51 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __two_opt_incr_eval_h +#define __two_opt_incr_eval_h + +#include +#include "two_opt.h" + +class TwoOptIncrEval : public moMoveIncrEval { + +public : + + int operator () (const TwoOpt & __move, const Route & __route) ; + +} ; + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_init.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_init.cpp new file mode 100644 index 000000000..862b5236e --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_init.cpp @@ -0,0 +1,42 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 "two_opt_init.h" + +void TwoOptInit :: operator () (TwoOpt & __move, const Route & __route) { + + __move.first = __move.second = 0; +} diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_init.h b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_init.h new file mode 100644 index 000000000..fc290b4f8 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_init.h @@ -0,0 +1,52 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __two_opt_init_h +#define __two_opt_init_h + +#include + +#include "two_opt.h" + +class TwoOptInit : public moMoveInit { + +public : + + void operator () (TwoOpt & __move, const Route & __route) ; + +} ; + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_next.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_next.cpp new file mode 100644 index 000000000..a80e973be --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_next.cpp @@ -0,0 +1,55 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 "two_opt_next.h" +#include "node.h" + +bool TwoOptNext :: operator () (TwoOpt & __move, const Route & __route) { + + if (__move.first == numNodes - 1 && __move.second == numNodes - 1) + return false; + + else { + + __move.second ++; + if (__move.second == numNodes) { + + __move.first ++; + __move.second = __move.first; + } + return true ; + } +} diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_next.h b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_next.h new file mode 100644 index 000000000..09844b8c4 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_next.h @@ -0,0 +1,52 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __two_opt_next_h +#define __two_opt_next_h + +#include + +#include "two_opt.h" + +class TwoOptNext : public moNextMove { + +public : + + bool operator () (TwoOpt & __move, const Route & __route); + +}; + +#endif diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_rand.cpp b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_rand.cpp new file mode 100644 index 000000000..9fa9270c8 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_rand.cpp @@ -0,0 +1,49 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* 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 + +#include "two_opt_rand.h" +#include "node.h" + +void TwoOptRand :: operator () (TwoOpt & __move, const Route & __route) { + + __move.second = rng.random (numNodes); + + __move.first = rng.random (__move.second); +} + + diff --git a/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_rand.h b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_rand.h new file mode 100644 index 000000000..c2cac3a7b --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_rand.h @@ -0,0 +1,52 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sebastien Cahon, Alexandru-Adrian Tantar +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __two_opt_rand_h +#define __two_opt_rand_h + +#include + +#include "two_opt.h" + +class TwoOptRand : public eoMoveRand { + +public : + + void operator () (TwoOpt & __move, const Route & __route) ; + +} ; + +#endif