-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeneticAlgorithm.h
55 lines (39 loc) · 934 Bytes
/
GeneticAlgorithm.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
#pragma once
#ifndef GENETICALGORITHM_H
#define GENETICALGORTIHM_H
#include "Population.h"
#include "Record.h"
class GeneticAlgorithm
{
public:
GeneticAlgorithm(void);
~GeneticAlgorithm(void);
void Load( const int& cratio, const int& mratio, const int& psize,
const int& iter, const int& csize, const int& ssize,
const std::string& path);
void Start();
private:
void CreatePopulation();
double Evaluate();
void Crossover();
void Mutate();
void Select();
void SetParameters(const int& cratio, const int& mratio,
const int& psize, const int& iter, const int& csize,
const int& ssize );
void RecordResult(const double& result, const int& iter);
private:
int numberGenerations;
int mutationRatio;
int crossoverRatio;
int populationSize;
int chromosomeSize;
int selection_size;
double bestFitness;
int bestFitnessIndex;
float best_x;
float best_y;
Population pop;
Record record;
};
#endif