added practices to version control

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1002 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
legrand 2008-02-25 13:56:53 +00:00
commit 22c6962aa2
72 changed files with 25134 additions and 0 deletions

View file

@ -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(simulated_annealing simulated_annealing.cpp)
ADD_DEPENDENCIES(simulated_annealing tsp)
######################################################################################
######################################################################################
### 4) Link the librairies for your target(s)
######################################################################################
TARGET_LINK_LIBRARIES(simulated_annealing tsp eo eoutils)
######################################################################################

View file

@ -0,0 +1,88 @@
\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 4: Implement a tabu search using ParadisEO}}
\normalsize
\vspace{-0,3cm}
\section{Example}
The archive {\tt paradiseo\_practices\_0208.tgz} installed
on your computer contains a tabu search implemented using ParadisEO-MO~
(see {\tt tabu\_search} in the {\bf build/lesson4} directory).
\medskip
To run it, please go in {\bf build/lesso4} and start the program {\tt tabu\_search} by giving
one of the TSP instances located in {\bf tsp/benchs}.
\medskip
When entering {\tt ./tabu\_search ../../tsp/benchs/berlin52.tsp}, you should end up with the
following outputs:
\smallskip
\noindent
\texttt{>> Loading [../tsp/benchs/berlin52.tsp]}\\
\texttt{[From] -29414 52 1 20 40 48 9 27 13 22 5 28 24 29 21 26 44 38 33 37 45 31 42 18 12 3 14}\\
\texttt{36 30 6 51 32 17 11 0 34 4 10 4350 16 2 23 35 19 46 49 39 25 15 41 8 7 47}\\
\texttt{[To] -8724 52 1 6 41 29 22 19 49 15 28 46 13 51 12 25 26 27 11 10 50 32 42 9 8 7 40 18}\\
\texttt{44 2 16 20 30 17 21 0 31 48 35 3438 39 37 36 33 43 45 24 3 5 4 14 23 47}\\
The printed-out results show for the initial best solution and the final one~:
\\ \hspace*{1cm}-the length of the route
\\ \hspace*{1cm}-the number of cities
\\ \hspace*{1cm}-the route itself (notice that the city index starts from 0).
\section{Study the tabu search dedicated components}
Study the {\tt tabu\_search.cpp} file located in the {\bf lesson4} 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 tabu search}
Make a backup (copy) of the cpp file {\tt tabu\_search.cpp}. You can now modify the
original {\tt tabu\_search.cpp} and use the existing makefiles to compile it.
Edit and modify the {\tt tabu\_search.cpp} file~:
\begin{itemize}
\item[$\bullet$] Try to tune a few parameters of the tabu search.
\item[$\bullet$] Change the initialization of the solution by
modifying the file {\tt route\_init.cpp}.
\end{itemize}
\smallskip
To compile {\tt tabu\_search.cpp},you should use the
command {\tt make} from {\bf build/lesson4}.
\medskip
Finally, test your modifications on several TSP instances ({\tt berlin52},
{\tt eil101} ...) and compare the results you get.
\end{document}

View file

@ -0,0 +1,67 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
// "simulated_annealing.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_rand.h>
#include <two_opt_incr_eval.h>
int
main (int __argc, char * __argv [])
{
if (__argc != 2)
{
std :: cerr << "Usage : ./simulated_annealing [instance]" << std :: endl ;
return 1 ;
}
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 ! */
TwoOptRand two_opt_rand ; // Route Random. Gen.
TwoOptIncrEval two_opt_incr_eval ; // Eff. eval.
TwoOpt move ;
moExponentialCoolingSchedule cool_sched (0.1, 0.98) ; // Exponential Cooling Schedule
//moLinearCoolingSchedule cool_sched (0.1, 0.5) ; // Linear Cooling Schedule
moGenSolContinue <Route> cont (1000) ; /* Temperature Descreasing
will occur each 1000
iterations */
moSA <TwoOpt> simulated_annealing (two_opt_rand, two_opt_incr_eval, cont, 1000, cool_sched, full_eval) ;
simulated_annealing (route) ;
std :: cout << "[To] " << route << std :: endl ;
return 0 ;
}