-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.hpp
54 lines (45 loc) · 1.36 KB
/
utils.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// Created by humbl on 11/13/2019.
//
//utility and helper program including file reading, environment setting, and etc.
#ifndef GENETICALGORITHM_UTILS_HPP
#define GENETICALGORITHM_UTILS_HPP
#include <ostream>
#include "city.hpp"
#include "tour.hpp"
//environment parameters from a config file
struct configure {
int CITIES_IN_TOUR;
int POPULATION_SIZE;
int SHUFFLES;
int ITERATIONS;
int MAP_BOUNDARY;
int PARENT_POOL_SIZE;
int MUTATION_RATE;
int NUMBER_OF_PARENTS;
int NUMBER_OF_ELITES;
int MUTATION_TOURS_RATIO;
int IMPROVEMENT_FACTOR;
void setValue(int idx, int val);
friend ostream &operator<<(ostream &os, const configure &configure);
};
//structure including report items
struct report {
int iteration;
tour elite_tour;
bool is_improved;
double improvement;
bool step_improved;
double step_improvement;
report(int iteration, const tour &eliteTour, bool isImproved, double improvement);
report(int iteration, const tour &eliteTour, bool isImproved, double improvement, bool stepImproved,
double stepImprovement);
};
//util methods
void readConfig(string & filename, configure & cfg);
//helper functions for printing
void print_city(city candidate);
void print_tour(tour t);
void print_report(report r);
void print_population(vector<tour> v);
#endif //GENETICALGORITHM_UTILS_HPP