-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndividual.h
67 lines (46 loc) · 1.28 KB
/
Individual.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
//
// Created by bruno on 07/03/2019.
//
#ifndef GENETICALGORITHM_INDIVIDUAL_H
#define GENETICALGORITHM_INDIVIDUAL_H
#include "random"
#include "constants.h"
#include <iostream>
#include <vector>
#include <iomanip>
#include <limits>
#include "bitset"
#include "Bitwise.h"
class Individual {
private:
std::vector<int> chromossome;
int size;
double fitness;
public:
virtual ~Individual();
Individual(int ArgSize);
Individual(const Individual& i);
Individual& operator =(const Individual& i);
void setFitness(double fitness) {
Individual::fitness = fitness;
}
double getFitness() const {
return fitness;
}
const std::vector<int> &getChromossome() const {
return chromossome;
}
void setChromossome(int index, int value) {
chromossome[index] = value;
}
int initializeChromossomeRandom();
int initializeChromossomeRange(int lower, int upper);
int initializeChromossomeRangeFloat(float lower, float upper);
void initializeChromossomeParameters(std::vector<int> coef);
void mutate();
void crossover(Individual* ind);
void evaluateIndividual(std::vector<double> point, char type);
void printIndividual();
void copy(Individual *i);
};
#endif //GENETICALGORITHM_INDIVIDUAL_H