exampleD.cpp

00001 /* 
00002 * <exampleD.cpp>
00003 * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
00004 * (C) OPAC Team, LIFL, 2002-2007
00005 *
00006 * Sebastien Cahon, Alexandru-Adrian Tantar
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 // (c) OPAC Team, LIFL, July 2007
00037 //
00038 // Contact: paradiseo-help@lists.gforge.inria.fr
00039 
00040 #include "param.h"
00041 #include "route_init.h"
00042 #include "route_eval.h"
00043 
00044 #include "order_xover.h"
00045 #include "edge_xover.h"
00046 #include "partial_mapped_xover.h"
00047 #include "city_swap.h"
00048 #include "part_route_eval.h"
00049 #include "merge_route_eval.h"
00050 #include "two_opt_init.h"
00051 #include "two_opt_next.h"
00052 #include "two_opt_incr_eval.h"
00053 
00054 #include <peo>
00055 
00056 #define POP_SIZE 10
00057 #define NUM_GEN 10
00058 #define CROSS_RATE 1.0
00059 #define MUT_RATE 0.01
00060 
00061 
00062 
00063 int main (int __argc, char * * __argv) {
00064 
00065   peo :: init (__argc, __argv);
00066 
00067   
00068   loadParameters (__argc, __argv); /* Processing some parameters relative to the tackled
00069                                       problem (TSP) */
00070 
00071   RouteInit route_init; /* Its builds random routes */  
00072   RouteEval full_eval; /* Full route evaluator */
00073 
00074   
00075   OrderXover order_cross; /* Recombination */
00076   CitySwap city_swap_mut;  /* Mutation */
00077 
00078 
00080   eoPop <Route> ox_pop (POP_SIZE, route_init);  /* Population */
00081   
00082   eoGenContinue <Route> ox_cont (NUM_GEN); /* A fixed number of iterations */  
00083   eoCheckPoint <Route> ox_checkpoint (ox_cont); /* Checkpoint */
00084   peoSeqPopEval <Route> ox_pop_eval (full_eval);  
00085   eoStochTournamentSelect <Route> ox_select_one;
00086   eoSelectNumber <Route> ox_select (ox_select_one, POP_SIZE);
00087   eoSGATransform <Route> ox_transform (order_cross, CROSS_RATE, city_swap_mut, MUT_RATE);
00088   peoSeqTransform <Route> ox_para_transform (ox_transform);    
00089   eoEPReplacement <Route> ox_replace (2);
00090 
00091   
00092   peoEA <Route> ox_ea (ox_checkpoint, ox_pop_eval, ox_select, ox_para_transform, ox_replace);
00093 
00094     
00095   ox_ea (ox_pop);   /* Application to the given population */
00096     
00097   peo :: run ();
00098   peo :: finalize (); /* Termination */
00099   
00100  
00101 
00102   // rank 0 is assigned to the scheduler in the XML mapping file
00103   if ( getNodeRank() == 1 ) {
00104 
00105     std::cout << "EA[ 0 ] -----> " << ox_pop.best_element().fitness() << std::endl;
00106   }
00107  
00108     
00109   return 0;
00110 }

Generated on Mon Oct 8 11:16:45 2007 for ParadisEO-PEOMovingObjects by  doxygen 1.4.7