This repository has been archived by the owner on Apr 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mapcolorga.h
118 lines (87 loc) · 2.53 KB
/
mapcolorga.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
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
#ifndef MAPCOLORGA_H_
#define MAPCOLORGA_H_
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include "mainscene.h"
#include "mainwindow.h"
using namespace std;
class MapColorGA {
public:
MapColorGA();
MapColorGA(int population, int crossing, int generations, int mutations, int genes);
~MapColorGA();
/** @fn vector<string> getMyPopulation() const
@brief Retorna vetor com a população de cromossomos
@param Nenhum
@return Vetor que representa a população
**/
multimap<int, string>& getMyPopulation()
{ return myPopulation; }
int getPopulation() const
{ return myPopulation.size(); }
int getMutations() const
{ return myMutations; }
int getCrossing() const
{ return myCrossing; }
int getGenerations() const
{ return myGenerations; }
int getGenes() const
{ return myGenes; }
vector<int> getColors() const
{ return myColors; }
void printParcialResult(int);
/** @fn void print_population()
@brief Função imprime população (modo texto)
@param Nenhum
@return Nenhum
**/
void printPopulation(int);
/** @fn void init_population(vector<string>)
@brief Inicializa população com valores aleatórios para seus genes
@param max população inicial
@return Nenhum
**/
void initPopulation();
/** @fn void crossing()
@brief Função cruzamento
@param Nenhum
@return Nenhum
**/
void crossing();
/** @fn void mutation(int k)
@brief Função mutação
@param Nenhum
@return Nenhum
**/
void mutation();
int calculateFitness(string chromossome);
void selection();
void setMyGenes(int genes)
{ myGenes = genes; }
void setInitPop(int population)
{ myInitPop = population; }
void setMutations(int mutations)
{ myMutations = mutations; }
void setGenerations(int generations)
{ myGenerations = generations; }
void setColors(vector<int> colors)
{ myColors = colors; }
void setCrossing(int crossing)
{ myCrossing = crossing; }
private:
int myMutations, myGenerations, myInitPop;
int myCrossing, myGenes;
vector<int> myColors;
multimap<int, string> myPopulation;
multimap<int, string> mySons;
/** @fn int roulette()
@brief Função roleta
@param Nenhum
@return Indice do cromossomo sorteado
**/
int roulette();
};
#endif