From 3ebd1879ec1a6d61787e7ce518ca74d0502f4f31 Mon Sep 17 00:00:00 2001 From: Andrew Pulsipher <45372570+apulsipher@users.noreply.github.com> Date: Mon, 4 Nov 2024 16:32:05 -0700 Subject: [PATCH] Add seed to lfmcmc run function (#30) * Add seed param to lfmcmc run function * Remove default param in lfmcmc-meat.hpp * Bumping version number * Make single header --- epiworld.hpp | 14 ++++++++++---- include/epiworld/epiworld.hpp | 2 +- include/epiworld/math/lfmcmc/lfmcmc-bones.hpp | 3 ++- include/epiworld/math/lfmcmc/lfmcmc-meat.hpp | 6 +++++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/epiworld.hpp b/epiworld.hpp index b59af62f..1e5a9a62 100644 --- a/epiworld.hpp +++ b/epiworld.hpp @@ -19,7 +19,7 @@ /* Versioning */ #define EPIWORLD_VERSION_MAJOR 0 #define EPIWORLD_VERSION_MINOR 4 -#define EPIWORLD_VERSION_PATCH 1 +#define EPIWORLD_VERSION_PATCH 2 static const int epiworld_version_major = EPIWORLD_VERSION_MAJOR; static const int epiworld_version_minor = EPIWORLD_VERSION_MINOR; @@ -1249,7 +1249,8 @@ class LFMCMC { void run( std::vector< epiworld_double > param_init, size_t n_samples_, - epiworld_double epsilon_ + epiworld_double epsilon_, + int seed = -1 ); LFMCMC() {}; @@ -1526,7 +1527,8 @@ class LFMCMC { void run( std::vector< epiworld_double > param_init, size_t n_samples_, - epiworld_double epsilon_ + epiworld_double epsilon_, + int seed = -1 ); LFMCMC() {}; @@ -1796,7 +1798,8 @@ template inline void LFMCMC::run( std::vector< epiworld_double > params_init_, size_t n_samples_, - epiworld_double epsilon_ + epiworld_double epsilon_, + int seed ) { @@ -1809,6 +1812,9 @@ inline void LFMCMC::run( params_init = params_init_; n_parameters = params_init_.size(); + if (seed >= 0) + this->seed(seed); + params_now.resize(n_parameters); params_prev.resize(n_parameters); diff --git a/include/epiworld/epiworld.hpp b/include/epiworld/epiworld.hpp index 398bf6c7..34501f93 100644 --- a/include/epiworld/epiworld.hpp +++ b/include/epiworld/epiworld.hpp @@ -19,7 +19,7 @@ /* Versioning */ #define EPIWORLD_VERSION_MAJOR 0 #define EPIWORLD_VERSION_MINOR 4 -#define EPIWORLD_VERSION_PATCH 1 +#define EPIWORLD_VERSION_PATCH 2 static const int epiworld_version_major = EPIWORLD_VERSION_MAJOR; static const int epiworld_version_minor = EPIWORLD_VERSION_MINOR; diff --git a/include/epiworld/math/lfmcmc/lfmcmc-bones.hpp b/include/epiworld/math/lfmcmc/lfmcmc-bones.hpp index 60a896f3..7002aa24 100755 --- a/include/epiworld/math/lfmcmc/lfmcmc-bones.hpp +++ b/include/epiworld/math/lfmcmc/lfmcmc-bones.hpp @@ -187,7 +187,8 @@ class LFMCMC { void run( std::vector< epiworld_double > param_init, size_t n_samples_, - epiworld_double epsilon_ + epiworld_double epsilon_, + int seed = -1 ); LFMCMC() {}; diff --git a/include/epiworld/math/lfmcmc/lfmcmc-meat.hpp b/include/epiworld/math/lfmcmc/lfmcmc-meat.hpp index 3984df2a..c7565121 100755 --- a/include/epiworld/math/lfmcmc/lfmcmc-meat.hpp +++ b/include/epiworld/math/lfmcmc/lfmcmc-meat.hpp @@ -205,7 +205,8 @@ template inline void LFMCMC::run( std::vector< epiworld_double > params_init_, size_t n_samples_, - epiworld_double epsilon_ + epiworld_double epsilon_, + int seed ) { @@ -218,6 +219,9 @@ inline void LFMCMC::run( params_init = params_init_; n_parameters = params_init_.size(); + if (seed >= 0) + this->seed(seed); + params_now.resize(n_parameters); params_prev.resize(n_parameters);