diff --git a/src/stan/mcmc/chains.hpp b/src/stan/mcmc/chains.hpp index a0c8e789727..507a5bc537e 100644 --- a/src/stan/mcmc/chains.hpp +++ b/src/stan/mcmc/chains.hpp @@ -13,8 +13,6 @@ #include #include #include -#include -#include #include #include #include @@ -44,7 +42,7 @@ using Eigen::Dynamic; * *

Storage Order: Storage is column/last-index major. */ -template +template class chains { private: std::vector param_names_; diff --git a/src/stan/model/model_base.hpp b/src/stan/model/model_base.hpp index bb9a50c20db..1f6de972f98 100644 --- a/src/stan/model/model_base.hpp +++ b/src/stan/model/model_base.hpp @@ -7,7 +7,7 @@ #include #endif #include -#include +#include #include #include #include @@ -367,8 +367,7 @@ class model_base : public prob_grad { * in output * @param[in,out] msgs msgs stream to which messages are written */ - virtual void write_array(boost::ecuyer1988& base_rng, - Eigen::VectorXd& params_r, + virtual void write_array(stan::rng_t& base_rng, Eigen::VectorXd& params_r, Eigen::VectorXd& params_constrained_r, bool include_tparams = true, bool include_gqs = true, std::ostream* msgs = 0) const = 0; @@ -618,8 +617,7 @@ class model_base : public prob_grad { * in output * @param[in,out] msgs msgs stream to which messages are written */ - virtual void write_array(boost::ecuyer1988& base_rng, - std::vector& params_r, + virtual void write_array(stan::rng_t& base_rng, std::vector& params_r, std::vector& params_i, std::vector& params_r_constrained, bool include_tparams = true, bool include_gqs = true, diff --git a/src/stan/model/model_base_crtp.hpp b/src/stan/model/model_base_crtp.hpp index 5a64ced8c07..1868b3e0567 100644 --- a/src/stan/model/model_base_crtp.hpp +++ b/src/stan/model/model_base_crtp.hpp @@ -133,7 +133,7 @@ class model_base_crtp : public stan::model::model_base { msgs); } - void write_array(boost::ecuyer1988& rng, Eigen::VectorXd& theta, + void write_array(stan::rng_t& rng, Eigen::VectorXd& theta, Eigen::VectorXd& vars, bool include_tparams = true, bool include_gqs = true, std::ostream* msgs = 0) const override { @@ -202,7 +202,7 @@ class model_base_crtp : public stan::model::model_base { theta, theta_i, msgs); } - void write_array(boost::ecuyer1988& rng, std::vector& theta, + void write_array(stan::rng_t& rng, std::vector& theta, std::vector& theta_i, std::vector& vars, bool include_tparams = true, bool include_gqs = true, std::ostream* msgs = 0) const override { diff --git a/src/stan/model/model_header.hpp b/src/stan/model/model_header.hpp index 75ac6c19cbd..34948377f74 100644 --- a/src/stan/model/model_header.hpp +++ b/src/stan/model/model_header.hpp @@ -13,9 +13,6 @@ #include #include -#include -#include - #include #include #include diff --git a/src/stan/services/diagnose/diagnose.hpp b/src/stan/services/diagnose/diagnose.hpp index 25b3907643c..caf5872169e 100644 --- a/src/stan/services/diagnose/diagnose.hpp +++ b/src/stan/services/diagnose/diagnose.hpp @@ -43,7 +43,7 @@ int diagnose(Model& model, const stan::io::var_context& init, double epsilon, double error, callbacks::interrupt& interrupt, callbacks::logger& logger, callbacks::writer& init_writer, callbacks::writer& parameter_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector = util::initialize( diff --git a/src/stan/services/experimental/advi/fullrank.hpp b/src/stan/services/experimental/advi/fullrank.hpp index 6eb8181ac20..96cf5d05c0b 100644 --- a/src/stan/services/experimental/advi/fullrank.hpp +++ b/src/stan/services/experimental/advi/fullrank.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -60,7 +59,7 @@ int fullrank(Model& model, const stan::io::var_context& init, callbacks::writer& diagnostic_writer) { util::experimental_message(logger); - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; @@ -84,7 +83,7 @@ int fullrank(Model& model, const stan::io::var_context& init, = Eigen::Map(&cont_vector[0], cont_vector.size(), 1); stan::variational::advi + stan::rng_t> cmd_advi(model, cont_params, rng, grad_samples, elbo_samples, eval_elbo, output_samples); cmd_advi.run(eta, adapt_engaged, adapt_iterations, tol_rel_obj, diff --git a/src/stan/services/experimental/advi/meanfield.hpp b/src/stan/services/experimental/advi/meanfield.hpp index 87772dda7b2..6cffe548acf 100644 --- a/src/stan/services/experimental/advi/meanfield.hpp +++ b/src/stan/services/experimental/advi/meanfield.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -60,7 +59,7 @@ int meanfield(Model& model, const stan::io::var_context& init, callbacks::writer& diagnostic_writer) { util::experimental_message(logger); - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; @@ -83,7 +82,7 @@ int meanfield(Model& model, const stan::io::var_context& init, = Eigen::Map(&cont_vector[0], cont_vector.size(), 1); stan::variational::advi + stan::rng_t> cmd_advi(model, cont_params, rng, grad_samples, elbo_samples, eval_elbo, output_samples); cmd_advi.run(eta, adapt_engaged, adapt_iterations, tol_rel_obj, diff --git a/src/stan/services/optimize/bfgs.hpp b/src/stan/services/optimize/bfgs.hpp index 12f1df56596..2819b853a63 100644 --- a/src/stan/services/optimize/bfgs.hpp +++ b/src/stan/services/optimize/bfgs.hpp @@ -57,7 +57,7 @@ int bfgs(Model& model, const stan::io::var_context& init, bool save_iterations, int refresh, callbacks::interrupt& interrupt, callbacks::logger& logger, callbacks::writer& init_writer, callbacks::writer& parameter_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; diff --git a/src/stan/services/optimize/laplace_sample.hpp b/src/stan/services/optimize/laplace_sample.hpp index 6ec1dfacad7..17b78ee5f76 100644 --- a/src/stan/services/optimize/laplace_sample.hpp +++ b/src/stan/services/optimize/laplace_sample.hpp @@ -88,7 +88,7 @@ void laplace_sample(const Model& model, const Eigen::VectorXd& theta_hat, } // generate draws std::stringstream refresh_msg; - boost::ecuyer1988 rng = util::create_rng(random_seed, 0); + stan::rng_t rng = util::create_rng(random_seed, 0); Eigen::VectorXd draw_vec; // declare draw_vec, msgs here to avoid re-alloc for (int m = 0; m < draws; ++m) { interrupt(); // allow interpution each iteration diff --git a/src/stan/services/optimize/lbfgs.hpp b/src/stan/services/optimize/lbfgs.hpp index 9955e8f8633..083e37ffed8 100644 --- a/src/stan/services/optimize/lbfgs.hpp +++ b/src/stan/services/optimize/lbfgs.hpp @@ -59,7 +59,7 @@ int lbfgs(Model& model, const stan::io::var_context& init, int refresh, callbacks::interrupt& interrupt, callbacks::logger& logger, callbacks::writer& init_writer, callbacks::writer& parameter_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; diff --git a/src/stan/services/optimize/newton.hpp b/src/stan/services/optimize/newton.hpp index 65d29f9088e..081365f0a9c 100644 --- a/src/stan/services/optimize/newton.hpp +++ b/src/stan/services/optimize/newton.hpp @@ -44,7 +44,7 @@ int newton(Model& model, const stan::io::var_context& init, callbacks::interrupt& interrupt, callbacks::logger& logger, callbacks::writer& init_writer, callbacks::writer& parameter_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; diff --git a/src/stan/services/pathfinder/multi.hpp b/src/stan/services/pathfinder/multi.hpp index f7836b73414..e87eaa63e32 100644 --- a/src/stan/services/pathfinder/multi.hpp +++ b/src/stan/services/pathfinder/multi.hpp @@ -194,11 +194,9 @@ inline int pathfinder_lbfgs_multi( 3 * std::sqrt(num_returned_samples)); Eigen::Array weight_vals = stan::services::psis::psis_weights(lp_ratios, tail_len, logger); - boost::ecuyer1988 rng - = util::create_rng(random_seed, stride_id); - boost::variate_generator< - boost::ecuyer1988&, - boost::random::discrete_distribution> + stan::rng_t rng = util::create_rng(random_seed, stride_id); + boost::variate_generator> rand_psis_idx( rng, boost::random::discrete_distribution( boost::iterator_range( diff --git a/src/stan/services/pathfinder/single.hpp b/src/stan/services/pathfinder/single.hpp index 5b163c519e8..fb7f3295a46 100644 --- a/src/stan/services/pathfinder/single.hpp +++ b/src/stan/services/pathfinder/single.hpp @@ -221,7 +221,7 @@ inline elbo_est_t est_approx_draws(LPF&& lp_fun, ConstrainF&& constrain_fun, size_t num_samples, const EigVec& alpha, const std::string& iter_msg, Logger&& logger, bool calculate_lp = true) { - boost::variate_generator> + boost::variate_generator> rand_unit_gaus(rng, boost::normal_distribution<>()); const auto num_params = taylor_approx.x_center.size(); size_t lp_fun_calls = 0; @@ -607,8 +607,7 @@ inline auto pathfinder_lbfgs_single( callbacks::writer& init_writer, ParamWriter& parameter_writer, DiagnosticWriter& diagnostic_writer, bool calculate_lp = true) { const auto start_pathfinder_time = std::chrono::steady_clock::now(); - boost::ecuyer1988 rng - = util::create_rng(random_seed, stride_id); + stan::rng_t rng = util::create_rng(random_seed, stride_id); std::vector disc_vector; std::vector cont_vector; diff --git a/src/stan/services/sample/fixed_param.hpp b/src/stan/services/sample/fixed_param.hpp index efe75c2f402..f407b14f57f 100644 --- a/src/stan/services/sample/fixed_param.hpp +++ b/src/stan/services/sample/fixed_param.hpp @@ -49,7 +49,7 @@ int fixed_param(Model& model, const stan::io::var_context& init, callbacks::writer& init_writer, callbacks::writer& sample_writer, callbacks::writer& diagnostic_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; @@ -134,7 +134,7 @@ int fixed_param(Model& model, const std::size_t num_chains, init_writer[0], sample_writers[0], diagnostic_writers[0]); } - std::vector rngs; + std::vector rngs; std::vector cont_vectors; std::vector writers; std::vector samples; diff --git a/src/stan/services/sample/hmc_nuts_dense_e.hpp b/src/stan/services/sample/hmc_nuts_dense_e.hpp index b2a4142eb89..bd20ad6c86f 100644 --- a/src/stan/services/sample/hmc_nuts_dense_e.hpp +++ b/src/stan/services/sample/hmc_nuts_dense_e.hpp @@ -56,7 +56,7 @@ int hmc_nuts_dense_e(Model& model, const stan::io::var_context& init, callbacks::writer& init_writer, callbacks::writer& sample_writer, callbacks::writer& diagnostic_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; @@ -73,7 +73,7 @@ int hmc_nuts_dense_e(Model& model, const stan::io::var_context& init, return error_codes::CONFIG; } - stan::mcmc::dense_e_nuts sampler(model, rng); + stan::mcmc::dense_e_nuts sampler(model, rng); sampler.set_metric(inv_metric); @@ -197,11 +197,11 @@ int hmc_nuts_dense_e(Model& model, size_t num_chains, stepsize, stepsize_jitter, max_depth, interrupt, logger, init_writer[0], sample_writer[0], diagnostic_writer[0]); } - std::vector rngs; + std::vector rngs; rngs.reserve(num_chains); std::vector> cont_vectors; cont_vectors.reserve(num_chains); - using sample_t = stan::mcmc::dense_e_nuts; + using sample_t = stan::mcmc::dense_e_nuts; std::vector samplers; samplers.reserve(num_chains); try { diff --git a/src/stan/services/sample/hmc_nuts_dense_e_adapt.hpp b/src/stan/services/sample/hmc_nuts_dense_e_adapt.hpp index 66d0f954f43..6ea6e38e109 100644 --- a/src/stan/services/sample/hmc_nuts_dense_e_adapt.hpp +++ b/src/stan/services/sample/hmc_nuts_dense_e_adapt.hpp @@ -66,7 +66,7 @@ int hmc_nuts_dense_e_adapt( callbacks::logger& logger, callbacks::writer& init_writer, callbacks::writer& sample_writer, callbacks::writer& diagnostic_writer, callbacks::structured_writer& metric_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector cont_vector; @@ -82,7 +82,7 @@ int hmc_nuts_dense_e_adapt( return error_codes::CONFIG; } - stan::mcmc::adapt_dense_e_nuts sampler(model, rng); + stan::mcmc::adapt_dense_e_nuts sampler(model, rng); sampler.set_metric(inv_metric); @@ -347,8 +347,8 @@ int hmc_nuts_dense_e_adapt( init_buffer, term_buffer, window, interrupt, logger, init_writer[0], sample_writer[0], diagnostic_writer[0], metric_writer[0]); } - using sample_t = stan::mcmc::adapt_dense_e_nuts; - std::vector rngs; + using sample_t = stan::mcmc::adapt_dense_e_nuts; + std::vector rngs; rngs.reserve(num_chains); std::vector> cont_vectors; cont_vectors.reserve(num_chains); diff --git a/src/stan/services/sample/hmc_nuts_diag_e.hpp b/src/stan/services/sample/hmc_nuts_diag_e.hpp index 7cdc2de3cc4..321608bd0b7 100644 --- a/src/stan/services/sample/hmc_nuts_diag_e.hpp +++ b/src/stan/services/sample/hmc_nuts_diag_e.hpp @@ -56,7 +56,7 @@ int hmc_nuts_diag_e(Model& model, const stan::io::var_context& init, callbacks::writer& init_writer, callbacks::writer& sample_writer, callbacks::writer& diagnostic_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; @@ -72,7 +72,7 @@ int hmc_nuts_diag_e(Model& model, const stan::io::var_context& init, return error_codes::CONFIG; } - stan::mcmc::diag_e_nuts sampler(model, rng); + stan::mcmc::diag_e_nuts sampler(model, rng); sampler.set_metric(inv_metric); sampler.set_nominal_stepsize(stepsize); @@ -194,11 +194,11 @@ int hmc_nuts_diag_e(Model& model, size_t num_chains, stepsize, stepsize_jitter, max_depth, interrupt, logger, init_writer[0], sample_writer[0], diagnostic_writer[0]); } - std::vector rngs; + std::vector rngs; rngs.reserve(num_chains); std::vector> cont_vectors; cont_vectors.reserve(num_chains); - using sample_t = stan::mcmc::diag_e_nuts; + using sample_t = stan::mcmc::diag_e_nuts; std::vector samplers; samplers.reserve(num_chains); try { diff --git a/src/stan/services/sample/hmc_nuts_diag_e_adapt.hpp b/src/stan/services/sample/hmc_nuts_diag_e_adapt.hpp index fc1d1f69d5d..8f6abed49b2 100644 --- a/src/stan/services/sample/hmc_nuts_diag_e_adapt.hpp +++ b/src/stan/services/sample/hmc_nuts_diag_e_adapt.hpp @@ -66,7 +66,7 @@ int hmc_nuts_diag_e_adapt( callbacks::logger& logger, callbacks::writer& init_writer, callbacks::writer& sample_writer, callbacks::writer& diagnostic_writer, callbacks::structured_writer& metric_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector cont_vector; @@ -83,7 +83,7 @@ int hmc_nuts_diag_e_adapt( return error_codes::CONFIG; } - stan::mcmc::adapt_diag_e_nuts sampler(model, rng); + stan::mcmc::adapt_diag_e_nuts sampler(model, rng); sampler.set_metric(inv_metric); sampler.set_nominal_stepsize(stepsize); @@ -347,8 +347,8 @@ int hmc_nuts_diag_e_adapt( init_buffer, term_buffer, window, interrupt, logger, init_writer[0], sample_writer[0], diagnostic_writer[0], metric_writer[0]); } - using sample_t = stan::mcmc::adapt_diag_e_nuts; - std::vector rngs; + using sample_t = stan::mcmc::adapt_diag_e_nuts; + std::vector rngs; rngs.reserve(num_chains); std::vector> cont_vectors; cont_vectors.reserve(num_chains); diff --git a/src/stan/services/sample/hmc_nuts_unit_e.hpp b/src/stan/services/sample/hmc_nuts_unit_e.hpp index e1d85079fc9..01c9fe2e1b0 100644 --- a/src/stan/services/sample/hmc_nuts_unit_e.hpp +++ b/src/stan/services/sample/hmc_nuts_unit_e.hpp @@ -52,7 +52,7 @@ int hmc_nuts_unit_e(Model& model, const stan::io::var_context& init, callbacks::writer& init_writer, callbacks::writer& sample_writer, callbacks::writer& diagnostic_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; @@ -64,7 +64,7 @@ int hmc_nuts_unit_e(Model& model, const stan::io::var_context& init, logger.error(e.what()); return error_codes::CONFIG; } - stan::mcmc::unit_e_nuts sampler(model, rng); + stan::mcmc::unit_e_nuts sampler(model, rng); sampler.set_nominal_stepsize(stepsize); sampler.set_stepsize_jitter(stepsize_jitter); sampler.set_max_depth(max_depth); @@ -133,8 +133,8 @@ int hmc_nuts_unit_e(Model& model, size_t num_chains, max_depth, interrupt, logger, init_writer[0], sample_writer[0], diagnostic_writer[0]); } - using sample_t = stan::mcmc::unit_e_nuts; - std::vector rngs; + using sample_t = stan::mcmc::unit_e_nuts; + std::vector rngs; rngs.reserve(num_chains); std::vector> cont_vectors; cont_vectors.reserve(num_chains); diff --git a/src/stan/services/sample/hmc_nuts_unit_e_adapt.hpp b/src/stan/services/sample/hmc_nuts_unit_e_adapt.hpp index 6af9c742349..889c6d89200 100644 --- a/src/stan/services/sample/hmc_nuts_unit_e_adapt.hpp +++ b/src/stan/services/sample/hmc_nuts_unit_e_adapt.hpp @@ -59,7 +59,7 @@ int hmc_nuts_unit_e_adapt( callbacks::logger& logger, callbacks::writer& init_writer, callbacks::writer& sample_writer, callbacks::writer& diagnostic_writer, callbacks::structured_writer& metric_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; @@ -72,7 +72,7 @@ int hmc_nuts_unit_e_adapt( return error_codes::CONFIG; } - stan::mcmc::adapt_unit_e_nuts sampler(model, rng); + stan::mcmc::adapt_unit_e_nuts sampler(model, rng); sampler.set_nominal_stepsize(stepsize); sampler.set_stepsize_jitter(stepsize_jitter); sampler.set_max_depth(max_depth); @@ -200,8 +200,8 @@ int hmc_nuts_unit_e_adapt( max_depth, delta, gamma, kappa, t0, interrupt, logger, init_writer[0], sample_writer[0], diagnostic_writer[0], metric_writer[0]); } - using sample_t = stan::mcmc::adapt_unit_e_nuts; - std::vector rngs; + using sample_t = stan::mcmc::adapt_unit_e_nuts; + std::vector rngs; rngs.reserve(num_chains); std::vector> cont_vectors; cont_vectors.reserve(num_chains); diff --git a/src/stan/services/sample/hmc_static_dense_e.hpp b/src/stan/services/sample/hmc_static_dense_e.hpp index 45ecb496ba3..4d2ac828815 100644 --- a/src/stan/services/sample/hmc_static_dense_e.hpp +++ b/src/stan/services/sample/hmc_static_dense_e.hpp @@ -53,7 +53,7 @@ int hmc_static_dense_e( double stepsize_jitter, double int_time, callbacks::interrupt& interrupt, callbacks::logger& logger, callbacks::writer& init_writer, callbacks::writer& sample_writer, callbacks::writer& diagnostic_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; @@ -70,7 +70,7 @@ int hmc_static_dense_e( return error_codes::CONFIG; } - stan::mcmc::dense_e_static_hmc sampler(model, rng); + stan::mcmc::dense_e_static_hmc sampler(model, rng); sampler.set_metric(inv_metric); sampler.set_nominal_stepsize_and_T(stepsize, int_time); diff --git a/src/stan/services/sample/hmc_static_dense_e_adapt.hpp b/src/stan/services/sample/hmc_static_dense_e_adapt.hpp index 98fcdbcefcf..709a875e594 100644 --- a/src/stan/services/sample/hmc_static_dense_e_adapt.hpp +++ b/src/stan/services/sample/hmc_static_dense_e_adapt.hpp @@ -65,7 +65,7 @@ int hmc_static_dense_e_adapt( unsigned int window, callbacks::interrupt& interrupt, callbacks::logger& logger, callbacks::writer& init_writer, callbacks::writer& sample_writer, callbacks::writer& diagnostic_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; @@ -82,8 +82,7 @@ int hmc_static_dense_e_adapt( return error_codes::CONFIG; } - stan::mcmc::adapt_dense_e_static_hmc sampler(model, - rng); + stan::mcmc::adapt_dense_e_static_hmc sampler(model, rng); sampler.set_metric(inv_metric); sampler.set_nominal_stepsize_and_T(stepsize, int_time); diff --git a/src/stan/services/sample/hmc_static_diag_e.hpp b/src/stan/services/sample/hmc_static_diag_e.hpp index 1e5d1f9b120..d478307744d 100644 --- a/src/stan/services/sample/hmc_static_diag_e.hpp +++ b/src/stan/services/sample/hmc_static_diag_e.hpp @@ -56,7 +56,7 @@ int hmc_static_diag_e(Model& model, const stan::io::var_context& init, callbacks::logger& logger, callbacks::writer& init_writer, callbacks::writer& sample_writer, callbacks::writer& diagnostic_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; @@ -73,7 +73,7 @@ int hmc_static_diag_e(Model& model, const stan::io::var_context& init, return error_codes::CONFIG; } - stan::mcmc::diag_e_static_hmc sampler(model, rng); + stan::mcmc::diag_e_static_hmc sampler(model, rng); sampler.set_metric(inv_metric); sampler.set_nominal_stepsize_and_T(stepsize, int_time); diff --git a/src/stan/services/sample/hmc_static_diag_e_adapt.hpp b/src/stan/services/sample/hmc_static_diag_e_adapt.hpp index 83b282ee733..86d0ee6acf9 100644 --- a/src/stan/services/sample/hmc_static_diag_e_adapt.hpp +++ b/src/stan/services/sample/hmc_static_diag_e_adapt.hpp @@ -64,7 +64,7 @@ int hmc_static_diag_e_adapt( unsigned int window, callbacks::interrupt& interrupt, callbacks::logger& logger, callbacks::writer& init_writer, callbacks::writer& sample_writer, callbacks::writer& diagnostic_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; @@ -80,8 +80,7 @@ int hmc_static_diag_e_adapt( return error_codes::CONFIG; } - stan::mcmc::adapt_diag_e_static_hmc sampler(model, - rng); + stan::mcmc::adapt_diag_e_static_hmc sampler(model, rng); sampler.set_metric(inv_metric); sampler.set_nominal_stepsize_and_T(stepsize, int_time); diff --git a/src/stan/services/sample/hmc_static_unit_e.hpp b/src/stan/services/sample/hmc_static_unit_e.hpp index d46cc6dc1fd..d50c902479f 100644 --- a/src/stan/services/sample/hmc_static_unit_e.hpp +++ b/src/stan/services/sample/hmc_static_unit_e.hpp @@ -52,7 +52,7 @@ int hmc_static_unit_e(Model& model, const stan::io::var_context& init, callbacks::logger& logger, callbacks::writer& init_writer, callbacks::writer& sample_writer, callbacks::writer& diagnostic_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; @@ -64,7 +64,7 @@ int hmc_static_unit_e(Model& model, const stan::io::var_context& init, logger.error(e.what()); return error_codes::CONFIG; } - stan::mcmc::unit_e_static_hmc sampler(model, rng); + stan::mcmc::unit_e_static_hmc sampler(model, rng); sampler.set_nominal_stepsize_and_T(stepsize, int_time); sampler.set_stepsize_jitter(stepsize_jitter); diff --git a/src/stan/services/sample/hmc_static_unit_e_adapt.hpp b/src/stan/services/sample/hmc_static_unit_e_adapt.hpp index 96459d57a12..fb0da9aff54 100644 --- a/src/stan/services/sample/hmc_static_unit_e_adapt.hpp +++ b/src/stan/services/sample/hmc_static_unit_e_adapt.hpp @@ -57,7 +57,7 @@ int hmc_static_unit_e_adapt( double kappa, double t0, callbacks::interrupt& interrupt, callbacks::logger& logger, callbacks::writer& init_writer, callbacks::writer& sample_writer, callbacks::writer& diagnostic_writer) { - boost::ecuyer1988 rng = util::create_rng(random_seed, chain); + stan::rng_t rng = util::create_rng(random_seed, chain); std::vector disc_vector; std::vector cont_vector; @@ -69,8 +69,7 @@ int hmc_static_unit_e_adapt( logger.error(e.what()); return error_codes::CONFIG; } - stan::mcmc::adapt_unit_e_static_hmc sampler(model, - rng); + stan::mcmc::adapt_unit_e_static_hmc sampler(model, rng); sampler.set_nominal_stepsize_and_T(stepsize, int_time); sampler.set_stepsize_jitter(stepsize_jitter); diff --git a/src/stan/services/sample/standalone_gqs.hpp b/src/stan/services/sample/standalone_gqs.hpp index 85f7ec5a5b2..378be61106d 100644 --- a/src/stan/services/sample/standalone_gqs.hpp +++ b/src/stan/services/sample/standalone_gqs.hpp @@ -63,7 +63,7 @@ int standalone_generate(const Model &model, const Eigen::MatrixXd &draws, util::gq_writer writer(sample_writer, logger, p_names.size()); writer.write_gq_names(model); - boost::ecuyer1988 rng = util::create_rng(seed, 1); + stan::rng_t rng = util::create_rng(seed, 1); std::vector unconstrained_params_r; std::vector row(draws.cols()); @@ -125,7 +125,7 @@ int standalone_generate(const Model &model, const int num_chains, } std::vector writers; writers.reserve(num_chains); - std::vector rngs; + std::vector rngs; rngs.reserve(num_chains); for (int i = 0; i < num_chains; ++i) { if (draws[i].size() == 0) { diff --git a/src/stan/services/util/create_rng.hpp b/src/stan/services/util/create_rng.hpp index cbc742c6686..9d3b79a1d38 100644 --- a/src/stan/services/util/create_rng.hpp +++ b/src/stan/services/util/create_rng.hpp @@ -4,6 +4,9 @@ #include namespace stan { + +using rng_t = boost::ecuyer1988; + namespace services { namespace util { @@ -18,16 +21,14 @@ namespace util { * that the draws used to initialized transformed data are not * duplicated. * - * @tparam RngType type of RNG to return, default is `boost::ecuyer1988` * @param[in] seed the random seed * @param[in] chain the chain id - * @return an RNG instance + * @return an stan::rng_t instance */ -template -inline RngType create_rng(unsigned int seed, unsigned int chain) { +inline rng_t create_rng(unsigned int seed, unsigned int chain) { using boost::uintmax_t; static constexpr uintmax_t DISCARD_STRIDE = static_cast(1) << 50; - RngType rng(seed); + rng_t rng(seed); // always discard at least 1 to avoid issue with small seeds for certain RNG // distributions. See stan#3167 and boostorg/random#92 rng.discard(std::max(static_cast(1), DISCARD_STRIDE * chain)); diff --git a/src/test/unit/io/random_var_context_test.cpp b/src/test/unit/io/random_var_context_test.cpp index 18bfeb7f2b0..64ea370f17a 100644 --- a/src/test/unit/io/random_var_context_test.cpp +++ b/src/test/unit/io/random_var_context_test.cpp @@ -1,7 +1,7 @@ #include #include +#include #include -#include // L'Ecuyer RNG #include #include #include @@ -95,12 +95,12 @@ class random_var_context : public testing::Test { random_var_context() : empty_context(), model(empty_context, 0, static_cast(0)), - rng(0), + rng(stan::services::util::create_rng(0, 0)), throwing_model() {} stan::io::empty_var_context empty_context; stan_model model; - boost::ecuyer1988 rng; + stan::rng_t rng; test::mock_throwing_model_in_write_array throwing_model; }; diff --git a/src/test/unit/mcmc/chains_test.cpp b/src/test/unit/mcmc/chains_test.cpp index 987279de66e..0862b962215 100644 --- a/src/test/unit/mcmc/chains_test.cpp +++ b/src/test/unit/mcmc/chains_test.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include diff --git a/src/test/unit/mcmc/hmc/base_hmc_test.cpp b/src/test/unit/mcmc/hmc/base_hmc_test.cpp index 00742532075..ce3d8f51f45 100644 --- a/src/test/unit/mcmc/hmc/base_hmc_test.cpp +++ b/src/test/unit/mcmc/hmc/base_hmc_test.cpp @@ -1,22 +1,20 @@ #include #include #include -#include +#include #include #include #include -typedef boost::ecuyer1988 rng_t; - namespace stan { namespace mcmc { -class mock_hmc - : public base_hmc { +class mock_hmc : public base_hmc { public: - mock_hmc(const mock_model& m, rng_t& rng) - : base_hmc(m, rng) { - } + mock_hmc(const mock_model& m, stan::rng_t& rng) + : base_hmc( + m, rng) {} sample transition(sample& init_sample, callbacks::logger& logger) { this->seed(init_sample.cont_params()); @@ -33,7 +31,7 @@ class mock_hmc } // namespace stan TEST(McmcBaseHMC, point_construction) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; @@ -47,14 +45,14 @@ TEST(McmcBaseHMC, point_construction) { } TEST(McmcBaseHMC, point_access_from_const_hmc) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); const stan::mcmc::mock_hmc sampler(stan::mcmc::mock_model(2), base_rng); EXPECT_EQ(2, sampler.z().q.size()); EXPECT_EQ(2, sampler.z().g.size()); } TEST(McmcBaseHMC, seed) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; @@ -70,7 +68,7 @@ TEST(McmcBaseHMC, seed) { } TEST(McmcBaseHMC, set_nominal_stepsize) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; @@ -88,7 +86,7 @@ TEST(McmcBaseHMC, set_nominal_stepsize) { } TEST(McmcBaseHMC, set_stepsize_jitter) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; @@ -108,7 +106,7 @@ TEST(McmcBaseHMC, set_stepsize_jitter) { TEST(McmcBaseHMC, streams) { stan::test::capture_std_streams(); - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; diff --git a/src/test/unit/mcmc/hmc/hamiltonians/base_hamiltonian_test.cpp b/src/test/unit/mcmc/hmc/hamiltonians/base_hamiltonian_test.cpp index 4926f6daef0..1e70c182594 100644 --- a/src/test/unit/mcmc/hmc/hamiltonians/base_hamiltonian_test.cpp +++ b/src/test/unit/mcmc/hmc/hamiltonians/base_hamiltonian_test.cpp @@ -3,12 +3,10 @@ #include #include #include -#include +#include #include #include -typedef boost::ecuyer1988 rng_t; - TEST(BaseHamiltonian, update_potential_gradient) { stan::io::empty_var_context data_var_context; @@ -16,7 +14,8 @@ TEST(BaseHamiltonian, update_potential_gradient) { funnel_model_namespace::funnel_model model(data_var_context, 0, &model_output); - stan::mcmc::mock_hamiltonian + stan::mcmc::mock_hamiltonian metric(model); stan::mcmc::ps_point z(11); z.q.setOnes(); diff --git a/src/test/unit/mcmc/hmc/hamiltonians/dense_e_metric_test.cpp b/src/test/unit/mcmc/hmc/hamiltonians/dense_e_metric_test.cpp index 31f5bcbcd75..fc351755f3f 100644 --- a/src/test/unit/mcmc/hmc/hamiltonians/dense_e_metric_test.cpp +++ b/src/test/unit/mcmc/hmc/hamiltonians/dense_e_metric_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -8,10 +8,8 @@ #include #include -typedef boost::ecuyer1988 rng_t; - TEST(McmcDenseEMetric, sample_p) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::Matrix2d m(2, 2); m(0, 0) = 3.0; @@ -23,7 +21,7 @@ TEST(McmcDenseEMetric, sample_p) { stan::mcmc::mock_model model(2); - stan::mcmc::dense_e_metric metric(model); + stan::mcmc::dense_e_metric metric(model); stan::mcmc::dense_e_point z(2); z.set_metric(m_inv); @@ -62,8 +60,6 @@ TEST(McmcDenseEMetric, sample_p) { } TEST(McmcDenseEMetric, gradients) { - rng_t base_rng(0); - Eigen::VectorXd q = Eigen::VectorXd::Ones(11); stan::mcmc::dense_e_point z(q.size()); @@ -79,7 +75,7 @@ TEST(McmcDenseEMetric, gradients) { funnel_model_namespace::funnel_model model(data_var_context, 0, &model_output); - stan::mcmc::dense_e_metric + stan::mcmc::dense_e_metric metric(model); double epsilon = 1e-6; @@ -156,8 +152,6 @@ TEST(McmcDenseEMetric, gradients) { TEST(McmcDenseEMetric, streams) { stan::test::capture_std_streams(); - rng_t base_rng(0); - Eigen::VectorXd q(2); q(0) = 5; q(1) = 1; @@ -165,7 +159,8 @@ TEST(McmcDenseEMetric, streams) { stan::mcmc::mock_model model(q.size()); // typedef to use within Google Test macros - typedef stan::mcmc::dense_e_metric dense_e; + typedef stan::mcmc::dense_e_metric + dense_e; EXPECT_NO_THROW(dense_e metric(model)); diff --git a/src/test/unit/mcmc/hmc/hamiltonians/diag_e_metric_test.cpp b/src/test/unit/mcmc/hmc/hamiltonians/diag_e_metric_test.cpp index 1d11e26db95..1e56a41b46f 100644 --- a/src/test/unit/mcmc/hmc/hamiltonians/diag_e_metric_test.cpp +++ b/src/test/unit/mcmc/hmc/hamiltonians/diag_e_metric_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -8,17 +8,15 @@ #include #include -typedef boost::ecuyer1988 rng_t; - TEST(McmcDiagEMetric, sample_p) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; q(1) = 1; stan::mcmc::mock_model model(q.size()); - stan::mcmc::diag_e_metric metric(model); + stan::mcmc::diag_e_metric metric(model); stan::mcmc::diag_e_point z(q.size()); int n_samples = 1000; @@ -44,8 +42,6 @@ TEST(McmcDiagEMetric, sample_p) { } TEST(McmcDiagEMetric, gradients) { - rng_t base_rng(0); - Eigen::VectorXd q = Eigen::VectorXd::Ones(11); stan::mcmc::diag_e_point z(q.size()); @@ -61,8 +57,8 @@ TEST(McmcDiagEMetric, gradients) { std::stringstream debug, info, warn, error, fatal; stan::callbacks::stream_logger logger(debug, info, warn, error, fatal); - stan::mcmc::diag_e_metric metric( - model); + stan::mcmc::diag_e_metric + metric(model); double epsilon = 1e-6; @@ -137,8 +133,6 @@ TEST(McmcDiagEMetric, gradients) { TEST(McmcDiagEMetric, streams) { stan::test::capture_std_streams(); - rng_t base_rng(0); - Eigen::VectorXd q(2); q(0) = 5; q(1) = 1; @@ -146,7 +140,7 @@ TEST(McmcDiagEMetric, streams) { stan::mcmc::mock_model model(q.size()); // typedef to use within Google Test macros - typedef stan::mcmc::diag_e_metric diag_e; + typedef stan::mcmc::diag_e_metric diag_e; EXPECT_NO_THROW(diag_e metric(model)); diff --git a/src/test/unit/mcmc/hmc/hamiltonians/softabs_metric_test.cpp b/src/test/unit/mcmc/hmc/hamiltonians/softabs_metric_test.cpp index c1a477c1a1c..194abacc0f6 100644 --- a/src/test/unit/mcmc/hmc/hamiltonians/softabs_metric_test.cpp +++ b/src/test/unit/mcmc/hmc/hamiltonians/softabs_metric_test.cpp @@ -1,27 +1,24 @@ #include #include +#include #include #include #include #include -#include - #include #include -typedef boost::ecuyer1988 rng_t; - TEST(McmcSoftAbs, sample_p) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; q(1) = 1; stan::mcmc::mock_model model(q.size()); - stan::mcmc::softabs_metric metric(model); + stan::mcmc::softabs_metric metric(model); stan::mcmc::softabs_point z(q.size()); int n_samples = 1000; @@ -60,8 +57,6 @@ TEST(McmcSoftAbs, sample_p) { } TEST(McmcSoftAbs, gradients) { - rng_t base_rng(0); - Eigen::VectorXd q = Eigen::VectorXd::Ones(11); stan::mcmc::softabs_point z(q.size()); @@ -77,7 +72,7 @@ TEST(McmcSoftAbs, gradients) { funnel_model_namespace::funnel_model model(data_var_context, 0, &model_output); - stan::mcmc::softabs_metric + stan::mcmc::softabs_metric metric(model); double epsilon = 1e-6; @@ -152,7 +147,6 @@ TEST(McmcSoftAbs, gradients) { TEST(McmcSoftAbs, streams) { stan::test::capture_std_streams(); - rng_t base_rng(0); Eigen::VectorXd q(2); q(0) = 5; @@ -160,7 +154,8 @@ TEST(McmcSoftAbs, streams) { stan::mcmc::mock_model model(q.size()); // for use in Google Test macros below - typedef stan::mcmc::softabs_metric softabs; + typedef stan::mcmc::softabs_metric + softabs; EXPECT_NO_THROW(softabs metric(model)); diff --git a/src/test/unit/mcmc/hmc/hamiltonians/unit_e_metric_test.cpp b/src/test/unit/mcmc/hmc/hamiltonians/unit_e_metric_test.cpp index 635386f55fc..51262a16dd7 100644 --- a/src/test/unit/mcmc/hmc/hamiltonians/unit_e_metric_test.cpp +++ b/src/test/unit/mcmc/hmc/hamiltonians/unit_e_metric_test.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -8,17 +8,15 @@ #include #include -typedef boost::ecuyer1988 rng_t; - TEST(McmcUnitEMetric, sample_p) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; q(1) = 1; stan::mcmc::mock_model model(q.size()); - stan::mcmc::unit_e_metric metric(model); + stan::mcmc::unit_e_metric metric(model); stan::mcmc::unit_e_point z(q.size()); int n_samples = 1000; @@ -44,8 +42,6 @@ TEST(McmcUnitEMetric, sample_p) { } TEST(McmcUnitEMetric, gradients) { - rng_t base_rng(0); - Eigen::VectorXd q = Eigen::VectorXd::Ones(11); stan::mcmc::unit_e_point z(q.size()); @@ -61,8 +57,8 @@ TEST(McmcUnitEMetric, gradients) { funnel_model_namespace::funnel_model model(data_var_context, 0, &model_output); - stan::mcmc::unit_e_metric metric( - model); + stan::mcmc::unit_e_metric + metric(model); double epsilon = 1e-6; @@ -136,7 +132,6 @@ TEST(McmcUnitEMetric, gradients) { TEST(McmcUnitEMetric, streams) { stan::test::capture_std_streams(); - rng_t base_rng(0); Eigen::VectorXd q(2); q(0) = 5; @@ -144,7 +139,7 @@ TEST(McmcUnitEMetric, streams) { stan::mcmc::mock_model model(q.size()); // for use in Google Test macros below - typedef stan::mcmc::unit_e_metric unit_e; + typedef stan::mcmc::unit_e_metric unit_e; EXPECT_NO_THROW(unit_e metric(model)); diff --git a/src/test/unit/mcmc/hmc/integrators/expl_leapfrog2_test.cpp b/src/test/unit/mcmc/hmc/integrators/expl_leapfrog2_test.cpp index 489eddf5d28..175a4b2e0b7 100644 --- a/src/test/unit/mcmc/hmc/integrators/expl_leapfrog2_test.cpp +++ b/src/test/unit/mcmc/hmc/integrators/expl_leapfrog2_test.cpp @@ -7,13 +7,9 @@ #include #include #include -#include // L'Ecuyer RNG - -typedef boost::ecuyer1988 rng_t; +#include TEST(McmcHmcIntegratorsExplLeapfrog, energy_conservation) { - rng_t base_rng(0); - stan::io::empty_var_context data_var_context; std::stringstream model_output; @@ -22,12 +18,12 @@ TEST(McmcHmcIntegratorsExplLeapfrog, energy_conservation) { gauss_model_namespace::gauss_model model(data_var_context, 0, &model_output); - stan::mcmc::expl_leapfrog< - stan::mcmc::unit_e_metric > + stan::mcmc::expl_leapfrog > integrator; - stan::mcmc::unit_e_metric metric( - model); + stan::mcmc::unit_e_metric + metric(model); stan::mcmc::unit_e_point z(1); z.q(0) = 1; @@ -61,8 +57,6 @@ TEST(McmcHmcIntegratorsExplLeapfrog, energy_conservation) { } TEST(McmcHmcIntegratorsExplLeapfrog, symplecticness) { - rng_t base_rng(0); - stan::io::empty_var_context data_var_context; std::stringstream model_output; @@ -71,12 +65,12 @@ TEST(McmcHmcIntegratorsExplLeapfrog, symplecticness) { gauss_model_namespace::gauss_model model(data_var_context, 0, &model_output); - stan::mcmc::expl_leapfrog< - stan::mcmc::unit_e_metric > + stan::mcmc::expl_leapfrog > integrator; - stan::mcmc::unit_e_metric metric( - model); + stan::mcmc::unit_e_metric + metric(model); // Create a circle of points const int n_points = 1000; diff --git a/src/test/unit/mcmc/hmc/integrators/expl_leapfrog_test.cpp b/src/test/unit/mcmc/hmc/integrators/expl_leapfrog_test.cpp index 6dd6eaf419e..629ff3ac5af 100644 --- a/src/test/unit/mcmc/hmc/integrators/expl_leapfrog_test.cpp +++ b/src/test/unit/mcmc/hmc/integrators/expl_leapfrog_test.cpp @@ -9,14 +9,12 @@ #include #include -#include // L'Ecuyer RNG +#include #include // namespace //************************************************************ -typedef boost::ecuyer1988 rng_t; - class McmcHmcIntegratorsExplLeapfrogF : public testing::Test { public: McmcHmcIntegratorsExplLeapfrogF() @@ -44,12 +42,12 @@ class McmcHmcIntegratorsExplLeapfrogF : public testing::Test { stan::callbacks::stream_logger logger; // integrator under test - stan::mcmc::expl_leapfrog< - stan::mcmc::unit_e_metric > + stan::mcmc::expl_leapfrog > unit_e_integrator; - stan::mcmc::expl_leapfrog< - stan::mcmc::diag_e_metric > + stan::mcmc::expl_leapfrog > diag_e_integrator; // model @@ -72,7 +70,7 @@ TEST_F(McmcHmcIntegratorsExplLeapfrogF, begin_update_p) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -104,7 +102,7 @@ TEST_F(McmcHmcIntegratorsExplLeapfrogF, update_q) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -136,7 +134,7 @@ TEST_F(McmcHmcIntegratorsExplLeapfrogF, end_update_p) { EXPECT_NEAR(z.g(0), 1.67264975797776, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -168,7 +166,7 @@ TEST_F(McmcHmcIntegratorsExplLeapfrogF, evolve_1) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -200,7 +198,7 @@ TEST_F(McmcHmcIntegratorsExplLeapfrogF, evolve_2) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -232,7 +230,7 @@ TEST_F(McmcHmcIntegratorsExplLeapfrogF, evolve_3) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -264,7 +262,7 @@ TEST_F(McmcHmcIntegratorsExplLeapfrogF, evolve_4) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -296,7 +294,7 @@ TEST_F(McmcHmcIntegratorsExplLeapfrogF, evolve_5) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -327,7 +325,7 @@ TEST_F(McmcHmcIntegratorsExplLeapfrogF, evolve_6) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -359,7 +357,7 @@ TEST_F(McmcHmcIntegratorsExplLeapfrogF, evolve_7) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -391,7 +389,7 @@ TEST_F(McmcHmcIntegratorsExplLeapfrogF, evolve_8) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -424,7 +422,7 @@ TEST_F(McmcHmcIntegratorsExplLeapfrogF, evolve_9) { EXPECT_NEAR(z.g(0), 1.27097196280777, 1e-15); // setup hamiltonian - stan::mcmc::diag_e_metric + stan::mcmc::diag_e_metric hamiltonian(*model); // setup epsilon @@ -446,8 +444,8 @@ TEST_F(McmcHmcIntegratorsExplLeapfrogF, evolve_9) { TEST_F(McmcHmcIntegratorsExplLeapfrogF, streams) { stan::test::capture_std_streams(); - typedef stan::mcmc::expl_leapfrog< - stan::mcmc::unit_e_metric > + typedef stan::mcmc::expl_leapfrog > integrator; EXPECT_NO_THROW(integrator i); diff --git a/src/test/unit/mcmc/hmc/integrators/impl_leapfrog2_test.cpp b/src/test/unit/mcmc/hmc/integrators/impl_leapfrog2_test.cpp index 47606be8eb4..23f72a40fa7 100644 --- a/src/test/unit/mcmc/hmc/integrators/impl_leapfrog2_test.cpp +++ b/src/test/unit/mcmc/hmc/integrators/impl_leapfrog2_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -6,17 +7,11 @@ #include -#include // L'Ecuyer RNG - #include #include -typedef boost::ecuyer1988 rng_t; - TEST(McmcHmcIntegratorsImplLeapfrog, unit_e_energy_conservation) { - rng_t base_rng(0); - stan::io::empty_var_context data_var_context; std::stringstream model_output; @@ -25,12 +20,12 @@ TEST(McmcHmcIntegratorsImplLeapfrog, unit_e_energy_conservation) { gauss_model_namespace::gauss_model model(data_var_context, 0, &model_output); - stan::mcmc::impl_leapfrog< - stan::mcmc::unit_e_metric > + stan::mcmc::impl_leapfrog > integrator; - stan::mcmc::unit_e_metric metric( - model); + stan::mcmc::unit_e_metric + metric(model); stan::mcmc::unit_e_point z(1); z.q(0) = 1; @@ -64,8 +59,6 @@ TEST(McmcHmcIntegratorsImplLeapfrog, unit_e_energy_conservation) { } TEST(McmcHmcIntegratorsImplLeapfrog, unit_e_symplecticness) { - rng_t base_rng(0); - stan::io::empty_var_context data_var_context; std::stringstream model_output; @@ -74,12 +67,12 @@ TEST(McmcHmcIntegratorsImplLeapfrog, unit_e_symplecticness) { gauss_model_namespace::gauss_model model(data_var_context, 0, &model_output); - stan::mcmc::impl_leapfrog< - stan::mcmc::unit_e_metric > + stan::mcmc::impl_leapfrog > integrator; - stan::mcmc::unit_e_metric metric( - model); + stan::mcmc::unit_e_metric + metric(model); // Create a circle of points const int n_points = 1000; @@ -151,8 +144,6 @@ TEST(McmcHmcIntegratorsImplLeapfrog, unit_e_symplecticness) { } TEST(McmcHmcIntegratorsImplLeapfrog, softabs_energy_conservation) { - rng_t base_rng(0); - stan::io::empty_var_context data_var_context; std::stringstream model_output; @@ -161,12 +152,12 @@ TEST(McmcHmcIntegratorsImplLeapfrog, softabs_energy_conservation) { gauss_model_namespace::gauss_model model(data_var_context, 0, &model_output); - stan::mcmc::impl_leapfrog< - stan::mcmc::softabs_metric > + stan::mcmc::impl_leapfrog > integrator; - stan::mcmc::softabs_metric metric( - model); + stan::mcmc::softabs_metric + metric(model); stan::mcmc::softabs_point z(1); z.q(0) = 1; @@ -200,8 +191,6 @@ TEST(McmcHmcIntegratorsImplLeapfrog, softabs_energy_conservation) { } TEST(McmcHmcIntegratorsImplLeapfrog, softabs_symplecticness) { - rng_t base_rng(0); - stan::io::empty_var_context data_var_context; std::stringstream model_output; @@ -210,12 +199,12 @@ TEST(McmcHmcIntegratorsImplLeapfrog, softabs_symplecticness) { gauss_model_namespace::gauss_model model(data_var_context, 0, &model_output); - stan::mcmc::impl_leapfrog< - stan::mcmc::softabs_metric > + stan::mcmc::impl_leapfrog > integrator; - stan::mcmc::softabs_metric metric( - model); + stan::mcmc::softabs_metric + metric(model); // Create a circle of points const int n_points = 1000; diff --git a/src/test/unit/mcmc/hmc/integrators/impl_leapfrog_test.cpp b/src/test/unit/mcmc/hmc/integrators/impl_leapfrog_test.cpp index 8aba1b21dff..3944f0d5e20 100644 --- a/src/test/unit/mcmc/hmc/integrators/impl_leapfrog_test.cpp +++ b/src/test/unit/mcmc/hmc/integrators/impl_leapfrog_test.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -8,8 +9,6 @@ #include #include -#include // L'Ecuyer RNG - #include #include @@ -17,8 +16,6 @@ // namespace //************************************************************ -typedef boost::ecuyer1988 rng_t; - class McmcHmcIntegratorsImplLeapfrogF : public testing::Test { public: McmcHmcIntegratorsImplLeapfrogF() @@ -46,16 +43,16 @@ class McmcHmcIntegratorsImplLeapfrogF : public testing::Test { stan::callbacks::stream_logger logger; // integrator under test - stan::mcmc::impl_leapfrog< - stan::mcmc::unit_e_metric > + stan::mcmc::impl_leapfrog > unit_e_integrator; - stan::mcmc::impl_leapfrog< - stan::mcmc::diag_e_metric > + stan::mcmc::impl_leapfrog > diag_e_integrator; stan::mcmc::impl_leapfrog > + command_model_namespace::command_model, stan::rng_t> > softabs_integrator; // model @@ -75,7 +72,7 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, begin_update_p) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -107,7 +104,8 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, softabs_begin_update_p) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::softabs_metric + stan::mcmc::softabs_metric hamiltonian(*model); // setup epsilon @@ -141,7 +139,7 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, update_q) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -173,7 +171,8 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, softabs_update_q) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::softabs_metric + stan::mcmc::softabs_metric hamiltonian(*model); // setup epsilon @@ -207,7 +206,7 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, end_update_p) { EXPECT_NEAR(z.g(0), 1.67264975797776, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -239,7 +238,8 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, softabs_end_update_p) { EXPECT_NEAR(z.g(0), 1.67264975797776, 1e-15); // setup hamiltonian - stan::mcmc::softabs_metric + stan::mcmc::softabs_metric hamiltonian(*model); // setup epsilon @@ -273,7 +273,7 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, evolve_1) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -305,7 +305,7 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, evolve_2) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -337,7 +337,7 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, evolve_3) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -369,7 +369,7 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, evolve_4) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -401,7 +401,7 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, evolve_5) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -432,7 +432,7 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, evolve_6) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -464,7 +464,7 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, evolve_7) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -496,7 +496,7 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, evolve_8) { EXPECT_NEAR(z.g(0), 1.99987371079118, 1e-15); // setup hamiltonian - stan::mcmc::unit_e_metric + stan::mcmc::unit_e_metric hamiltonian(*model); // setup epsilon @@ -529,7 +529,7 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, evolve_9) { EXPECT_NEAR(z.g(0), 1.27097196280777, 1e-15); // setup hamiltonian - stan::mcmc::diag_e_metric + stan::mcmc::diag_e_metric hamiltonian(*model); // setup epsilon @@ -561,7 +561,8 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, softabs_evolve) { EXPECT_NEAR(z.g(0), 1.27097196280777, 1e-15); // setup hamiltonian - stan::mcmc::softabs_metric + stan::mcmc::softabs_metric hamiltonian(*model); // setup epsilon @@ -585,8 +586,8 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, softabs_evolve) { TEST_F(McmcHmcIntegratorsImplLeapfrogF, streams) { stan::test::capture_std_streams(); - typedef stan::mcmc::impl_leapfrog< - stan::mcmc::unit_e_metric > + typedef stan::mcmc::impl_leapfrog > integrator; EXPECT_NO_THROW(integrator i); @@ -600,7 +601,7 @@ TEST_F(McmcHmcIntegratorsImplLeapfrogF, softabs_streams) { stan::test::capture_std_streams(); typedef stan::mcmc::impl_leapfrog > + command_model_namespace::command_model, stan::rng_t> > integrator; EXPECT_NO_THROW(integrator i); diff --git a/src/test/unit/mcmc/hmc/nuts/base_nuts_test.cpp b/src/test/unit/mcmc/hmc/nuts/base_nuts_test.cpp index 50527c03cda..ba814578cfb 100644 --- a/src/test/unit/mcmc/hmc/nuts/base_nuts_test.cpp +++ b/src/test/unit/mcmc/hmc/nuts/base_nuts_test.cpp @@ -3,20 +3,18 @@ #include #include #include -#include +#include #include -typedef boost::ecuyer1988 rng_t; - namespace stan { namespace mcmc { -class mock_nuts - : public base_nuts { +class mock_nuts : public base_nuts { public: - mock_nuts(const mock_model& m, rng_t& rng) - : base_nuts(m, - rng) {} + mock_nuts(const mock_model& m, stan::rng_t& rng) + : base_nuts( + m, rng) {} bool compute_criterion(Eigen::VectorXd& p_sharp_minus, Eigen::VectorXd& p_sharp_plus, Eigen::VectorXd& rho) { @@ -24,13 +22,13 @@ class mock_nuts } }; -class rho_inspector_mock_nuts - : public base_nuts { +class rho_inspector_mock_nuts : public base_nuts { public: std::vector rho_values; - rho_inspector_mock_nuts(const mock_model& m, rng_t& rng) - : base_nuts(m, - rng) {} + rho_inspector_mock_nuts(const mock_model& m, stan::rng_t& rng) + : base_nuts( + m, rng) {} bool compute_criterion(Eigen::VectorXd& p_sharp_minus, Eigen::VectorXd& p_sharp_plus, Eigen::VectorXd& rho) { @@ -40,13 +38,14 @@ class rho_inspector_mock_nuts }; class edge_inspector_mock_nuts - : public base_nuts { + : public base_nuts { public: std::vector p_sharp_minus_values; std::vector p_sharp_plus_values; - edge_inspector_mock_nuts(const mock_model& m, rng_t& rng) - : base_nuts(m, - rng) {} + edge_inspector_mock_nuts(const mock_model& m, stan::rng_t& rng) + : base_nuts( + m, rng) {} bool compute_criterion(Eigen::VectorXd& p_sharp_minus, Eigen::VectorXd& p_sharp_plus, Eigen::VectorXd& rho) { @@ -92,18 +91,18 @@ class divergent_hamiltonian : public base_hamiltonian { }; class divergent_nuts : public base_nuts { + expl_leapfrog, stan::rng_t> { public: - divergent_nuts(const mock_model& m, rng_t& rng) - : base_nuts( - m, rng) {} + divergent_nuts(const mock_model& m, stan::rng_t& rng) + : base_nuts(m, rng) {} }; } // namespace mcmc } // namespace stan TEST(McmcNutsBaseNuts, set_max_depth_test) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; @@ -123,7 +122,7 @@ TEST(McmcNutsBaseNuts, set_max_depth_test) { } TEST(McmcNutsBaseNuts, set_max_delta_test) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; @@ -138,7 +137,7 @@ TEST(McmcNutsBaseNuts, set_max_delta_test) { } TEST(McmcNutsBaseNuts, build_tree_test) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; double init_momentum = 1.5; @@ -199,7 +198,7 @@ TEST(McmcNutsBaseNuts, build_tree_test) { } TEST(McmcNutsBaseNuts, rho_aggregation_test) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; double init_momentum = 1.5; @@ -267,7 +266,7 @@ TEST(McmcNutsBaseNuts, rho_aggregation_test) { } TEST(McmcNutsBaseNuts, divergence_test) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; double init_momentum = 1.5; @@ -334,7 +333,7 @@ TEST(McmcNutsBaseNuts, divergence_test) { } TEST(McmcNutsBaseNuts, transition) { - rng_t base_rng(0); + stan::rng_t base_rng(0); int model_size = 1; double init_momentum = 1.5; @@ -374,7 +373,7 @@ TEST(McmcNutsBaseNuts, transition) { } TEST(McmcNutsBaseNuts, transition_egde_momenta) { - rng_t base_rng(0); + stan::rng_t base_rng(0); int model_size = 1; double init_momentum = 1.5; diff --git a/src/test/unit/mcmc/hmc/nuts/derived_nuts_test.cpp b/src/test/unit/mcmc/hmc/nuts/derived_nuts_test.cpp index 1bf6e3dbb1c..a6d0669ed6b 100644 --- a/src/test/unit/mcmc/hmc/nuts/derived_nuts_test.cpp +++ b/src/test/unit/mcmc/hmc/nuts/derived_nuts_test.cpp @@ -5,17 +5,14 @@ #include #include #include +#include #include -#include - #include -typedef boost::ecuyer1988 rng_t; - TEST(McmcNutsDerivedNuts, compute_criterion_unit_e) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; @@ -26,8 +23,8 @@ TEST(McmcNutsDerivedNuts, compute_criterion_unit_e) { Eigen::VectorXd rho(model_size); stan::mcmc::mock_model model(model_size); - stan::mcmc::unit_e_nuts sampler(model, - base_rng); + stan::mcmc::unit_e_nuts sampler( + model, base_rng); start.q(0) = 1; start.p(0) = 1; @@ -55,7 +52,7 @@ TEST(McmcNutsDerivedNuts, compute_criterion_unit_e) { } TEST(McmcNutsDerivedNuts, compute_criterion_diag_e) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; @@ -66,8 +63,8 @@ TEST(McmcNutsDerivedNuts, compute_criterion_diag_e) { Eigen::VectorXd rho(model_size); stan::mcmc::mock_model model(model_size); - stan::mcmc::diag_e_nuts sampler(model, - base_rng); + stan::mcmc::diag_e_nuts sampler( + model, base_rng); start.q(0) = 1; start.p(0) = 1; @@ -95,7 +92,7 @@ TEST(McmcNutsDerivedNuts, compute_criterion_diag_e) { } TEST(McmcNutsDerivedNuts, compute_criterion_dense_e) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; @@ -106,8 +103,8 @@ TEST(McmcNutsDerivedNuts, compute_criterion_dense_e) { Eigen::VectorXd rho(model_size); stan::mcmc::mock_model model(model_size); - stan::mcmc::dense_e_nuts sampler(model, - base_rng); + stan::mcmc::dense_e_nuts sampler( + model, base_rng); start.q(0) = 1; start.p(0) = 1; @@ -135,7 +132,7 @@ TEST(McmcNutsDerivedNuts, compute_criterion_dense_e) { } TEST(McmcNutsDerivedNuts, compute_criterion_softabs) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; @@ -146,8 +143,8 @@ TEST(McmcNutsDerivedNuts, compute_criterion_softabs) { Eigen::VectorXd rho(model_size); stan::mcmc::mock_model model(model_size); - stan::mcmc::softabs_nuts sampler(model, - base_rng); + stan::mcmc::softabs_nuts sampler( + model, base_rng); start.q(0) = 1; start.p(0) = 1; diff --git a/src/test/unit/mcmc/hmc/nuts/instantiation_test.cpp b/src/test/unit/mcmc/hmc/nuts/instantiation_test.cpp index 241d2e38f69..bd0070944fd 100644 --- a/src/test/unit/mcmc/hmc/nuts/instantiation_test.cpp +++ b/src/test/unit/mcmc/hmc/nuts/instantiation_test.cpp @@ -6,16 +6,14 @@ #include #include #include -#include +#include #include #include #include -typedef boost::ecuyer1988 rng_t; - TEST(McmcNuts, instantiaton_test) { - rng_t base_rng(4839294); + stan::rng_t base_rng = stan::services::util::create_rng(4839294, 0); std::stringstream output; stan::callbacks::stream_writer writer(output); @@ -25,21 +23,24 @@ TEST(McmcNuts, instantiaton_test) { stan::io::empty_var_context data_var_context; gauss3D_model_namespace::gauss3D_model model(data_var_context); - stan::mcmc::unit_e_nuts + stan::mcmc::unit_e_nuts unit_e_sampler(model, base_rng); - stan::mcmc::diag_e_nuts + stan::mcmc::diag_e_nuts diag_e_sampler(model, base_rng); - stan::mcmc::dense_e_nuts + stan::mcmc::dense_e_nuts dense_e_sampler(model, base_rng); - stan::mcmc::adapt_unit_e_nuts + stan::mcmc::adapt_unit_e_nuts adapt_unit_e_sampler(model, base_rng); - stan::mcmc::adapt_diag_e_nuts + stan::mcmc::adapt_diag_e_nuts adapt_diag_e_sampler(model, base_rng); - stan::mcmc::adapt_dense_e_nuts + stan::mcmc::adapt_dense_e_nuts adapt_dense_e_sampler(model, base_rng); } diff --git a/src/test/unit/mcmc/hmc/nuts/softabs_nuts_test.cpp b/src/test/unit/mcmc/hmc/nuts/softabs_nuts_test.cpp index 7d4506b788b..62fc69aa5b1 100644 --- a/src/test/unit/mcmc/hmc/nuts/softabs_nuts_test.cpp +++ b/src/test/unit/mcmc/hmc/nuts/softabs_nuts_test.cpp @@ -1,16 +1,14 @@ #include #include #include -#include +#include #include #include #include -typedef boost::ecuyer1988 rng_t; - TEST(McmcSoftAbsNuts, build_tree_test) { - rng_t base_rng(4839294); + stan::rng_t base_rng = stan::services::util::create_rng(4839294, 0); stan::mcmc::softabs_point z_init(3); z_init.q(0) = 1; @@ -26,7 +24,7 @@ TEST(McmcSoftAbsNuts, build_tree_test) { stan::io::empty_var_context data_var_context; gauss3D_model_namespace::gauss3D_model model(data_var_context); - stan::mcmc::softabs_nuts + stan::mcmc::softabs_nuts sampler(model, base_rng); sampler.z() = z_init; @@ -97,7 +95,7 @@ TEST(McmcSoftAbsNuts, build_tree_test) { } TEST(McmcSoftAbsNuts, tree_boundary_test) { - rng_t base_rng(4839294); + stan::rng_t base_rng = stan::services::util::create_rng(4839294, 0); stan::mcmc::softabs_point z_init(3); z_init.q(0) = 1; @@ -116,7 +114,7 @@ TEST(McmcSoftAbsNuts, tree_boundary_test) { model_t model(data_var_context); // Compute expected tree boundaries - typedef stan::mcmc::softabs_metric metric_t; + typedef stan::mcmc::softabs_metric metric_t; metric_t metric(model); stan::mcmc::impl_leapfrog softabs_integrator; @@ -169,7 +167,7 @@ TEST(McmcSoftAbsNuts, tree_boundary_test) { Eigen::VectorXd p_sharp_backward_4 = metric.dtau_dp(z_test); // Check expected tree boundaries to those dynamically generated by NUTS - stan::mcmc::softabs_nuts sampler(model, base_rng); + stan::mcmc::softabs_nuts sampler(model, base_rng); sampler.set_nominal_stepsize(epsilon); sampler.set_stepsize_jitter(0); @@ -311,7 +309,7 @@ TEST(McmcSoftAbsNuts, tree_boundary_test) { } TEST(McmcSoftAbsNuts, transition_test) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::softabs_point z_init(3); z_init.q(0) = 1; @@ -327,7 +325,7 @@ TEST(McmcSoftAbsNuts, transition_test) { stan::io::empty_var_context data_var_context; gauss3D_model_namespace::gauss3D_model model(data_var_context); - stan::mcmc::softabs_nuts + stan::mcmc::softabs_nuts sampler(model, base_rng); sampler.z() = z_init; diff --git a/src/test/unit/mcmc/hmc/nuts/unit_e_nuts_test.cpp b/src/test/unit/mcmc/hmc/nuts/unit_e_nuts_test.cpp index bd77c25b9a1..076e12ce7b4 100644 --- a/src/test/unit/mcmc/hmc/nuts/unit_e_nuts_test.cpp +++ b/src/test/unit/mcmc/hmc/nuts/unit_e_nuts_test.cpp @@ -1,16 +1,14 @@ #include #include #include -#include +#include #include #include #include -typedef boost::ecuyer1988 rng_t; - TEST(McmcUnitENuts, build_tree_test) { - rng_t base_rng(4839294); + stan::rng_t base_rng = stan::services::util::create_rng(4839294, 0); stan::mcmc::unit_e_point z_init(3); z_init.q(0) = 1; @@ -26,7 +24,7 @@ TEST(McmcUnitENuts, build_tree_test) { stan::io::empty_var_context data_var_context; gauss3D_model_namespace::gauss3D_model model(data_var_context); - stan::mcmc::unit_e_nuts + stan::mcmc::unit_e_nuts sampler(model, base_rng); sampler.z() = z_init; @@ -97,7 +95,7 @@ TEST(McmcUnitENuts, build_tree_test) { } TEST(McmcUnitENuts, tree_boundary_test) { - rng_t base_rng(4839294); + stan::rng_t base_rng = stan::services::util::create_rng(4839294, 0); stan::mcmc::unit_e_point z_init(3); z_init.q(0) = 1; @@ -116,7 +114,7 @@ TEST(McmcUnitENuts, tree_boundary_test) { model_t model(data_var_context); // Compute expected tree boundaries - typedef stan::mcmc::unit_e_metric metric_t; + typedef stan::mcmc::unit_e_metric metric_t; metric_t metric(model); stan::mcmc::expl_leapfrog unit_e_integrator; @@ -169,7 +167,7 @@ TEST(McmcUnitENuts, tree_boundary_test) { Eigen::VectorXd p_sharp_backward_4 = metric.dtau_dp(z_test); // Check expected tree boundaries to those dynamically generated by NUTS - stan::mcmc::unit_e_nuts sampler(model, base_rng); + stan::mcmc::unit_e_nuts sampler(model, base_rng); sampler.set_nominal_stepsize(epsilon); sampler.set_stepsize_jitter(0); @@ -311,7 +309,7 @@ TEST(McmcUnitENuts, tree_boundary_test) { } TEST(McmcUnitENuts, transition_test) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::unit_e_point z_init(3); z_init.q(0) = 1; @@ -327,7 +325,7 @@ TEST(McmcUnitENuts, transition_test) { stan::io::empty_var_context data_var_context; gauss3D_model_namespace::gauss3D_model model(data_var_context); - stan::mcmc::unit_e_nuts + stan::mcmc::unit_e_nuts sampler(model, base_rng); sampler.z() = z_init; diff --git a/src/test/unit/mcmc/hmc/nuts_classic/base_nuts_classic_test.cpp b/src/test/unit/mcmc/hmc/nuts_classic/base_nuts_classic_test.cpp index 7fbd6304cf1..c3862c2c889 100644 --- a/src/test/unit/mcmc/hmc/nuts_classic/base_nuts_classic_test.cpp +++ b/src/test/unit/mcmc/hmc/nuts_classic/base_nuts_classic_test.cpp @@ -2,20 +2,19 @@ #include #include #include -#include +#include #include -typedef boost::ecuyer1988 rng_t; - namespace stan { namespace mcmc { -class mock_nuts_classic : public base_nuts_classic { +class mock_nuts_classic + : public base_nuts_classic { public: - mock_nuts_classic(const mock_model& m, rng_t& rng) - : base_nuts_classic( - m, rng) {} + mock_nuts_classic(const mock_model& m, stan::rng_t& rng) + : base_nuts_classic(m, rng) {} private: bool compute_criterion(ps_point& start, ps_point& finish, @@ -61,11 +60,11 @@ class divergent_hamiltonian : public base_hamiltonian { class divergent_nuts_classic : public base_nuts_classic { + stan::rng_t> { public: - divergent_nuts_classic(const mock_model& m, rng_t& rng) + divergent_nuts_classic(const mock_model& m, stan::rng_t& rng) : base_nuts_classic(m, rng) {} + stan::rng_t>(m, rng) {} private: bool compute_criterion(ps_point& start, ps_point& finish, @@ -78,7 +77,7 @@ class divergent_nuts_classic } // namespace stan TEST(McmcNutsBaseNutsClassic, set_max_depth) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; @@ -98,7 +97,7 @@ TEST(McmcNutsBaseNutsClassic, set_max_depth) { } TEST(McmcNutsBaseNuts, set_max_delta) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; @@ -113,7 +112,7 @@ TEST(McmcNutsBaseNuts, set_max_delta) { } TEST(McmcNutsBaseNutsClassic, build_tree) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; double init_momentum = 1.5; @@ -167,7 +166,7 @@ TEST(McmcNutsBaseNutsClassic, build_tree) { } TEST(McmcNutsBaseNutsClassic, slice_criterion) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; double init_momentum = 1.5; diff --git a/src/test/unit/mcmc/hmc/nuts_classic/derived_nuts_classic_test.cpp b/src/test/unit/mcmc/hmc/nuts_classic/derived_nuts_classic_test.cpp index e9f4637ab4e..593c1e56189 100644 --- a/src/test/unit/mcmc/hmc/nuts_classic/derived_nuts_classic_test.cpp +++ b/src/test/unit/mcmc/hmc/nuts_classic/derived_nuts_classic_test.cpp @@ -7,12 +7,10 @@ #include #include #include -#include - -typedef boost::ecuyer1988 rng_t; +#include TEST(McmcDerivedNutsClassic, compute_criterion_unit_e) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; @@ -21,7 +19,7 @@ TEST(McmcDerivedNutsClassic, compute_criterion_unit_e) { Eigen::VectorXd rho(model_size); stan::mcmc::mock_model model(model_size); - stan::mcmc::unit_e_nuts_classic sampler( + stan::mcmc::unit_e_nuts_classic sampler( model, base_rng); start.q(0) = 1; @@ -46,7 +44,7 @@ TEST(McmcDerivedNutsClassic, compute_criterion_unit_e) { } TEST(McmcDerivedNutsClassic, compute_criterion_diag_e) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; @@ -55,7 +53,7 @@ TEST(McmcDerivedNutsClassic, compute_criterion_diag_e) { Eigen::VectorXd rho(model_size); stan::mcmc::mock_model model(model_size); - stan::mcmc::diag_e_nuts_classic sampler( + stan::mcmc::diag_e_nuts_classic sampler( model, base_rng); start.q(0) = 1; @@ -80,7 +78,7 @@ TEST(McmcDerivedNutsClassic, compute_criterion_diag_e) { } TEST(McmcDerivedNutsClassic, compute_criterion_dense_e) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; @@ -89,7 +87,7 @@ TEST(McmcDerivedNutsClassic, compute_criterion_dense_e) { Eigen::VectorXd rho(model_size); stan::mcmc::mock_model model(model_size); - stan::mcmc::dense_e_nuts_classic sampler( + stan::mcmc::dense_e_nuts_classic sampler( model, base_rng); start.q(0) = 1; diff --git a/src/test/unit/mcmc/hmc/nuts_classic/instantiation_test.cpp b/src/test/unit/mcmc/hmc/nuts_classic/instantiation_test.cpp index 70f8f38977d..654f75079c1 100644 --- a/src/test/unit/mcmc/hmc/nuts_classic/instantiation_test.cpp +++ b/src/test/unit/mcmc/hmc/nuts_classic/instantiation_test.cpp @@ -6,16 +6,14 @@ #include #include #include -#include +#include #include #include #include -typedef boost::ecuyer1988 rng_t; - TEST(McmcNutsClassic, instantiaton_test) { - rng_t base_rng(4839294); + stan::rng_t base_rng = stan::services::util::create_rng(4839294, 0); std::stringstream output; stan::callbacks::stream_writer writer(output); @@ -25,25 +23,27 @@ TEST(McmcNutsClassic, instantiaton_test) { stan::io::empty_var_context data_var_context; gauss3D_model_namespace::gauss3D_model model(data_var_context); - stan::mcmc::unit_e_nuts_classic + stan::mcmc::unit_e_nuts_classic unit_e_sampler(model, base_rng); - stan::mcmc::diag_e_nuts_classic + stan::mcmc::diag_e_nuts_classic diag_e_sampler(model, base_rng); stan::mcmc::dense_e_nuts_classic + stan::rng_t> dense_e_sampler(model, base_rng); stan::mcmc::adapt_unit_e_nuts_classic + stan::rng_t> adapt_unit_e_sampler(model, base_rng); stan::mcmc::adapt_diag_e_nuts_classic + stan::rng_t> adapt_diag_e_sampler(model, base_rng); stan::mcmc::adapt_dense_e_nuts_classic + stan::rng_t> adapt_dense_e_sampler(model, base_rng); } diff --git a/src/test/unit/mcmc/hmc/static/base_static_hmc_test.cpp b/src/test/unit/mcmc/hmc/static/base_static_hmc_test.cpp index 632426ff270..4d571f6a927 100644 --- a/src/test/unit/mcmc/hmc/static/base_static_hmc_test.cpp +++ b/src/test/unit/mcmc/hmc/static/base_static_hmc_test.cpp @@ -2,28 +2,26 @@ #include #include #include -#include +#include #include -typedef boost::ecuyer1988 rng_t; - namespace stan { namespace mcmc { // Mock Static HMC class mock_static_hmc : public base_static_hmc { + mock_integrator, stan::rng_t> { public: - mock_static_hmc(const mock_model& m, rng_t& rng) - : base_static_hmc( - m, rng) {} + mock_static_hmc(const mock_model& m, stan::rng_t& rng) + : base_static_hmc(m, rng) {} }; } // namespace mcmc } // namespace stan TEST(McmcStaticBaseStaticHMC, set_nominal_stepsize) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); std::vector q(5, 1.0); std::vector r(2, 2); @@ -43,7 +41,7 @@ TEST(McmcStaticBaseStaticHMC, set_nominal_stepsize) { } TEST(McmcStaticBaseStaticHMC, set_T) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); std::vector q(5, 1.0); std::vector r(2, 2); @@ -63,7 +61,7 @@ TEST(McmcStaticBaseStaticHMC, set_T) { } TEST(McmcStaticBaseStaticHMC, set_nominal_stepsize_and_T) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); std::vector q(5, 1.0); std::vector r(2, 2); @@ -90,7 +88,7 @@ TEST(McmcStaticBaseStaticHMC, set_nominal_stepsize_and_T) { } TEST(McmcStaticBaseStaticHMC, set_nominal_stepsize_and_L) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); std::vector q(5, 1.0); std::vector r(2, 2); diff --git a/src/test/unit/mcmc/hmc/static_uniform/base_static_uniform_test.cpp b/src/test/unit/mcmc/hmc/static_uniform/base_static_uniform_test.cpp index 4b8892eb767..a9f81458d2c 100644 --- a/src/test/unit/mcmc/hmc/static_uniform/base_static_uniform_test.cpp +++ b/src/test/unit/mcmc/hmc/static_uniform/base_static_uniform_test.cpp @@ -5,27 +5,25 @@ #include #include -#include +#include #include -typedef boost::ecuyer1988 rng_t; - namespace stan { namespace mcmc { // Mock Static HMC class mock_static_uniform : public base_static_uniform { + stan::rng_t> { public: - mock_static_uniform(const mock_model& m, rng_t& rng) + mock_static_uniform(const mock_model& m, stan::rng_t& rng) : base_static_uniform(m, rng) {} + stan::rng_t>(m, rng) {} }; } // namespace mcmc } // namespace stan TEST(McmcBaseStaticUniform, set_nominal_stepsize) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); std::vector q(5, 1.0); std::vector r(2, 2); @@ -45,7 +43,7 @@ TEST(McmcBaseStaticUniform, set_nominal_stepsize) { } TEST(McmcBaseStaticUniform, set_T) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); std::vector q(5, 1.0); std::vector r(2, 2); @@ -65,7 +63,7 @@ TEST(McmcBaseStaticUniform, set_T) { } TEST(McmcBaseStaticUniform, set_nominal_stepsize_and_T) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); std::vector q(5, 1.0); std::vector r(2, 2); @@ -92,7 +90,7 @@ TEST(McmcBaseStaticUniform, set_nominal_stepsize_and_T) { } TEST(McmcBaseStaticUniform, set_nominal_stepsize_and_L) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); std::vector q(5, 1.0); std::vector r(2, 2); diff --git a/src/test/unit/mcmc/hmc/static_uniform/derived_static_uniform_test.cpp b/src/test/unit/mcmc/hmc/static_uniform/derived_static_uniform_test.cpp index 89f16df1edc..0791f943194 100644 --- a/src/test/unit/mcmc/hmc/static_uniform/derived_static_uniform_test.cpp +++ b/src/test/unit/mcmc/hmc/static_uniform/derived_static_uniform_test.cpp @@ -8,17 +8,14 @@ #include #include #include +#include #include -#include - #include -typedef boost::ecuyer1988 rng_t; - TEST(McmcStaticUniform, unit_e_transition) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::unit_e_point z_init(1); z_init.q(0) = 1; @@ -30,7 +27,8 @@ TEST(McmcStaticUniform, unit_e_transition) { stan::io::empty_var_context data_var_context; gauss_model_namespace::gauss_model model(data_var_context); - stan::mcmc::unit_e_static_uniform + stan::mcmc::unit_e_static_uniform sampler(model, base_rng); sampler.z() = z_init; @@ -54,7 +52,7 @@ TEST(McmcStaticUniform, unit_e_transition) { } TEST(McmcStaticUniform, diag_e_transition) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::diag_e_point z_init(1); z_init.q(0) = 1; @@ -66,7 +64,8 @@ TEST(McmcStaticUniform, diag_e_transition) { stan::io::empty_var_context data_var_context; gauss_model_namespace::gauss_model model(data_var_context); - stan::mcmc::diag_e_static_uniform + stan::mcmc::diag_e_static_uniform sampler(model, base_rng); sampler.z() = z_init; @@ -90,7 +89,7 @@ TEST(McmcStaticUniform, diag_e_transition) { } TEST(McmcStaticUniform, dense_e_transition) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::dense_e_point z_init(1); z_init.q(0) = 1; @@ -102,7 +101,8 @@ TEST(McmcStaticUniform, dense_e_transition) { stan::io::empty_var_context data_var_context; gauss_model_namespace::gauss_model model(data_var_context); - stan::mcmc::dense_e_static_uniform + stan::mcmc::dense_e_static_uniform sampler(model, base_rng); sampler.z() = z_init; @@ -126,7 +126,7 @@ TEST(McmcStaticUniform, dense_e_transition) { } TEST(McmcStaticUniform, softabs_transition) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::softabs_point z_init(1); z_init.q(0) = 1; @@ -138,7 +138,8 @@ TEST(McmcStaticUniform, softabs_transition) { stan::io::empty_var_context data_var_context; gauss_model_namespace::gauss_model model(data_var_context); - stan::mcmc::softabs_static_uniform + stan::mcmc::softabs_static_uniform sampler(model, base_rng); sampler.z() = z_init; @@ -162,7 +163,7 @@ TEST(McmcStaticUniform, softabs_transition) { } TEST(McmcStaticUniform, adapt_unit_e_transition) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::unit_e_point z_init(1); z_init.q(0) = 1; @@ -175,7 +176,7 @@ TEST(McmcStaticUniform, adapt_unit_e_transition) { gauss_model_namespace::gauss_model model(data_var_context); stan::mcmc::adapt_unit_e_static_uniform + stan::rng_t> sampler(model, base_rng); sampler.z() = z_init; @@ -199,7 +200,7 @@ TEST(McmcStaticUniform, adapt_unit_e_transition) { } TEST(McmcStaticUniform, adapt_diag_e_transition) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::diag_e_point z_init(1); z_init.q(0) = 1; @@ -212,7 +213,7 @@ TEST(McmcStaticUniform, adapt_diag_e_transition) { gauss_model_namespace::gauss_model model(data_var_context); stan::mcmc::adapt_diag_e_static_uniform + stan::rng_t> sampler(model, base_rng); sampler.z() = z_init; @@ -236,7 +237,7 @@ TEST(McmcStaticUniform, adapt_diag_e_transition) { } TEST(McmcStaticUniform, adapt_dense_e_transition) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::dense_e_point z_init(1); z_init.q(0) = 1; @@ -249,7 +250,7 @@ TEST(McmcStaticUniform, adapt_dense_e_transition) { gauss_model_namespace::gauss_model model(data_var_context); stan::mcmc::adapt_dense_e_static_uniform + stan::rng_t> sampler(model, base_rng); sampler.z() = z_init; @@ -273,7 +274,7 @@ TEST(McmcStaticUniform, adapt_dense_e_transition) { } TEST(McmcStaticUniform, adapt_softabs_e_transition) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::softabs_point z_init(1); z_init.q(0) = 1; @@ -286,7 +287,7 @@ TEST(McmcStaticUniform, adapt_softabs_e_transition) { gauss_model_namespace::gauss_model model(data_var_context); stan::mcmc::adapt_softabs_static_uniform + stan::rng_t> sampler(model, base_rng); sampler.z() = z_init; diff --git a/src/test/unit/mcmc/hmc/xhmc/base_xhmc_test.cpp b/src/test/unit/mcmc/hmc/xhmc/base_xhmc_test.cpp index f27eb9f37ca..f09b4374ede 100644 --- a/src/test/unit/mcmc/hmc/xhmc/base_xhmc_test.cpp +++ b/src/test/unit/mcmc/hmc/xhmc/base_xhmc_test.cpp @@ -2,20 +2,18 @@ #include #include #include -#include +#include #include -typedef boost::ecuyer1988 rng_t; - namespace stan { namespace mcmc { -class mock_xhmc - : public base_xhmc { +class mock_xhmc : public base_xhmc { public: - mock_xhmc(const mock_model& m, rng_t& rng) - : base_xhmc(m, - rng) {} + mock_xhmc(const mock_model& m, stan::rng_t& rng) + : base_xhmc( + m, rng) {} }; // Mock Hamiltonian @@ -54,18 +52,18 @@ class divergent_hamiltonian : public base_hamiltonian { }; class divergent_xhmc : public base_xhmc { + expl_leapfrog, stan::rng_t> { public: - divergent_xhmc(const mock_model& m, rng_t& rng) - : base_xhmc( - m, rng) {} + divergent_xhmc(const mock_model& m, stan::rng_t& rng) + : base_xhmc(m, rng) {} }; } // namespace mcmc } // namespace stan TEST(McmcXHMCBaseXHMC, set_max_depth) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; @@ -83,7 +81,7 @@ TEST(McmcXHMCBaseXHMC, set_max_depth) { } TEST(McmcXHMCBaseXHMC, set_max_deltaH) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; @@ -98,7 +96,7 @@ TEST(McmcXHMCBaseXHMC, set_max_deltaH) { } TEST(McmcXHMCBaseXHMC, set_x_delta) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); Eigen::VectorXd q(2); q(0) = 5; @@ -113,7 +111,7 @@ TEST(McmcXHMCBaseXHMC, set_x_delta) { } TEST(McmcXHMCBaseXHMC, build_tree) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; double init_momentum = 1.5; @@ -164,7 +162,7 @@ TEST(McmcXHMCBaseXHMC, build_tree) { } TEST(McmcXHMCBaseXHMC, divergence_test) { - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); int model_size = 1; double init_momentum = 1.5; @@ -223,7 +221,7 @@ TEST(McmcXHMCBaseXHMC, divergence_test) { } TEST(McmcXHMCBaseXHMC, transition) { - rng_t base_rng(0); + stan::rng_t base_rng(0); int model_size = 1; double init_momentum = 1.5; diff --git a/src/test/unit/mcmc/hmc/xhmc/softabs_xhmc_test.cpp b/src/test/unit/mcmc/hmc/xhmc/softabs_xhmc_test.cpp index 600785eaf76..274732fc14d 100644 --- a/src/test/unit/mcmc/hmc/xhmc/softabs_xhmc_test.cpp +++ b/src/test/unit/mcmc/hmc/xhmc/softabs_xhmc_test.cpp @@ -1,16 +1,14 @@ #include #include -#include +#include #include #include #include #include -typedef boost::ecuyer1988 rng_t; - TEST(McmcUnitEXHMC, build_tree) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::softabs_point z_init(3); z_init.q(0) = 1; @@ -26,7 +24,7 @@ TEST(McmcUnitEXHMC, build_tree) { stan::io::empty_var_context data_var_context; gauss3D_model_namespace::gauss3D_model model(data_var_context); - stan::mcmc::softabs_xhmc + stan::mcmc::softabs_xhmc sampler(model, base_rng); sampler.z() = z_init; @@ -81,7 +79,7 @@ TEST(McmcUnitEXHMC, build_tree) { } TEST(McmcUnitEXHMC, transition) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::softabs_point z_init(3); z_init.q(0) = 1; @@ -97,7 +95,7 @@ TEST(McmcUnitEXHMC, transition) { stan::io::empty_var_context data_var_context; gauss3D_model_namespace::gauss3D_model model(data_var_context); - stan::mcmc::softabs_xhmc + stan::mcmc::softabs_xhmc sampler(model, base_rng); sampler.z() = z_init; @@ -121,4 +119,4 @@ TEST(McmcUnitEXHMC, transition) { EXPECT_EQ("", warn.str()); EXPECT_EQ("", error.str()); EXPECT_EQ("", fatal.str()); -} \ No newline at end of file +} diff --git a/src/test/unit/mcmc/hmc/xhmc/unit_e_xhmc_test.cpp b/src/test/unit/mcmc/hmc/xhmc/unit_e_xhmc_test.cpp index a9c53459754..87726ad4993 100644 --- a/src/test/unit/mcmc/hmc/xhmc/unit_e_xhmc_test.cpp +++ b/src/test/unit/mcmc/hmc/xhmc/unit_e_xhmc_test.cpp @@ -1,16 +1,14 @@ #include #include -#include +#include #include #include #include #include -typedef boost::ecuyer1988 rng_t; - TEST(McmcUnitEXHMC, build_tree) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::unit_e_point z_init(3); z_init.q(0) = 1; @@ -26,7 +24,7 @@ TEST(McmcUnitEXHMC, build_tree) { stan::io::empty_var_context data_var_context; gauss3D_model_namespace::gauss3D_model model(data_var_context); - stan::mcmc::unit_e_xhmc + stan::mcmc::unit_e_xhmc sampler(model, base_rng); sampler.z() = z_init; @@ -81,7 +79,7 @@ TEST(McmcUnitEXHMC, build_tree) { } TEST(McmcUnitEXHMC, transition) { - rng_t base_rng(4839294); + stan::rng_t base_rng(4839294); stan::mcmc::unit_e_point z_init(3); z_init.q(0) = 1; @@ -97,7 +95,7 @@ TEST(McmcUnitEXHMC, transition) { stan::io::empty_var_context data_var_context; gauss3D_model_namespace::gauss3D_model model(data_var_context); - stan::mcmc::unit_e_xhmc + stan::mcmc::unit_e_xhmc sampler(model, base_rng); sampler.z() = z_init; diff --git a/src/test/unit/model/array_functions_roundtrip_test.cpp b/src/test/unit/model/array_functions_roundtrip_test.cpp index 0f37719c42e..9c5cffa4a87 100644 --- a/src/test/unit/model/array_functions_roundtrip_test.cpp +++ b/src/test/unit/model/array_functions_roundtrip_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -20,7 +21,7 @@ class ModelArrayFunctionsRoundtripTest : public testing::Test { stan::io::empty_var_context context; stan_model model; - boost::ecuyer1988 rng; + stan::rng_t rng; std::unique_ptr inits; std::stringstream out; diff --git a/src/test/unit/model/model_base_test.cpp b/src/test/unit/model/model_base_test.cpp index a015588948e..c4a81f71323 100644 --- a/src/test/unit/model/model_base_test.cpp +++ b/src/test/unit/model/model_base_test.cpp @@ -79,7 +79,7 @@ struct mock_model : public stan::model::model_base { Eigen::VectorXd& params_r, std::ostream* msgs) const override {} - void write_array(boost::ecuyer1988& base_rng, Eigen::VectorXd& params_r, + void write_array(stan::rng_t& base_rng, Eigen::VectorXd& params_r, Eigen::VectorXd& params_constrained_r, bool include_tparams, bool include_gqs, std::ostream* msgs) const override {} @@ -139,7 +139,7 @@ struct mock_model : public stan::model::model_base { std::vector& params_r, std::ostream* msgs) const override {} - void write_array(boost::ecuyer1988& base_rng, std::vector& params_r, + void write_array(stan::rng_t& base_rng, std::vector& params_r, std::vector& params_i, std::vector& params_r_constrained, bool include_tparams, bool include_gqs, diff --git a/src/test/unit/services/pathfinder/eight_schools_test.cpp b/src/test/unit/services/pathfinder/eight_schools_test.cpp index 8955f5e9e49..5d5626b9016 100644 --- a/src/test/unit/services/pathfinder/eight_schools_test.cpp +++ b/src/test/unit/services/pathfinder/eight_schools_test.cpp @@ -192,7 +192,7 @@ TEST_F(ServicesPathfinderEightSchools, single) { Eigen::MatrixXd r_constrainted_draws_mat(20, 100); { - auto rng = stan::services::util::create_rng(0123, 0); + stan::rng_t rng = stan::services::util::create_rng(0123, 0); auto fn = [&model = ServicesPathfinderEightSchools::model](auto&& u) { return -model.log_prob_propto_jacobian(u, 0); }; diff --git a/src/test/unit/services/util/create_rng_test.cpp b/src/test/unit/services/util/create_rng_test.cpp index adca8ecccd1..5dee9c8656a 100644 --- a/src/test/unit/services/util/create_rng_test.cpp +++ b/src/test/unit/services/util/create_rng_test.cpp @@ -2,8 +2,8 @@ #include TEST(rng, initialize_with_seed) { - boost::ecuyer1988 rng1 = stan::services::util::create_rng(0, 1); - boost::ecuyer1988 rng2 = stan::services::util::create_rng(0, 1); + stan::rng_t rng1 = stan::services::util::create_rng(0, 1); + stan::rng_t rng2 = stan::services::util::create_rng(0, 1); EXPECT_EQ(rng1, rng2); rng2(); // generate a random number @@ -11,9 +11,9 @@ TEST(rng, initialize_with_seed) { } TEST(rng, initialize_with_id) { - boost::ecuyer1988 rng1 = stan::services::util::create_rng(0, 1); + stan::rng_t rng1 = stan::services::util::create_rng(0, 1); for (unsigned int n = 2; n < 20; n++) { - boost::ecuyer1988 rng2 = stan::services::util::create_rng(0, n); + stan::rng_t rng2 = stan::services::util::create_rng(0, n); EXPECT_NE(rng1, rng2); } } @@ -21,8 +21,8 @@ TEST(rng, initialize_with_id) { // warning---this will reuse draws from transformed data // if we initialize with zero TEST(rng, initialize_with_zero) { - boost::ecuyer1988 rng1 = stan::services::util::create_rng(0, 0); - boost::ecuyer1988 rng2 = stan::services::util::create_rng(0, 0); + stan::rng_t rng1 = stan::services::util::create_rng(0, 0); + stan::rng_t rng2 = stan::services::util::create_rng(0, 0); EXPECT_EQ(rng1, rng2); rng2(); diff --git a/src/test/unit/services/util/generate_transitions_test.cpp b/src/test/unit/services/util/generate_transitions_test.cpp index e4cbb5d4bac..0de3c699867 100644 --- a/src/test/unit/services/util/generate_transitions_test.cpp +++ b/src/test/unit/services/util/generate_transitions_test.cpp @@ -30,7 +30,7 @@ TEST_F(ServicesSamplesGenerateTransitions, call_counting) { stan::test::unit::instrumented_interrupt interrupt; EXPECT_EQ(interrupt.call_count(), 0); - boost::ecuyer1988 rng = stan::services::util::create_rng(seed, chain); + stan::rng_t rng = stan::services::util::create_rng(seed, chain); std::vector disc_vector; std::vector cont_vector = stan::services::util::initialize( @@ -86,7 +86,7 @@ TEST_F(ServicesSamplesGenerateTransitions, output_sizes) { stan::test::unit::instrumented_interrupt interrupt; EXPECT_EQ(interrupt.call_count(), 0); - boost::ecuyer1988 rng = stan::services::util::create_rng(seed, chain); + stan::rng_t rng = stan::services::util::create_rng(seed, chain); std::vector disc_vector; std::vector cont_vector = stan::services::util::initialize( diff --git a/src/test/unit/services/util/gq_writer_test.cpp b/src/test/unit/services/util/gq_writer_test.cpp index 04b93d9ec38..7b3017887ad 100644 --- a/src/test/unit/services/util/gq_writer_test.cpp +++ b/src/test/unit/services/util/gq_writer_test.cpp @@ -35,7 +35,7 @@ TEST_F(ServicesUtilGQWriter, t2) { stan::callbacks::stream_writer sample_writer(sample_ss, ""); stan::callbacks::stream_logger logger(logger_ss, logger_ss, logger_ss, logger_ss, logger_ss); - boost::ecuyer1988 rng1 = stan::services::util::create_rng(0, 1); + stan::rng_t rng1 = stan::services::util::create_rng(0, 1); std::vector draw; draw.push_back(-2.345); draw.push_back(-6.789); @@ -50,7 +50,7 @@ TEST_F(ServicesUtilGQWriter, TestExceptions) { stan::callbacks::stream_writer sample_writer(sample_ss, ""); stan::callbacks::stream_logger logger(logger_ss, logger_ss, logger_ss, logger_ss, logger_ss); - boost::ecuyer1988 rng1 = stan::services::util::create_rng(0, 1); + stan::rng_t rng1 = stan::services::util::create_rng(0, 1); std::vector draw; draw.push_back(2.345); draw.push_back(6.789); diff --git a/src/test/unit/services/util/initialize_test.cpp b/src/test/unit/services/util/initialize_test.cpp index 768929da5c1..a0acf6db685 100644 --- a/src/test/unit/services/util/initialize_test.cpp +++ b/src/test/unit/services/util/initialize_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -24,7 +25,7 @@ class ServicesUtilInitialize : public testing::Test { stan::callbacks::stream_writer message; stan::test::unit::instrumented_logger logger; stan::test::unit::instrumented_writer init; - boost::ecuyer1988 rng; + stan::rng_t rng; }; TEST_F(ServicesUtilInitialize, radius_zero__print_false) { diff --git a/src/test/unit/services/util/mcmc_writer_test.cpp b/src/test/unit/services/util/mcmc_writer_test.cpp index 6c0cba15b06..c9840a68806 100644 --- a/src/test/unit/services/util/mcmc_writer_test.cpp +++ b/src/test/unit/services/util/mcmc_writer_test.cpp @@ -247,7 +247,7 @@ TEST_F(ServicesUtil, write_sample_names) { } TEST_F(ServicesUtil, write_sample_params) { - boost::ecuyer1988 rng = stan::services::util::create_rng(0, 1); + stan::rng_t rng = stan::services::util::create_rng(0, 1); Eigen::VectorXd x = Eigen::VectorXd::Zero(2); stan::mcmc::sample sample(x, 1, 2); mock_sampler sampler; @@ -314,7 +314,7 @@ TEST_F(ServicesUtil, write_timing) { } TEST_F(ServicesUtil, throwing_model__write_sample_parameters) { - boost::ecuyer1988 rng = stan::services::util::create_rng(0, 1); + stan::rng_t rng = stan::services::util::create_rng(0, 1); Eigen::VectorXd x = Eigen::VectorXd::Zero(2); stan::mcmc::sample sample(x, 1, 2); mock_sampler sampler; diff --git a/src/test/unit/services/util/run_adaptive_sampler_test.cpp b/src/test/unit/services/util/run_adaptive_sampler_test.cpp index 476d4cbad74..9c7d892707b 100644 --- a/src/test/unit/services/util/run_adaptive_sampler_test.cpp +++ b/src/test/unit/services/util/run_adaptive_sampler_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -27,12 +28,12 @@ class ServicesUtil : public testing::Test { stan::io::empty_var_context context; stan_model model; std::vector cont_vector; - boost::ecuyer1988 rng; + stan::rng_t rng; stan::test::unit::instrumented_interrupt interrupt; stan::test::unit::instrumented_writer sample_writer, diagnostic_writer; stan::callbacks::structured_writer dummy_metric_writer; stan::test::unit::instrumented_logger logger; - stan::mcmc::adapt_unit_e_nuts sampler; + stan::mcmc::adapt_unit_e_nuts sampler; int num_warmup, num_samples, num_thin, refresh; bool save_warmup; }; diff --git a/src/test/unit/services/util/run_sampler_test.cpp b/src/test/unit/services/util/run_sampler_test.cpp index 1b51781569c..4b63d61d686 100644 --- a/src/test/unit/services/util/run_sampler_test.cpp +++ b/src/test/unit/services/util/run_sampler_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -73,7 +74,7 @@ class ServicesUtil : public testing::Test { stan::io::empty_var_context context; stan_model model; std::vector cont_vector; - boost::ecuyer1988 rng; + stan::rng_t rng; stan::test::unit::instrumented_interrupt interrupt; stan::test::unit::instrumented_writer sample_writer, diagnostic_writer; stan::test::unit::instrumented_logger logger; diff --git a/src/test/unit/variational/advi_messages_test.cpp b/src/test/unit/variational/advi_messages_test.cpp index 486a8240c7e..3371186cbac 100644 --- a/src/test/unit/variational/advi_messages_test.cpp +++ b/src/test/unit/variational/advi_messages_test.cpp @@ -6,9 +6,7 @@ #include #include #include -#include // L'Ecuyer RNG - -typedef boost::ecuyer1988 rng_t; +#include class advi_test : public ::testing::Test { public: @@ -39,10 +37,10 @@ class advi_test : public ::testing::Test { diagnostic_stream_.str(""); advi_meanfield_ = new stan::variational::advi< - stan_model, stan::variational::normal_meanfield, rng_t>( + stan_model, stan::variational::normal_meanfield, stan::rng_t>( *model_, cont_params_, base_rng_, 1, 100, 1, 1); advi_fullrank_ = new stan::variational::advi< - stan_model, stan::variational::normal_fullrank, rng_t>( + stan_model, stan::variational::normal_fullrank, stan::rng_t>( *model_, cont_params_, base_rng_, 1, 100, 1, 1); } @@ -56,9 +54,9 @@ class advi_test : public ::testing::Test { std::string err_msg2; stan::variational::advi *advi_meanfield_; - stan::variational::advi - *advi_fullrank_; + stan::rng_t> *advi_meanfield_; + stan::variational::advi *advi_fullrank_; std::stringstream model_stream_; std::stringstream log_stream_; std::stringstream parameter_stream_; @@ -69,7 +67,7 @@ class advi_test : public ::testing::Test { private: stan_model *model_; - rng_t base_rng_; + stan::rng_t base_rng_; Eigen::VectorXd cont_params_; }; diff --git a/src/test/unit/variational/advi_multivar_no_constraint_test.cpp b/src/test/unit/variational/advi_multivar_no_constraint_test.cpp index 4310938aec1..a0513690c78 100644 --- a/src/test/unit/variational/advi_multivar_no_constraint_test.cpp +++ b/src/test/unit/variational/advi_multivar_no_constraint_test.cpp @@ -5,9 +5,8 @@ #include #include #include -#include // L'Ecuyer RNG +#include -typedef boost::ecuyer1988 rng_t; typedef multivariate_no_constraint_model_namespace:: multivariate_no_constraint_model Model; @@ -21,7 +20,7 @@ TEST(advi_test, multivar_no_constraint_fullrank) { Model my_model(dummy_context); // RNG - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); // Other params int n_monte_carlo_grad = 10; @@ -36,7 +35,8 @@ TEST(advi_test, multivar_no_constraint_fullrank) { cont_params(1) = 0.75; // ADVI - stan::variational::advi + stan::variational::advi test_advi(my_model, cont_params, base_rng, n_monte_carlo_grad, n_grad_samples, 100, 1); @@ -139,7 +139,7 @@ TEST(advi_test, multivar_no_constraint_meanfield) { Model my_model(dummy_context); // RNG - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); // Other params int n_monte_carlo_grad = 10; @@ -153,7 +153,8 @@ TEST(advi_test, multivar_no_constraint_meanfield) { cont_params(1) = 0.75; // ADVI - stan::variational::advi + stan::variational::advi test_advi(my_model, cont_params, base_rng, n_monte_carlo_grad, 1e4, // absurdly high! 100, 1); diff --git a/src/test/unit/variational/advi_multivar_with_constraint_test.cpp b/src/test/unit/variational/advi_multivar_with_constraint_test.cpp index 8730b3b0672..ae6bcf6d882 100644 --- a/src/test/unit/variational/advi_multivar_with_constraint_test.cpp +++ b/src/test/unit/variational/advi_multivar_with_constraint_test.cpp @@ -5,9 +5,8 @@ #include #include #include -#include // L'Ecuyer RNG +#include -typedef boost::ecuyer1988 rng_t; typedef multivariate_with_constraint_model_namespace:: multivariate_with_constraint_model Model; @@ -21,7 +20,7 @@ TEST(advi_test, multivar_with_constraint_fullrank) { Model my_model(dummy_context); // RNG - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); // Other params int n_monte_carlo_grad = 10; @@ -36,7 +35,8 @@ TEST(advi_test, multivar_with_constraint_fullrank) { cont_params(1) = 0.75; // ADVI - stan::variational::advi + stan::variational::advi test_advi(my_model, cont_params, base_rng, n_monte_carlo_grad, n_monte_carlo_elbo, 100, 1); @@ -78,7 +78,7 @@ TEST(advi_test, multivar_with_constraint_meanfield) { Model my_model(dummy_context); // RNG - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); // Other params int n_monte_carlo_grad = 10; @@ -93,7 +93,8 @@ TEST(advi_test, multivar_with_constraint_meanfield) { cont_params(1) = 0.75; // ADVI - stan::variational::advi + stan::variational::advi test_advi(my_model, cont_params, base_rng, n_monte_carlo_grad, n_monte_carlo_elbo, 100, 1); diff --git a/src/test/unit/variational/advi_univar_no_constraint_test.cpp b/src/test/unit/variational/advi_univar_no_constraint_test.cpp index f1394948ff6..ef8d5fd1dce 100644 --- a/src/test/unit/variational/advi_univar_no_constraint_test.cpp +++ b/src/test/unit/variational/advi_univar_no_constraint_test.cpp @@ -2,13 +2,12 @@ #include #include #include -#include // L'Ecuyer RNG +#include #include #include #include #include -typedef boost::ecuyer1988 rng_t; typedef univariate_no_constraint_model_namespace::univariate_no_constraint_model Model; @@ -22,7 +21,7 @@ TEST(advi_test, univar_no_constraint_fullrank) { Model my_model(dummy_context); // RNG - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); // Other params int n_monte_carlo_grad = 10; @@ -35,7 +34,8 @@ TEST(advi_test, univar_no_constraint_fullrank) { cont_params(0) = -0.75; // ADVI - stan::variational::advi + stan::variational::advi test_advi(my_model, cont_params, base_rng, n_monte_carlo_grad, 1e4, // absurdly high! 100, 1); @@ -146,7 +146,7 @@ TEST(advi_test, univar_no_constraint_meanfield) { Model my_model(dummy_context); // RNG - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); // Other params int n_monte_carlo_grad = 10; @@ -159,7 +159,8 @@ TEST(advi_test, univar_no_constraint_meanfield) { cont_params(0) = -0.75; // ADVI - stan::variational::advi + stan::variational::advi test_advi(my_model, cont_params, base_rng, n_monte_carlo_grad, 1e4, // absurdly high! 100, 1); diff --git a/src/test/unit/variational/advi_univar_with_constraint_test.cpp b/src/test/unit/variational/advi_univar_with_constraint_test.cpp index c12ac4f4b27..d28844a01fa 100644 --- a/src/test/unit/variational/advi_univar_with_constraint_test.cpp +++ b/src/test/unit/variational/advi_univar_with_constraint_test.cpp @@ -2,13 +2,12 @@ #include #include #include -#include // L'Ecuyer RNG +#include #include #include #include #include -typedef boost::ecuyer1988 rng_t; typedef univariate_with_constraint_model_namespace:: univariate_with_constraint_model Model; @@ -22,7 +21,7 @@ TEST(advi_test, univar_with_constraint_fullrank) { Model my_model(dummy_context); // RNG - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); // Other params int n_monte_carlo_grad = 10; @@ -35,7 +34,8 @@ TEST(advi_test, univar_with_constraint_fullrank) { cont_params(0) = -0.75; // ADVI - stan::variational::advi + stan::variational::advi test_advi(my_model, cont_params, base_rng, n_monte_carlo_grad, 5e5, // absurdly high! 100, 1); @@ -151,7 +151,7 @@ TEST(advi_test, univar_with_constraint_meanfield) { Model my_model(dummy_context); // RNG - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); // Other params int n_monte_carlo_grad = 10; @@ -164,7 +164,8 @@ TEST(advi_test, univar_with_constraint_meanfield) { cont_params(0) = -0.75; // ADVI - stan::variational::advi + stan::variational::advi test_advi(my_model, cont_params, base_rng, n_monte_carlo_grad, 5e5, // absurdly high! 100, 1); diff --git a/src/test/unit/variational/eta_adapt_big_test.cpp b/src/test/unit/variational/eta_adapt_big_test.cpp index 080c666b328..2d7f7a2ce5c 100644 --- a/src/test/unit/variational/eta_adapt_big_test.cpp +++ b/src/test/unit/variational/eta_adapt_big_test.cpp @@ -1,14 +1,12 @@ #include #include #include +#include #include #include #include #include #include -#include // L'Ecuyer RNG - -typedef boost::ecuyer1988 rng_t; class eta_adapt_big_test : public ::testing::Test { public: @@ -28,11 +26,11 @@ class eta_adapt_big_test : public ::testing::Test { log_stream_.str(""); advi_meanfield_ = new stan::variational::advi< - stan_model, stan::variational::normal_meanfield, rng_t>( + stan_model, stan::variational::normal_meanfield, stan::rng_t>( *model_, cont_params_, base_rng_, 1, 100, 100, 1); advi_fullrank_ = new stan::variational::advi< - stan_model, stan::variational::normal_fullrank, rng_t>( + stan_model, stan::variational::normal_fullrank, stan::rng_t>( *model_, cont_params_, base_rng_, 1, 100, 100, 1); } @@ -43,15 +41,15 @@ class eta_adapt_big_test : public ::testing::Test { } stan::variational::advi *advi_meanfield_; - stan::variational::advi - *advi_fullrank_; + stan::rng_t> *advi_meanfield_; + stan::variational::advi *advi_fullrank_; std::stringstream model_stream_; std::stringstream log_stream_; stan::callbacks::stream_logger logger; stan_model *model_; - rng_t base_rng_; + stan::rng_t base_rng_; Eigen::VectorXd cont_params_; }; diff --git a/src/test/unit/variational/eta_adapt_fail_test.cpp b/src/test/unit/variational/eta_adapt_fail_test.cpp index 1b98f930f6b..84229f839c4 100644 --- a/src/test/unit/variational/eta_adapt_fail_test.cpp +++ b/src/test/unit/variational/eta_adapt_fail_test.cpp @@ -1,14 +1,12 @@ #include #include #include +#include #include #include #include #include #include -#include // L'Ecuyer RNG - -typedef boost::ecuyer1988 rng_t; class eta_should_fail_test : public ::testing::Test { public: @@ -28,11 +26,11 @@ class eta_should_fail_test : public ::testing::Test { log_stream_.str(""); advi_meanfield_ = new stan::variational::advi< - stan_model, stan::variational::normal_meanfield, rng_t>( + stan_model, stan::variational::normal_meanfield, stan::rng_t>( *model_, cont_params_, base_rng_, 1, 1, 100, 1); advi_fullrank_ = new stan::variational::advi< - stan_model, stan::variational::normal_fullrank, rng_t>( + stan_model, stan::variational::normal_fullrank, stan::rng_t>( *model_, cont_params_, base_rng_, 1, 1, 100, 1); } @@ -43,15 +41,15 @@ class eta_should_fail_test : public ::testing::Test { } stan::variational::advi *advi_meanfield_; - stan::variational::advi - *advi_fullrank_; + stan::rng_t> *advi_meanfield_; + stan::variational::advi *advi_fullrank_; std::stringstream model_stream_; std::stringstream log_stream_; stan::callbacks::stream_logger logger; stan_model *model_; - rng_t base_rng_; + stan::rng_t base_rng_; Eigen::VectorXd cont_params_; }; diff --git a/src/test/unit/variational/eta_adapt_mock_models_test.cpp b/src/test/unit/variational/eta_adapt_mock_models_test.cpp index 26d9ecb4b57..e4f7b3a627d 100644 --- a/src/test/unit/variational/eta_adapt_mock_models_test.cpp +++ b/src/test/unit/variational/eta_adapt_mock_models_test.cpp @@ -7,9 +7,6 @@ #include #include #include -#include // L'Ecuyer RNG - -typedef boost::ecuyer1988 rng_t; // Mock Model class mock_model : public stan::model::prob_grad { diff --git a/src/test/unit/variational/eta_adapt_small_test.cpp b/src/test/unit/variational/eta_adapt_small_test.cpp index 0b2fd28f79e..715d68c4c76 100644 --- a/src/test/unit/variational/eta_adapt_small_test.cpp +++ b/src/test/unit/variational/eta_adapt_small_test.cpp @@ -6,11 +6,9 @@ #include #include #include -#include // L'Ecuyer RNG +#include #include -typedef boost::ecuyer1988 rng_t; - class eta_adapt_small_test : public ::testing::Test { public: eta_adapt_small_test() @@ -29,11 +27,11 @@ class eta_adapt_small_test : public ::testing::Test { log_stream_.str(""); advi_meanfield_ = new stan::variational::advi< - stan_model, stan::variational::normal_meanfield, rng_t>( + stan_model, stan::variational::normal_meanfield, stan::rng_t>( *model_, cont_params_, base_rng_, 1, 100, 100, 1); advi_fullrank_ = new stan::variational::advi< - stan_model, stan::variational::normal_fullrank, rng_t>( + stan_model, stan::variational::normal_fullrank, stan::rng_t>( *model_, cont_params_, base_rng_, 1, 100, 100, 1); } @@ -44,15 +42,15 @@ class eta_adapt_small_test : public ::testing::Test { } stan::variational::advi *advi_meanfield_; - stan::variational::advi - *advi_fullrank_; + stan::rng_t> *advi_meanfield_; + stan::variational::advi *advi_fullrank_; std::stringstream model_stream_; std::stringstream log_stream_; stan::callbacks::stream_logger logger; stan_model *model_; - rng_t base_rng_; + stan::rng_t base_rng_; Eigen::VectorXd cont_params_; }; diff --git a/src/test/unit/variational/gradient_warn_test.cpp b/src/test/unit/variational/gradient_warn_test.cpp index 2dab70c96dc..de9b476b269 100644 --- a/src/test/unit/variational/gradient_warn_test.cpp +++ b/src/test/unit/variational/gradient_warn_test.cpp @@ -2,14 +2,13 @@ #include #include #include +#include + #include #include #include #include #include -#include // L'Ecuyer RNG - -typedef boost::ecuyer1988 rng_t; class advi_test : public ::testing::Test { public: @@ -35,10 +34,10 @@ class advi_test : public ::testing::Test { diagnostic_stream_.str(""); advi_meanfield_ = new stan::variational::advi< - stan_model, stan::variational::normal_meanfield, rng_t>( + stan_model, stan::variational::normal_meanfield, stan::rng_t>( *model_, cont_params_, base_rng_, 1, 100, 100, 1); advi_fullrank_ = new stan::variational::advi< - stan_model, stan::variational::normal_fullrank, rng_t>( + stan_model, stan::variational::normal_fullrank, stan::rng_t>( *model_, cont_params_, base_rng_, 1, 100, 100, 1); } @@ -49,9 +48,9 @@ class advi_test : public ::testing::Test { } stan::variational::advi *advi_meanfield_; - stan::variational::advi - *advi_fullrank_; + stan::rng_t> *advi_meanfield_; + stan::variational::advi *advi_fullrank_; std::stringstream model_stream_; std::stringstream message_stream_; std::stringstream parameter_stream_; @@ -63,7 +62,7 @@ class advi_test : public ::testing::Test { private: stan_model *model_; - rng_t base_rng_; + stan::rng_t base_rng_; Eigen::VectorXd cont_params_; }; diff --git a/src/test/unit/variational/hier_logistic_cp_test.cpp b/src/test/unit/variational/hier_logistic_cp_test.cpp index 0905aeedc80..1c1fea788bf 100644 --- a/src/test/unit/variational/hier_logistic_cp_test.cpp +++ b/src/test/unit/variational/hier_logistic_cp_test.cpp @@ -2,14 +2,13 @@ #include #include #include +#include #include #include #include #include #include -#include // L'Ecuyer RNG -typedef boost::ecuyer1988 rng_t; typedef hier_logistic_cp_model_namespace::hier_logistic_cp_model Model_cp; TEST(advi_test, hier_logistic_cp_constraint_meanfield) { @@ -27,13 +26,14 @@ TEST(advi_test, hier_logistic_cp_constraint_meanfield) { Model_cp my_model(data_var_context); // RNG - rng_t base_rng(0); + stan::rng_t base_rng = stan::services::util::create_rng(0, 0); // Dummy input Eigen::VectorXd cont_params = Eigen::VectorXd::Zero(my_model.num_params_r()); // ADVI - stan::variational::advi + stan::variational::advi test_advi(my_model, cont_params, base_rng, 10, 100, 100, 1); stan::callbacks::writer writer; diff --git a/src/test/unit/variational/hier_logistic_test.cpp b/src/test/unit/variational/hier_logistic_test.cpp index df0092aa120..a469fba98e7 100644 --- a/src/test/unit/variational/hier_logistic_test.cpp +++ b/src/test/unit/variational/hier_logistic_test.cpp @@ -5,11 +5,9 @@ #include #include #include -#include // L'Ecuyer RNG +#include #include -typedef boost::ecuyer1988 rng_t; - class advi_test : public ::testing::Test { public: advi_test() @@ -38,10 +36,10 @@ class advi_test : public ::testing::Test { diagnostic_stream_.str(""); advi_ = new stan::variational::advi< - stan_model, stan::variational::normal_meanfield, rng_t>( + stan_model, stan::variational::normal_meanfield, stan::rng_t>( *model_, cont_params_, base_rng_, 10, 100, 100, 1); advi_fullrank_ = new stan::variational::advi< - stan_model, stan::variational::normal_fullrank, rng_t>( + stan_model, stan::variational::normal_fullrank, stan::rng_t>( *model_, cont_params_, base_rng_, 10, 100, 100, 1); } @@ -53,9 +51,9 @@ class advi_test : public ::testing::Test { } stan::variational::advi *advi_; - stan::variational::advi - *advi_fullrank_; + stan::rng_t> *advi_; + stan::variational::advi *advi_fullrank_; std::stringstream model_stream_; std::stringstream message_stream_; std::stringstream parameter_stream_; @@ -67,7 +65,7 @@ class advi_test : public ::testing::Test { private: stan_model *model_; stan_model *model_null_stream_; - rng_t base_rng_; + stan::rng_t base_rng_; Eigen::VectorXd cont_params_; }; diff --git a/src/test/unit/variational/stochastic_gradient_ascent_test.cpp b/src/test/unit/variational/stochastic_gradient_ascent_test.cpp index a9bf7e6273b..a51f3dc5a34 100644 --- a/src/test/unit/variational/stochastic_gradient_ascent_test.cpp +++ b/src/test/unit/variational/stochastic_gradient_ascent_test.cpp @@ -8,9 +8,6 @@ #include #include #include -#include // L'Ecuyer RNG - -typedef boost::ecuyer1988 rng_t; // Mock Model class mock_model : public stan::model::prob_grad {