8 #include "core/LongOptions.h" 9 #include "core/Arguments.h" 12 #include "ABCSMCController.h" 17 R
"(* Help message for 'smc' controller * 20 The ABC sequential Monte Carlo (SMC) method evolves a population of 21 parameters through multiple generations to an approximate posterior 22 distribution, with epsilon decreasing at each generation. The generations 23 are numbered starting from 0. 25 The sequence of epsilon values is given by the comma-separated list 26 'epsilons'. The number of values in 'epsilons' determines the number of 29 The first generation of candidate parameters is obtained from the stdout of 32 In subsequent generations, candidate parameters are sampled by perturbing a 33 parameter from the previous generation with 'perturber'. 'perturber' accepts 34 two lines as its input; the first line contains the current generation 't' 35 and the second line contains the parameter to be perturbed. 37 The parameter to be perturbed is sampled from the previous generation with 38 weights that are calculated using 'prior_pdf' and 'perturbation_pdf'. 39 'prior_pdf' accepts a parameter on its stdin and returns the corresponding 40 prior probability density on its stdout. 42 'perturbation_pdf' accepts at least two lines on its stdin, containing the 43 current generation 't' and the perturbed parameter, respectively. This is 44 then followed by an arbitrary number of parameters, each on a separate line. 45 For every parameter from the third line onwards, 'perturbation_pdf' outputs 46 on its stdout the corresponding probability density for reaching the 47 perturbed parameter by perturbing the given parameter. 49 For every candidate parameter, 'simulator' is invoked and given two lines as 50 its input; the first line contains the current epsilon value and the second 51 line contains the candidate parameter. 53 The output of 'simulator' indicates whether the parameter was accepted or 54 rejected; an output of '0', 'reject' or 'rejected' means that the parameter 55 was rejected and an output of '1', 'accept' or 'accepted' means that the 56 parameter was accepted. 58 Upon completion, the controller outputs the parameter names, followed by 59 newline-separated list of accepted parameters. 62 -N, --population-size=NUM NUM is the parameter population size 63 -E, --epsilons=EPS EPS is comma-separated list of tolerances 64 that are passed to simulator 65 -P, --parameter-names=NAMES NAMES is comma-separated list of 67 -S, --simulator=CMD CMD is simulator command 68 -R, --prior-sampler=CMD CMD is prior_sampler command 69 -T, --perturber=CMD CMD is perturber command 70 -I, --prior-pdf=CMD CMD is prior_pdf command 71 -U, --perturbation-pdf=CMD CMD is perturbation_pdf command 73 ABC SMC controller options: 74 -s, --seed=SEED SEED is the seed for the pseudo random number 75 generator that is used to sample from the 76 parameter population (by default, the seed is 77 derived from the system clock). 84 lopts.
add({
"population-size", required_argument,
nullptr,
'N'});
85 lopts.
add({
"epsilons", required_argument,
nullptr,
'E'});
86 lopts.
add({
"parameter-names", required_argument,
nullptr,
'P'});
87 lopts.
add({
"simulator", required_argument,
nullptr,
'S'});
88 lopts.
add({
"prior-sampler", required_argument,
nullptr,
'R'});
89 lopts.
add({
"perturber", required_argument,
nullptr,
'T'});
90 lopts.
add({
"prior-pdf", required_argument,
nullptr,
'I'});
91 lopts.
add({
"perturbation-pdf", required_argument,
nullptr,
'U'});
92 lopts.
add({
"seed", required_argument,
nullptr,
's'});
145 catch (
const std::out_of_range& e)
147 std::string error_msg;
148 error_msg +=
"Out of range: ";
149 error_msg += e.what();
151 error_msg +=
"One or more arguments missing or incorrect, try '";
153 error_msg +=
" smc --help' for more info";
154 throw std::runtime_error(error_msg);
156 catch (
const std::invalid_argument& e)
158 std::string error_msg;
159 error_msg +=
" Invalid argument: ";
160 error_msg += e.what();
162 error_msg +=
"One or more arguments missing or incorrect, try '";
164 error_msg +=
" smc --help' for more info";
165 throw std::runtime_error(error_msg);
static ABCSMCController * makeController(const Arguments &args)
const char * g_program_name
ABCSMCController(const Input &input_obj)
static void addLongOptions(LongOptions &lopts)
bool isOptionalArgumentSet(const std::string &option_name) const
static std::string help()
void add(struct option long_opt)
std::string optionalArgument(const std::string &option_name) const