initializer.h 981 Bytes
Newer Older
Alexis Lebis's avatar
Alexis Lebis committed
1 2 3
#ifndef SRC_MODEL_EA_INITIALIZER_H_
#define SRC_MODEL_EA_INITIALIZER_H_

4 5 6 7 8 9 10
#include<queue>
#include<vector>
#include<cassert>
#include<algorithm>
#include<random>
#include<functional>

Alexis Lebis's avatar
Alexis Lebis committed
11 12
#include <eoInit.h>

13
#include "model/problem.h"
Alexis Lebis's avatar
Alexis Lebis committed
14 15
#include "cursus.h"

16 17 18 19 20 21 22
template <class EOT>
class eoInitCSDVP: public eoInit<EOT>
{
    public:

    typedef typename EOT::AtomType AtomType;

jerem's avatar
jerem committed
23 24
        eoInitCSDVP(unsigned _chromSize, unsigned _maxVal, int _seed)
	  : chromSize(_chromSize), maxVal(_maxVal), seed(_seed)
25 26 27 28
        {}

        virtual void operator()(EOT& chrom)
        {
jerem's avatar
jerem committed
29 30 31 32 33 34
	  chrom.resize(0);
	  for(int i = 0; i < maxVal; i++)
	    chrom.push_back(i);
	  std::random_shuffle(chrom.begin(), chrom.end());
	  chrom.resize(chromSize);
          chrom.invalidate();
35 36 37
        }

    private :
jerem's avatar
jerem committed
38 39
        unsigned chromSize;
        unsigned maxVal;
40
        UF_random_generator<unsigned int> gen;
jerem's avatar
jerem committed
41
        int seed;
42 43 44
};

typedef eoInitCSDVP<Cursus> CursusInit;
Alexis Lebis's avatar
Alexis Lebis committed
45

jerem's avatar
jerem committed
46
#endif // SRC_MODEL_EA_INITIALIZER_H_