FlowShopEA.cpp

00001 /*
00002 * <FlowShopEA.cpp>
00003 * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
00004 * (C) OPAC Team, LIFL, 2002-2007
00005 *
00006 * Arnaud Liefooghe
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 
00038 
00039 // moeo general include
00040 #include <moeo>
00041 // for the creation of an evaluator
00042 #include <make_eval_FlowShop.h>
00043 // for the creation of an initializer
00044 #include <make_genotype_FlowShop.h>
00045 // for the creation of the variation operators
00046 #include <make_op_FlowShop.h>
00047 // how to initialize the population
00048 #include <do/make_pop.h>
00049 // the stopping criterion
00050 #include <do/make_continue_moeo.h>
00051 // outputs (stats, population dumps, ...)
00052 #include <do/make_checkpoint_moeo.h>
00053 // evolution engine (selection and replacement)
00054 #include <do/make_ea_moeo.h>
00055 // simple call to the algo
00056 #include <do/make_run.h>
00057 // checks for help demand, and writes the status file and make_help; in libutils
00058 void make_help(eoParser & _parser);
00059 // definition of the representation
00060 #include <FlowShop.h>
00061 
00062 
00063 using namespace std;
00064 
00065 
00066 int main(int argc, char* argv[])
00067 {
00068     try
00069     {
00070 
00071         eoParser parser(argc, argv);  // for user-parameter reading
00072         eoState state;                // to keep all things allocated
00073 
00074 
00075         /*** the representation-dependent things ***/
00076 
00077         // The fitness evaluation
00078         eoEvalFuncCounter<FlowShop>& eval = do_make_eval(parser, state);
00079         // the genotype (through a genotype initializer)
00080         eoInit<FlowShop>& init = do_make_genotype(parser, state);
00081         // the variation operators
00082         eoGenOp<FlowShop>& op = do_make_op(parser, state);
00083 
00084 
00085         /*** the representation-independent things ***/
00086 
00087         // initialization of the population
00088         eoPop<FlowShop>& pop = do_make_pop(parser, state, init);
00089         // definition of the archive
00090         moeoArchive<FlowShop> arch;
00091         // stopping criteria
00092         unsigned int maxGen = parser.createParam((unsigned int)(100), "maxGen", "Maximum number of gen.",'G',"Stopping criterion").value();
00093         eoGenContinue<FlowShop> term(maxGen);
00094         // checkpointing
00095         eoCheckPoint<FlowShop> checkpoint(term);
00096         moeoArchiveUpdater < FlowShop > updater(arch, pop);
00097         checkpoint.add(updater);
00098         // fitness assignment
00099         moeoFastNonDominatedSortingFitnessAssignment <FlowShop> fitnessAssignment;
00100         // diversity preservation
00101         moeoFrontByFrontCrowdingDiversityAssignment <FlowShop> diversityAssignment;
00102         // comparator
00103         moeoFitnessThenDiversityComparator <FlowShop> comparator;
00104         // selection scheme
00105         moeoDetTournamentSelect <FlowShop> select(comparator, 2);
00106         // replacement scheme
00107         moeoElitistReplacement <FlowShop> replace(fitnessAssignment, diversityAssignment, comparator);
00108         // breeder
00109         eoGeneralBreeder <FlowShop> breed(select, op);
00110         // algorithm
00111         moeoEasyEA <FlowShop> algo (checkpoint, eval, breed, replace, fitnessAssignment, diversityAssignment);
00112 
00113 
00114         /*** Go ! ***/
00115 
00116         // help ?
00117         make_help(parser);
00118 
00119         // first evalution (for printing)
00120         apply<FlowShop>(eval, pop);
00121 
00122         // printing of the initial population
00123         cout << "Initial Population\n";
00124         pop.sortedPrintOn(cout);
00125         cout << endl;
00126 
00127         // run the algo
00128         algo(pop);
00129 
00130         // printing of the final population
00131         cout << "Final Population\n";
00132         pop.sortedPrintOn(cout);
00133         cout << endl;
00134 
00135         // printing of the final archive
00136         cout << "Final Archive\n";
00137         arch.sortedPrintOn(cout);
00138         cout << endl;
00139 
00140 
00141     }
00142     catch (exception& e)
00143     {
00144         cout << e.what() << endl;
00145     }
00146     return EXIT_SUCCESS;
00147 }

Generated on Thu Mar 13 15:54:07 2008 for ParadisEO-MOEO-MultiObjectiveEvolvingObjects by  doxygen 1.4.7