-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
133 lines (114 loc) · 3.32 KB
/
main.cpp
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <iostream>
#include "Evolution.h"
#include "params.h"
using namespace std;
int MUTATIONPROB;
int MUTATEDGENES;
int CROSSOVERPROBABILITY;
int TOURNAMENTSIZE;
int POPSIZE;
int MAXGENERATIONS;
int STATES;
int NEIGHBOURHOOD;
int SIMULATIONSTEPS;
int SIZEOFCA;
int MINRULES;
int MAXRULES;
string FILENAME;
int MAXFITENSS;
int main(int argc, char* argv[]) {
//argumenty 90 6 80 15 1 stats-rucne 60
//90 6 80 15 1 stats-rucne 60
MUTATIONPROB = 90;
MUTATEDGENES = 6;
CROSSOVERPROBABILITY = 80;
TOURNAMENTSIZE = 15;
POPSIZE = 20;
MAXGENERATIONS = 60;
STATES = 7;
NEIGHBOURHOOD = 9;
SIMULATIONSTEPS = 30;
SIZEOFCA = 45;
MINRULES = 10;
MAXRULES = 15;
FILENAME = "3";
MAXFITENSS = (STATES*STATES*(SIZEOFCA-1)*(SIZEOFCA-1)) / (STATES*NEIGHBOURHOOD) * MAXRULES;
// MAXFITENSS = 999999999;
string FILENAMESTATS = "stats-rucne";
if(argc == 8){
MUTATIONPROB = stoi (argv[1],nullptr,10);
MUTATEDGENES = stoi (argv[2],nullptr,10);
CROSSOVERPROBABILITY = stoi (argv[3],nullptr,10);
TOURNAMENTSIZE = stoi (argv[4],nullptr,10);
FILENAME = argv[5];
FILENAMESTATS = argv[6];
MAXGENERATIONS = stoi (argv[7],nullptr,10);;
cout <<MAXGENERATIONS<<" max fit = "<<MAXFITENSS <<" "<< MUTATIONPROB<<" " << MUTATEDGENES<<" " << CROSSOVERPROBABILITY<<" "<<TOURNAMENTSIZE<<" "<<FILENAME<<endl;
}
time_t seed = time(0);
srand(seed);
Evolution evolution;
evolution.initialize();
evolution.evolve();
evolution.exportChromosome(std::__cxx11::string());
// Chromosome c;
// c.initialize();
// c.calculateFittness();
// c.exportCA();
// cout << "fitness " << c.fittness << endl;
string filename = "bicas/" + FILENAME + "info";
cout << filename << endl;
ofstream fout(filename, std::ofstream::out);
ofstream statsOut(FILENAMESTATS, std::ofstream::app);
fout << "Filename" << ",";
fout << "Fittness" << ",";
fout << "Seed" << ",";
fout << "MUTATIONPROB" << ",";
fout << "MUTATEDGENES" << ",";
fout << "CROSSOVERPROBABILITY" << ",";
fout << "TOURNAMENTSIZE" << ",";
fout << "POPSIZE" << ",";
fout << "MAXGENERATIONS" << ",";
fout << "STATES" << ",";
fout << "NEIGHBOURHOOD" << ",";
fout << "SIMULATIONSTEPS" << ",";
fout << "SIZEOFCA" << ",";
fout << "MINRULES" << ",";
fout << "MAXRULES" << ",";
fout << endl;
fout << FILENAME << ",";
fout << evolution.bestEver.fittness << ",";
fout << seed << ",";
fout << MUTATIONPROB << ",";
fout << MUTATEDGENES << ",";
fout << CROSSOVERPROBABILITY << ",";
fout << TOURNAMENTSIZE << ",";
fout << POPSIZE << ",";
fout << MAXGENERATIONS << ",";
fout << STATES << ",";
fout << NEIGHBOURHOOD << ",";
fout << SIMULATIONSTEPS << ",";
fout << SIZEOFCA << ",";
fout << MINRULES << ",";
fout << MAXRULES << ",";
fout << endl;
statsOut << FILENAME << ",";
statsOut << evolution.bestEver.fittness << ",";
statsOut << seed << ",";
statsOut << MUTATIONPROB << ",";
statsOut << MUTATEDGENES << ",";
statsOut << CROSSOVERPROBABILITY << ",";
statsOut << TOURNAMENTSIZE << ",";
statsOut << POPSIZE << ",";
statsOut << MAXGENERATIONS << ",";
statsOut << STATES << ",";
statsOut << NEIGHBOURHOOD << ",";
statsOut << SIMULATIONSTEPS << ",";
statsOut << SIZEOFCA << ",";
statsOut << MINRULES << ",";
statsOut << MAXRULES << ",";
statsOut << endl;
fout.close();
statsOut.close();
return 0;
}