-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.hpp
55 lines (40 loc) · 1.03 KB
/
main.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
55
#include <iostream>
#include <set>
#include <exception>
#include <string>
#include <vector>
const int ANT_COUNT = 100;
const int BETA = 2;
const float PHEROMONE_INIT_VALUE = 5;
const float ALPHA = 0.1;
const float RHO = 0.1;
struct MissingColumnException : public std::exception {
const char * what () const throw () {
return "Malformed line in CSV input. There was expected another column.";
}
};
struct Flight {
std::string source;
std::string destination;
uint16_t departure;
uint16_t price;
float pheromone;
};
struct Ant {
std::string actualCity;
std::string nextCity;
std::set<std::string> nonVisitedCities;
std::vector<Flight> path;
uint16_t cost;
bool active;
};
void printResults();
void printPath(std::vector<Flight> path);
void sig_handler(int signal);
void readCsv();
void printCities();
void initAnts();
void init();
std::string getNextCity(std::string source, uint16_t departure, std::set<std::string> nonVisitedCities);
void evaluateAnt(int antIndex);
void evaluate();