moved utilities and contribution in branchez
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2183 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
6c3383d718
commit
8280cf082b
1346 changed files with 0 additions and 0 deletions
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
|
||||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src/utils)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/tsp/src)
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${CMAKE_BINARY_DIR}/tsp/src)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
ADD_EXECUTABLE(hill_climbing hill_climbing.cpp)
|
||||
|
||||
ADD_DEPENDENCIES(hill_climbing tsp)
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 4) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(hill_climbing tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
// "hill_climbing.cpp"
|
||||
|
||||
// (c) OPAC Team, LIFL, 2003-2006
|
||||
|
||||
/* LICENCE TEXT
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#include <mo.h>
|
||||
|
||||
#include <graph.h>
|
||||
#include <route.h>
|
||||
#include <route_eval.h>
|
||||
#include <route_init.h>
|
||||
|
||||
#include <two_opt.h>
|
||||
#include <two_opt_init.h>
|
||||
#include <two_opt_next.h>
|
||||
#include <two_opt_incr_eval.h>
|
||||
|
||||
int
|
||||
main (int __argc, char * __argv [])
|
||||
{
|
||||
if (__argc != 2) {
|
||||
|
||||
std :: cerr << "Usage : ./hill_climbing [instance]" << std :: endl ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
srand (1000) ;
|
||||
|
||||
Graph :: load (__argv [1]) ; // Instance
|
||||
|
||||
Route route ; // Solution
|
||||
|
||||
RouteInit init ; // Sol. Random Init.
|
||||
init (route) ;
|
||||
|
||||
RouteEval full_eval ; // Full. Eval.
|
||||
full_eval (route) ;
|
||||
|
||||
std :: cout << "[From] " << route << std :: endl ;
|
||||
|
||||
/* Tools for an efficient (? :-))
|
||||
local search ! */
|
||||
|
||||
TwoOptInit two_opt_init ; // Init.
|
||||
|
||||
TwoOptNext two_opt_next ; // Explorer.
|
||||
|
||||
TwoOptIncrEval two_opt_incr_eval ; // Eff. eval.
|
||||
|
||||
//moFirstImprSelect <TwoOpt> two_opt_select ;
|
||||
moBestImprSelect <TwoOpt> two_opt_select ;
|
||||
//moRandImprSelect <TwoOpt> two_opt_select ;
|
||||
|
||||
moHC <TwoOpt> hill_climbing (two_opt_init, two_opt_next, two_opt_incr_eval, two_opt_select, full_eval) ;
|
||||
hill_climbing (route) ;
|
||||
|
||||
std :: cout << "[To] " << route << std :: endl ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
|
@ -0,0 +1,96 @@
|
|||
\documentclass[a4paper]{article}
|
||||
|
||||
\usepackage[english]{babel}
|
||||
\usepackage{epsf}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{here}
|
||||
\usepackage{comment}
|
||||
\usepackage{graphicx}
|
||||
|
||||
\topmargin -2.5cm
|
||||
\textheight 25,5cm
|
||||
\textwidth 16cm
|
||||
\oddsidemargin 0cm
|
||||
\evensidemargin 0cm
|
||||
|
||||
|
||||
\begin{document}
|
||||
|
||||
\textbf{ParadisEO Practices} {\copyright Franck Seynhaeve,
|
||||
Jean-Charles Boisson, Thomas Legrand} \Large{\textbf{\\\\
|
||||
Lesson 2: Implement a Hill-Climbing using ParadisEO}}
|
||||
|
||||
\normalsize
|
||||
|
||||
\vspace{-0,3cm}
|
||||
|
||||
\section{Example}
|
||||
|
||||
The archive {\tt paradiseo\_practices\_0208.tgz} installed
|
||||
on your computer contains a Hill-Climbing implemented using ParadisEO-MO~
|
||||
(see {\tt hill\_climbing} in the {\bf build/lesson2} directory).
|
||||
|
||||
\medskip
|
||||
To run it, please go in {\bf build/lesson2} and start the program {\tt hill\_climbing} by giving
|
||||
one of the TSP instances located in {\bf tsp/benchs}.
|
||||
|
||||
|
||||
\medskip
|
||||
When entering {\tt ./hill\_climbing ../../tsp/benchs/berlin52.tsp}, you should end up with the
|
||||
following outputs:
|
||||
|
||||
\smallskip
|
||||
\noindent
|
||||
\texttt{>> Loading [../../tsp/benchs/eil101.tsp]} \\
|
||||
\texttt{[From] -3435 101 36 55 54 65 50 80 14 27 46 15 93 58 78 47 99 64 68}\\
|
||||
\texttt{49 72 81 82 76 41 16 66 30 29 83 95 71 38 35 19 5 63 26 43 96 79 52}\\
|
||||
\texttt{59 69 7 56 37 3 32 28 9 13 1 91 31 73 11 40 62 17 24 45 88 6 85 22}\\
|
||||
\texttt{18 20 44 94 12 33 60 89 74 42 97 21 100 57 77 92 98 51 2 25 75 10 86}\\
|
||||
\texttt{8 23 67 70 34 90 87 48 53 0 39 4 84 61}\\
|
||||
\texttt{[To] -708 101 36 97 91 58 95}\\
|
||||
\texttt{98 92 84 99 90 43 13 37 85 15 60 16 83 4 59 82 44 7 45 35 48 63 10}\\
|
||||
\texttt{18 46 47 81 17 51 26 27 25 39 57 52 100 88 5 93 94 12 1 56 86 96 41}\\
|
||||
\texttt{42 14 40 21 73 71 72 20 3 55 74 22 66 38 24 54 53 23 28 78 2 76 67}\\
|
||||
\texttt{79 11 75 68 0 49 32 80 77 33 50 8 34 70 64 65 19 29 69 31 89 62 9 30}\\
|
||||
\texttt{87 6 61}\\
|
||||
|
||||
The printed-out results show for the initial best solution and the final one~:
|
||||
\\ \hspace*{0.5cm}-the length of the route
|
||||
\\ \hspace*{0.5cm}-the number of cities
|
||||
\\ \hspace*{0.5cm}-the route itself (notice that the city index starts from 0).
|
||||
|
||||
|
||||
\section{Tabu search}
|
||||
|
||||
Study the {\tt hill\_climbing.cpp} file located in the {\bf lesson2} directory
|
||||
using~:
|
||||
\begin{itemize}
|
||||
\item[$\bullet$] the ParadisEO-MO API documentation available at~:
|
||||
|
||||
\hspace{1cm}http$\,:$//paradiseo.gforge.inria.fr/addon/paradiseo-mo/doc/index.html
|
||||
\item[$\bullet$] the source files located in the {\bf tsp/src/} directory
|
||||
\end{itemize}
|
||||
|
||||
\section{Customize the Hill CLimbing}
|
||||
|
||||
Make a backup (copy) of the cpp file {\tt tabuhill\_climbing.cpp}. You can now modify the
|
||||
original {\tt hill\_climbing.cpp} and use the existing makefiles to compile it.
|
||||
|
||||
Edit and modify the {\tt hill\_climbing.cpp} file~:
|
||||
\begin{itemize}
|
||||
\item[$\bullet$] Try to tune a few parameters (random seed
|
||||
and the move selector) and observe the changes on the final
|
||||
solution.
|
||||
|
||||
\end{itemize}
|
||||
|
||||
\smallskip
|
||||
To compile {\tt hill\_climbing.cpp}, you should use the
|
||||
command {\tt make} from {\bf build/lesson2}.
|
||||
|
||||
\medskip
|
||||
Finally, test your modifications on several TSP instances ({\tt berlin52},
|
||||
{\tt eil101} ...) and compare the results you get.
|
||||
|
||||
|
||||
\end{document}
|
||||
Loading…
Add table
Add a link
Reference in a new issue