-
Notifications
You must be signed in to change notification settings - Fork 0
/
ga.hpp
37 lines (32 loc) · 794 Bytes
/
ga.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
#pragma once
#include "config.hpp"
#include <memory>
#include <string>
#include <vector>
class Chromosome;
class Population;
/*
* Genetic Algorithm class
* The genetic algorithm class is responsible for running the genetic
algorithm
*/
class GeneticAlgorithm {
public:
GeneticAlgorithm(int populationSize, int maxGenerations,
double mutationRate, double selectionPressure);
void save();
static void rouletteWheelSelection(
std::vector<std::shared_ptr<Chromosome>> &chromosomes,
int survivorsSize);
void initPopulation();
void run();
void printSummary();
void report();
int multiRoundTournamentSelection();
std::shared_ptr<Population> population;
int maxGenerations;
double mutationRate;
double selectionPressure;
int populationSize;
std::string resultsPath;
};