BayesOpt
bayesopt::BayesOptBase Class Referenceabstract

Abstract module for Bayesian optimization. More...

#include <bayesoptbase.hpp>

+ Inheritance diagram for bayesopt::BayesOptBase:
+ Collaboration diagram for bayesopt::BayesOptBase:

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.
 
ProbabilityDistributiongetPrediction (const vectord &query)
 
const DatasetgetData ()
 
ParametersgetParameters ()
 
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< PosteriorModelmModel
 
double mYPrev
 
size_t mCounterStuck
 

Detailed Description

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.

See also
ContinuousModel for implementations of this module for a continuous input spaces
DiscreteModel for implementations of this module for a discrete input spaces or categorical input variables

Definition at line 72 of file bayesoptbase.hpp.

Constructor & Destructor Documentation

◆ BayesOptBase()

bayesopt::BayesOptBase::BayesOptBase ( size_t  dim,
Parameters  params 
)

Constructor.

Parameters
paramsset 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.

Member Function Documentation

◆ checkReachability()

virtual bool bayesopt::BayesOptBase::checkReachability ( const vectord &  query)
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.

Parameters
querypoint to be evaluated.
Returns
boolean value showing if the the function is valid at the query point or not.

Reimplemented in ExampleHartmann6, XMLCallsBranin, ExampleCamelback, BraninNormalized, SystemCallsBranin, ExampleDisc, ExampleQuadratic, and ExampleOneD.

Definition at line 113 of file bayesoptbase.hpp.

◆ evaluateSample()

virtual double bayesopt::BayesOptBase::evaluateSample ( const vectord &  query)
pure virtual

Function that defines the actual function to be optimized.

This function must be modified (overriden) according to the specific problem.

Parameters
querypoint to be evaluated.
Returns
value of the function at the point 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().

◆ evaluateSampleInternal()

double bayesopt::BayesOptBase::evaluateSampleInternal ( const vectord &  query)
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().

◆ findOptimal()

virtual void bayesopt::BayesOptBase::findOptimal ( vectord &  xOpt)
protectedpure virtual

Call the inner optimization method to find the optimal point acording to the criteria.

Parameters
xOptoptimal point

Implemented in bayesopt::DiscreteModel, and bayesopt::ContinuousModel.

◆ generateInitialPoints()

virtual void bayesopt::BayesOptBase::generateInitialPoints ( matrixd &  xPoints)
protectedpure virtual

Selects the initial set of points to build the surrogate model.

Implemented in bayesopt::DiscreteModel, and bayesopt::ContinuousModel.

Referenced by initializeOptimization().

◆ getFinalResult()

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().

◆ getPointAtMinimum()

vectord bayesopt::BayesOptBase::getPointAtMinimum ( )
protected

Get optimal point in the inner space (e.g.

: [0-1] hypercube)

Definition at line 313 of file bayesoptbase.cpp.

Referenced by getFinalResult().

◆ initializeOptimization()

void bayesopt::BayesOptBase::initializeOptimization ( )

◆ nextPoint()

vectord bayesopt::BayesOptBase::nextPoint ( )
private

Selects the next point to evaluate according to a certain criteria or metacriteria.

Returns
next point to evaluate

Definition at line 387 of file bayesoptbase.cpp.

References bayesopt::Parameters::epsilon, mEngine, and mParameters.

Referenced by stepOptimization().

◆ optimize()

void bayesopt::BayesOptBase::optimize ( vectord &  bestPoint)

Execute the optimization process of the function defined in evaluateSample.

See also
evaluateSample
checkReachability
Parameters
bestPointreturns 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().

◆ plotStepData()

void bayesopt::BayesOptBase::plotStepData ( size_t  iteration,
const vectord &  xNext,
double  yNext 
)
protected

Print data for every step according to the verbose level.

Parameters
iterationiteration number
xNextnext point
yNextfunction value at next point

Definition at line 330 of file bayesoptbase.cpp.

References mParameters, and bayesopt::Parameters::verbose_level.

◆ remapPoint()

virtual vectord bayesopt::BayesOptBase::remapPoint ( const vectord &  x)
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().

◆ samplePoint()

virtual vectord bayesopt::BayesOptBase::samplePoint ( )
protectedpure virtual

Sample a single point in the input space.

Used for epsilon greedy exploration.

Implemented in bayesopt::DiscreteModel, and bayesopt::ContinuousModel.

◆ saveOptimization()

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().


The documentation for this class was generated from the following files: