1 #ifndef STAN_SERVICES_VARIATIONAL_PRINT_PROGRESS_HPP
2 #define STAN_SERVICES_VARIATIONAL_PRINT_PROGRESS_HPP
5 #include <stan/math/prim/scal/err/check_positive.hpp>
6 #include <stan/math/prim/scal/err/check_nonnegative.hpp>
15 namespace variational {
34 const std::string& prefix,
35 const std::string& suffix,
37 static const char*
function =
38 "stan::services::variational::print_progress";
40 stan::math::check_positive(
function,
41 "Total number of iterations",
43 stan::math::check_nonnegative(
function,
46 stan::math::check_positive(
function,
49 stan::math::check_positive(
function,
53 int it_print_width = std::ceil(std::log10(static_cast<double>(finish)));
54 if (
io::do_print(m - 1, (start + m == finish), refresh)) {
58 ss << std::setw(it_print_width) << m + start
60 ss <<
" [" << std::setw(3)
61 << (100 * (start + m)) / finish
63 ss << (tune ?
" (Adaptation)" :
" (Variational Inference)");
Probability, optimization and sampling library.
bool do_print(const int n, const bool special, const int refresh)
Indicates whether it should print on the current iteration.
base_writer is an abstract base class defining the interface for Stan writer callbacks.
void print_progress(int m, int start, int finish, int refresh, bool tune, const std::string &prefix, const std::string &suffix, interface_callbacks::writer::base_writer &writer)
Helper function for printing progress for variational inference.