Commit 18dc4a2c authored by Konstantinos Chatzilygeroudis's avatar Konstantinos Chatzilygeroudis
Browse files

Bug fixes + proper limits in kernel hp opt

parent 2f8b3cce
......@@ -40,20 +40,17 @@ struct Params {
struct DirectParams {
struct opt_nloptnograd {
BO_DYN_PARAM(int, iterations);
BO_PARAM(bool, test, false);
};
};
struct BobyqaParams {
struct opt_nloptnograd {
BO_DYN_PARAM(int, iterations);
BO_PARAM(bool, test, false);
};
};
struct BobyqaParams_HP {
struct opt_nloptnograd {
BO_DYN_PARAM(int, iterations);
BO_PARAM(bool, test, true);
};
};
......@@ -68,7 +65,7 @@ void benchmark(const std::string& name)
DirectParams::opt_nloptnograd::set_iterations(static_cast<int>(iters_base * Function::dim_in * 0.9));
BobyqaParams::opt_nloptnograd::set_iterations(iters_base * Function::dim_in - DirectParams::opt_nloptnograd::iterations());
BobyqaParams_HP::opt_nloptnograd::set_iterations(10 * Function::dim_in * (Function::dim_in - 1));
BobyqaParams_HP::opt_nloptnograd::set_iterations(10 * Function::dim_in * Function::dim_in);
auto t1 = std::chrono::steady_clock::now();
Optimizer opt;
......
......@@ -36,14 +36,12 @@ struct Params {
struct DirectParams {
struct opt_nloptnograd {
BO_DYN_PARAM(int, iterations);
BO_PARAM(bool, test, false);
};
};
struct BobyqaParams {
struct opt_nloptnograd {
BO_DYN_PARAM(int, iterations);
BO_PARAM(bool, test, false);
};
};
......
......@@ -33,7 +33,7 @@ namespace limbo {
{
//assert(Params::SquaredExpARD::k()<dim);
Eigen::VectorXd p = Eigen::VectorXd::Zero(_ell.size() + _ell.size() * Params::kernel_squared_exp_ard::k());
p.head(_ell.size()) = Eigen::VectorXd::Ones(_ell.size()) * -1;
p.head(_ell.size()) = Eigen::VectorXd::Ones(_ell.size());
this->set_h_params(p);
_sf2 = Params::kernel_squared_exp_ard::sigma_sq();
}
......@@ -46,7 +46,7 @@ namespace limbo {
{
_h_params = p;
for (size_t i = 0; i < _input_dim; ++i)
_ell(i) = std::exp(p(i));
_ell(i) = p(i);
for (size_t j = 0; j < (unsigned int)Params::kernel_squared_exp_ard::k(); ++j)
for (size_t i = 0; i < _input_dim; ++i)
_A(i, j) = p((j + 1) * _input_dim + i); //can be negative
......
......@@ -18,11 +18,10 @@ namespace limbo {
template <typename GP>
void operator()(GP& gp) const
{
int dim = gp.kernel_function().h_params_size();
KernelLFOptimization<GP> optimization(gp);
Optimizer optimizer;
auto params = optimizer(optimization, gp.kernel_function().h_params(), true);
gp.kernel_function().set_h_params(params);
gp.kernel_function().set_h_params(-6.0 + params.array() * 7.0);
gp.set_lik(opt::eval(optimization, params));
gp.recompute(false);
}
......@@ -36,7 +35,7 @@ namespace limbo {
opt::eval_t operator()(const Eigen::VectorXd& params, bool compute_grad) const
{
GP gp(this->_original_gp);
gp.kernel_function().set_h_params(params);
gp.kernel_function().set_h_params(-6.0 + params.array() * 7.0);
gp.recompute(false);
......
......@@ -87,10 +87,6 @@ namespace limbo {
if (bounded) {
opt.set_lower_bounds(std::vector<double>(dim, 0));
opt.set_upper_bounds(std::vector<double>(dim, 1));
if (Params::opt_nloptnograd::test()) {
opt.set_lower_bounds(std::vector<double>(dim, -6.0));
opt.set_upper_bounds(std::vector<double>(dim, 1.0));
}
}
double max;
......
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