-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenealgomanager.h
50 lines (42 loc) · 1.02 KB
/
genealgomanager.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
#ifndef __genealgomanager_h__
#define __genealgomanager_h__
#include "gene.h"
#include "genemanager.h"
#include <bits/stdc++.h>
using namespace std;
class GeneAlgoManager {
private:
const double fitness_k = 3;
const double mutate_prob = 0.01;
const double gene_mutate_prob = 0.2;
const double all_init = 0.07;
const int elite = 5;
const int max_iter = 15;
int n;
double fitSum;
Gene bestGene;
vector<Gene> geneArr;
vector<int> geneScore;
vector<double> geneFitScore;
vector<double> geneFitness;
GeneManager gm;
RandomManager rm;
void CalculateScore();
double CalculateFitness();
int SelectParent(double);
void IndividualCross(Gene&, Gene&, Gene&);
void Cross();
void Mutate();
void Optimize();
void SaveBestGene();
public:
GeneAlgoManager(int, int);
void NextGeneration();
void PrintBestGene();
int BestGeneScore();
void SaveAllGene(ofstream&);
void LoadAllGene(ifstream&);
double returnAverageScore();
vector<int> top10Score();
};
#endif __genealgomanager_h__