diff --git a/epiworld.hpp b/epiworld.hpp index 5ce8e0ea..fdd96e08 100644 --- a/epiworld.hpp +++ b/epiworld.hpp @@ -1232,6 +1232,7 @@ class LFMCMC { std::chrono::time_point m_start_time; std::chrono::time_point m_end_time; + // Timing // std::chrono::milliseconds std::chrono::duration m_elapsed_time = std::chrono::duration::zero(); @@ -1245,6 +1246,10 @@ class LFMCMC { void chrono_start(); void chrono_end(); + + // Progress + bool verbose = true; + Progress progress_bar; public: @@ -1316,6 +1321,8 @@ class LFMCMC { std::vector< epiworld_double > get_mean_stats(); // Printing + LFMCMC & verbose_off(); + LFMCMC & verbose_on(); void print(size_t burnin = 0u) const; }; @@ -1523,6 +1530,7 @@ class LFMCMC { std::chrono::time_point m_start_time; std::chrono::time_point m_end_time; + // Timing // std::chrono::milliseconds std::chrono::duration m_elapsed_time = std::chrono::duration::zero(); @@ -1536,6 +1544,10 @@ class LFMCMC { void chrono_start(); void chrono_end(); + + // Progress + bool verbose = true; + Progress progress_bar; public: @@ -1607,6 +1619,8 @@ class LFMCMC { std::vector< epiworld_double > get_mean_stats(); // Printing + LFMCMC & verbose_off(); + LFMCMC & verbose_on(); void print(size_t burnin = 0u) const; }; @@ -1882,6 +1896,13 @@ inline void LFMCMC::run( for (size_t k = 0u; k < m_n_params; ++k) m_accepted_params[k] = m_initial_params[k]; + // Init progress bar + progress_bar = Progress(m_n_samples, 80); + if (verbose) { + progress_bar.next(); + } + + // Run LFMCMC for (size_t i = 1u; i < m_n_samples; ++i) { // Step 1: Generate a proposal and store it in m_current_params @@ -1938,6 +1959,9 @@ inline void LFMCMC::run( for (size_t k = 0u; k < m_n_params; ++k) m_accepted_params[i * m_n_params + k] = m_previous_params[k]; + if (verbose) { + progress_bar.next(); + } } // End timing @@ -2412,6 +2436,20 @@ inline std::vector< epiworld_double > LFMCMC::get_mean_stats() } +template +inline LFMCMC & LFMCMC::verbose_off() +{ + verbose = false; + return *this; +} + +template +inline LFMCMC & LFMCMC::verbose_on() +{ + verbose = true; + return *this; +} + #endif /*////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// diff --git a/include/epiworld/math/lfmcmc/lfmcmc-bones.hpp b/include/epiworld/math/lfmcmc/lfmcmc-bones.hpp index 4ec81ccd..ace7b637 100755 --- a/include/epiworld/math/lfmcmc/lfmcmc-bones.hpp +++ b/include/epiworld/math/lfmcmc/lfmcmc-bones.hpp @@ -170,6 +170,7 @@ class LFMCMC { std::chrono::time_point m_start_time; std::chrono::time_point m_end_time; + // Timing // std::chrono::milliseconds std::chrono::duration m_elapsed_time = std::chrono::duration::zero(); @@ -183,6 +184,10 @@ class LFMCMC { void chrono_start(); void chrono_end(); + + // Progress + bool verbose = true; + Progress progress_bar; public: @@ -254,6 +259,8 @@ class LFMCMC { std::vector< epiworld_double > get_mean_stats(); // Printing + LFMCMC & verbose_off(); + LFMCMC & verbose_on(); void print(size_t burnin = 0u) const; }; diff --git a/include/epiworld/math/lfmcmc/lfmcmc-meat.hpp b/include/epiworld/math/lfmcmc/lfmcmc-meat.hpp index a44b6f0a..c4f68f47 100755 --- a/include/epiworld/math/lfmcmc/lfmcmc-meat.hpp +++ b/include/epiworld/math/lfmcmc/lfmcmc-meat.hpp @@ -263,6 +263,13 @@ inline void LFMCMC::run( for (size_t k = 0u; k < m_n_params; ++k) m_accepted_params[k] = m_initial_params[k]; + // Init progress bar + progress_bar = Progress(m_n_samples, 80); + if (verbose) { + progress_bar.next(); + } + + // Run LFMCMC for (size_t i = 1u; i < m_n_samples; ++i) { // Step 1: Generate a proposal and store it in m_current_params @@ -319,6 +326,9 @@ inline void LFMCMC::run( for (size_t k = 0u; k < m_n_params; ++k) m_accepted_params[i * m_n_params + k] = m_previous_params[k]; + if (verbose) { + progress_bar.next(); + } } // End timing @@ -544,4 +554,18 @@ inline std::vector< epiworld_double > LFMCMC::get_mean_stats() } +template +inline LFMCMC & LFMCMC::verbose_off() +{ + verbose = false; + return *this; +} + +template +inline LFMCMC & LFMCMC::verbose_on() +{ + verbose = true; + return *this; +} + #endif \ No newline at end of file