modif cmake configuration

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1277 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2008-12-03 14:41:25 +00:00
commit 350bdfc7de
1261 changed files with 144616 additions and 0 deletions

View file

@ -0,0 +1,45 @@
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
######################################################################################
######################################################################################
### 2) Define your target(s): just the tsp here
######################################################################################
SET(TSP_LIB_OUTPUT_PATH ${TSP_BIN_DIR}/lib)
SET(LIBRARY_OUTPUT_PATH ${TSP_LIB_OUTPUT_PATH})
SET (TSP_SOURCES graph.cpp
route_init.cpp
route_eval.cpp
part_route_eval.cpp
edge_xover.cpp
order_xover.cpp
route_valid.cpp
partial_mapped_xover.cpp
city_swap.cpp
two_opt.cpp
two_opt_init.cpp
two_opt_next.cpp
two_opt_incr_eval.cpp
two_opt_tabu_list.cpp
two_opt_rand.cpp)
ADD_LIBRARY(tsp STATIC ${TSP_SOURCES})
######################################################################################
######################################################################################
### 3) Optionnal: define your target(s)'s version: no effect for windows
######################################################################################
SET(TSP_VERSION "${GLOBAL_VERSION}")
SET_TARGET_PROPERTIES(tsp PROPERTIES VERSION "${TSP_VERSION}")
######################################################################################

View file

@ -0,0 +1,60 @@
NAME: berlin52
TYPE: TSP
COMMENT: 52 locations in Berlin (Groetschel)
DIMENSION: 52
EDGE_WEIGHT_TYPE: EUC_2D
NODE_COORD_SECTION
1 565.0 575.0
2 25.0 185.0
3 345.0 750.0
4 945.0 685.0
5 845.0 655.0
6 880.0 660.0
7 25.0 230.0
8 525.0 1000.0
9 580.0 1175.0
10 650.0 1130.0
11 1605.0 620.0
12 1220.0 580.0
13 1465.0 200.0
14 1530.0 5.0
15 845.0 680.0
16 725.0 370.0
17 145.0 665.0
18 415.0 635.0
19 510.0 875.0
20 560.0 365.0
21 300.0 465.0
22 520.0 585.0
23 480.0 415.0
24 835.0 625.0
25 975.0 580.0
26 1215.0 245.0
27 1320.0 315.0
28 1250.0 400.0
29 660.0 180.0
30 410.0 250.0
31 420.0 555.0
32 575.0 665.0
33 1150.0 1160.0
34 700.0 580.0
35 685.0 595.0
36 685.0 610.0
37 770.0 610.0
38 795.0 645.0
39 720.0 635.0
40 760.0 650.0
41 475.0 960.0
42 95.0 260.0
43 875.0 920.0
44 700.0 500.0
45 555.0 815.0
46 830.0 485.0
47 1170.0 65.0
48 830.0 610.0
49 605.0 625.0
50 595.0 360.0
51 1340.0 725.0
52 1740.0 245.0
EOF

View file

@ -0,0 +1,108 @@
NAME: eil101
TYPE: TSP
COMMENT: 101-city problem (Christofides/Eilon)
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

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,93 @@
All the instances in this directory come from the TSPLIB database. All the TSPLIB instances can be downloaded at this address:
http://www.iwr.uni-heidelberg.de/groups/comopt/software/TSPLIB95/tsp/
The accepted format is:
NAME: instance_name
TYPE: TSP
COMMENT: comments about the instance
DIMENSION: number of towns.
EDGE_WEIGHT_TYPE: EUC_2D
NODE_COORD_SECTION
1 565.0 575.0
2 25.0 185.0
3 345.0 750.0
.
.
.
.
.
.
EOF
Compatibility bugs with some TSPLIB instances (soon corrected):
==> some instances have a space after a section title, for example "NAME :" instead of "NAME:".
==> several instances have the "COMMENT:" section before the "TYPE:" section.
==> several section are not yet implemented ("DISPLAY_DATA_TYPE:", ...).
Already corrected bugs:
==> some instances have several lines with the keyword "COMMENTS:"
For instance, the Berlin52 instance:
NAME: berlin52
TYPE: TSP
COMMENT: 52 locations in Berlin (Groetschel)
DIMENSION: 52
EDGE_WEIGHT_TYPE: EUC_2D
NODE_COORD_SECTION
1 565.0 575.0
2 25.0 185.0
3 345.0 750.0
4 945.0 685.0
5 845.0 655.0
6 880.0 660.0
7 25.0 230.0
8 525.0 1000.0
9 580.0 1175.0
10 650.0 1130.0
11 1605.0 620.0
12 1220.0 580.0
13 1465.0 200.0
14 1530.0 5.0
15 845.0 680.0
16 725.0 370.0
17 145.0 665.0
18 415.0 635.0
19 510.0 875.0
20 560.0 365.0
21 300.0 465.0
22 520.0 585.0
23 480.0 415.0
24 835.0 625.0
25 975.0 580.0
26 1215.0 245.0
27 1320.0 315.0
28 1250.0 400.0
29 660.0 180.0
30 410.0 250.0
31 420.0 555.0
32 575.0 665.0
33 1150.0 1160.0
34 700.0 580.0
35 685.0 595.0
36 685.0 610.0
37 770.0 610.0
38 795.0 645.0
39 720.0 635.0
40 760.0 650.0
41 475.0 960.0
42 95.0 260.0
43 875.0 920.0
44 700.0 500.0
45 555.0 815.0
46 830.0 485.0
47 1170.0 65.0
48 830.0 610.0
49 605.0 625.0
50 595.0 360.0
51 1340.0 725.0
52 1740.0 245.0
EOF

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,50 @@
/*
* <city_swap.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 ;
}

View file

@ -0,0 +1,55 @@
/*
* <city_swap.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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

View file

@ -0,0 +1,169 @@
/*
* <edge_xover.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 "edge_xover.h"
#include "route_valid.h"
#define MAXINT 1000000
void
EdgeXover :: build_map (const Route & __par1, const Route & __par2)
{
unsigned int len = __par1.size () ;
/* Initialization */
_map.clear () ;
_map.resize (len) ;
for (unsigned int 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 int __vertex, std :: vector <std :: set <unsigned int> > & __map)
{
std :: set <unsigned int> & neigh = __map [__vertex] ;
for (std :: set <unsigned int> :: iterator it = neigh.begin () ; it != neigh.end () ; it ++)
{
__map [* it].erase (__vertex) ;
}
}
void
EdgeXover :: add_vertex (unsigned int __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 int len = __par1.size () ;
/* Go ! */
__child.clear () ;
unsigned int cur_vertex = rng.random (len) ;
add_vertex (cur_vertex, __child) ;
for (unsigned int i = 1 ; i < len ; i ++)
{
unsigned int len_min_entry = MAXINT ;
std :: set <unsigned int> & neigh = _map [cur_vertex] ;
for (std :: set <unsigned int> :: iterator it = neigh.begin () ; it != neigh.end () ; it ++)
{
unsigned int l = _map [* it].size () ;
if (len_min_entry > l)
{
len_min_entry = l ;
}
}
std :: vector <unsigned int> cand ; /* Candidates */
for (std :: set <unsigned> :: iterator it = neigh.begin () ; it != neigh.end () ; it ++)
{
unsigned int l = _map [* it].size () ;
if (len_min_entry == l)
{
cand.push_back (* it) ;
}
}
if (! cand.size ())
{
/* Oh no ! Implicit mutation */
for (unsigned int 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) ;
assert (valid (__route1)) ;
assert (valid (__route2)) ;
__route1.invalidate () ;
__route2.invalidate () ;
return true ;
}

View file

@ -0,0 +1,72 @@
/*
* <edge_xover.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 int __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 int __vertex, Route & __child) ;
std :: vector <std :: set <unsigned int> > _map ; /* The handled map */
std :: vector <bool> visited ; /* Vertices that are already visited */
} ;
#endif

View file

@ -0,0 +1,207 @@
/*
* <graph.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 "graph.h"
using std::cout;
using std::endl;
namespace Graph
{
static std :: vector <std :: pair <double, double> > vectCoord ; // Coordinates
static std :: vector <std :: vector <unsigned int> > dist ; // Distances Mat.
unsigned size ()
{
return dist.size () ;
}
void computeDistances ()
{
// Dim.
unsigned int numCities = vectCoord.size () ;
dist.resize (numCities) ;
for (unsigned int i = 0 ; i < dist.size () ; i ++)
{
dist [i].resize (numCities) ;
}
// Computations.
for (unsigned int i = 0 ; i < dist.size () ; i ++)
{
for (unsigned int j = i + 1 ; j < dist.size () ; j ++)
{
double distX = (double)(vectCoord [i].first - vectCoord [j].first) ;
double distY = (double)(vectCoord [i].second - vectCoord [j].second) ;
dist [i] [j] = dist [j] [i] = (unsigned int) (sqrt ((float) (distX * distX + distY * distY)) + 0.5) ;
}
}
}
void load (const char * _fileName)
{
unsigned int i, dimension;
std::string string_read, buffer;
std :: ifstream file (_fileName) ;
cout << endl << "\tLoading [" << _fileName << "]" << endl << endl;
if( file.is_open() )
{
// Read NAME:
file >> string_read;
if (string_read.compare("NAME:")!=0)
{
cout << "ERROR: \'NAME:\' espected, \'" << string_read << "\' found" << endl;
exit(EXIT_FAILURE);
}
// Read instance name
file >> string_read;
cout << "\t\tInstance Name = " << string_read << endl;
// Read TYPE:
file >> string_read;
if (string_read.compare("TYPE:")!=0)
{
cout << "ERROR: \'TYPE:\' espected, \'" << string_read << "\' found" << endl;
exit(EXIT_FAILURE);
}
// Read instance type;
file >> string_read;
cout << "\t\tInstance type = " << string_read << endl;
if (string_read.compare("TSP")!=0)
{
cout << "ERROR: only TSP type instance can be loaded" << endl;
exit(EXIT_FAILURE);
}
// Read COMMENT:
file >> string_read;
if (string_read.compare("COMMENT:")!=0)
{
cout << "ERROR: \'COMMENT:\' espected, \'" << string_read << "\' found" << endl;
exit(EXIT_FAILURE);
}
// Read comments
cout << "\t\tInstance comments = ";
file >> string_read;
buffer = string_read+"_first";
while((string_read.compare("DIMENSION:")!=0) && (string_read.compare(buffer)!=0))
{
if(string_read.compare("COMMENT:")!=0)
{
cout << string_read << " ";
}
else
{
cout << endl << "\t ";
}
buffer = string_read;
file >> string_read;
}
cout << endl;
// Read dimension;
file >> dimension ;
cout << "\t\tInstance dimension = " << dimension << endl;
vectCoord.resize (dimension) ;
// Read EDGE_WEIGHT_TYPE
file >> string_read;
if (string_read.compare("EDGE_WEIGHT_TYPE:")!=0)
{
cout << "ERROR: \'EDGE_WEIGHT_TYPE:\' espected, \'" << string_read << "\' found" << endl;
exit(EXIT_FAILURE);
}
// Read edge weight type
file >> string_read;
cout << "\t\tInstance edge weight type = " << string_read << endl;
if (string_read.compare("EUC_2D")!=0)
{
cout << "ERROR: only EUC_2D edge weight type instance can be loaded" << endl;
exit(EXIT_FAILURE);
}
// Read NODE_COORD_SECTION
file >> string_read;
if (string_read.compare("NODE_COORD_SECTION")!=0)
{
cout << "ERROR: \'NODE_COORD_SECTION\' espected, \'" << string_read << "\' found" << endl;
exit(EXIT_FAILURE);
}
// Read coordonates.
for(i=0;i<dimension;i++)
{
// Read index
file >> string_read;
//Read Coordinate
file >> vectCoord [i].first >> vectCoord [i].second ;
}
// Read EOF
file >> string_read;
if(string_read.compare("EOF")!=0)
{
cout << "ERROR: \'EOF\' espected, \'" << string_read << "\' found" << endl;
exit(EXIT_FAILURE);
}
cout << endl;
file.close () ;
computeDistances () ;
}
else
{
cout << _fileName << " does not exist !!!" << endl ;
exit(EXIT_FAILURE) ;
}
}
float distance (unsigned int _from, unsigned int _to)
{
return (float)(dist [_from] [_to]) ;
}
}

View file

@ -0,0 +1,61 @@
/*
* <graph.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 graph_h
#define graph_h
#include <string>
#include <vector>
#include <utility>
#include <fstream>
#include <iostream>
#include <math.h>
#include <stdlib.h>
namespace Graph
{
void load (const char * _file_name) ;
/* Loading cities
(expressed by their coordinates)
from the given file name */
float distance (unsigned int _from, unsigned int _to) ;
unsigned int size () ; // How many cities ?
}
#endif

View file

@ -0,0 +1,50 @@
/*
* <mix.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 <utils/eoRNG.h>
template <class T> void mix (std :: vector <T> & __vect)
{
for (unsigned int i = 0 ; i < __vect.size () ; i ++)
{
std :: swap (__vect [i], __vect [rng.random (__vect.size ())]) ;
}
}
#endif

View file

@ -0,0 +1,119 @@
/*
* <order_xover.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 <vector>
#include <utils/eoRNG.h>
#include "order_xover.h"
#include "route_valid.h"
void OrderXover :: cross (const Route & __par1, const Route & __par2, Route & __child)
{
unsigned int cut = rng.random (__par1.size ()) ;
/* To store vertices that have
already been crossed */
std::vector<bool> v;
v.resize(__par1.size());
for (unsigned int i = 0 ; i < __par1.size () ; i ++)
{
v [i] = false ;
}
/* Copy of the left partial
route of the first parent */
for (unsigned int i = 0 ; i < cut ; i ++)
{
__child [i] = __par1 [i] ;
v [__par1 [i]] = true ;
}
/* Searching the vertex of the second path, that ended
the previous first one */
unsigned int from = 0 ;
for (unsigned int i = 0 ; i < __par2.size () ; i ++)
{
if (__par2 [i] == __child [cut - 1])
{
from = i ;
break ;
}
}
/* Selecting a direction
Left or Right */
char direct = rng.flip () ? 1 : -1 ;
/* Copy of the left vertices from
the second parent path */
unsigned int l = cut ;
for (unsigned int i = 0 ; i < __par2.size () ; i ++)
{
unsigned int bidule /* :-) */ = (direct * i + from + __par2.size ()) % __par2.size () ;
if (! v [__par2 [bidule]])
{
__child [l ++] = __par2 [bidule] ;
v [__par2 [bidule]] = true ;
}
}
v.clear();
}
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) ;
assert (valid (__route1)) ;
assert (valid (__route2)) ;
__route1.invalidate () ;
__route2.invalidate () ;
return true ;
}

View file

@ -0,0 +1,57 @@
/*
* <order_xover.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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

View file

@ -0,0 +1,53 @@
/*
* <part_route_eval.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 "graph.h"
PartRouteEval :: PartRouteEval (float __from, float __to) : from (__from), to (__to)
{}
void PartRouteEval :: operator () (Route & __route)
{
float len = 0 ;
for (unsigned int i = (unsigned int) (__route.size () * from) ; i < (unsigned int ) (__route.size () * to) ; i ++)
{
len += Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ;
}
__route.fitness (len) ;
}

View file

@ -0,0 +1,62 @@
/*
* <part_route_eval.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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

View file

@ -0,0 +1,45 @@
/*
* <part_two_opt_init.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 "part_two_opt_init.h"
void PartTwoOptInit :: operator () (TwoOpt & __move, const Route & __route)
{
__move.first = rng.random (__route.size () - 6) ;
__move.second = __move.first + 2 ;
}

View file

@ -0,0 +1,54 @@
/*
* <part_two_opt_init.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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_two_opt_init_h
#define part_two_opt_init_h
#include <moMoveInit.h>
#include "two_opt.h"
/** It sets the first couple of edges */
class PartTwoOptInit : public moMoveInit <TwoOpt>
{
public :
void operator () (TwoOpt & __move, const Route & __route) ;
} ;
#endif

View file

@ -0,0 +1,57 @@
/*
* <part_two_opt_next.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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_two_opt_next.h"
#include "graph.h"
bool TwoOptNext :: operator () (TwoOpt & __move, const Route & __route)
{
if (__move.first == Graph :: size () - 4 && __move.second == __move.first + 2)
{
return false ;
}
else
{
__move.second ++ ;
if (__move.second == Graph :: size () - 1)
{
__move.first ++ ;
__move.second = __move.first + 2 ;
}
return true ;
}
}

View file

@ -0,0 +1,53 @@
/*
* <part_two_opt_next.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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_two_opt_next_h
#define part_two_opt_next_h
#include <moNextMove.h>
#include "two_opt.h"
/** It updates a couple of edges */
class PartTwoOptNext : public moNextMove <TwoOpt>
{
public :
bool operator () (TwoOpt & __move, const Route & __route) ;
} ;
#endif

View file

@ -0,0 +1,118 @@
/*
* <partial_mapped_xover.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 <vector>
#include <utils/eoRNG.h>
#include "partial_mapped_xover.h"
#include "route_valid.h"
#include "mix.h"
void PartialMappedXover :: repair (Route & __route, unsigned __cut1, unsigned __cut2)
{
std::vector<unsigned int> v; // Number of times a cities are visited ...
v.resize(__route.size ());
for (unsigned int i = 0 ; i < __route.size () ; i ++)
{
v [i] = 0 ;
}
for (unsigned int i = 0 ; i < __route.size () ; i ++)
{
v [__route [i]] ++ ;
}
std :: vector <unsigned int> vert ;
for (unsigned int i = 0 ; i < __route.size () ; i ++)
{
if (! v [i])
{
vert.push_back (i) ;
}
}
mix (vert) ;
for (unsigned int i = 0 ; i < __route.size () ; i ++)
{
if (i < __cut1 || i >= __cut2)
{
if (v [__route [i]] > 1)
{
__route [i] = vert.back () ;
vert.pop_back () ;
}
}
}
v.clear();
}
bool PartialMappedXover :: operator () (Route & __route1, Route & __route2)
{
unsigned int cut1 = rng.random (__route1.size ()), cut2 = rng.random (__route2.size ()) ;
if (cut2 < cut1)
{
std :: swap (cut1, cut2) ;
}
// Between the cuts
for (unsigned int i = cut1 ; i < cut2 ; i ++)
{
std :: swap (__route1 [i], __route2 [i]) ;
}
// Outside the cuts
repair (__route1, cut1, cut2) ;
repair (__route2, cut1, cut2) ;
// Debug
assert (valid (__route1)) ;
assert (valid (__route2)) ;
__route1.invalidate () ;
__route2.invalidate () ;
return true ;
}

View file

@ -0,0 +1,57 @@
/*
* <partial_mapped_xover.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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

View file

@ -0,0 +1,48 @@
/*
* <route.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 <eoScalarFitness.h>
// A float that has to be minimized.
typedef eoScalarFitness< float, std::greater<float> > tspFitness ;
typedef eoVector <tspFitness, unsigned int> Route ; // [Fitness (length), Gene (city)]
#endif

View file

@ -0,0 +1,51 @@
/*
* <route_eval.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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"
#include "graph.h"
void RouteEval :: operator () (Route & __route)
{
float len = 0.0 ;
for (unsigned int i = 0 ; i < Graph :: size () ; i ++)
{
len += Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ;
}
__route.fitness (len) ;
}

View file

@ -0,0 +1,55 @@
/*
* <route_eval.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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"
/** Route Evaluator */
class RouteEval : public eoEvalFunc <Route>
{
public :
void operator () (Route & __route) ;
} ;
#endif

View file

@ -0,0 +1,63 @@
/*
* <route_init.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 "graph.h"
void RouteInit :: operator () (Route & __route)
{
// Init.
__route.clear () ;
for (unsigned int i = 0 ; i < Graph :: size () ; i ++)
{
__route.push_back (i) ;
}
// Swap. cities
for (unsigned int i = 0 ; i < Graph :: size () ; i ++)
{
//unsigned int j = rng.random (Graph :: size ()) ;
unsigned int j = (unsigned int) (Graph :: size () * (rand () / (RAND_MAX + 1.0))) ;
unsigned int city = __route [i] ;
__route [i] = __route [j] ;
__route [j] = city ;
}
}

View file

@ -0,0 +1,53 @@
/*
* <route_init.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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

View file

@ -0,0 +1,68 @@
/*
* <route_valid.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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_valid.h"
#include <vector>
bool valid (Route & __route)
{
std::vector<unsigned int> t;
t.resize(__route.size());
for (unsigned int i = 0 ; i < __route.size () ; i ++)
{
t [i] = 0 ;
}
for (unsigned int i = 0 ; i < __route.size () ; i ++)
{
t [__route [i]] ++ ;
}
for (unsigned int i = 0 ; i < __route.size () ; i ++)
{
if (t [i] != 1)
{
t.clear();
return false ;
}
}
t.clear();
return true ; // OK.
}

View file

@ -0,0 +1,44 @@
/*
* <route_valid.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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_valid_h
#define route_valid_h
#include "route.h"
bool valid (Route & __route) ;
#endif

View file

@ -0,0 +1,41 @@
/*
* <tsp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
*
* 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 __tsp
#define __tsp
#include "tsp.h"
#endif

View file

@ -0,0 +1,60 @@
/*
* <tsp.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
*
* 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 __tsp_h
#define __tsp_h
#include "city_swap.h"
#include "edge_xover.h"
#include "graph.h"
#include "mix.h"
#include "order_xover.h"
#include "partial_mapped_xover.h"
#include "part_route_eval.h"
#include "part_two_opt_init.h"
#include "part_two_opt_next.h"
#include "route_eval.h"
#include "route.h"
#include "route_init.h"
#include "route_valid.h"
#include "two_opt.h"
#include "two_opt_incr_eval.h"
#include "two_opt_init.h"
#include "two_opt_next.h"
#include "two_opt_rand.h"
#include "two_opt_tabu_list.h"
#endif

View file

@ -0,0 +1,72 @@
/*
* <two_opt.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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"
TwoOpt TwoOpt :: operator ! () const
{
TwoOpt move = * this ;
std :: swap (move.first, move.second) ;
return move ;
}
void TwoOpt :: operator () (Route & __route)
{
std :: vector <unsigned int> seq_cities ;
for (unsigned int i = second ; i > first ; i --)
{
seq_cities.push_back (__route [i]) ;
}
unsigned int j = 0 ;
for (unsigned int i = first + 1 ; i < second + 1 ; i ++)
{
__route [i] = seq_cities [j ++] ;
}
}
void TwoOpt :: readFrom (std :: istream & __is)
{
__is >> first >> second ;
}
void TwoOpt :: printOn (std :: ostream & __os) const
{
__os << first << ' ' << second ;
}

View file

@ -0,0 +1,61 @@
/*
* <two_opt.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 <eoPersistent.h>
#include <utility>
#include <moMove.h>
#include "route.h"
class TwoOpt : public moMove <Route>, public std :: pair <unsigned, unsigned>, public eoPersistent
{
public :
TwoOpt operator ! () const ;
void operator () (Route & __route) ;
void readFrom (std :: istream & __is) ;
void printOn (std :: ostream & __os) const ;
} ;
#endif

View file

@ -0,0 +1,53 @@
/*
* <two_opt_incr_eval.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 "graph.h"
tspFitness TwoOptIncrEval :: operator () (const TwoOpt & __move, const Route & __route)
{
// From
unsigned int v1 = __route [__move.first], v1_next = __route [__move.first + 1] ;
// To
unsigned int v2 = __route [__move.second], v2_next = __route [__move.second + 1] ;
return __route.fitness ()
+ Graph :: distance (v1, v2)
+ Graph :: distance (v1_next, v2_next)
- Graph :: distance (v1, v1_next)
- Graph :: distance (v2, v2_next) ;
}

View file

@ -0,0 +1,51 @@
/*
* <two_opt_incr_eval.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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_optincr_eval_h
#define two_optincr_eval_h
#include <moMoveIncrEval.h>
#include "two_opt.h"
class TwoOptIncrEval : public moMoveIncrEval <TwoOpt>
{
public :
tspFitness operator () (const TwoOpt & __move, const Route & __route) ;
} ;
#endif

View file

@ -0,0 +1,45 @@
/*
* <two_opt_init.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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)
{
Route route=_route;
_move.first = 0 ;
_move.second = 2 ;
}

View file

@ -0,0 +1,54 @@
/*
* <two_opt_init.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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"
/** It sets the first couple of edges */
class TwoOptInit : public moMoveInit <TwoOpt>
{
public :
void operator () (TwoOpt & _move, const Route & _route) ;
} ;
#endif

View file

@ -0,0 +1,59 @@
/*
* <two_opt_next.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 "graph.h"
bool TwoOptNext :: operator () (TwoOpt & _move, const Route & _route)
{
Route route=_route;
if (_move.first == Graph :: size () - 4 && _move.second == _move.first + 2)
{
return false ;
}
else
{
_move.second ++ ;
if (_move.second == Graph :: size () - 1)
{
_move.first ++ ;
_move.second = _move.first + 2 ;
}
return true ;
}
}

View file

@ -0,0 +1,53 @@
/*
* <two_opt_next.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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"
/** It updates a couple of edges */
class TwoOptNext : public moNextMove <TwoOpt>
{
public :
bool operator () (TwoOpt & _move, const Route & _route) ;
} ;
#endif

View file

@ -0,0 +1,45 @@
/*
* <two_opt_rand.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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_rand.h"
#include "graph.h"
#include <utils/eoRNG.h>
void TwoOptRand :: operator () (TwoOpt & __move)
{
__move.first = rng.random (Graph :: size () - 3) ;
__move.second = __move.first + 2 + rng.random (Graph :: size () - __move.first - 3) ;
}

View file

@ -0,0 +1,53 @@
/*
* <two_opt_rand.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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 <moRandMove.h>
#include "two_opt.h"
class TwoOptRand : public moRandMove <TwoOpt>
{
public :
void operator () (TwoOpt & __move) ;
} ;
#endif

View file

@ -0,0 +1,93 @@
/*
* <two_opt_tabu_list.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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_tabu_list.h"
#include "graph.h"
#define TABU_LENGTH 10
void
TwoOptTabuList :: init ()
{
// Size (eventually)
tabu_span.resize (Graph :: size ()) ;
for (unsigned int i = 0 ; i < tabu_span.size () ; i ++)
{
tabu_span [i].resize (Graph :: size ()) ;
}
// Clear
for (unsigned int i = 0 ; i < tabu_span.size () ; i ++)
{
for (unsigned int j = 0 ; j < tabu_span [i].size () ; j ++)
{
tabu_span [i] [j] = 0 ;
}
}
}
bool
TwoOptTabuList :: operator () (const TwoOpt & _move, const Route & _route)
{
Route route=_route;
return tabu_span [_move.first] [_move.second] > 0 ;
}
void
TwoOptTabuList :: add (const TwoOpt & _move, const Route & _route)
{
Route route=_route;
tabu_span [_move.first] [_move.second] = tabu_span [_move.second] [_move.first] = TABU_LENGTH ;
}
void
TwoOptTabuList :: update ()
{
unsigned int i,j;
for (i = 0 ; i < tabu_span.size () ; i ++)
{
for (j = 0 ; j < tabu_span [i].size () ; j ++)
{
if ( tabu_span [i] [j] > 0 )
{
tabu_span [i] [j] -- ;
}
}
}
}

View file

@ -0,0 +1,63 @@
/*
* <two_opt_tabu_list.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sébastien Cahon, Jean-Charles Boisson
*
* 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_tabu_list_h
#define two_opt_tabu_list_h
#include <moTabuList.h>
#include "two_opt.h"
#include "route.h"
/** The table of tabu movements, i.e. forbidden edges */
class TwoOptTabuList : public moTabuList <TwoOpt>
{
public :
bool operator () (const TwoOpt & _move, const Route & _route) ;
void add (const TwoOpt & _move, const Route & _route) ;
void update () ;
void init () ;
private :
std :: vector <std :: vector <unsigned> > tabu_span ;
} ;
#endif