-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGene.hpp
37 lines (28 loc) · 819 Bytes
/
Gene.hpp
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
#ifndef __JM_GENETIC_ALGORITHM_GENE
#define __JM_GENETIC_ALGORITHM_GENE
#include <string>
#include <vector>
enum class Type {Operator, Variable, Constant};
class Gene {
public:
static void init(unsigned num_args, unsigned num_genes);
Gene() {}
Gene(unsigned gene_count);
void mutate();
unsigned getValue() const;
Type getType() const;
unsigned getIdx() const;
std::string toString() const;
double getValue(const std::vector<double>& args) const;
double doOperation(double val1, double val2) const;
private:
static unsigned m_num_args;
static unsigned m_num_genes;
unsigned m_idx;
Type m_type;
unsigned m_value;
Type _getNewType() const;
int _getNewValue() const;
bool _isOperator(char op) const;
};
#endif // __JM_GENETIC_ALGORITHM_GENE