- Main Page
- Classes
- Files

- Search for |

# FlowShopInit.cpp

    00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003 //-----------------------------------------------------------------------------
    00004 // FlowShopInit.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 <FlowShopInit.h>
    00014
    00015
    00016 FlowShopInit::FlowShopInit(unsigned int _N) : N(_N)
    00017 {}
    00018
    00019
    00020 void FlowShopInit::operator()(FlowShop & _flowshop)
    00021 {
    00022     // scheduling vector
    00023     std::vector<unsigned int> scheduling(N);
    00024     // initialisation of possible values
    00025     std::vector<unsigned int> possibles(N);
    00026     for (unsigned int i=0 ; i<N ; i++)
    00027         possibles[i] = i;
    00028     // random initialization
    00029     unsigned int rInd;     // random index
    00030     for (unsigned int i=0; i<N; i++)
    00031     {
    00032         rInd = (unsigned int) rng.uniform(N-i);
    00033         scheduling[i] = possibles[rInd];
    00034         possibles[rInd] = possibles[N-i-1];
    00035     }
    00036     _flowshop.resize(N);
    00037     _flowshop.value(scheduling);
    00038     _flowshop.invalidate();        // IMPORTANT in case the _genotype is old
    00039 }