- Main Page
- Namespaces
- Classes
- Files

- Search for |

# hill_climbing.cpp

    00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003 // "hill_climbing.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_init.h>
    00021 #include <two_opt_next.h>
    00022 #include <two_opt_incr_eval.h>
    00023
    00024 int
    00025 main (int __argc, char * __argv [])
    00026 {
    00027   if (__argc != 2) {
    00028
    00029     std :: cerr << "Usage : ./hill_climbing [instance]" << std :: endl ;
    00030     return 1 ;
    00031   }
    00032
    00033   srand (1000) ;
    00034
    00035   Graph :: load (__argv [1]) ; // Instance
    00036
    00037   Route route ; // Solution
    00038
    00039   RouteInit init ; // Sol. Random Init.
    00040   init (route) ;
    00041
    00042   RouteEval full_eval ; // Full. Eval.
    00043   full_eval (route) ;
    00044
    00045   std :: cout << "[From] " << route << std :: endl ;
    00046
    00047   /* Tools for an efficient (? :-))
    00048      local search ! */
    00049
    00050   TwoOptInit two_opt_init ; // Init.
    00051
    00052   TwoOptNext two_opt_next ; // Explorer.
    00053
    00054   TwoOptIncrEval two_opt_incr_eval ; // Eff. eval.
    00055
    00056   //moFirstImprSelect <TwoOpt> two_opt_select ;
    00057   moBestImprSelect <TwoOpt> two_opt_select ;
    00058   //moRandImprSelect <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   hill_climbing (route) ;
    00062
    00063   std :: cout << "[To] " << route << std :: endl ;
    00064
    00065   return 0 ;
    00066 }
    00067