make_op_FlowShop.h

00001 /*
00002 * <make_op_FlowShop.h>
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 #ifndef MAKE_OP_FLOWSHOP_H_
00039 #define MAKE_OP_FLOWSHOP_H_
00040 
00041 #include <utils/eoParser.h>
00042 #include <utils/eoState.h>
00043 #include <eoOp.h>
00044 #include <eoGenOp.h>
00045 #include <eoCloneOps.h>
00046 #include <eoOpContainer.h>
00047 #include <eoProportionalCombinedOp.h>
00048 #include <FlowShopOpCrossoverQuad.h>
00049 #include <FlowShopOpMutationShift.h>
00050 #include <FlowShopOpMutationExchange.h>
00051 
00052 /*
00053  * This function builds the operators that will be applied to the eoFlowShop
00054  * @param eoParameterLoader& _parser to get user parameters
00055  * @param eoState& _state to store the memory
00056  */
00057 eoGenOp<FlowShop> & do_make_op(eoParameterLoader& _parser, eoState& _state)
00058 {
00059 
00061   // Variation operators
00063 
00064   // the crossover
00066 
00067   // a first crossover
00068   eoQuadOp<FlowShop> *cross = new FlowShopOpCrossoverQuad;
00069   // store in the state
00070   _state.storeFunctor(cross);
00071 
00072   // relative rate in the combination
00073   double cross1Rate = _parser.createParam(1.0, "crossRate", "Relative rate for the only crossover", 0, "Variation Operators").value();
00074   // creation of the combined operator with this one
00075   eoPropCombinedQuadOp<FlowShop> *propXover = new eoPropCombinedQuadOp<FlowShop>(*cross, cross1Rate);
00076   // store in the state
00077   _state.storeFunctor(propXover);
00078 
00079 
00080   // the mutation
00082 
00083   // a first mutation : the shift mutation
00084   eoMonOp<FlowShop> *mut = new FlowShopOpMutationShift;
00085   _state.storeFunctor(mut);
00086   // its relative rate in the combination
00087   double mut1Rate = _parser.createParam(0.5, "shiftMutRate", "Relative rate for shift mutation", 0, "Variation Operators").value();
00088   // creation of the combined operator with this one
00089   eoPropCombinedMonOp<FlowShop> *propMutation = new eoPropCombinedMonOp<FlowShop>(*mut, mut1Rate);
00090   _state.storeFunctor(propMutation);
00091 
00092   // a second mutation : the exchange mutation
00093   mut = new FlowShopOpMutationExchange;
00094   _state.storeFunctor(mut);
00095   // its relative rate in the combination
00096   double mut2Rate = _parser.createParam(0.5, "exchangeMutRate", "Relative rate for exchange mutation", 0, "Variation Operators").value();
00097   // addition of this one to the combined operator
00098   propMutation -> add(*mut, mut2Rate);
00099 
00100   // end of crossover and mutation definitions
00102 
00103   // First read the individual level parameters
00104   eoValueParam<double>& pCrossParam = _parser.createParam(0.25, "pCross", "Probability of Crossover", 'c', "Variation Operators" );
00105   // minimum check
00106   if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
00107     throw std::runtime_error("Invalid pCross");
00108 
00109   eoValueParam<double>& pMutParam = _parser.createParam(0.35, "pMut", "Probability of Mutation", 'm', "Variation Operators" );
00110   // minimum check
00111   if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
00112     throw std::runtime_error("Invalid pMut");
00113 
00114   // the crossover - with probability pCross
00115   eoProportionalOp<FlowShop> * propOp = new eoProportionalOp<FlowShop> ;
00116   _state.storeFunctor(propOp);
00117   eoQuadOp<FlowShop> *ptQuad = new eoQuadCloneOp<FlowShop>;
00118   _state.storeFunctor(ptQuad);
00119   propOp -> add(*propXover, pCrossParam.value()); // crossover, with proba pcross
00120   propOp -> add(*ptQuad, 1-pCrossParam.value()); // nothing, with proba 1-pcross
00121 
00122   // now the sequential
00123   eoSequentialOp<FlowShop> *op = new eoSequentialOp<FlowShop>;
00124   _state.storeFunctor(op);
00125   op -> add(*propOp, 1.0);       // always do combined crossover
00126   op -> add(*propMutation, pMutParam.value()); // then mutation, with proba pmut
00127 
00128   // return a reference
00129   return *op;
00130 }
00131 
00132 #endif /*MAKE_OP_FLOWSHOP_H_*/

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