-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSupport.cpp
More file actions
89 lines (81 loc) · 1.54 KB
/
Support.cpp
File metadata and controls
89 lines (81 loc) · 1.54 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// Created by Sanyog Chhetri on 05/11/16.
//
#include "Support.h"
unsigned long Checker(const vector<string >& in_out_genes,
const vector<string >& in_outgen_genes,
const vector<unsigned char >& out_gen_genes,
const vector<unsigned char >& out_out_genes)
{
unsigned long fitness = 0;
for(int i = 0; i < (in_out_genes.size()-1); i++)
{
for(int j = 0; j < in_outgen_genes.size(); j++)
{
if(in_out_genes.at(i).compare(in_outgen_genes.at(j)) == 0)
{
if(out_gen_genes.at(j) == out_out_genes.at(i))
{
fitness++;
}
break;
}
}
}
return fitness;
}
data::data() : out_tmp(0, 0), num_tmps(0, 0)
{
}
void data::Read_data(int a)
{
char name[200];
unsigned char value;
string char_value;
int check = 0;
sprintf(name, "/Users/sanyogchhetri/ClionProjects/Backpropagation/Data%d.txt", a);
ifstream read_data(name);
if (!read_data)
{
cout << "non_existent file " << endl;
}
while (!read_data.eof())
{
if (check == 0)
{
read_data >> char_value;
tmp.push_back(char_value);
}
else if (check)
{
read_data >> value;
out_tmp.push_back(value);
}
check = ~check;
}
}
void data::separator(int a)
{
int val = 0;
for (int i = 0; i < tmp.size(); i++)
{
// stringstream stream(tmp.at(i));
for (char &z:tmp.at(i))
{
val = z - '0';
num_tmps.push_back(val);
}
}
}
vector<float> data::num_tmps_get()
{
return num_tmps;
}
vector<string> data::tmp_get()
{
return tmp;
}
vector<unsigned char> data::out_tmp_get()
{
return out_tmp;
}