rosa/bench/graspels/main.cpp

50 lines
1.0 KiB
C++

#include <getopt.h>
#include <sstream>
#include "common.h"
#include "decl.h"
Arguments cli(int argc, char **argv) {
int option_index, option;
struct option long_options[] = {
{"seed", required_argument, 0, 's' },
{0, 0, 0, 0 }
};
Arguments args;
args.seed = SEED;
optind = 0;
while((option = getopt_long(argc, argv,
"" "" "" "s:",
long_options, &option_index)) != -1) {
switch(option) {
case 's': {
std::istringstream iss{optarg};
iss >> args.seed;
} break;
default:;
}
}
return args;
}
int main(int argc, char **argv) {
Arguments args = cli(argc, argv);
tsp::Tsp tspData{DATA_FILE};
tsp::Problem problem{tspData.points()};
RNG rng{args.seed};
std::printf("conf: f: %s, data: %s, grasp: %s, outer: %s, inner: %s, threads: %s, seed: %zu\n",
STR(FUNC), STR(DATA_FILE), STR(GRASP_N), STR(ELS_ITER_MAX), STR(ELS_GEN), STR(NTHREADS), args.seed);
tsp::Solution s;
auto task = [&]{ s = FUNC(problem, rng, args); };
timeit(RUSAGE_SELF, "", task);
std::cout << "result: " << s.value() << std::endl;
}