-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdsmga2.h
executable file
·110 lines (80 loc) · 2.77 KB
/
dsmga2.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
/*
* dsmga2.h
*
* Created on: May 2, 2011
* Author: tianliyu
*/
#ifndef _DSMGA2_H_
#define _DSMGA2_H_
#include <list>
#include <map>
#include "chromosome.h"
#include "statistics.h"
#include "trimatrix.h"
#include "doublelinkedlistarray.h"
#include "fastcounting.h"
class DSMGA2 {
public:
DSMGA2 (int n_ell, int n_nInitial, int n_maxGen, int n_maxFe, int fffff);
~DSMGA2 ();
void selection ();
/** tournament selection without replacement*/
void tournamentSelection();
void oneRun (bool output = true);
int doIt (bool output = true);
void buildGraph ();
void mixing ();
void restrictedMixing(Chromosome&);
bool restrictedMixing(Chromosome& ch, list<int>& mask);
void backMixing(Chromosome& source, list<int>& mask, Chromosome& des);
void backMixingE(Chromosome& source, list<int>& mask, Chromosome& des);
bool shouldTerminate ();
bool foundOptima ();
int getGeneration () const {
return generation;
}
bool isInP(const Chromosome& ) const;
void genOrderN();
void genOrderELL();
void showStatistics ();
bool isSteadyState ();
//protected:
public:
int ell; // chromosome length
int nCurrent; // population size
bool EQ;
unordered_map<unsigned long, double> pHash; // to check if a chromosome is in the population
list<int> *masks;
int *selectionIndex;
int *orderN; // for random order
int *orderELL; // for random order
int selectionPressure;
int maxGen;
int maxFe;
int repeat;
int generation;
int bestIndex;
Chromosome* population;
FastCounting* fastCounting;
TriMatrix<double> graph;
double previousFitnessMean;
Statistics stFitness;
// methods
double computeMI(double, double, double, double) const;
void findClique(int startNode, list<int>& result);
void buildFastCounting();
int countXOR(int, int) const;
int countOne(int) const;
size_t findSize(Chromosome&, list<int>&) const;
size_t findSize(Chromosome&, list<int>&, Chromosome&) const;
void printPopulation() const;
void populationMaskStatus( const Chromosome&, const list<int>& );
bool matchPattern(Chromosome& source, list<int>& mask, Chromosome& des);
//2016-12-06
int RM_succeed, RM_failed, BM_succeed, BM_failed;
map<string, int> succeedPattern, failedPattern;
void printMapOrder(map<string, int>& m);
void countSucceed(list<int>& mask, Chromosome& des, bool evaluated);
void countFailed(list<int>& mask, Chromosome& des, bool evaluated);
};
#endif /* _DSMGA2_H_ */