-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneticAlgorithm.hpp
More file actions
34 lines (29 loc) · 918 Bytes
/
GeneticAlgorithm.hpp
File metadata and controls
34 lines (29 loc) · 918 Bytes
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
//
// Created by danny on 2018-11-09.
//
#ifndef GENETICALGORITHM_GENETICALGORITHM_HPP
#define GENETICALGORITHM_GENETICALGORITHM_HPP
#include "Population.hpp"
#include "RandomNumGenerator.hpp"
#include <algorithm>
#include <iomanip>
#include <chrono>
class GeneticAlgorithm {
private:
constexpr static double MUTATION_RATE = 0.15;
constexpr static int CITIES_IN_TOUR = 32;
constexpr static int NUMBER_OF_PARENTS = 2;
constexpr static int PARENT_POOL_SIZE = 5;
constexpr static int NUMBER_OF_ELITES = 1;
constexpr static int ITERATIONS = 1000;
constexpr static double IMPROVEMENT = 0.54;
public:
GeneticAlgorithm() = default;
void evolve(Population&);
void selection(Population&) const;
Tour crossover(Tour, Tour);
void mutate(Tour &t) ;
vector<Tour> selectParents(Population &);
void optimize(Population&);
};
#endif //GENETICALGORITHM_GENETICALGORITHM_HPP