-
Notifications
You must be signed in to change notification settings - Fork 20
/
main.cpp
49 lines (44 loc) · 1.49 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
#include "espprc.h"
#include <sstream>
#include <fstream>
#include <ctime>
void reader(std::vector< std::vector<int> >& data, std::string& filename, int& max_capacity) {
std::ifstream infile(filename);
std::string line;
int tmp;
for (int i = 0; i < 9; i++) {
std::getline(infile, line);
if (i == 4) {
std::istringstream iss(line);
iss >> tmp >> max_capacity;
}
}
while (std::getline(infile, line)) {
if (line.size() < 2) break;
if (line.empty() || std::all_of(line.begin(), line.end(), isspace)) {
break; // Exit the loop if an empty line is found
}
std::istringstream iss(line);
std::vector<int> tv;
iss >> tmp;
while (iss >> tmp)
tv.push_back(tmp);
data.push_back(tv);
}
}
int main(int args, char *argv[]) {
std::string filename = argv[1];
//std::string filename = "data/solomon_100/C201.txt";
int max_capacity;
std::vector< std::vector<int> > data;
reader(data, filename, max_capacity);
int node_number = int(data.size()) + 1, step = 10, lt = int(0.1 * data[0][4]), ut = data[0][4];
Espprc model(node_number, 0, node_number - 1, step, lt, ut, max_capacity, data);
//model.G.show_graph(); model.print_para();
double duration;
std::clock_t start = std::clock();
model.espprc();
duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
std::cout<<"duration: "<<duration<<std::endl;
return 0;
}