-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_main.cpp
71 lines (64 loc) · 1.46 KB
/
gen_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <iomanip>
#include "bigint/BigIntegerLibrary.hh"
#include "MatrixGen.h"
#include "GTGen.h"
#include "PermutationsGen.h"
void print_usage()
{
std::cerr << "Usage: cvrp_gen_cpp [<N>] [<method>]" << std::endl;
std::cerr << " where <N> is the number of customers" << std::endl;
std::cerr << " where <method> is the generation method \"matrix\"/\"giant_tours\"/\"permutations\"" << std::endl;
}
/*
Enumerates all solutions and prints them (if compiled with PRINT_SOLUTIONS),
otherwise just print the number of generated solutions.
*/
int main(int argc, char **argv)
{
unsigned long long possible_sols = 0;
int N = 3;
std::string method = "permutations";
if (argc == 0)
{
print_usage();
std::cerr << "Running with defaults N=" << N <<" method=" << method << std::endl;
}
if (argc > 1)
{
N = atoi(argv[1]);
if (N<=0)
{
print_usage();
exit(-1);
}
}
if (argc > 2)
method = std::string(argv[2]);
if (method == "matrix")
{
possible_sols = generate_solutions_M(N);
}
else if (method == "giant_tours")
{
possible_sols = generate_solutions_gt(N);
}
else if (method == "permutations")
{
possible_sols = generate_solutions_P(N);
}
else
{
std::cerr << "Unknown generation method " << method << "!" <<std::endl;
print_usage();
exit(-1);
}
#ifndef PRINT_SOLUTIONS
std::cout << std::setprecision(30) << possible_sols << std::endl;
#endif
#ifdef _DEBUG
getchar();
#endif
}