BayesOpt
|
Abstract module for Bayesian optimization. More...
#include <bayesoptbase.hpp>
Public Member Functions | |
BayesOptBase (size_t dim, Parameters params) | |
Constructor. More... | |
virtual | ~BayesOptBase () |
Default destructor. | |
virtual double | evaluateSample (const vectord &query)=0 |
Function that defines the actual function to be optimized. More... | |
virtual bool | checkReachability (const vectord &query) |
This function checks if the query is valid or not. More... | |
void | optimize (vectord &bestPoint) |
Execute the optimization process of the function defined in evaluateSample. More... | |
void | stepOptimization () |
Execute ONE step the optimization process of the function defined in evaluateSample. | |
void | initializeOptimization () |
Initialize the optimization process. More... | |
vectord | getFinalResult () |
Once the optimization has been perfomed, return the optimal point. More... | |
void | saveOptimization (BOptState &state) |
Saves the current state of the optimization process into a state class. More... | |
void | restoreOptimization (BOptState state) |
Restores the optimization process of a previous execution. | |
ProbabilityDistribution * | getPrediction (const vectord &query) |
const Dataset * | getData () |
Parameters * | getParameters () |
double | getValueAtMinimum () |
size_t | getCurrentIter () |
double | evaluateCriteria (const vectord &query) |
Protected Member Functions | |
vectord | getPointAtMinimum () |
Get optimal point in the inner space (e.g. More... | |
double | evaluateSampleInternal (const vectord &query) |
Wrapper for the target function adding any preprocessing or constraint. More... | |
virtual vectord | samplePoint ()=0 |
Sample a single point in the input space. More... | |
virtual void | findOptimal (vectord &xOpt)=0 |
Call the inner optimization method to find the optimal point acording to the criteria. More... | |
virtual vectord | remapPoint (const vectord &x)=0 |
Remap the point x to the original space (e.g. More... | |
virtual void | generateInitialPoints (matrixd &xPoints)=0 |
Selects the initial set of points to build the surrogate model. More... | |
void | plotStepData (size_t iteration, const vectord &xNext, double yNext) |
Print data for every step according to the verbose level. More... | |
void | saveInitialSamples (matrixd xPoints) |
Eases the process of saving a state during initial samples. | |
void | saveResponse (double yPoint, bool clear) |
Protected Attributes | |
Parameters | mParameters |
Configuration parameters. | |
size_t | mDims |
Number of dimensions. | |
size_t | mCurrentIter |
Current iteration number. | |
boost::mt19937 | mEngine |
Random number generator. | |
Private Member Functions | |
vectord | nextPoint () |
Selects the next point to evaluate according to a certain criteria or metacriteria. More... | |
Private Attributes | |
boost::scoped_ptr< PosteriorModel > | mModel |
double | mYPrev |
size_t | mCounterStuck |
Abstract module for Bayesian optimization.
This module provides Bayesian optimization using different non-parametric processes (Gaussian process or Student's t process) as distributions over surrogate functions.
Definition at line 72 of file bayesoptbase.hpp.
bayesopt::BayesOptBase::BayesOptBase | ( | size_t | dim, |
Parameters | params | ||
) |
Constructor.
params | set of parameters (see parameters.hpp) |
Definition at line 35 of file bayesoptbase.cpp.
References bayesopt::Parameters::log_filename, mEngine, mParameters, bayesopt::Parameters::random_seed, and bayesopt::Parameters::verbose_level.
|
inlinevirtual |
This function checks if the query is valid or not.
It can be used to introduce arbitrary constrains. Since the Gaussian process assumes smoothness, constrains are managed by the inner optimizer (e.g.:DIRECT), being highly time consuming. If the constrain is very tricky, DIRECT will need much more function evaluations.
Note: This function is experimental. Thus it is not made pure virtual. Using it is completely optional.
query | point to be evaluated. |
Reimplemented in ExampleHartmann6, XMLCallsBranin, ExampleCamelback, BraninNormalized, SystemCallsBranin, ExampleDisc, ExampleQuadratic, and ExampleOneD.
Definition at line 113 of file bayesoptbase.hpp.
|
pure virtual |
Function that defines the actual function to be optimized.
This function must be modified (overriden) according to the specific problem.
query | point to be evaluated. |
Implemented in ExampleHartmann6, ExampleCamelback, XMLCallsBranin, CDiscreteModel, BraninNormalized, ExampleDisc, ExampleQuadratic, CContinuousModel, SystemCallsBranin, and ExampleOneD.
Referenced by evaluateSampleInternal(), bayesoptmodule.BayesOptContinuous::optimize(), bayesoptmodule.BayesOptDiscrete::optimize(), and bayesoptmodule.BayesOptCategorical::optimize().
|
protected |
Wrapper for the target function adding any preprocessing or constraint.
It also maps the box constrains to the [0,1] hypercube if applicable.
Definition at line 316 of file bayesoptbase.cpp.
References evaluateSample(), and remapPoint().
Referenced by initializeOptimization(), restoreOptimization(), and stepOptimization().
|
protectedpure virtual |
Call the inner optimization method to find the optimal point acording to the criteria.
xOpt | optimal point |
Implemented in bayesopt::DiscreteModel, and bayesopt::ContinuousModel.
|
protectedpure virtual |
Selects the initial set of points to build the surrogate model.
Implemented in bayesopt::DiscreteModel, and bayesopt::ContinuousModel.
Referenced by initializeOptimization().
vectord bayesopt::BayesOptBase::getFinalResult | ( | ) |
Once the optimization has been perfomed, return the optimal point.
Definition at line 213 of file bayesoptbase.cpp.
References getPointAtMinimum(), and remapPoint().
|
protected |
Get optimal point in the inner space (e.g.
: [0-1] hypercube)
Definition at line 313 of file bayesoptbase.cpp.
Referenced by getFinalResult().
void bayesopt::BayesOptBase::initializeOptimization | ( | ) |
Initialize the optimization process.
Definition at line 166 of file bayesoptbase.cpp.
References evaluateSampleInternal(), generateInitialPoints(), mDims, mEngine, mParameters, bayesopt::Parameters::n_init_samples, bayesopt::Parameters::n_iterations, saveInitialSamples(), and bayesopt::Parameters::verbose_level.
|
private |
Selects the next point to evaluate according to a certain criteria or metacriteria.
Definition at line 387 of file bayesoptbase.cpp.
References bayesopt::Parameters::epsilon, mEngine, and mParameters.
Referenced by stepOptimization().
void bayesopt::BayesOptBase::optimize | ( | vectord & | bestPoint | ) |
Execute the optimization process of the function defined in evaluateSample.
bestPoint | returns point with the optimum value in a ublas::vector. |
Definition at line 66 of file bayesoptbase.cpp.
References bayesopt::Parameters::load_filename, bayesopt::Parameters::load_save_flag, bayesopt::BOptState::loadFromFile(), mDims, mParameters, and restoreOptimization().
Referenced by ExampleDisc::checkReachability().
|
protected |
Print data for every step according to the verbose level.
iteration | iteration number |
xNext | next point |
yNext | function value at next point |
Definition at line 330 of file bayesoptbase.cpp.
References mParameters, and bayesopt::Parameters::verbose_level.
|
protectedpure virtual |
Remap the point x to the original space (e.g.
: unnormalization)
Implemented in bayesopt::DiscreteModel, and bayesopt::ContinuousModel.
Referenced by evaluateSampleInternal(), and getFinalResult().
|
protectedpure virtual |
Sample a single point in the input space.
Used for epsilon greedy exploration.
Implemented in bayesopt::DiscreteModel, and bayesopt::ContinuousModel.
void bayesopt::BayesOptBase::saveOptimization | ( | BOptState & | state | ) |
Saves the current state of the optimization process into a state class.
Definition at line 220 of file bayesoptbase.cpp.
References mCurrentIter, and mParameters.
Referenced by saveInitialSamples().