-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_program.hpp
65 lines (56 loc) · 1.63 KB
/
run_program.hpp
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
/**
* @file program.hpp
* @author Simone Romiti ([email protected])
* @brief Running program function. Template argument specified gauge group
* @version 0.1
* @date 2022-10-16
*
* @copyright Copyright (c) 2022
*
*/
#pragma once
#include <ctime>
#include <iostream>
#include <sstream>
#include "boost/lexical_cast.hpp"
#include "parse_input_file.hh"
#include "hmc.hpp"
#include "measure.hpp"
#include "metropolis.hpp"
/**
* @brief program function for hmc, metropolis and measure
* This function takes the `int main()` function parameters and runs the MCMC simulation.
* Depending on the input file passed through `argv` it decides whether to
* - do the MCMC with metropolis or hmc
* - do the offline/online measurements
*
* @tparam Group gauge group: _u1 or _su2
* @param argc
* @param argv
*/
template <class Group> void run_program(int argc, char *argv[]) {
std::string input_file;
parse_command_line(argc, argv, input_file);
std::cout << "## Parsing input file: " << input_file << "\n";
running_program rp; // running program
YAML::Node nd = YAML::Clone(get_cleaned_input_file(rp, input_file));
bool &do_hmc = rp.do_hmc;
bool &do_metropolis = rp.do_metropolis;
bool &do_omeas = rp.do_omeas;
if (do_hmc ^ do_metropolis) { // one of the 2 algorithms
if (do_hmc) {
hmc_algo<Group> h;
h.run(nd);
} else if (do_metropolis) {
metropolis_algo<Group> mpl;
mpl.run(nd);
}
} else if (do_omeas) { // offline measurements
measure_algo<Group> ms;
ms.run(nd);
} else { // program does nothing
std::cerr << "ERROR: Program ineffective.\n";
exit(1);
}
return;
}