- Main Page
- Classes
- Files

- Search for |

# make_op_FlowShop.h

    00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003 //-----------------------------------------------------------------------------
    00004 // make_op_FlowShop.h
    00005 // (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
    00006 /*
    00007     This library...
    00008
    00009     Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
    00010  */
    00011 //-----------------------------------------------------------------------------
    00012
    00013 #ifndef MAKE_OP_FLOWSHOP_H_
    00014 #define MAKE_OP_FLOWSHOP_H_
    00015
    00016 #include <utils/eoParser.h>
    00017 #include <utils/eoState.h>
    00018 #include <eoOp.h>
    00019 #include <eoGenOp.h>
    00020 #include <eoCloneOps.h>
    00021 #include <eoOpContainer.h>
    00022 #include <eoProportionalCombinedOp.h>
    00023 #include <FlowShopOpCrossoverQuad.h>
    00024 #include <FlowShopOpMutationShift.h>
    00025 #include <FlowShopOpMutationExchange.h>
    00026
    00027 /*
    00028  * This function builds the operators that will be applied to the eoFlowShop
    00029  * @param eoParameterLoader& _parser to get user parameters
    00030  * @param eoState& _state to store the memory
    00031  */
    00032 eoGenOp<FlowShop> & do_make_op(eoParameterLoader& _parser, eoState& _state)
    00033 {
    00034
    00036     // Variation operators
    00038
    00039     // the crossover
    00041
    00042     // a first crossover
    00043     eoQuadOp<FlowShop> *cross = new FlowShopOpCrossoverQuad;
    00044     // store in the state
    00045     _state.storeFunctor(cross);
    00046
    00047     // relative rate in the combination
    00048     double cross1Rate = _parser.createParam(1.0, "crossRate", "Relative rate for the only crossover", 0, "Variation Operators").value();
    00049     // creation of the combined operator with this one
    00050     eoPropCombinedQuadOp<FlowShop> *propXover = new eoPropCombinedQuadOp<FlowShop>(*cross, cross1Rate);
    00051     // store in the state
    00052     _state.storeFunctor(propXover);
    00053
    00054
    00055     // the mutation
    00057
    00058     // a first mutation : the shift mutation
    00059     eoMonOp<FlowShop> *mut = new FlowShopOpMutationShift;
    00060     _state.storeFunctor(mut);
    00061     // its relative rate in the combination
    00062     double mut1Rate = _parser.createParam(0.5, "shiftMutRate", "Relative rate for shift mutation", 0, "Variation Operators").value();
    00063     // creation of the combined operator with this one
    00064     eoPropCombinedMonOp<FlowShop> *propMutation = new eoPropCombinedMonOp<FlowShop>(*mut, mut1Rate);
    00065     _state.storeFunctor(propMutation);
    00066
    00067     // a second mutation : the exchange mutation
    00068     mut = new FlowShopOpMutationExchange;
    00069     _state.storeFunctor(mut);
    00070     // its relative rate in the combination
    00071     double mut2Rate = _parser.createParam(0.5, "exchangeMutRate", "Relative rate for exchange mutation", 0, "Variation Operators").value();
    00072     // addition of this one to the combined operator
    00073     propMutation -> add(*mut, mut2Rate);
    00074
    00075     // end of crossover and mutation definitions
    00077
    00078     // First read the individual level parameters
    00079     eoValueParam<double>& pCrossParam = _parser.createParam(0.25, "pCross", "Probability of Crossover", 'c', "Variation Operators" );
    00080     // minimum check
    00081     if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) )
    00082         throw std::runtime_error("Invalid pCross");
    00083
    00084     eoValueParam<double>& pMutParam = _parser.createParam(0.35, "pMut", "Probability of Mutation", 'm', "Variation Operators" );
    00085     // minimum check
    00086     if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) )
    00087         throw std::runtime_error("Invalid pMut");
    00088
    00089     // the crossover - with probability pCross
    00090     eoProportionalOp<FlowShop> * propOp = new eoProportionalOp<FlowShop> ;
    00091     _state.storeFunctor(propOp);
    00092     eoQuadOp<FlowShop> *ptQuad = new eoQuadCloneOp<FlowShop>;
    00093     _state.storeFunctor(ptQuad);
    00094     propOp -> add(*propXover, pCrossParam.value()); // crossover, with proba pcross
    00095     propOp -> add(*ptQuad, 1-pCrossParam.value()); // nothing, with proba 1-pcross
    00096
    00097     // now the sequential
    00098     eoSequentialOp<FlowShop> *op = new eoSequentialOp<FlowShop>;
    00099     _state.storeFunctor(op);
    00100     op -> add(*propOp, 1.0);     // always do combined crossover
    00101     op -> add(*propMutation, pMutParam.value()); // then mutation, with proba pmut
    00102
    00103     // return a reference
    00104     return *op;
    00105 }
    00106
    00107 #endif /*MAKE_OP_FLOWSHOP_H_*/