-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.cpp
More file actions
82 lines (69 loc) · 2.4 KB
/
Copy pathrunner.cpp
File metadata and controls
82 lines (69 loc) · 2.4 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include <vector>
#include <fstream>
#include <unordered_set>
#include <chrono>
#include <iomanip>
#include <random>
#include <boost/multi_array.hpp>
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
namespace po = boost::program_options;
using namespace boost;
using namespace std;
unsigned timeLimit;
string format;
chrono::system_clock::time_point startTime;
#include "rng.hpp"
#include "instance.hpp"
#include "solution.hpp"
#include "report.hpp"
Report report;
#include "library/elite.hpp"
#include "library/localsearch.hpp"
#include "library/tabusearch.hpp"
#include "library/construct.hpp"
#include "library/recombine.hpp"
#include "algorithm.cpp"
int main(int argc, char *argv[]) {
po::options_description desc("General options");
desc.add_options()
("help", "show help")
("ins", po::value<string>(), "instance")
("seed", po::value<unsigned>()->default_value(0), "random seed")
("runtime", po::value<unsigned>()->default_value(300), "running time limit (s)")
("maximize", po::value<bool>()->default_value(false), "multiply weight by -1")
("format", po::value<string>()->default_value("sparse"), "instance format (sparse, pgen, maxcut, tap...)")
("target", po::value<double>()->default_value(numeric_limits<int>::min()), "target value")
;
po::positional_options_description pod;
pod.add("ins", 1);
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).options(desc).positional(pod).run(), vm);
po::notify(vm);
cout << fixed;
if (vm.count("help") || !vm.count("ins")) {
cout << desc << endl;
return 0;
}
unsigned seed = vm["seed"].as<unsigned>();
setupRandom(seed);
Instance I;
string instanceName = vm["ins"].as<string>();
ifstream ins(instanceName);
if (!ins.good()) {
cout << "Can't open instance file " << instanceName << endl;
return 1;
}
double target = vm["target"].as<double>();
timeLimit = vm["runtime"].as<unsigned>();
bool maximize = vm["maximize"].as<bool>();
string format = vm["format"].as<string>();
I.readInstance(ins, maximize, format);
Solution S(I);
startTime = chrono::system_clock::now();
run(S, I, target, startTime);
if(format == "tap") S.value += (I.btb * I.P);
cout << S.value << endl;
}