-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
135 lines (95 loc) · 2.99 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
134
/*
* File: main.cpp
* Author: jaime
*
* Created on April 11, 2016, 7:06 PM
*/
#include <cstdlib>
#include <vector>
#include <iostream>
#include <fstream>
#include "genetico.h"
#include "annealing.h"
using namespace std;
int main(int argc, char* argv[]){
vector<int> cromossomo;
//---------------------------Genetico
/*
if(argc != 6 ){
cout << "Comandos para rodar: ./a.out tamCromossomo tamPop probMutacao probCrossover qtMaxGeracoes"<<endl;
exit(0);
}
int tamCromossomo = atoi(argv[1]);
int tamPop = atoi(argv[2]);
float probMutacao = atof(argv[3]);
float probCrossover = atof(argv[4]);
int qtMaxGeracoes = atoi(argv[5]);
Genetico * g = new Genetico(tamCromossomo, tamPop, probMutacao, probCrossover, qtMaxGeracoes);
g->run();
delete g;
//-----------------------Annealing
if(argc != 6 ){
cout << "Comandos para rodar: ./a.out tamCromossomo tamPop probMutacao probCrossover qtMaxGeracoes"<<endl;
exit(0);
}
int tamCromossomo = atoi(argv[1]);
float temperturaInicial = atoi(argv[3]);
float _a = atof(argv[4]);
Annealing * a = new Annealing(tamCromossomo, temperturaInicial, _a);
a->run();
//delete a;//nao pode deletar, da bug no netbeans.
*/
//-------DEBUGACAO
float media = 0;
int k;
int amostra=100;
int tamCromossomo = 10;
int tamPop =15;
float probMutacao = 0.0001;
float probCrossover = 0.7;
int qtMaxGeracoes = 50000;
//Annealing * a = new Annealing(tamanho, temperatura, resfriamento);
Genetico * g = new Genetico(tamCromossomo, tamPop, probMutacao, probCrossover, qtMaxGeracoes);
int teste;
for (int i=0; i<amostra; i++){
teste = g->run();
//cout<<endl;
k = g->fitness(teste);
media+=k;
}
cout<<"\nColisoes: "<<(int)media/amostra<<endl;
//delete a;
delete g;
/*
cout<<"\n------>criou a";
a->criarCromossomo();
cout<<"\n------>criou Cromossomo";
//cromossomo[0] = 0;
//cromossomo[1] = 1;
//cromossomo[2] = 2;
//cromossomo[3] = 3;
//a->criarCromossomo();
cromossomo = a->getCromossomo();
vizinho = a->criarVizinho(cromossomo);
cout<<"\n------>Pegou o cromossomo\n";
cout<<"-----Cromossomo ";
for(int i=0;i<4;i++){
cout<<cromossomo[i]<<" ";
}
//cromossomo = a->criarVizinho(cromossomo);
cout<<"\n------criou vizinho: ";
for(int i=0;i<4;i++){
cout<<vizinho[i]<<" ";
}
int gol;
gol = a->fitness(cromossomo);
cout<<"\n------teste de fitness: ";
cout<<gol<<endl;
cout<<"------teste de zero colisoes: ";
cout<<a->zeroColisao(cromossomo);
a->run();
*/
//delete g;
//delete a;
return 0;
}