-
Notifications
You must be signed in to change notification settings - Fork 0
/
TSP.h
55 lines (39 loc) · 964 Bytes
/
TSP.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
/**
* @file TSP.h
* @brief TSP data
*
*/
#ifndef TSP_H
#define TSP_H
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
/**
* Class that describes a TSP instance (a cost matrix, nodes are identified by integer 0 ... n-1)
*/
class TSP
{
public:
int n;
std::vector< std::vector<double> > cost;
double infinite; // infinite value (an upper bound on the value of any feasible solution
TSP() : n(0) , infinite(1e10) {}
void readFromFile(const char* filename) {
std::ifstream in(filename);
in >> n;
std::cout << "read from file, num nodes = " << n << std::endl;
cost.resize(n);
for (int i = 0; i < n; i++) {
cost[i].reserve(n);
for (int j = 0; j < n; j++) {
double c;
in >> c;
cost[i].push_back(c);
}
}
in.close();
}
};
#endif /* TSP_H */