Commit e1f4ac32 authored by Federico Allocati's avatar Federico Allocati
Browse files

Fixed includes in examples and tests to use only necessary files

parent 88b29bb0
//#define SHOW_TIMER
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/include/vector.hpp>
#include <limbo/limbo.hpp>
#include <limbo/inner_opt/cmaes.hpp>
#include <limbo/tools/macros.hpp>
#include <limbo/kernel/matern_five_halfs.hpp>
#include <limbo/mean/data.hpp>
#include <limbo/model/gp.hpp>
#include <limbo/acqui/ucb.hpp>
#include <limbo/bayes_opt/boptimizer.hpp>
using namespace limbo;
......@@ -53,7 +53,6 @@ struct fit_eval {
int main()
{
typedef kernel::MaternFiveHalfs<Params> Kernel_t;
typedef mean::Data<Params> Mean_t;
typedef model::GP<Params, Kernel_t, Mean_t> GP_t;
......
//#define SHOW_TIMER
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/include/vector.hpp>
#include <limbo/limbo.hpp>
#include <limbo/inner_opt/cmaes.hpp>
#include <limbo/tools/macros.hpp>
#include <limbo/kernel/matern_five_halfs.hpp>
#include <limbo/mean/data.hpp>
#include <limbo/model/gp.hpp>
#include <limbo/acqui/gp_ucb.hpp>
#include <limbo/bayes_opt/boptimizer.hpp>
using namespace limbo;
......@@ -14,10 +14,6 @@ struct Params {
struct cmaes : public defaults::cmaes {
};
struct ucb {
BO_PARAM(float, alpha, 0.1);
};
struct kf_maternfivehalfs {
BO_PARAM(float, sigma, 1);
BO_PARAM(float, l, 0.2);
......
//#define SHOW_TIMER
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/include/vector.hpp>
#include <limbo/limbo.hpp>
#include <limbo/inner_opt/cmaes.hpp>
#include <limbo/tools/macros.hpp>
#include <limbo/kernel/squared_exp_ard.hpp>
#include <limbo/mean/function_ard.hpp>
#include <limbo/model/gp_auto_mean.hpp>
#include <limbo/bayes_opt/boptimizer.hpp>
using namespace limbo;
struct Params {
// struct gp_ucb : public defaults::gp_ucb {};
struct Params {
struct gp_auto_mean {
BO_PARAM(int, n_rprop, 100);
BO_PARAM(int, rprop_restart, 10);
......@@ -18,10 +15,6 @@ struct Params {
struct cmaes : public defaults::cmaes {
};
struct ucb {
BO_PARAM(float, alpha, 0.1);
};
struct kf_maternfivehalfs {
BO_PARAM(float, sigma, 1);
BO_PARAM(float, l, 0.2);
......
......@@ -39,6 +39,7 @@
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <list>
#include <stdlib.h>
#include <boost/swap.hpp>
......
//#define SHOW_TIMER
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#ifdef USE_TBB
#include <tbb/task_scheduler_init.h>
#include <tbb/parallel_for.h>
#include <tbb/concurrent_hash_map.h>
#include <map>
#else
#endif
#include <limbo/limbo.hpp>
#include <limbo/inner_opt/cmaes.hpp>
#include <limbo/tools/parallel.hpp>
#include <Eigen/Core>
#include "default_params.hpp"
#include <limbo/tools/macros.hpp>
#include <limbo/bayes_opt/boptimizer.hpp>
#include <limbo/tools/parallel.hpp>
using namespace limbo;
using namespace tests;
static constexpr int nb_replicates = 4;
......@@ -205,8 +209,6 @@ struct Params {
};
};
// BO_DECLARE_DYN_PARAM(double, Params::meanconstant, constant);
template <typename T>
void print_res(const T& r)
{
......@@ -248,22 +250,6 @@ bool is_in_argv(int argc, char** argv, const char* needle)
return !(it == argv + argc);
}
template <typename F>
void replicate(const F& f, size_t nb)
{
#ifdef USE_TBB
static tbb::task_scheduler_init init;
tbb::parallel_for(size_t(0), nb, size_t(1), [&](size_t i) {
// clang-format off
f();
// clang-format on
});
#else
for (size_t i = 0; i < nb; i++)
f();
#endif
}
template <typename T1, typename T2>
void add_to_results(const char* key, T1& map, const T2& p)
{
......@@ -274,13 +260,12 @@ void add_to_results(const char* key, T1& map, const T2& p)
}
int main(int argc, char** argv)
{
{
tools::par::init();
typedef bayes_opt::BOptimizer<Params> Opt_t;
#ifdef USE_TBB
typedef tbb::concurrent_hash_map<std::string, std::vector<std::pair<double, double>>>
res_t;
res_t;
#else
typedef std::map<std::string,
std::vector<std::pair<double, double>>>
......@@ -288,6 +273,8 @@ int main(int argc, char** argv)
#endif
res_t results;
typedef bayes_opt::BOptimizer<Params> Opt_t;
if (!is_in_argv(argc, argv, "--only") || is_in_argv(argc, argv, "sphere"))
tools::par::replicate(nb_replicates, [&]() {
// clang-format off
......
#ifndef BO_DEFAULT_PARAMS_HPP
#define BO_DEFAULT_PARAMS_HPP
namespace limbo {
namespace tests {
namespace def {
struct cmaes {
BO_PARAM(double, stopMaxFunEvals, 1e5);
BO_PARAM(double, stopMaxIter, 1e5);
BO_PARAM(double, stopTolFun, 1e-5);
BO_PARAM(double, stopTolFunHist, 1e-6);
BO_PARAM(int, nb_pts, 20);
BO_PARAM(bool, discrete, false);
};
}
}
}
#endif
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE parallel
#define BOOST_TEST_MODULE gp
#include <boost/test/unit_test.hpp>
#include <limbo/tools/macros.hpp>
#include <limbo/kernel/matern_five_halfs.hpp>
#include <limbo/mean/constant.hpp>
#include <limbo/model/gp.hpp>
using namespace limbo;
......
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE parallel
#define BOOST_TEST_MODULE gp_auto
#include <boost/test/unit_test.hpp>
#include <limbo/tools/macros.hpp>
#include <limbo/kernel/squared_exp_ard.hpp>
#include <limbo/mean/constant.hpp>
#include <limbo/model/gp_auto.hpp>
#include <fstream>
......
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE initctions
#define BOOST_TEST_MODULE init_functions
#include <boost/test/unit_test.hpp>
#include <limbo/limbo.hpp>
#include <limbo/inner_opt/cmaes.hpp>
#include <limbo/tools/macros.hpp>
#include <limbo/init.hpp>
#include <limbo/acqui.hpp>
#include <limbo/bayes_opt/boptimizer.hpp>
using namespace limbo;
......
......@@ -3,7 +3,9 @@
#include <boost/test/unit_test.hpp>
#include <limbo/limbo.hpp>
#include <limbo/tools/macros.hpp>
#include <limbo/inner_opt.hpp>
#include <limbo/bayes_opt/bo_base.hpp>
using namespace limbo;
......
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE parallel
#define BOOST_TEST_MODULE macros
#include <boost/test/unit_test.hpp>
#include <cstring>
......
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