- Main Page
- Namespaces
- Classes
- Files

- Search for |

# iterated_local_search.cpp

    00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003 // "iterated_local_search.cpp"
    00004
    00005 // (c) OPAC Team, LIFL, 2003-2007
    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_init.h>
    00021 #include <two_opt_next.h>
    00022 #include <two_opt_incr_eval.h>
    00023 #include <two_opt_tabu_list.h>
    00024 #include <two_opt_rand.h>
    00025
    00026 #include <city_swap.h>
    00027
    00028 int
    00029 main (int __argc, char * __argv [])
    00030 {
    00031   if (__argc != 2)
    00032     {
    00033       std :: cerr << "Usage : ./iterated_local_search [instance]" << std :: endl ;
    00034       return 1 ;
    00035     }
    00036
    00037   Graph :: load (__argv [1]) ; // Instance
    00038
    00039   Route route ; // Solution
    00040
    00041   RouteInit init ; // Sol. Random Init.
    00042   init (route) ;
    00043
    00044   RouteEval full_eval ; // Full. Eval.
    00045   full_eval (route) ;
    00046
    00047   std :: cout << "[From] " << route << std :: endl ;
    00048
    00049   /* Tools for an efficient (? :-))
    00050      local search ! */
    00051
    00052   TwoOptInit two_opt_init ; // Init.
    00053
    00054   TwoOptNext two_opt_next ; // Explorer.
    00055
    00056   TwoOptIncrEval two_opt_incr_eval ; // Eff. eval.
    00057
    00058   moBestImprSelect <TwoOpt> two_opt_select ;
    00059
    00060   //moHC<TwoOpt> hill_climbing (two_opt_init, two_opt_next, two_opt_incr_eval, two_opt_select, full_eval) ;
    00061
    00062   moGenSolContinue <Route> cont (1000) ;
    00063
    00064   moFitComparator<Route> comparator;
    00065
    00066   CitySwap perturbation;
    00067
    00068   //moILS<TwoOpt> iterated_local_search (hill_climbing, cont, comparator, perturbation, full_eval) ;
    00069   //moILS<TwoOpt> iterated_local_search (two_opt_init, two_opt_next, two_opt_incr_eval,
    00070   //                           two_opt_select, cont, comparator, perturbation, full_eval) ;
    00071
    00072   moGenSolContinue <Route> ts_cont (100) ;
    00073
    00074   TwoOptTabuList tabu_list ; // Tabu List
    00075   moNoAspirCrit <TwoOpt> aspir_crit ; // Aspiration Criterion
    00076
    00077   //moILS<TwoOpt> iterated_local_search (two_opt_init, two_opt_next, two_opt_incr_eval, tabu_list, aspir_crit, ts_cont,
    00078   //                                   cont, comparator, perturbation, full_eval) ;
    00079
    00080   TwoOptRand two_opt_rand ; // Route Random. Gen.
    00081
    00082   moExponentialCoolingSchedule cool_sched (0.1, 0.98) ; // Exponential Cooling Schedule
    00083
    00084   moGenSolContinue <Route> sa_cont (100) ;
    00085
    00086   moILS<TwoOpt> iterated_local_search (two_opt_rand, two_opt_incr_eval, sa_cont, 100, cool_sched,
    00087                                        cont, comparator, perturbation, full_eval) ;
    00088
    00089   iterated_local_search(route) ;
    00090
    00091   std :: cout << "[To] " << route << std :: endl ;
    00092
    00093   return 0 ;
    00094 }
    00095