-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
57 lines (48 loc) · 1.7 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
50
51
52
53
54
55
56
57
#include <iostream>
#include <chrono>
#include "Config.h"
#include "Grid.h"
int main(int argc, char *argv[]) {
// arguments to take are only the config file, which defines everything else
auto start_t = std::chrono::high_resolution_clock::now();
// CONFIG - variables
std::string configFileAddress{"config.yaml"};
if (argc == 1) {
configFileAddress = "config.yaml";
} else if (argc == 2) {
configFileAddress = argv[1];
} else {
std::cerr << "Too many arguments passed. Model takes only one argument, the config filepath.\n";
exit(1);
}
const Config modelConfig(configFileAddress);
if (modelConfig.m_verbosity == 2) {
std::cout << "Number of arguments received: " << argc << "\nArguments received:\n";
for (int i = 0; i < argc; ++i) {
std::cout << argv[i] << '\n';
}
std::flush(std::cout);
}
// Base Grid which each run will work off
Grid baseGrid(&modelConfig);
// BURN IN
if (modelConfig.m_burnIn) {
baseGrid.run("run_burn_in", true);
}
// RUNS
for (size_t run = 1; run <= modelConfig.m_numModelRuns; ++run) {
std::string runName{"run_" + std::to_string((run))};
Grid runGrid = baseGrid;
runGrid.run(runName, false);
}
// REPORTING - WRITING
modelConfig.writeReports();
auto end_t = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed_t{end_t - start_t};
if (modelConfig.m_verbosity >= 1) {
std::cout << "\nProgram duration (s): " << elapsed_t.count() << "\nAverage Run Duration (s): "
<< elapsed_t.count() / modelConfig.m_numModelRuns << '\n';
}
return 0;
}
//