-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathparams_reader.cpp
More file actions
60 lines (56 loc) · 2.26 KB
/
Copy pathparams_reader.cpp
File metadata and controls
60 lines (56 loc) · 2.26 KB
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
51
52
53
54
55
56
57
58
59
60
#include"agent_defn.hpp"
#include"dataTYPE.hpp"
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<cmath>
template<typename Agent_data>
void params_reader(unsigned int &generations,unsigned int &dimensions,unsigned int &agents,Agent_data &CR,Agent_data &F,
std::vector<Agent_data> &L,std::vector<Agent_data> &H,int &cost_select,unsigned int &threads_no,
std::string filename,int &seedval,int &agtinit,std::string &agtinputfile,std::string &bestagtfile,
int &rebound,std::vector<Agent_data> &newboundlimit)
{
std::fstream fin(filename,std::ios::in);
Agent_data Ltemp,Htemp;
if(fin.good())
{
fin>>generations>>dimensions>>agents>>CR>>F;
std::string selector;
fin>>selector;
if(selector=="carry_toAll"){
fin>>Ltemp>>Htemp;
for(unsigned int i=0;i<dimensions;i++){
L.push_back(Ltemp);H.push_back(Htemp);
}
}
else{
for(unsigned int i=0;i<dimensions;i++){
fin>>Ltemp;L.push_back(Ltemp);
}
for(unsigned int i=0;i<dimensions;i++){
fin>>Htemp;H.push_back(Htemp);
}
}
fin>>cost_select>>threads_no>>seedval;
fin>>agtinit>>agtinputfile>>bestagtfile>>rebound;
if(rebound){
Agent_data tempval;
for(unsigned int i=0;i<dimensions;i++){
fin>>tempval;newboundlimit.push_back(tempval);
}
}
}
else
{
std::cout<<std::endl<<"Error opening input file \""<<filename<<"\""<<std::endl;
exit(-101);
}
fin.close();
}
///TEMPLATE FUNCTION INSTANTIATION
template void params_reader(unsigned int &generations,unsigned int &dimensions,unsigned int &agents,Agent_datatype &CR,
Agent_datatype &F,std::vector<Agent_datatype> &L,std::vector<Agent_datatype> &H,
int &cost_select,unsigned int &threads_no,std::string filename,int &seedval,
int &agtinit,std::string &agtinputfile,std::string &bestagtfile,int &rebound,
std::vector<Agent_datatype> &newboundlimit);