mainEALS.cpp

00001 /*
00002 * <mainEALS.cpp>
00003 * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
00004 * (C) OPAC Team, INRIA, 2008
00005 *
00006 * Clive Canape
00007 *
00008 * This software is governed by the CeCILL license under French law and
00009 * abiding by the rules of distribution of free software.  You can  use,
00010 * modify and/ or redistribute the software under the terms of the CeCILL
00011 * license as circulated by CEA, CNRS and INRIA at the following URL
00012 * "http://www.cecill.info".
00013 *
00014 * As a counterpart to the access to the source code and  rights to copy,
00015 * modify and redistribute granted by the license, users are provided only
00016 * with a limited warranty  and the software's author,  the holder of the
00017 * economic rights,  and the successive licensors  have only  limited liability.
00018 *
00019 * In this respect, the user's attention is drawn to the risks associated
00020 * with loading,  using,  modifying and/or developing or reproducing the
00021 * software by the user in light of its specific status of free software,
00022 * that may mean  that it is complicated to manipulate,  and  that  also
00023 * therefore means  that it is reserved for developers  and  experienced
00024 * professionals having in-depth computer knowledge. Users are therefore
00025 * encouraged to load and test the software's suitability as regards their
00026 * requirements in conditions enabling the security of their systems and/or
00027 * data to be ensured and,  more generally, to use and operate it in the
00028 * same conditions as regards security.
00029 * The fact that you are presently reading this means that you have had
00030 * knowledge of the CeCILL license and that you accept its terms.
00031 *
00032 * ParadisEO WebSite : http://paradiseo.gforge.inria.fr
00033 * Contact: paradiseo-help@lists.gforge.inria.fr
00034 *
00035 */
00036 
00037 #include "param.h"
00038 #include "route_init.h"
00039 #include "route_eval.h"
00040 #include "order_xover.h"
00041 #include "edge_xover.h"
00042 #include "partial_mapped_xover.h"
00043 #include "city_swap.h"
00044 #include "part_route_eval.h"
00045 #include "merge_route_eval.h"
00046 #include "two_opt_init.h"
00047 #include "two_opt_next.h"
00048 #include "two_opt_incr_eval.h"
00049 
00050 #include <peo>
00051 
00052 #define POP_SIZE 10
00053 #define NUM_GEN 100
00054 #define CROSS_RATE 1.0
00055 #define MUT_RATE 0.01
00056 
00057 
00058 int main (int __argc, char * * __argv)
00059 {
00060 
00061   peo :: init (__argc, __argv);
00062   loadParameters (__argc, __argv);
00063   RouteInit route_init;
00064   RouteEval full_eval;
00065   OrderXover order_cross;
00066   PartialMappedXover pm_cross;
00067   EdgeXover edge_cross;
00068   CitySwap city_swap_mut;
00069 
00070 // Initialization of the local search
00071   TwoOptInit pmx_two_opt_init;
00072   TwoOptNext pmx_two_opt_next;
00073   TwoOptIncrEval pmx_two_opt_incr_eval;
00074   moBestImprSelect <TwoOpt> pmx_two_opt_move_select;
00075   moHC <TwoOpt> hc (pmx_two_opt_init, pmx_two_opt_next, pmx_two_opt_incr_eval, pmx_two_opt_move_select, full_eval);
00076 
00077 // EA
00078   eoPop <Route> pop (POP_SIZE, route_init);
00079   eoGenContinue <Route> cont (NUM_GEN);
00080   eoCheckPoint <Route> checkpoint (cont);
00081   eoEvalFuncCounter< Route > eval(full_eval);
00082   eoStochTournamentSelect <Route> select_one;
00083   eoSelectNumber <Route> select (select_one, POP_SIZE);
00084   eoSGATransform <Route> transform (order_cross, CROSS_RATE, city_swap_mut, MUT_RATE);
00085   eoEPReplacement <Route> replace (2);
00086   eoEasyEA< Route > eaAlg( checkpoint, eval, select, transform, replace );
00087   peoWrapper parallelEA( eaAlg, pop);
00088   peo :: run ();
00089   peo :: finalize ();
00090 
00091   if (getNodeRank()==1)
00092     {
00093       pop.sort();
00094       std :: cout << "\nResult before the local search\n";
00095       for (unsigned i=0;i<pop.size();i++)
00096         std::cout<<"\n"<<pop[i].fitness();
00097     }
00098 
00099 // Local search
00100   peo :: init (__argc, __argv);
00101   peoMultiStart <Route> initParallelHC (hc);
00102   peoWrapper parallelHC (initParallelHC, pop);
00103   initParallelHC.setOwner(parallelHC);
00104   peo :: run( );
00105   peo :: finalize( );
00106 
00107   if (getNodeRank()==1)
00108     {
00109       std :: cout << "\nResult after the local search\n";
00110       pop.sort();
00111       for (unsigned i=0;i<pop.size();i++)
00112         std::cout<<"\n"<<pop[i].fitness();
00113     }
00114 }

Generated on Thu Mar 13 15:55:03 2008 for ParadisEO-PEO-ParallelanddistributedEvolvingObjects by  doxygen 1.4.7