- Main Page
- Classes
- Files

- Search for |

# FlowShopOpMutationExchange.cpp

    00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003 //-----------------------------------------------------------------------------
    00004 // FlowShopOpCrossoverQuad.cpp
    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 #include <FlowShopOpMutationExchange.h>
    00014
    00015
    00016 std::string FlowShopOpMutationExchange::className() const
    00017 {
    00018     return "FlowShopOpMutationExchange";
    00019 }
    00020
    00021
    00022 bool FlowShopOpMutationExchange::operator()(FlowShop & _flowshop)
    00023 {
    00024     bool isModified;
    00025     FlowShop result = _flowshop;
    00026     // computation of the 2 random points
    00027     unsigned int point1, point2;
    00028     do
    00029     {
    00030         point1 = rng.random(result.size());
    00031         point2 = rng.random(result.size());
    00032     } while (point1 == point2);
    00033     // swap
    00034     std::swap (result[point1], result[point2]);
    00035     // update (if necessary)
    00036     if (result != _flowshop)
    00037     {
    00038         // update
    00039         _flowshop.value(result);
    00040         // the genotype has been modified
    00041         isModified = true;
    00042     }
    00043     else
    00044     {
    00045         // the genotype has not been modified
    00046         isModified = false;
    00047     }
    00048     // return 'true' if the genotype has been modified
    00049     return isModified;
    00050 }