-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
59 lines (30 loc) · 1.31 KB
/
main.cpp
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
#include <iostream>
#include <ctime>
#include "Graph.hpp"
#include "antColony.hpp"
int main()
{
Graph map("TSPLIB/kroC100.tsp/kroC100.tsp","TSPLIB/kroC100.opt.tour/kroC100.opt.tour" );
// Graph map("TSPLIB/st70.tsp/st70.tsp","TSPLIB/st70.opt.tour/st70.opt.tour" );
// Graph map("TSPLIB/pr76.tsp/pr76.tsp","TSPLIB/pr76.opt.tour/pr76.opt.tour" );
// Graph map("TSPLIB/lin105.tsp/lin105.tsp","TSPLIB/lin105.opt.tour/lin105.opt.tour" );
int max_it = 100;
int num_ants = 100;
float decay_factor = 0.1;
float heuristic_coefficient = 2;
float history_coefficient = 1;
float greediness_factor = 0.9;
bool elitist = false;
float solution = 0;
std::cout<< "Initializing ant_colony"<<std::endl;
std::cout<< "Number of cities: "<<map.num_vertices()<<std::endl;
std::cout<<"Optimal Cost: "<<map.optimal_cost()<<std::endl;
clock_t start;
start = clock();
float aproximation = ant_colony(map, max_it, num_ants, decay_factor, heuristic_coefficient,
history_coefficient,greediness_factor,elitist);
clock_t end = clock() - start;
double timeACO = ((double)end)/CLOCKS_PER_SEC; // in seconds
std::cout<<"Time ACO version: "<<timeACO<<std::endl;
std::cout<<"Aproximation ACO version: "<<aproximation<<std::endl;
}