simulated_annealing.cpp

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 // "simulated_annealing.cpp"
00004 
00005 // (c) OPAC Team, LIFL, 2003-2006
00006 
00007 /* LICENCE TEXT
00008 
00009    Contact:  paradiseo-help@lists.gforge.inria.fr
00010 */
00011 
00012 #include <mo.h>
00013 
00014 #include <graph.h>
00015 #include <route.h>
00016 #include <route_eval.h>
00017 #include <route_init.h>
00018 
00019 #include <two_opt.h>
00020 #include <two_opt_rand.h>
00021 #include <two_opt_incr_eval.h>
00022 
00023 int
00024 main (int __argc, char * __argv []) 
00025 {
00026   if (__argc != 2) 
00027     {
00028       std :: cerr << "Usage : ./simulated_annealing [instance]" << std :: endl ;
00029       return 1 ;
00030     }
00031   
00032   Graph :: load (__argv [1]) ; // Instance
00033 
00034   Route route ; // Solution
00035   
00036   RouteInit init ; // Sol. Random Init.
00037   init (route) ;
00038 
00039   RouteEval full_eval ; // Full. Eval.
00040   full_eval (route) ;
00041   
00042   std :: cout << "[From] " << route << std :: endl ;
00043   
00044   /* Tools for an efficient (? :-))
00045      local search ! */
00046   
00047   TwoOptRand two_opt_rand ; // Route Random. Gen.
00048      
00049   TwoOptIncrEval two_opt_incr_eval ; // Eff. eval.
00050   
00051   TwoOpt move ;
00052   
00053   moExponentialCoolingSchedule cool_sched (0.1, 0.98) ; // Exponential Cooling Schedule 
00054   //moLinearCoolingSchedule cool_sched (0.1, 0.5) ; // Linear Cooling Schedule 
00055   
00056   moGenSolContinue <Route> cont (1000) ; /* Temperature Descreasing
00057                                             will occur each 1000
00058                                             iterations */ 
00059   
00060   moSA <TwoOpt> simulated_annealing (two_opt_rand, two_opt_incr_eval, cont, 1000, cool_sched, full_eval) ;
00061   simulated_annealing (route) ;
00062 
00063   std :: cout << "[To] " << route << std :: endl ;
00064   
00065   return 0 ;
00066 }
00067 

Generated on Thu Sep 20 11:30:28 2007 for ParadisEO-MOMovingObjects by  doxygen 1.5.2