-
Notifications
You must be signed in to change notification settings - Fork 0
/
individual.hpp
36 lines (35 loc) · 1.23 KB
/
individual.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
#include <iostream>
using std::string;
#include <vector>
using std::vector;
class Individual {
private:
vector<size_t> _genes;
double _fitness;
double _proportional_faction;
public:
//propios
Individual();
Individual(const vector<size_t>& genes);
~Individual();
//getters & setters
float getFitness() const;
string getGenes() const;
vector<size_t> getGenesValues() const;
Individual swapGenesOnePoint(const Individual& parent);
void swapMutation();
void setProportionalFraction(const double value);
//metodos
void calcFitness();
Individual mate(const Individual& parent);
void mutateGenes(double probability); //falta
void initRandGenes();
bool operator<(Individual &p);
//friends
friend void orderCrossover_OX(Individual& parent1, Individual& parent2);
void orderCrossover_PX(const Individual& parent1, const Individual& parent2);
private:
inline double calcDistance(double,double,double,double);
inline double calcRouteDistance();
inline bool isGeneInSection( size_t gene, size_t iSectionStart, size_t iSectionEnd) const;
};