NANA
gene.h
浏览该文件的文档.
1#pragma once
14#include <NANA/core.hpp>
15#include <vector>
16namespace NANA {
17namespace GA {
21class NA_API CGeneInt NA_FINAL {
22public:
23
24 CGeneInt(int minV, int maxV);
28 void initGene();
32 int translate();
33private:
34 std::vector<bool> m_gene;
35 int m_minV;
36 int m_maxV;
37};
38
39
43class NA_API GeneFloat NA_FINAL {
44public:
45
46 GeneFloat(double minV, double maxV, double eps);
50 void initGene();
51
55 double translate();
56
57
61 void mutate();
62
69 static void cross(const GeneFloat& father, const GeneFloat& mother, GeneFloat& child);
70
71
72private:
73 double m_minV;
74 double m_maxV;
75 double m_eps;
76 double m_rate;
77 int m_lenGene;
78 std::vector<bool> m_gene;
79};
80
81
82
83
84
85
86}
87}
基因表示整数
Definition: gene.h:21
static void cross(const GeneFloat &father, const GeneFloat &mother, GeneFloat &child)
染色体的交换
int translate()
将基因转化为对应的值
void initGene()
基因初始化
double translate()
转录,将基因信息转为值
void mutate()
基因变异
#define NA_API
兼容windows系统与linux系统
Definition: core_global.h:24