|
ʻOhana
Population structure, admixture history, and selection using learning methods.
|
7 #ifndef JADE_CONTROLLER_HPP__
8 #define JADE_CONTROLLER_HPP__
10 #include "jade.likelihood.hpp"
11 #include "jade.settings.hpp"
12 #include "jade.simplex.hpp"
13 #include "jade.stopwatch.hpp"
22 template <
typename TValue>
71 static const auto inf = std::numeric_limits<value_type>::max();
86 for (
size_t row = 0; row < _rk; row++)
87 for (
size_t col = 0; col <= row; col++)
104 return -_likelihood(_c, log_c_det);
126 <<
"\nlog likelihood = "
135 const auto & cout = opts.
get_cout();
136 std::cout <<
"Writing C matrix to " << cout << std::endl;
138 std::ofstream out (cout);
140 throw error() <<
"failed to create matrix '" << cout <<
"'";
147 std::cout <<
"[C Matrix]\n";
149 std::cout << _c << std::endl;
186 const auto dlle = log_args.
iteration == 1
190 std::ostringstream line;
192 << std::fixed << std::setprecision(6)
193 <<
'\t' << _iteration_time;
195 line <<
'\t' << dlle <<
'\t' << lle;
196 std::cout << line.str() << std::endl;
209 : _rk (settings.get_rf().get_height())
210 , _c (settings.
get_c())
212 , _likelihood (settings.get_rf(), settings.get_mu())
239 #endif // JADE_CONTROLLER_HPP__
basic_controller(const settings_type &settings)
Initializes a new instance of the class based on the specified settings.
virtual container_type init_parameters()=0
Creates and returns the initial set of parameters for the Nelder- Mead algorithm.
A template for a class that performs the Nelder-Mead optimization. This class implements shared featu...
value_type compute_objfunc(const container_type ¶ms)
Computes the objective function by decoding the specified Nelder- Mead parameters into a covariance m...
basic_settings< value_type > settings_type
The settings type.
Arguments passed to the logging function.
bool is_cout_specified() const
virtual bool _decode_lower(matrix_type &dst, const container_type &src)=0
Decodes the specified Nelder-Mead container and stores the result into the lower triangle,...
void log_iteration(const log_args_type &log_args)
Logs information about the specified context for one iteration of the Nelder-Mead algorithm.
simplex_type::exit_condition_type exit_condition_type
The exit condition for the simplex.
static void set_high_precision(std::ostream &out)
Sets the specified stream to scientific notation with a high precision.
basic_options< value_type > options_type
The options type.
basic_likelihood< value_type > likelihood_type
The likelihood type.
A template for a class that implements the Nelder-Mead Simplex Method, which attempts to minimize an ...
std::vector< value_type > container_type
The container type.
bool is_size(const basic_matrix &other) const
simplex_type::container_type container_type
The container type for the simplex.
simplex_type::log_args log_args_type
The loc arguments for the simplex.
virtual void emit_results(const options_type &opts, const simplex_type &simplex, const exit_condition_type &)
Writes results to standard output and files.
const value_type & get_objval() const
bool invert(value_type &log_det)
Computes and stores the inverse of this matrix using the Cholesky square root method....
A template for a class encapsulating the settings provided to the optimizer.
const container_type & get_vertex() const
TValue value_type
The value type.
virtual ~basic_controller()
Reclaims resources, if any, used by the instance.
basic_matrix< value_type > matrix_type
The matrix type.
void copy_lower_to_upper()
Copies the elements in the lower triangle of the square matrix to the corresponding upper triangle el...
A template for a class representing an exception thrown from this namespace.
const matrix_type & get_c() const
const basic_simplex * simplex
The simplex instance.
basic_simplex< value_type > simplex_type
The simplex type.
const std::string & get_cout() const
size_t iteration
The completed iteration.