fullrank_test.cpp
Go to the documentation of this file.
2 #include <gtest/gtest.h>
4 #include <test/test-models/good/services/test_lp.hpp>
6 
7 class ServicesExperimentalAdvi : public testing::Test {
8 public:
10  : model(context, &model_log) {}
11 
12  std::stringstream model_log;
17  stan_model model;
18 };
19 
21  unsigned int seed = 0;
22  unsigned int chain = 1;
23  double init_radius = 0;
24  int grad_samples = 1;
25  int elbo_samples = 100;
26  int max_iterations = 10000;
27  double tol_rel_obj = 0.01;
28  double eta = 1.0;
29  bool adapt_engaged = true;
30  int adapt_iterations = 50;
31  int eval_elbo = 100;
32  int output_samples = 1000;
33 
36  seed, chain, init_radius,
37  grad_samples, elbo_samples,
38  max_iterations, tol_rel_obj,
39  eta, adapt_engaged,
40  adapt_iterations,
41  eval_elbo, output_samples,
42  interrupt,
44 
45  EXPECT_GT(logger.call_count(), 0);
46  EXPECT_EQ(logger.call_count(), logger.call_count_info())
47  << "all messages go to info";
48 
49  EXPECT_EQ(1, logger.find_info("EXPERIMENTAL ALGORITHM"))
50  << "Missing experimental algorithm message";
51 }
52 
54  unsigned int seed = 0;
55  unsigned int chain = 1;
56  double init_radius = 0;
57  int grad_samples = 1;
58  int elbo_samples = 100;
59  int max_iterations = 10000;
60  double tol_rel_obj = 0.01;
61  double eta = 1.0;
62  bool adapt_engaged = true;
63  int adapt_iterations = 50;
64  int eval_elbo = 100;
65  int output_samples = 1000;
66 
69  seed, chain, init_radius,
70  grad_samples, elbo_samples,
71  max_iterations, tol_rel_obj,
72  eta, adapt_engaged,
73  adapt_iterations,
74  eval_elbo, output_samples,
75  interrupt,
77  EXPECT_EQ(0, return_code);
78 
79  ASSERT_EQ(1, init.vector_double_values().size());
80  ASSERT_EQ(2, init.vector_double_values().at(0).size());
81  std::vector<double> init_values = init.vector_double_values().at(0);
82  EXPECT_FLOAT_EQ(0, init_values[0]);
83  EXPECT_FLOAT_EQ(0, init_values[1]);
84 
85  ASSERT_EQ(output_samples + 1, parameter.vector_double_values().size());
86  ASSERT_EQ(eval_elbo, diagnostic.vector_double_values().size());
87 
88  EXPECT_EQ(0, interrupt.call_count());
89 }
stan::test::unit::instrumented_logger logger
int fullrank(Model &model, stan::io::var_context &init, unsigned int random_seed, unsigned int chain, double init_radius, int grad_samples, int elbo_samples, int max_iterations, double tol_rel_obj, double eta, bool adapt_engaged, int adapt_iterations, int eval_elbo, int output_samples, callbacks::interrupt &interrupt, callbacks::logger &logger, callbacks::writer &init_writer, callbacks::writer &parameter_writer, callbacks::writer &diagnostic_writer)
Definition: fullrank.hpp:51
void experimental_message(stan::callbacks::logger &logger)
unsigned int seed
Definition: runWimpSim.h:102
stan::test::unit::instrumented_writer init
stan::test::unit::instrumented_writer diagnostic
chain
Check that an output directory exists.
std::stringstream model_log
stan::test::unit::instrumented_interrupt interrupt
stan::test::unit::instrumented_writer parameter
const XML_Char * context
Definition: expat.h:434
stan::io::empty_var_context context
std::vector< std::vector< double > > vector_double_values()
unsigned int find_info(const std::string &msg)
const XML_Char XML_Content * model
Definition: expat.h:151
TEST_F(ServicesExperimentalAdvi, experimental_message)