-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfig.h
More file actions
148 lines (114 loc) · 4.72 KB
/
Config.h
File metadata and controls
148 lines (114 loc) · 4.72 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#pragma once
#include <unordered_map>
#include <string>
#include <tclap/CmdLine.h>
#include <stdexcept>
// set to 1 to output intermediate values to file
#define OUTPUT_INTERMEDIATE 1
#define USE_TIME_LIMIT 0
class Config {
public:
Config(const TCLAP::CmdLine& cmd){
auto args = cmd.getArgList();
for(auto it = args.begin(); it != args.end(); it++)
{
std::string name = (*it)->getName();
if(name == "cbne_version"){
auto casted_arg = static_cast<TCLAP::ValueArg<std::string>*>(*it);
cbne_version = casted_arg->getValue();
if(cbne_version != "cbne" && cbne_version != "cbneCheby" && cbne_version != "cbneMusco" && cbne_version != "cbneCompressed"){
throw std::invalid_argument("Value " + cbne_version + " is not valid for option -a. Please set a valid algorithm version.");
}
} else if (name == "output_shot_count") {
auto casted_arg = static_cast<TCLAP::SwitchArg*>(*it);
output_shot_count = casted_arg->getValue();
} else if (name == "output_step_count") {
auto casted_arg = static_cast<TCLAP::SwitchArg*>(*it);
output_step_count = casted_arg->getValue();
} else if (name == "out") {
auto casted_arg = static_cast<TCLAP::ValueArg<std::string>*>(*it);
out = casted_arg->getValue();
} else if (name == "num_data_points") {
auto casted_arg = static_cast<TCLAP::ValueArg<int>*>(*it);
number_of_data_points = casted_arg->getValue();
if(number_of_data_points < 1){
throw std::invalid_argument("Value " + std::to_string(number_of_data_points) + " is not valid for option -n. Please choose a number of data points >= 1.");
}
} else if (name == "time_limit"){
auto casted_arg = static_cast<TCLAP::ValueArg<int>*>(*it);
time_limit = casted_arg->getValue();
if(time_limit < -1){
throw std::invalid_argument("Value " + std::to_string(time_limit) + " is not valid for option -t. Please set a time limit >= -1.");
}
} else if (name == "path"){
auto casted_arg = static_cast<TCLAP::ValueArg<std::string>*>(*it);
path = casted_arg->getValue();
} else if (name == "iter_limit") {
auto casted_arg = static_cast<TCLAP::ValueArg<int>*>(*it);
iter_limit = casted_arg->getValue();
if(iter_limit < -1){
throw std::invalid_argument("Value " + std::to_string(iter_limit) + " is not valid for option -t. Please set an iteration limit >= -1.");
}
} else if( name == "deg_limit"){
auto casted_arg = static_cast<TCLAP::ValueArg<int>*>(*it);
deg_limit = casted_arg->getValue();
if(deg_limit < -1){
throw std::invalid_argument("Value " + std::to_string(deg_limit) + " is not valid for option -d. Please set a time limit >= -1.");
}
} else if (name == "use_one_norm") {
auto casted_arg = static_cast<TCLAP::SwitchArg*>(*it);
one_norm = casted_arg->getValue();
} else if (name == "epsilon"){
auto casted_arg = static_cast<TCLAP::ValueArg<double>*>(*it);
epsilon = casted_arg->getValue();
} else {
// TODO deal with unexpected arguments that are not help, version or ignore_rest
}
}
}
std::string get_path() const {
return path;
}
int get_iter_limit() const {
return iter_limit;
}
int get_deg_limit() const {
return deg_limit;
}
std::string get_out_path() const {
return out;
}
int get_num_data_points() const {
return number_of_data_points;
}
bool output_count() const {
return output_shot_count;
}
bool output_count_step() const {
return output_step_count;
}
bool use_one_norm() const {
return one_norm;
}
double get_epsilon() const {
return epsilon;
}
int get_time_limit() const {
return time_limit;
}
std::string get_cbne_version() const {
return cbne_version;
}
private:
int iter_limit;
int deg_limit;
std::string path;
std::string out;
int number_of_data_points;
bool output_shot_count;
bool output_step_count;
bool one_norm;
double epsilon;
int time_limit;
std::string cbne_version;
};