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

Small fixes for unbounded BO

parent 74ab2f05
...@@ -72,7 +72,7 @@ namespace limbo { ...@@ -72,7 +72,7 @@ namespace limbo {
void operator()(const StateFunction& seval, const AggregatorFunction&, Opt& opt) const void operator()(const StateFunction& seval, const AggregatorFunction&, Opt& opt) const
{ {
for (int i = 0; i < Params::init_randomsampling::samples(); i++) { for (int i = 0; i < Params::init_randomsampling::samples(); i++) {
auto new_sample = tools::random_vector(StateFunction::dim_in); auto new_sample = tools::random_vector(StateFunction::dim_in, Params::bayes_opt_boptimizer::bounded());
opt.eval_and_add(seval, new_sample); opt.eval_and_add(seval, new_sample);
} }
} }
......
...@@ -62,8 +62,8 @@ namespace limbo { ...@@ -62,8 +62,8 @@ namespace limbo {
namespace init { namespace init {
/** @ingroup init /** @ingroup init
\rst \rst
Grid-based random sampling: in effect, define a grid and takes random samples from this grid. The number of bins in the grid is ``bins``^number_of_dimensions Grid-based random sampling: in effect, define a grid and takes random samples from this grid. The number of bins in the grid is ``bins``^number_of_dimensions
For instance, if bins = 5 and there are 3 inputs dimensions, then the grid is 5*5*5=125, and random points will all be points of this grid. For instance, if bins = 5 and there are 3 inputs dimensions, then the grid is 5*5*5=125, and random points will all be points of this grid.
Parameters: Parameters:
...@@ -76,6 +76,9 @@ namespace limbo { ...@@ -76,6 +76,9 @@ namespace limbo {
template <typename StateFunction, typename AggregatorFunction, typename Opt> template <typename StateFunction, typename AggregatorFunction, typename Opt>
void operator()(const StateFunction& seval, const AggregatorFunction&, Opt& opt) const void operator()(const StateFunction& seval, const AggregatorFunction&, Opt& opt) const
{ {
// Only works with bounded BO
assert(Params::bayes_opt_boptimizer::bounded());
tools::rgen_int_t rgen(0, Params::init_randomsamplinggrid::bins()); tools::rgen_int_t rgen(0, Params::init_randomsamplinggrid::bins());
for (int i = 0; i < Params::init_randomsamplinggrid::samples(); i++) { for (int i = 0; i < Params::init_randomsamplinggrid::samples(); i++) {
Eigen::VectorXd new_sample(StateFunction::dim_in); Eigen::VectorXd new_sample(StateFunction::dim_in);
......
...@@ -90,11 +90,17 @@ namespace limbo { ...@@ -90,11 +90,17 @@ namespace limbo {
using rdist_double_t = std::uniform_real_distribution<double>; using rdist_double_t = std::uniform_real_distribution<double>;
/// @ingroup tools /// @ingroup tools
using rdist_int_t = std::uniform_int_distribution<int>; using rdist_int_t = std::uniform_int_distribution<int>;
/// @ingroup tools
using rdist_gauss_t = std::normal_distribution<>;
/// @ingroup tools /// @ingroup tools
/// Double random number generator /// Double random number generator
using rgen_double_t = RandomGenerator<rdist_double_t>; using rgen_double_t = RandomGenerator<rdist_double_t>;
/// @ingroup tools
/// Double random number generator (gaussian)
using rgen_gauss_t = RandomGenerator<rdist_gauss_t>;
///@ingroup tools ///@ingroup tools
///integer random number generator ///integer random number generator
using rgen_int_t = RandomGenerator<rdist_int_t>; using rgen_int_t = RandomGenerator<rdist_int_t>;
...@@ -120,7 +126,7 @@ namespace limbo { ...@@ -120,7 +126,7 @@ namespace limbo {
/// - we use a C++11 random number generator /// - we use a C++11 random number generator
Eigen::VectorXd random_vector_unbounded(int size) Eigen::VectorXd random_vector_unbounded(int size)
{ {
static rgen_double_t rgen(std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max()); static rgen_gauss_t rgen(0.0, 100.0);
Eigen::VectorXd res(size); Eigen::VectorXd res(size);
for (int i = 0; i < size; ++i) for (int i = 0; i < size; ++i)
res[i] = rgen.rand(); res[i] = rgen.rand();
......
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