Commit a2b91d3f authored by Konstantinos Chatzilygeroudis's avatar Konstantinos Chatzilygeroudis Committed by GitHub
Browse files

Merge pull request #165 from resibots/cleaning_mo

Cleaning experimental/Multi objective
parents 49228900 c760f420
......@@ -46,7 +46,9 @@
#include <limbo/experimental/bayes_opt/parego.hpp>
#include <limbo/experimental/bayes_opt/nsbo.hpp>
#include <limbo/experimental/bayes_opt/ehvi.hpp>
#include <limbo/experimental/stat/pareto_front.hpp>
#include <limbo/experimental/stat/pareto_benchmark.hpp>
#include <limbo/experimental/stat/hyper_volume.hpp>
using namespace limbo;
......@@ -90,10 +92,17 @@ struct Params {
struct mean_constant : public defaults::mean_constant {
};
struct bayes_opt_ehvi {
struct bayes_opt_ehvi : public defaults::bayes_opt_ehvi {
BO_PARAM(double, x_ref, -11);
BO_PARAM(double, y_ref, -11);
};
struct model_gp_parego : public experimental::defaults::model_gp_parego {
};
struct stat_hyper_volume {
BO_PARAM_ARRAY(double, ref, 10, 10);
};
};
#ifdef DIM6
......@@ -106,6 +115,8 @@ struct Params {
struct zdt1 {
static constexpr size_t dim_in = ZDT_DIM;
static constexpr size_t dim_out = 2;
Eigen::VectorXd operator()(const Eigen::VectorXd& x) const
{
Eigen::VectorXd res(2);
......@@ -123,6 +134,8 @@ struct zdt1 {
struct zdt2 {
static constexpr size_t dim_in = ZDT_DIM;
static constexpr size_t dim_out = 2;
Eigen::VectorXd operator()(const Eigen::VectorXd& x) const
{
Eigen::VectorXd res(2);
......@@ -140,6 +153,8 @@ struct zdt2 {
struct zdt3 {
static constexpr size_t dim_in = ZDT_DIM;
static constexpr size_t dim_out = 2;
Eigen::VectorXd operator()(const Eigen::VectorXd& x) const
{
Eigen::VectorXd res(2);
......@@ -190,13 +205,16 @@ int main()
typedef mop2 func_t;
#endif
using stat_t = boost::fusion::vector<experimental::stat::ParetoBenchmark<func_t>>;
#ifdef PAREGO
Parego<Params, statsfun<stat_t>> opt;
using stat_t = boost::fusion::vector<experimental::stat::ParetoFront<Params>,
experimental::stat::HyperVolume<Params>,
stat::ConsoleSummary<Params>>;
experimental::bayes_opt::Parego<Params, statsfun<stat_t>> opt;
#elif defined(NSBO)
Nsbo<Params, statsfun<stat_t>> opt;
using stat_t = boost::fusion::vector<experimental::stat::ParetoBenchmark<func_t>>;
experimental::bayes_opt::Nsbo<Params, statsfun<stat_t>> opt;
#else
using stat_t = boost::fusion::vector<experimental::stat::ParetoBenchmark<func_t>>;
experimental::bayes_opt::Ehvi<Params, statsfun<stat_t>> opt;
#endif
opt.optimize(func_t());
......
......@@ -62,9 +62,23 @@ def build(bld):
obj = bld.program(features = 'cxx',
source = 'multi.cpp',
includes = '.. ../.. ../../../',
target = 'multi',
target = 'multi_ehvi',
uselib = 'BOOST EIGEN TBB SFERES LIBCMAES NLOPT',
use = 'limbo')
obj = bld.program(features = 'cxx',
source = 'multi.cpp',
includes = '.. ../.. ../../../',
target = 'multi_parego',
uselib = 'BOOST EIGEN TBB SFERES LIBCMAES NLOPT',
defines = 'PAREGO',
use = 'limbo')
obj = bld.program(features = 'cxx',
source = 'multi.cpp',
includes = '.. ../.. ../../../',
target = 'multi_nsbo',
uselib = 'BOOST EIGEN TBB SFERES LIBCMAES NLOPT',
defines = 'NSBO',
use = 'limbo')
obj = bld.program(features = 'cxx',
source = 'constrained_ei.cpp',
includes = '.. ../.. ../../../',
......
......@@ -106,7 +106,6 @@ namespace limbo {
acqui_optimizer_t inner_opt;
while (this->_samples.size() == 0 || !this->_stop(*this, FirstElem())) {
std::cout.flush();
this->template update_pareto_model<EvalFunction::dim_in>();
this->update_pareto_data();
......@@ -141,7 +140,7 @@ namespace limbo {
};
auto comp = [](const pair_t& v1, const pair_t& v2) {
return v1.second > v2.second;
return v1.second > v2.second;
};
auto m = tools::par::max(init, this->pareto_data().size(), body, comp);
......
......@@ -74,7 +74,7 @@ namespace limbo {
while (this->_samples.size() == 0 || !this->_stop(*this, FirstElem())) {
std::cout << "updating pareto model...";
std::cout.flush();
this->template update_pareto_model<EvalFunction::dim>();
this->template update_pareto_model<EvalFunction::dim_in>();
std::cout << "ok" << std::endl;
auto pareto = this->pareto_model();
......@@ -98,9 +98,10 @@ namespace limbo {
protected:
// former way to deal with the template of RefreshStat
/* void _update_stats() {
boost::fusion::for_each(this->_stat, RefreshStat_f<Nsbo>(*this));
}*/
// void _update_stats()
// {
// boost::fusion::for_each(this->_stat, RefreshStat_f<Nsbo>(*this));
// }
};
}
}
......
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