resibots / limbo

A lightweight framework for Gaussian processes and Bayesian optimization of black-box functions (C++11)
http://www.resibots.eu/limbo
Other
243 stars 52 forks source link

How to manage the GP model-based BO? #299

Closed LorisR closed 3 years ago

LorisR commented 5 years ago

Hi,

I'm Loris and I would like to use limbo lib for model-based BO. Following the advanced example on the website, I noticed that a very high number of samples are generated in order to create the GP model. In my case, each sample to create the GP model is an experimental test and I need to reduce this number of samples. Is it possible to use the same samples evaluated by the BO to also create the GP model? If not, is it possible to have one sample for BO and only one for the GP model? Which parameter do I have to set to modulate the number of samples used for the GP model generation?

Thanks!

Loris

costashatz commented 5 years ago

Hello Loris,

Thanks for using our library..

Is it possible to use the same samples evaluated by the BO to also create the GP model? If not, is it possible to have one sample for BO and only one for the GP model?

I do not understand exactly what you mean. In BO, every sample is used to create the GP model. In essence, every function evaluation (that can be a real experiment, a simulator or just a function) is used to create the GP model and then the GP model is used for the BO procedure (see more here). There is not separate process to create the GP or do the BO procedure..

Which parameter do I have to set to modulate the number of samples used for the GP model generation?

The main parameters that you need to tune are the parameters of the acquisition function (they depend on the type of acquisition function that you choose: see here for the ones that already implemented in limbo).

I hope I helped..

LorisR commented 5 years ago

Sorry, I was completely wrong :)

Let me reformulate the question. Considering the advanced example:

int main() { using kernel_t = kernel::SquaredExpARD;

using mean_t = MeanFWModel<Params>;

using gp_opt_t = model::gp::KernelLFOpt<Params>;

using gp_t = model::GP<Params, kernel_t, mean_t, gp_opt_t>;

using acqui_t = acqui::EI<Params, gp_t>;
using acqui_opt_t = opt::Cmaes<Params>;

using init_t = init::RandomSampling<Params>;

using stop_t = boost::fusion::vector<stop::MaxIterations<Params>, MinTolerance<Params>>;

using stat_t = boost::fusion::vector<stat::ConsoleSummary<Params>, stat::Samples<Params>, stat::Observations<Params>, stat::AggregatedObservations<Params>, stat::GPAcquisitions<Params>, stat::BestAggregatedObservations<Params>, stat::GPKernelHParams<Params>>;

bayes_opt::BOptimizer<Params, modelfun<gp_t>, acquifun<acqui_t>, acquiopt<acqui_opt_t>, initfun<init_t>, statsfun<stat_t>, stopcrit<stop_t>> boptimizer;
// Instantiate aggregator
DistanceToTarget<Params> aggregator({1, 1});
boptimizer.optimize(eval_func<Params>(), aggregator);
std::cout << "New target!" << std::endl;
aggregator = DistanceToTarget<Params>({1.5, 1});
// Do not forget to pass `false` as the last parameter in `optimize`,
// so you do not reset the data in boptimizer
// i.e. keep all the previous data points in the Gaussian Process
boptimizer.optimize(eval_func<Params>(), aggregator, false);
return 1;

}

The GP model gp_t uses a mathematical model to improve the BO, right? State-based BO means that it is possible to improve BO with such a mathematical model?

If I would like to create a model from samples to be used later I should use what I see here: http://www.resibots.eu/limbo/tutorials/gp.html

Am I right?

Thanks and sorry for the confusion :)

costashatz commented 5 years ago

The GP model gp_t uses a mathematical model to improve the BO, right?

No. Bayesian optimization needs a model; the model does not improve BO. BO is not something that you can improve; it is a procedure/an algorithm. You can use any model of your liking. The most popular one (and most effective) is Gaussian processes.

State-based BO means that it is possible to improve BO with such a mathematical model?

State-based BO should not be the general use-case. I would suggest to not look at this case. The "advanced example" is advanced in terms of using the library and not in terms of BO effectiveness.. We tried in the advanced example to make the simplest most complicated (in terms of code) example with limbo.

If I would like to create a model from samples to be used later I should use what I see here: http://www.resibots.eu/limbo/tutorials/gp.html

You can do it like this. Of course, when having BO object (boptimizer), you can get the already learned model by model() function.

Overall I would suggest you to stay to the basic example and possibly the example here. These examples should cover the basics so that you can use limbo for performing BO in your application.. I doubt that you will need anything more sophisticated. If you additionally need to have access to the GP, then have a look at the GP tutorial...

Hope that I helped!