-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaco.h
66 lines (49 loc) · 1.26 KB
/
aco.h
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
56
57
58
59
60
61
62
63
64
65
66
#include <vector>
#include <iostream>
using namespace std;
class ACO{
vector<vector<double> > dist;
vector<vector<double> > pheromone;
vector<vector<double> > choice_info;
struct single_ant{
double tour_length;
vector<int> tour;
vector<bool> visited;
};
struct tour{
vector<int> tour;
double tour_length;
};
int numTour;
int numBit;
int numAnt;
int numNode;//Number of Node.
double ph;//the initial value of Pheromones
double ep;//the parameter of the evaporation of Pheromones
double q;//the random number parameter
string C;
string M;
vector<single_ant> ant;//arrey of ant's struct.
vector<tour> collectorTour;
bool PoB;//false for Pixel position and true for Bit position.
public:
int iteration;
double bestTourLength;
vector<int> bestTour;
ACO(string,string,int,bool);
private:
void init();
void constructSolution();
void chooseBestNext(int,int);
void ASDecisionRule(int, int);
void ACSLocalPheromoneUpdate(int,int);
void ACSGlobalPheromoneUpdate();
void ASPheromoneUpdate();
void evaporate();
void depositPheromoneBestSoFar(int);
void depositPheromone(int);
void computeChoiceInformation();
double ComputeTourLength(int);
void updateStatistics();
int bitToDec(string);
};