update lesson1 new version

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@268 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
liefooga 2007-04-17 15:55:58 +00:00
commit 97b9338bef
14 changed files with 454 additions and 689 deletions

View file

@ -2,7 +2,7 @@
//-----------------------------------------------------------------------------
// FlowShopInit.h
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
/*
This library...
@ -10,18 +10,17 @@
*/
//-----------------------------------------------------------------------------
#ifndef _FlowShopInit_h
#define _FlowShopInit_h
#ifndef FLOWSHOPINIT_H_
#define FLOWSHOPINIT_H_
#include <eoInit.h>
#include "FlowShop.h"
/**
* Functor
* Initialisation of a random genotype built by the default constructor of the eoFlowShop class
*/
class FlowShopInit:public eoInit < FlowShop >
{
class FlowShopInit: public eoInit<FlowShop> {
public:
@ -29,40 +28,37 @@ public:
* constructor
* @param const unsigned _N the number of jobs to schedule
*/
FlowShopInit (const unsigned _N)
{
FlowShopInit(const unsigned _N) {
N = _N;
}
/**
* randomize a genotype
* @param FlowShop & _genotype a genotype that has been default-constructed
*/
void operator () (FlowShop & _genotype)
{
void operator()(FlowShop & _genotype) {
// scheduling vector
vector < unsigned >scheduling (N);
vector<unsigned> scheduling(N);
// initialisation of possible values
vector < unsigned >possibles (N);
for (unsigned i = 0; i < N; i++)
vector<unsigned> possibles(N);
for(unsigned i=0 ; i<N ; i++)
possibles[i] = i;
// random initialization
unsigned rInd; // random index
for (unsigned i = 0; i < N; i++)
{
rInd = (unsigned) rng.uniform (N - i);
scheduling[i] = possibles[rInd];
possibles[rInd] = possibles[N - i - 1];
}
_genotype.setScheduling (scheduling);
_genotype.invalidate (); // IMPORTANT in case the _genotype is old
unsigned rInd; // random index
for (unsigned i=0; i<N; i++) {
rInd = (unsigned) rng.uniform(N-i);
scheduling[i] = possibles[rInd];
possibles[rInd] = possibles[N-i-1];
}
_genotype.setScheduling(scheduling);
_genotype.invalidate(); // IMPORTANT in case the _genotype is old
}
private:
/** the number of jobs (size of a scheduling vector) */
unsigned N;
};
#endif
#endif /*FLOWSHOPINIT_H_*/