-
Notifications
You must be signed in to change notification settings - Fork 0
/
popInit.h
51 lines (43 loc) · 1.14 KB
/
popInit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* File: popInit.h
* Author: MAN
*
* Created on September 7, 2013, 7:01 AM
*/
#ifndef _POPINIT_H
#define _POPINIT_H
#include <eo>
#include "routeSet.h"
#include "inputData.h"
void popInit(eoPop< RouteSet<double> >& _pop, int popSize, int routeSetSize, eoEvalFunc< RouteSet<double> >& _eval)
{
RouteSet<double> initRs;
vector< Route<double> > initV;
ifstream fin(INITIAL_ROUTE_SET);
for (int iroute = 0; iroute < routeSetSize; iroute++)
{
Route<double> initR;
vector<int> initNodeList(VERTICES_NO, 0);
list<int> initL;
int node;
fin >> node;
while (node != -1)
{
initL.push_back(node);
initNodeList[node] = 1;
fin >> node;
}
initR.setR(initL);
initR.setNodeList(initNodeList);
initR.fitness(1.0 / DS[initL.front()][initL.back()]); //fitness 1/ds
initV.push_back(initR);
}
initRs.setRs(initV);
_eval(initRs);
//std::cout<<initRs<<std::endl; //comment after test
for (int igeno = 0; igeno < popSize; igeno++)
{
_pop.push_back(initRs);
}
}
#endif /* _POPINIT_H */