-
Notifications
You must be signed in to change notification settings - Fork 1
/
AntColony.hpp
53 lines (46 loc) · 1.04 KB
/
AntColony.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
#ifndef ANTCOLONY_H
#define ANTCOLONY_H
#include <vector>
#include <unordered_set>
#include <random>
#include "Graph.hpp"
#include "Ant.hpp"
using namespace std;
#define ANTS 10
#define RELATIVE_SIGNIFICANCE 1
#define THRESHOLD 0.9
#define EVAPORATION_RATE 0.9
#define PHI 0.9
#define MAX_IMPROVE_ATTEMPTS 150
class AntColony
{
private:
int n;
int m;
Graph G;
Graph GC;
vector<Ant *> ants;
vector<double> globalPheromone;
double initialPheromone;
unordered_set<int> bestSolution;
int bestCost;
int improveAttempts;
default_random_engine dre;
uniform_real_distribution<double> urd;
void computeGComplete();
void resetAnt(Ant *);
void updateConnectivityValue(Ant *, int);
void computeStep(Ant *);
void computeCycle();
void antTransition(Ant *, int);
void compareSolution(unordered_set<int> &, int);
void computeInitialSolution();
public:
AntColony(int, int);
~AntColony();
void addEdge(int, int);
void setWeight(int, int);
void setRandomEngine(int);
pair<unordered_set<int>, int> computeSolution();
};
#endif