Commit 76407789 authored by Jean-Baptiste Mouret's avatar Jean-Baptiste Mouret
Browse files

add tests in test_serialize

parent 8b3b9587
...@@ -95,6 +95,19 @@ BOOST_AUTO_TEST_CASE(test_text_archive) ...@@ -95,6 +95,19 @@ BOOST_AUTO_TEST_CASE(test_text_archive)
model::GPOpt<Params> gp2(3, 1); model::GPOpt<Params> gp2(3, 1);
serialize::TextArchive a2("/tmp/test_model.dat"); serialize::TextArchive a2("/tmp/test_model.dat");
gp2.load(a2); gp2.load(a2);
BOOST_CHECK_EQUAL(gp.nb_samples(), gp2.nb_samples());
// check that the two GP make the same predictions
size_t k = 1000;
for (size_t i = 0; i < k; i++) {
Eigen::VectorXd s = tools::random_vector(3).array() * 4.0 - 2.0;
auto v1 = gp.query(s);
auto v2 = gp.query(s);
BOOST_CHECK_CLOSE(std::get<0>(v1)[0], std::get<0>(v2)[0], 1e-10);
BOOST_CHECK_CLOSE(std::get<1>(v1), std::get<1>(v2), 1e-10);
}
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment