-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.cc
35 lines (30 loc) · 978 Bytes
/
options.cc
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
#include <cmath>
#include <stdexcept>
#include "options.hpp"
command_line_options::command_line_options()
: N{1000}, psurvival{0.}, nsteps{1000},
simplification_interval{100}, rho{0.}, treefile{"treefile.trees"},
buffer_new_edges{false}, cppsort{false}, parallel_sort{false}, seed{42}
{
}
void
validate_cli(const command_line_options& options)
{
if (options.N == 0)
{
throw std::invalid_argument("Population size must be > 0");
}
if (options.psurvival < 0. || options.psurvival >= 1.
|| std::isfinite(options.psurvival) == false)
{
throw std::invalid_argument("psurvival must be 0.0 <= p < 1.0");
}
if (options.rho < 0.0 || std::isfinite(options.rho) == false)
{
throw std::invalid_argument("rho must be >= 0.0");
}
if (options.treefile.empty())
{
throw std::invalid_argument("treefile must not be an empty string");
}
}