-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (32 loc) · 972 Bytes
/
Copy pathmain.cpp
File metadata and controls
48 lines (32 loc) · 972 Bytes
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
#include "data.h"
#include <time.h>
#include <iostream>
#include <chrono>
#include <fstream>
#include "ils.h"
#include "solution.h"
int main() {
auto inicio = std::chrono::high_resolution_clock::now();
char *argv[2];
argv[0] = (char *) "TSP";
argv[1] = (char *) "instances/burma14.tsp";
srand(time(NULL));
Data & data = Data::getInstance();
data.read(2, argv);
Solution s;
int maxIter = 50, maxIterIls = data.n >= 150 ? data.n / 2: data.n;
s = ils(maxIter, maxIterIls);
s.print();
auto fim = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> duracao = fim - inicio;
std::ofstream tempo("tempo.txt", std::ios::app);
if(tempo.is_open()) {
tempo << "+ " << duracao.count() << std::endl;
tempo.close();
}
std::ofstream custo("custo.txt", std::ios::app);
if(custo.is_open()) {
custo << "+ " << s.cost << std::endl;
}
return 0;
}