forked from wookje/GeneticAlgorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDNA.h
45 lines (37 loc) · 787 Bytes
/
DNA.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
#ifndef __DNA_H__
#define __DNA_H__
#include <vector>
#include <random>
#include <time.h>
using namespace std;
class Drive
{
public:
double angle;
double interval;
void CreateRandomGene() {
std::random_device rdt;
std::mt19937 mtt(rdt());
std::uniform_real_distribution<double> randangle(-40, 40);
std::uniform_real_distribution<double> randinterval(0, 10);
angle = (double)randangle(mtt);
interval = (double)randinterval(mtt);
}
};
class DNA
{
public:
DNA() {};
~DNA() {};
vector<Drive> gene;
int len = 0;
clock_t start = 0, end = 0;
double time = 0.0f;
double fit = 0.0f;
int now = 0;
bool isStart = false;
void CreateRandomData(int size);
void SetData(DNA* dna);
DNA* CreateNextGene(DNA* dna);
};
#endif