Commit 486f167a authored by Konstantinos Chatzilygeroudis's avatar Konstantinos Chatzilygeroudis
Browse files

Fix for boptimizer inheritance problem

parent 4a684359
......@@ -82,7 +82,7 @@ namespace limbo {
boost::parameter::optional<tag::initfun>,
boost::parameter::optional<tag::acquifun>,
boost::parameter::optional<tag::stopcrit>,
boost::parameter::optional<tag::modelfun>> class_signature;
boost::parameter::optional<tag::modelfun>> bobase_signature;
// clang-format off
template <class Params,
......@@ -90,7 +90,8 @@ namespace limbo {
class A2 = boost::parameter::void_,
class A3 = boost::parameter::void_,
class A4 = boost::parameter::void_,
class A5 = boost::parameter::void_>
class A5 = boost::parameter::void_,
class A6 = boost::parameter::void_>
// clang-format on
/**
\rst
......@@ -153,7 +154,7 @@ namespace limbo {
};
// extract the types
typedef typename class_signature::bind<A1, A2, A3, A4, A5>::type args;
typedef typename bobase_signature::bind<A1, A2, A3, A4, A5, A6>::type args;
typedef typename boost::parameter::binding<args, tag::initfun, typename defaults::init_t>::type init_function_t;
typedef typename boost::parameter::binding<args, tag::acquifun, typename defaults::acqui_t>::type acquisition_function_t;
typedef typename boost::parameter::binding<args, tag::modelfun, typename defaults::model_t>::type model_t;
......
......@@ -62,7 +62,7 @@ namespace limbo {
class A5 = boost::parameter::void_,
class A6 = boost::parameter::void_>
// clang-format on
class BOptimizer : public BoBase<Params, A1, A2, A3, A4, A5> {
class BOptimizer : public BoBase<Params, A1, A2, A3, A4, A5, A6> {
public:
// defaults
struct defaults {
......@@ -76,7 +76,7 @@ namespace limbo {
#endif
};
/// link to the corresponding BoBase (useful for typedefs)
typedef BoBase<Params, A1, A2, A3, A4, A5> base_t;
typedef BoBase<Params, A1, A2, A3, A4, A5, A6> base_t;
typedef typename base_t::model_t model_t;
typedef typename base_t::acquisition_function_t acquisition_function_t;
// extract the types
......
......@@ -99,6 +99,32 @@ struct eval1 {
}
};
BOOST_AUTO_TEST_CASE(test_bo_inheritance)
{
using namespace limbo;
struct Parameters {
struct stop_maxiterations {
BO_PARAM(int, iterations, 1);
};
};
typedef kernel::SquaredExpARD<Params> Kernel_t;
typedef opt::GridSearch<Params> AcquiOpt_t;
typedef boost::fusion::vector<stop::MaxIterations<Parameters>> Stop_t;
// typedef mean_functions::MeanFunctionARD<Params, mean_functions::MeanData<Params>> Mean_t;
typedef mean::Data<Params> Mean_t;
typedef boost::fusion::vector<stat::Samples<Params>, stat::Observations<Params>> Stat_t;
typedef init::NoInit<Params> Init_t;
typedef model::GP<Params, Kernel_t, Mean_t> GP_t;
typedef acqui::UCB<Params, GP_t> Acqui_t;
bayes_opt::BOptimizer<Params, modelfun<GP_t>, initfun<Init_t>, acquifun<Acqui_t>, acquiopt<AcquiOpt_t>, statsfun<Stat_t>, stopcrit<Stop_t>> opt;
opt.optimize(eval3<Params>());
BOOST_CHECK(opt.total_iterations() == 1);
}
BOOST_AUTO_TEST_CASE(test_bo_gp)
{
using namespace limbo;
......
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