Commit bd92a748 authored by Konstantinos Chatzilygeroudis's avatar Konstantinos Chatzilygeroudis
Browse files

Merge remote-tracking branch 'origin/gp_multi' into libcmaes

Conflicts:
	src/limbo/opt/cmaes.hpp
parents af4a9c65 1defabaa
...@@ -2287,7 +2287,7 @@ long random_init(random_t* t, long unsigned inseed) ...@@ -2287,7 +2287,7 @@ long random_init(random_t* t, long unsigned inseed)
if (inseed < 1) { if (inseed < 1) {
while ((long)(cloc - clock()) == 0) while ((long)(cloc - clock()) == 0)
; /* TODO: remove this for time critical applications? */ ; /* TODO: remove this for time critical applications? */
inseed = (long unsigned)abs((long)(100 * time(NULL) + clock())); inseed = (long unsigned)labs((long)(100 * time(NULL) + clock()));
} }
return random_Start(t, inseed); return random_Start(t, inseed);
} }
...@@ -2670,7 +2670,7 @@ void readpara_SupplementDefaults(readpara_t* t) ...@@ -2670,7 +2670,7 @@ void readpara_SupplementDefaults(readpara_t* t)
if (t->seed < 1) { if (t->seed < 1) {
while ((int)(cloc - clock()) == 0) while ((int)(cloc - clock()) == 0)
; /* TODO: remove this for time critical applications!? */ ; /* TODO: remove this for time critical applications!? */
t->seed = (unsigned int)abs((long)(100 * time(NULL) + clock())); t->seed = (unsigned int)labs((long)(100 * time(NULL) + clock()));
} }
if (t->stStopFitness.flg == -1) if (t->stStopFitness.flg == -1)
......
...@@ -88,7 +88,7 @@ double ehvi3d_2term(deque<individual*> P, double r[], double mu[], ...@@ -88,7 +88,7 @@ double ehvi3d_2term(deque<individual*> P, double r[], double mu[],
double Sminus; // Correction term for the integral. double Sminus; // Correction term for the integral.
deque<individual*> Py, Pz; // P sorted by y/z coordinate deque<individual*> Py, Pz; // P sorted by y/z coordinate
sort(P.begin(), P.end(), ycomparator); sort(P.begin(), P.end(), ycomparator);
for (int i = 0; i < P.size(); i++) { for (size_t i = 0; i < P.size(); i++) {
Py.push_back(P[i]); Py.push_back(P[i]);
} }
sort(P.begin(), P.end(), zcomparator); sort(P.begin(), P.end(), zcomparator);
...@@ -145,7 +145,7 @@ double ehvi3d_5term(deque<individual*> P, double r[], double mu[], ...@@ -145,7 +145,7 @@ double ehvi3d_5term(deque<individual*> P, double r[], double mu[],
double Sminus; // Correction term for the integral. double Sminus; // Correction term for the integral.
deque<individual*> Py, Pz; // P sorted by y/z coordinate deque<individual*> Py, Pz; // P sorted by y/z coordinate
sort(P.begin(), P.end(), ycomparator); sort(P.begin(), P.end(), ycomparator);
for (int i = 0; i < P.size(); i++) { for (size_t i = 0; i < P.size(); i++) {
Py.push_back(P[i]); Py.push_back(P[i]);
} }
sort(P.begin(), P.end(), zcomparator); sort(P.begin(), P.end(), zcomparator);
...@@ -231,7 +231,7 @@ double ehvi3d_8term(deque<individual*> P, double r[], double mu[], ...@@ -231,7 +231,7 @@ double ehvi3d_8term(deque<individual*> P, double r[], double mu[],
tempimp; // Correction term, rectangular volume, temp. improvement tempimp; // Correction term, rectangular volume, temp. improvement
deque<individual*> Py, Pz; // P sorted by y/z coordinate deque<individual*> Py, Pz; // P sorted by y/z coordinate
sort(P.begin(), P.end(), ycomparator); sort(P.begin(), P.end(), ycomparator);
for (int i = 0; i < P.size(); i++) { for (size_t i = 0; i < P.size(); i++) {
Py.push_back(P[i]); Py.push_back(P[i]);
} }
sort(P.begin(), P.end(), zcomparator); sort(P.begin(), P.end(), zcomparator);
......
...@@ -20,15 +20,15 @@ vector<double> ehvi3d_5term(deque<individual*> P, double r[], ...@@ -20,15 +20,15 @@ vector<double> ehvi3d_5term(deque<individual*> P, double r[],
double Sminus; // Correction term for the integral. double Sminus; // Correction term for the integral.
deque<individual*> Py, Pz; // P sorted by y/z coordinate deque<individual*> Py, Pz; // P sorted by y/z coordinate
sort(P.begin(), P.end(), ycomparator); sort(P.begin(), P.end(), ycomparator);
for (int i = 0; i < P.size(); i++) { for (size_t i = 0; i < P.size(); i++) {
Py.push_back(P[i]); Py.push_back(P[i]);
} }
sort(P.begin(), P.end(), zcomparator); sort(P.begin(), P.end(), zcomparator);
for (unsigned int i = 0; i < P.size(); i++) { for (size_t i = 0; i < P.size(); i++) {
Pz.push_back(P[i]); Pz.push_back(P[i]);
} }
sort(P.begin(), P.end(), xcomparator); sort(P.begin(), P.end(), xcomparator);
for (int i = 0; i < pdf.size(); i++) { for (size_t i = 0; i < pdf.size(); i++) {
answer.push_back(0); answer.push_back(0);
} }
for (int z = 0; z <= n; z++) { for (int z = 0; z <= n; z++) {
...@@ -72,7 +72,7 @@ vector<double> ehvi3d_5term(deque<individual*> P, double r[], ...@@ -72,7 +72,7 @@ vector<double> ehvi3d_5term(deque<individual*> P, double r[],
double yslice = calculateslice(Py, v, cl, 1); double yslice = calculateslice(Py, v, cl, 1);
double zslice = calculateslice(Pz, v, cl, 2); double zslice = calculateslice(Pz, v, cl, 2);
// And then we integrate. // And then we integrate.
for (int i = 0; i < pdf.size(); i++) { for (size_t i = 0; i < pdf.size(); i++) {
double psi1 = exipsi(v[0], cl[0], pdf[i]->mu[0], pdf[i]->s[0]) - exipsi(v[0], cu[0], pdf[i]->mu[0], pdf[i]->s[0]); double psi1 = exipsi(v[0], cl[0], pdf[i]->mu[0], pdf[i]->s[0]) - exipsi(v[0], cu[0], pdf[i]->mu[0], pdf[i]->s[0]);
double psi2 = exipsi(v[1], cl[1], pdf[i]->mu[1], pdf[i]->s[1]) - exipsi(v[1], cu[1], pdf[i]->mu[1], pdf[i]->s[1]); double psi2 = exipsi(v[1], cl[1], pdf[i]->mu[1], pdf[i]->s[1]) - exipsi(v[1], cu[1], pdf[i]->mu[1], pdf[i]->s[1]);
double psi3 = exipsi(v[2], cl[2], pdf[i]->mu[2], pdf[i]->s[2]) - exipsi(v[2], cu[2], pdf[i]->mu[2], pdf[i]->s[2]); double psi3 = exipsi(v[2], cl[2], pdf[i]->mu[2], pdf[i]->s[2]) - exipsi(v[2], cu[2], pdf[i]->mu[2], pdf[i]->s[2]);
...@@ -116,7 +116,7 @@ vector<double> ehvi3d_sliceupdate(deque<individual*> P, double r[DIMENSIONS], ...@@ -116,7 +116,7 @@ vector<double> ehvi3d_sliceupdate(deque<individual*> P, double r[DIMENSIONS],
// location in // location in
// the other sorting orders to be ascertained in O(1). // the other sorting orders to be ascertained in O(1).
sort(P.begin(), P.end(), xcomparator); sort(P.begin(), P.end(), xcomparator);
for (unsigned int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
newind = new specialind; newind = new specialind;
newind->point = P[i]; newind->point = P[i];
newind->xorder = i; newind->xorder = i;
...@@ -125,11 +125,11 @@ vector<double> ehvi3d_sliceupdate(deque<individual*> P, double r[DIMENSIONS], ...@@ -125,11 +125,11 @@ vector<double> ehvi3d_sliceupdate(deque<individual*> P, double r[DIMENSIONS],
Pz.push_back(newind); Pz.push_back(newind);
} }
sort(Py.begin(), Py.end(), specialycomparator); sort(Py.begin(), Py.end(), specialycomparator);
for (unsigned int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
Py[i]->yorder = i; Py[i]->yorder = i;
} }
sort(Pz.begin(), Pz.end(), specialzcomparator); sort(Pz.begin(), Pz.end(), specialzcomparator);
for (unsigned int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
Pz[i]->zorder = i; Pz[i]->zorder = i;
} }
// Then also reserve memory for the structure array. // Then also reserve memory for the structure array.
...@@ -244,7 +244,7 @@ vector<double> ehvi3d_sliceupdate(deque<individual*> P, double r[DIMENSIONS], ...@@ -244,7 +244,7 @@ vector<double> ehvi3d_sliceupdate(deque<individual*> P, double r[DIMENSIONS],
v[2] = (Pstruct[x + y * n].highestdominator == -1 v[2] = (Pstruct[x + y * n].highestdominator == -1
? 0 ? 0
: (Pz[Pstruct[x + y * n].highestdominator]->point->f[2] - r[2])); : (Pz[Pstruct[x + y * n].highestdominator]->point->f[2] - r[2]));
for (int i = 0; i < pdf.size(); i++) { for (size_t i = 0; i < pdf.size(); i++) {
double psi1 = exipsi(r[0], cl[0], pdf[i]->mu[0], pdf[i]->s[0]) - exipsi(r[0], cu[0], pdf[i]->mu[0], pdf[i]->s[0]); double psi1 = exipsi(r[0], cl[0], pdf[i]->mu[0], pdf[i]->s[0]) - exipsi(r[0], cu[0], pdf[i]->mu[0], pdf[i]->s[0]);
double psi2 = exipsi(r[1], cl[1], pdf[i]->mu[1], pdf[i]->s[1]) - exipsi(r[1], cu[1], pdf[i]->mu[1], pdf[i]->s[1]); double psi2 = exipsi(r[1], cl[1], pdf[i]->mu[1], pdf[i]->s[1]) - exipsi(r[1], cu[1], pdf[i]->mu[1], pdf[i]->s[1]);
double psi3 = exipsi(r[2], cl[2], pdf[i]->mu[2], pdf[i]->s[2]) - exipsi(r[2], cu[2], pdf[i]->mu[2], pdf[i]->s[2]); double psi3 = exipsi(r[2], cl[2], pdf[i]->mu[2], pdf[i]->s[2]) - exipsi(r[2], cu[2], pdf[i]->mu[2], pdf[i]->s[2]);
......
...@@ -27,7 +27,7 @@ double ehvi3d_sliceupdate(deque<individual*> P, double r[], double mu[], ...@@ -27,7 +27,7 @@ double ehvi3d_sliceupdate(deque<individual*> P, double r[], double mu[],
// location in // location in
// the other sorting orders to be ascertained in O(1). // the other sorting orders to be ascertained in O(1).
sort(P.begin(), P.end(), xcomparator); sort(P.begin(), P.end(), xcomparator);
for (unsigned int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
newind = new specialind; newind = new specialind;
newind->point = P[i]; newind->point = P[i];
newind->xorder = i; newind->xorder = i;
...@@ -36,11 +36,11 @@ double ehvi3d_sliceupdate(deque<individual*> P, double r[], double mu[], ...@@ -36,11 +36,11 @@ double ehvi3d_sliceupdate(deque<individual*> P, double r[], double mu[],
Pz.push_back(newind); Pz.push_back(newind);
} }
sort(Py.begin(), Py.end(), specialycomparator); sort(Py.begin(), Py.end(), specialycomparator);
for (unsigned int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
Py[i]->yorder = i; Py[i]->yorder = i;
} }
sort(Pz.begin(), Pz.end(), specialzcomparator); sort(Pz.begin(), Pz.end(), specialzcomparator);
for (unsigned int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
Pz[i]->zorder = i; Pz[i]->zorder = i;
} }
// Then also reserve memory for the structure array. // Then also reserve memory for the structure array.
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <limbo/stop/max_iterations.hpp> #include <limbo/stop/max_iterations.hpp>
#include <limbo/stat/samples.hpp> #include <limbo/stat/samples.hpp>
#include <limbo/stat/aggregated_observations.hpp> #include <limbo/stat/aggregated_observations.hpp>
#include <limbo/stat/console_summary.hpp>
#include <limbo/tools/sys.hpp> #include <limbo/tools/sys.hpp>
#include <limbo/kernel/squared_exp_ard.hpp> #include <limbo/kernel/squared_exp_ard.hpp>
#include <limbo/acqui/gp_ucb.hpp> #include <limbo/acqui/gp_ucb.hpp>
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,7 @@
namespace limbo { namespace limbo {
namespace defaults { namespace defaults {
struct bayes_opt_bobase { struct bayes_opt_bobase {
BO_PARAM(bool, stats_enabled, true); BO_PARAM(bool, stats_enabled, true);
}; };
} }
template <typename BO, typename AggregatorFunction> template <typename BO, typename AggregatorFunction>
...@@ -108,7 +109,7 @@ namespace limbo { ...@@ -108,7 +109,7 @@ namespace limbo {
// WARNING: you have to specify the acquisition function // WARNING: you have to specify the acquisition function
// if you use a custom model // if you use a custom model
typedef acqui::GP_UCB<Params, model_t> acqui_t; // 4 typedef acqui::GP_UCB<Params, model_t> acqui_t; // 4
typedef boost::fusion::vector<stat::Samples<Params>, stat::AggregatedObservations<Params>> stat_t; // 5 typedef boost::fusion::vector<stat::Samples<Params>, stat::AggregatedObservations<Params>, stat::ConsoleSummary<Params>> stat_t; // 5
typedef boost::fusion::vector<stop::MaxIterations<Params>> stop_t; // 6 typedef boost::fusion::vector<stop::MaxIterations<Params>> stop_t; // 6
}; };
...@@ -165,7 +166,7 @@ namespace limbo { ...@@ -165,7 +166,7 @@ namespace limbo {
this->_total_iterations = 0; this->_total_iterations = 0;
this->_samples.clear(); this->_samples.clear();
this->_observations.clear(); this->_observations.clear();
this->_bl_samples.clear(); this->_bl_samples.clear();
} }
if (this->_total_iterations == 0) if (this->_total_iterations == 0)
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <iterator> #include <iterator>
#include <boost/parameter/aux_/void.hpp> #include <boost/parameter/aux_/void.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <Eigen/Core> #include <Eigen/Core>
...@@ -65,8 +64,8 @@ namespace limbo { ...@@ -65,8 +64,8 @@ namespace limbo {
this->_init(sfun, afun, reset); this->_init(sfun, afun, reset);
if (!this->_observations.empty()) if (!this->_observations.empty())
_model.compute(this->_samples, this->_observations, Params::bayes_opt_boptimizer::noise(), this->_bl_samples); _model.compute(this->_samples, this->_observations, Params::bayes_opt_boptimizer::noise(), this->_bl_samples);
acqui_optimizer_t acqui_optimizer; acqui_optimizer_t acqui_optimizer;
while (this->_samples.size() == 0 || !this->_stop(*this, afun)) { while (this->_samples.size() == 0 || !this->_stop(*this, afun)) {
...@@ -86,23 +85,6 @@ namespace limbo { ...@@ -86,23 +85,6 @@ namespace limbo {
this->_update_stats(*this, afun, blacklisted); this->_update_stats(*this, afun, blacklisted);
std::cout << this->_current_iteration << " new point: "
<< (blacklisted ? this->_bl_samples.back()
: this->_samples.back()).transpose();
if (blacklisted)
std::cout << " value: " << "No data, blacklisted";
else
std::cout << " value: " << afun(this->_observations.back());
// std::cout << " mu: "<< _model.mu(blacklisted ? this->_bl_samples.back()
// : this->_samples.back()).transpose()
//<< " mean: " << _model.mean_function()(new_sample, _model).transpose()
//<< " sigma: "<< _model.sigma(blacklisted ? this->_bl_samples.back() :
//this->_samples.back())
//<< " acqui: "<< acqui(blacklisted ? this->_bl_samples.back() :
//this->_samples.back(), afun)
std::cout << " best:" << afun(this->best_observation(afun)) << std::endl;
if (!this->_observations.empty()) if (!this->_observations.empty())
_model.compute(this->_samples, this->_observations, Params::bayes_opt_boptimizer::noise(), this->_bl_samples); _model.compute(this->_samples, this->_observations, Params::bayes_opt_boptimizer::noise(), this->_bl_samples);
...@@ -114,7 +96,8 @@ namespace limbo { ...@@ -114,7 +96,8 @@ namespace limbo {
template <typename AggregatorFunction = FirstElem> template <typename AggregatorFunction = FirstElem>
const Eigen::VectorXd& best_observation(const AggregatorFunction& afun = AggregatorFunction()) const const Eigen::VectorXd& best_observation(const AggregatorFunction& afun = AggregatorFunction()) const
{ {
auto rewards = boost::adaptors::transform(this->_observations, afun); auto rewards = std::vector<double>(this->_observations.size());
std::transform(this->_observations.begin(), this->_observations.end(), rewards.begin(), afun);
auto max_e = std::max_element(rewards.begin(), rewards.end()); auto max_e = std::max_element(rewards.begin(), rewards.end());
return this->_observations[std::distance(rewards.begin(), max_e)]; return this->_observations[std::distance(rewards.begin(), max_e)];
} }
...@@ -122,7 +105,8 @@ namespace limbo { ...@@ -122,7 +105,8 @@ namespace limbo {
template <typename AggregatorFunction = FirstElem> template <typename AggregatorFunction = FirstElem>
const Eigen::VectorXd& best_sample(const AggregatorFunction& afun = AggregatorFunction()) const const Eigen::VectorXd& best_sample(const AggregatorFunction& afun = AggregatorFunction()) const
{ {
auto rewards = boost::adaptors::transform(this->_observations, afun); auto rewards = std::vector<double>(this->_observations.size());
std::transform(this->_observations.begin(), this->_observations.end(), rewards.begin(), afun);
auto max_e = std::max_element(rewards.begin(), rewards.end()); auto max_e = std::max_element(rewards.begin(), rewards.end());
return this->_samples[std::distance(rewards.begin(), max_e)]; return this->_samples[std::distance(rewards.begin(), max_e)];
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <Eigen/Core> #include <Eigen/Core>
#include <limbo/tools/macros.hpp> #include <limbo/tools/macros.hpp>
#include <limbo/tools/rand.hpp> #include <limbo/tools/math.hpp>
namespace limbo { namespace limbo {
namespace defaults { namespace defaults {
...@@ -20,8 +20,8 @@ namespace limbo { ...@@ -20,8 +20,8 @@ namespace limbo {
{ {
for (int i = 0; i < Params::init_randomsampling::samples(); i++) { for (int i = 0; i < Params::init_randomsampling::samples(); i++) {
Eigen::VectorXd new_sample(StateFunction::dim_in); Eigen::VectorXd new_sample(StateFunction::dim_in);
for (int i = 0; i < StateFunction::dim_in; i++) for (size_t j = 0; j < StateFunction::dim_in; j++)
new_sample[i] = tools::rand<double>(0, 1); new_sample[j] = tools::rand<double>(0, 1);
opt.add_new_sample(new_sample, seval(new_sample)); opt.add_new_sample(new_sample, seval(new_sample));
} }
} }
......
...@@ -180,8 +180,8 @@ namespace limbo { ...@@ -180,8 +180,8 @@ namespace limbo {
{ {
// O(n^2) [should be negligible] // O(n^2) [should be negligible]
_kernel.resize(_samples.size(), _samples.size()); _kernel.resize(_samples.size(), _samples.size());
for (int i = 0; i < _samples.size(); i++) for (size_t i = 0; i < _samples.size(); i++)
for (int j = 0; j < _samples.size(); ++j) for (size_t j = 0; j < _samples.size(); ++j)
_kernel(i, j) = _kernel_function(_samples[i], _samples[j]) + ((i == j) ? _noise : 0); // noise only on the diagonal _kernel(i, j) = _kernel_function(_samples[i], _samples[j]) + ((i == j) ? _noise : 0); // noise only on the diagonal
// O(n^3) // O(n^3)
......
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
#include <limbo/tools/macros.hpp> #include <limbo/tools/macros.hpp>
namespace limbo { namespace limbo {
namespace defaults { namespace defaults {
struct opt_gridsearch { struct opt_gridsearch {
BO_PARAM(int, bins, 5); BO_PARAM(int, bins, 5);
}; };
} }
namespace opt { namespace opt {
template <typename Params> template <typename Params>
struct GridSearch { struct GridSearch {
...@@ -27,7 +27,7 @@ namespace limbo { ...@@ -27,7 +27,7 @@ namespace limbo {
protected: protected:
template <typename F> template <typename F>
Eigen::VectorXd _inner_search(const F& f, int depth, const Eigen::VectorXd& current) const Eigen::VectorXd _inner_search(const F& f, size_t depth, const Eigen::VectorXd& current) const
{ {
double step_size = 1.0 / (double)Params::opt_gridsearch::bins(); double step_size = 1.0 / (double)Params::opt_gridsearch::bins();
double upper_lim = 1.0 + step_size; double upper_lim = 1.0 + step_size;
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
#include <algorithm> #include <algorithm>
#include <boost/math/special_functions/sign.hpp>
#include <Eigen/Core> #include <Eigen/Core>
#include <limbo/tools/macros.hpp> #include <limbo/tools/macros.hpp>
......
...@@ -8,9 +8,10 @@ ...@@ -8,9 +8,10 @@
#include <Eigen/Core> #include <Eigen/Core>
#include <limbo/tools/macros.hpp> #include <limbo/tools/macros.hpp>
#include <limbo/tools/math.hpp>
namespace limbo { namespace limbo {
namespace defaults { namespace defaults {
struct opt_rprop { struct opt_rprop {
BO_PARAM(int, iterations, 300); BO_PARAM(int, iterations, 300);
}; };
...@@ -70,7 +71,7 @@ namespace limbo { ...@@ -70,7 +71,7 @@ namespace limbo {
delta(j) = std::max(delta(j) * etaminus, deltamin); delta(j) = std::max(delta(j) * etaminus, deltamin);
grad(j) = 0; grad(j) = 0;
} }
params(j) += -boost::math::sign(grad(j)) * delta(j); params(j) += -tools::signum(grad(j)) * delta(j);
if (bounded && params(j) < 0) if (bounded && params(j) < 0)
params(j) = 0; params(j) = 0;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <limbo/stat/best_observations.hpp> #include <limbo/stat/best_observations.hpp>
#include <limbo/stat/best_samples.hpp> #include <limbo/stat/best_samples.hpp>
#include <limbo/stat/bl_samples.hpp> #include <limbo/stat/bl_samples.hpp>
#include <limbo/stat/console_summary.hpp>
#include <limbo/stat/aggregated_observations.hpp> #include <limbo/stat/aggregated_observations.hpp>
#include <limbo/stat/observations.hpp> #include <limbo/stat/observations.hpp>
#include <limbo/stat/gp_acquisitions.hpp> #include <limbo/stat/gp_acquisitions.hpp>
......
#ifndef LIMBO_STAT_CONSOLE_SUMMARY_HPP
#define LIMBO_STAT_CONSOLE_SUMMARY_HPP
#include <limbo/stat/stat_base.hpp>
namespace limbo {
namespace stat {
template <typename Params>
struct ConsoleSummary : public StatBase<Params> {
template <typename BO, typename AggregatorFunction>
void operator()(const BO& bo, const AggregatorFunction& afun, bool blacklisted)
{
if (!bo.stats_enabled() || bo.observations().empty())
return;
std::cout << bo.total_iterations() << " new point: "
<< (blacklisted ? bo.bl_samples().back()
: bo.samples().back()).transpose();
if (blacklisted)
std::cout << " value: "
<< "No data, blacklisted";
else
std::cout << " value: " << afun(bo.observations().back());
std::cout << " best:" << afun(bo.best_observation(afun)) << std::endl;
}
};
}
}
#endif
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <fstream> #include <fstream>
#include <string> #include <string>
#include <boost/shared_ptr.hpp> #include <memory>
namespace limbo { namespace limbo {
namespace stat { namespace stat {
...@@ -19,14 +19,14 @@ namespace limbo { ...@@ -19,14 +19,14 @@ namespace limbo {
} }
protected: protected:
boost::shared_ptr<std::ofstream> _log_file; std::shared_ptr<std::ofstream> _log_file;
template <typename BO> template <typename BO>
void _create_log_file(const BO& bo, const std::string& name) void _create_log_file(const BO& bo, const std::string& name)
{ {
if (!_log_file && bo.stats_enabled()) { if (!_log_file && bo.stats_enabled()) {
std::string log = bo.res_dir() + "/" + name; std::string log = bo.res_dir() + "/" + name;
_log_file = boost::shared_ptr<std::ofstream>(new std::ofstream(log.c_str())); _log_file = std::make_shared<std::ofstream>(log.c_str());
} }
} }
}; };
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <limbo/tools/macros.hpp> #include <limbo/tools/macros.hpp>
#include <limbo/tools/parallel.hpp> #include <limbo/tools/parallel.hpp>
#include <limbo/tools/rand.hpp> #include <limbo/tools/math.hpp>
#include <limbo/tools/sys.hpp> #include <limbo/tools/sys.hpp>
#endif #endif
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
//| The fact that you are presently reading this means that you have //| The fact that you are presently reading this means that you have
//| had knowledge of the CeCILL license and that you accept its terms. //| had knowledge of the CeCILL license and that you accept its terms.
#ifndef LIMBO_TOOLS_RAND_HPP #ifndef LIMBO_TOOLS_MATH_HPP
#define LIMBO_TOOLS_RAND_HPP #define LIMBO_TOOLS_MATH_HPP
#include <cstdlib> #include <cstdlib>
#include <cmath> #include <cmath>
...@@ -43,8 +43,7 @@ ...@@ -43,8 +43,7 @@
#include <list> #include <list>
#include <stdlib.h> #include <