New lesson
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@782 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
3efa2380dd
commit
1100fbdb90
47 changed files with 3266 additions and 0 deletions
11
trunk/paradiseo-peo/tutorial/examples/CMakeLists.txt
Normal file
11
trunk/paradiseo-peo/tutorial/examples/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
|
||||
######################################################################################
|
||||
### 1) Where must cmake go now ?
|
||||
######################################################################################
|
||||
|
||||
SUBDIRS(tsp)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
110
trunk/paradiseo-peo/tutorial/examples/tsp/CMakeLists.txt
Normal file
110
trunk/paradiseo-peo/tutorial/examples/tsp/CMakeLists.txt
Normal file
|
|
@ -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
|
||||
|
||||
######################################################################################
|
||||
108
trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.opt.tour
Normal file
108
trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.opt.tour
Normal file
|
|
@ -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
|
||||
108
trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.tsp
Normal file
108
trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.tsp
Normal file
|
|
@ -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
|
||||
102
trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.tsp.hc
Normal file
102
trunk/paradiseo-peo/tutorial/examples/tsp/benchs/eil101.tsp.hc
Normal file
|
|
@ -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
|
||||
49
trunk/paradiseo-peo/tutorial/examples/tsp/city_swap.cpp
Normal file
49
trunk/paradiseo-peo/tutorial/examples/tsp/city_swap.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* <city_swap.cpp>
|
||||
* 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 <utils/eoRNG.h>
|
||||
|
||||
#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 ;
|
||||
}
|
||||
54
trunk/paradiseo-peo/tutorial/examples/tsp/city_swap.h
Normal file
54
trunk/paradiseo-peo/tutorial/examples/tsp/city_swap.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* <city_swap.h>
|
||||
* 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 <eoOp.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
/** Its swaps two vertices
|
||||
randomly choosen */
|
||||
class CitySwap : public eoMonOp <Route> {
|
||||
|
||||
public :
|
||||
|
||||
bool operator () (Route & __route) ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
126
trunk/paradiseo-peo/tutorial/examples/tsp/data.cpp
Normal file
126
trunk/paradiseo-peo/tutorial/examples/tsp/data.cpp
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* <data.cpp>
|
||||
* 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 <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <utils/eoParser.h>
|
||||
|
||||
#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 <std :: string> param ("", "inst", "Path of the instance") ;
|
||||
__parser.processParam (param) ;
|
||||
loadData (param.value ().c_str ());
|
||||
}
|
||||
46
trunk/paradiseo-peo/tutorial/examples/tsp/data.h
Normal file
46
trunk/paradiseo-peo/tutorial/examples/tsp/data.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* <data.h>
|
||||
* 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 <utils/eoParser.h>
|
||||
|
||||
extern void loadData (const char * __filename);
|
||||
|
||||
extern void loadData (eoParser & __parser);
|
||||
|
||||
#endif
|
||||
145
trunk/paradiseo-peo/tutorial/examples/tsp/display.cpp
Normal file
145
trunk/paradiseo-peo/tutorial/examples/tsp/display.cpp
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* <display.cpp>
|
||||
* 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 <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#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) ;
|
||||
}
|
||||
}
|
||||
44
trunk/paradiseo-peo/tutorial/examples/tsp/display.h
Normal file
44
trunk/paradiseo-peo/tutorial/examples/tsp/display.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* <display.h>
|
||||
* 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
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* <display_best_route.cpp>
|
||||
* 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 <Route> & __pop
|
||||
) : pop (__pop) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
void DisplayBestRoute :: operator () () {
|
||||
|
||||
displayRoute (pop.best_element ());
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* <display_best_route.h>
|
||||
* 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 <utils/eoUpdater.h>
|
||||
|
||||
#include <eoPop.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
class DisplayBestRoute : public eoUpdater {
|
||||
|
||||
public :
|
||||
|
||||
DisplayBestRoute (eoPop <Route> & __pop);
|
||||
|
||||
void operator () ();
|
||||
|
||||
private :
|
||||
|
||||
eoPop <Route> & pop;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
146
trunk/paradiseo-peo/tutorial/examples/tsp/edge_xover.cpp
Normal file
146
trunk/paradiseo-peo/tutorial/examples/tsp/edge_xover.cpp
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* <edge_xover.cpp>
|
||||
* 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 <assert.h>
|
||||
#include <values.h>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#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 <std :: set <unsigned> > & __map) {
|
||||
|
||||
std :: set <unsigned> & neigh = __map [__vertex] ;
|
||||
|
||||
for (std :: set <unsigned> :: 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 <unsigned> & neigh = _map [cur_vertex] ;
|
||||
|
||||
for (std :: set <unsigned> :: iterator it = neigh.begin () ;
|
||||
it != neigh.end () ;
|
||||
it ++) {
|
||||
unsigned l = _map [* it].size () ;
|
||||
if (len_min_entry > l)
|
||||
len_min_entry = l ;
|
||||
}
|
||||
|
||||
std :: vector <unsigned> cand ; /* Candidates */
|
||||
|
||||
for (std :: set <unsigned> :: 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 ;
|
||||
}
|
||||
71
trunk/paradiseo-peo/tutorial/examples/tsp/edge_xover.h
Normal file
71
trunk/paradiseo-peo/tutorial/examples/tsp/edge_xover.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* <edge_xover.h>
|
||||
* 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 <vector>
|
||||
#include <set>
|
||||
|
||||
#include <eoOp.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
/** Edge Crossover */
|
||||
class EdgeXover : public eoQuadOp <Route> {
|
||||
|
||||
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 <std :: set <unsigned> > & __map) ;
|
||||
/* Updating the map of entries */
|
||||
|
||||
void build_map (const Route & __par1, const Route & __par2) ;
|
||||
|
||||
void add_vertex (unsigned __vertex, Route & __child) ;
|
||||
|
||||
std :: vector <std :: set <unsigned> > _map ; /* The handled map */
|
||||
|
||||
std :: vector <bool> visited ; /* Vertices that are already visited */
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* <merge_route_eval.cpp>
|
||||
* 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);
|
||||
}
|
||||
|
||||
52
trunk/paradiseo-peo/tutorial/examples/tsp/merge_route_eval.h
Normal file
52
trunk/paradiseo-peo/tutorial/examples/tsp/merge_route_eval.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* <merge_route_eval.h>
|
||||
* 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 <peoAggEvalFunc.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
class MergeRouteEval : public peoAggEvalFunc <Route> {
|
||||
|
||||
public :
|
||||
|
||||
void operator () (Route & __route, const int & __part_fit) ;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
52
trunk/paradiseo-peo/tutorial/examples/tsp/mix.h
Normal file
52
trunk/paradiseo-peo/tutorial/examples/tsp/mix.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* <mix.h>
|
||||
* 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 <vector>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
template <class T> void mix (std :: vector <T> & __v) {
|
||||
|
||||
unsigned len = __v.size () ;
|
||||
|
||||
for (unsigned i = 0 ; i < len ; i ++)
|
||||
std :: swap (__v [i], __v [rng.random (len)]) ;
|
||||
}
|
||||
|
||||
#endif
|
||||
105
trunk/paradiseo-peo/tutorial/examples/tsp/node.cpp
Normal file
105
trunk/paradiseo-peo/tutorial/examples/tsp/node.cpp
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* <node.cpp>
|
||||
* 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 <math.h>
|
||||
#include <values.h>
|
||||
|
||||
#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) ;
|
||||
}
|
||||
|
||||
54
trunk/paradiseo-peo/tutorial/examples/tsp/node.h
Normal file
54
trunk/paradiseo-peo/tutorial/examples/tsp/node.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* <node.h>
|
||||
* 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 <stdio.h>
|
||||
|
||||
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
|
||||
135
trunk/paradiseo-peo/tutorial/examples/tsp/opt_route.cpp
Normal file
135
trunk/paradiseo-peo/tutorial/examples/tsp/opt_route.cpp
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* <opt_route.cpp>
|
||||
* 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 <std :: string> 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 */
|
||||
|
||||
|
||||
51
trunk/paradiseo-peo/tutorial/examples/tsp/opt_route.h
Normal file
51
trunk/paradiseo-peo/tutorial/examples/tsp/opt_route.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* <opt_route.h>
|
||||
* 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 <cassert>
|
||||
#include <utils/eoParser.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
extern void loadOptimumRoute (const char * __filename);
|
||||
|
||||
extern void loadOptimumRoute (eoParser & __parser);
|
||||
|
||||
extern Route opt_route; /* Optimum route */
|
||||
|
||||
#endif
|
||||
92
trunk/paradiseo-peo/tutorial/examples/tsp/order_xover.cpp
Normal file
92
trunk/paradiseo-peo/tutorial/examples/tsp/order_xover.cpp
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* <order_xover.cpp>
|
||||
* 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 <assert.h>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#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 <bool> 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 ;
|
||||
}
|
||||
56
trunk/paradiseo-peo/tutorial/examples/tsp/order_xover.h
Normal file
56
trunk/paradiseo-peo/tutorial/examples/tsp/order_xover.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* <order_xover.h>
|
||||
* 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 <eoOp.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
/** Order Crossover */
|
||||
class OrderXover : public eoQuadOp <Route> {
|
||||
|
||||
public :
|
||||
|
||||
bool operator () (Route & __route1, Route & __route2) ;
|
||||
|
||||
private :
|
||||
|
||||
void cross (const Route & __par1, const Route & __par2, Route & __child) ;
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -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
|
||||
51
trunk/paradiseo-peo/tutorial/examples/tsp/param.cpp
Normal file
51
trunk/paradiseo-peo/tutorial/examples/tsp/param.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* <param.cpp>
|
||||
* 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 <utils/eoParser.h>
|
||||
|
||||
#include "data.h"
|
||||
#include "opt_route.h"
|
||||
|
||||
void loadParameters (int __argc, char * * __argv) {
|
||||
|
||||
eoParser parser (__argc, __argv);
|
||||
|
||||
loadData (parser);
|
||||
|
||||
loadOptimumRoute (parser);
|
||||
}
|
||||
|
||||
|
||||
42
trunk/paradiseo-peo/tutorial/examples/tsp/param.h
Normal file
42
trunk/paradiseo-peo/tutorial/examples/tsp/param.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* <param.h>
|
||||
* 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
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* <part_route_eval.cpp>
|
||||
* 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) ;
|
||||
}
|
||||
61
trunk/paradiseo-peo/tutorial/examples/tsp/part_route_eval.h
Normal file
61
trunk/paradiseo-peo/tutorial/examples/tsp/part_route_eval.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* <part_route_eval.h>
|
||||
* 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 <eoEvalFunc.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
/** Route Evaluator */
|
||||
class PartRouteEval : public eoEvalFunc <Route> {
|
||||
|
||||
public :
|
||||
|
||||
/** Constructor */
|
||||
PartRouteEval (float __from, float __to) ;
|
||||
|
||||
void operator () (Route & __route) ;
|
||||
|
||||
private :
|
||||
|
||||
float from, to ;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* <partial_mapped_xover.cpp>
|
||||
* 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 <assert.h>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#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 <unsigned> 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 ;
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* <partial_mapped_xover.h>
|
||||
* 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 <eoOp.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
/** Partial Mapped Crossover */
|
||||
class PartialMappedXover : public eoQuadOp <Route> {
|
||||
|
||||
public :
|
||||
|
||||
bool operator () (Route & __route1, Route & __route2) ;
|
||||
|
||||
private :
|
||||
|
||||
void repair (Route & __route, unsigned __cut1, unsigned __cut2) ;
|
||||
} ;
|
||||
|
||||
#endif
|
||||
49
trunk/paradiseo-peo/tutorial/examples/tsp/route.cpp
Normal file
49
trunk/paradiseo-peo/tutorial/examples/tsp/route.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* <route.cpp>
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
48
trunk/paradiseo-peo/tutorial/examples/tsp/route.h
Normal file
48
trunk/paradiseo-peo/tutorial/examples/tsp/route.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* <route.h>
|
||||
* 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 <eoVector.h>
|
||||
|
||||
#include "node.h"
|
||||
|
||||
typedef eoVector <int, Node> Route;
|
||||
|
||||
unsigned length (const Route & __route);
|
||||
|
||||
#endif
|
||||
41
trunk/paradiseo-peo/tutorial/examples/tsp/route_eval.cpp
Normal file
41
trunk/paradiseo-peo/tutorial/examples/tsp/route_eval.cpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* <route_eval.cpp>
|
||||
* 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));
|
||||
}
|
||||
51
trunk/paradiseo-peo/tutorial/examples/tsp/route_eval.h
Normal file
51
trunk/paradiseo-peo/tutorial/examples/tsp/route_eval.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* <route_eval.h>
|
||||
* 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 <eoEvalFunc.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
class RouteEval : public eoEvalFunc <Route> {
|
||||
|
||||
public :
|
||||
|
||||
void operator () (Route & __route) ;
|
||||
} ;
|
||||
|
||||
#endif
|
||||
51
trunk/paradiseo-peo/tutorial/examples/tsp/route_init.cpp
Normal file
51
trunk/paradiseo-peo/tutorial/examples/tsp/route_init.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* <route_init.cpp>
|
||||
* 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 <utils/eoRNG.h>
|
||||
|
||||
#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)]);
|
||||
}
|
||||
51
trunk/paradiseo-peo/tutorial/examples/tsp/route_init.h
Normal file
51
trunk/paradiseo-peo/tutorial/examples/tsp/route_init.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* <route_init.h>
|
||||
* 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 <eoInit.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
class RouteInit : public eoInit <Route> {
|
||||
|
||||
public :
|
||||
|
||||
void operator () (Route & __route);
|
||||
} ;
|
||||
|
||||
#endif
|
||||
48
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt.cpp
Normal file
48
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt.cpp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* <two_opt.cpp>
|
||||
* 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 ++;
|
||||
}
|
||||
}
|
||||
53
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt.h
Normal file
53
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* <two_opt.h>
|
||||
* 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 <utility>
|
||||
#include <moMove.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
class TwoOpt : public moMove <Route>, public std :: pair <unsigned, unsigned> {
|
||||
|
||||
public :
|
||||
|
||||
void operator () (Route & __route);
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* <two_opt_incr_eval.cpp>
|
||||
* 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);
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* <two_opt_incr_eval.h>
|
||||
* 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 <moMoveIncrEval.h>
|
||||
#include "two_opt.h"
|
||||
|
||||
class TwoOptIncrEval : public moMoveIncrEval <TwoOpt> {
|
||||
|
||||
public :
|
||||
|
||||
int operator () (const TwoOpt & __move, const Route & __route) ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
42
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_init.cpp
Normal file
42
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_init.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* <two_opt_init.cpp>
|
||||
* 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;
|
||||
}
|
||||
52
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_init.h
Normal file
52
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_init.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* <two_opt_init.h>
|
||||
* 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 <moMoveInit.h>
|
||||
|
||||
#include "two_opt.h"
|
||||
|
||||
class TwoOptInit : public moMoveInit <TwoOpt> {
|
||||
|
||||
public :
|
||||
|
||||
void operator () (TwoOpt & __move, const Route & __route) ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
55
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_next.cpp
Normal file
55
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_next.cpp
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* <two_opt_next.cpp>
|
||||
* 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 ;
|
||||
}
|
||||
}
|
||||
52
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_next.h
Normal file
52
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_next.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* <two_opt_next.h>
|
||||
* 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 <moNextMove.h>
|
||||
|
||||
#include "two_opt.h"
|
||||
|
||||
class TwoOptNext : public moNextMove <TwoOpt> {
|
||||
|
||||
public :
|
||||
|
||||
bool operator () (TwoOpt & __move, const Route & __route);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
49
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_rand.cpp
Normal file
49
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_rand.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* <two_opt_rand.cpp>
|
||||
* 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 <utils/eoRNG.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
|
||||
52
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_rand.h
Normal file
52
trunk/paradiseo-peo/tutorial/examples/tsp/two_opt_rand.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* <two_opt_rand.h>
|
||||
* 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 <eoMoveRand.h>
|
||||
|
||||
#include "two_opt.h"
|
||||
|
||||
class TwoOptRand : public eoMoveRand <TwoOpt> {
|
||||
|
||||
public :
|
||||
|
||||
void operator () (TwoOpt & __move, const Route & __route) ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue