BayesOpt
bayesopt::ContinuousModel Class Reference

Bayesian optimization for functions in continuous input spaces. More...

#include <bayesopt.hpp>

+ Inheritance diagram for bayesopt::ContinuousModel:
+ Collaboration diagram for bayesopt::ContinuousModel:

Public Member Functions

 ContinuousModel (size_t dim, Parameters params)
 Constructor. More...
 
virtual ~ContinuousModel ()
 Default destructor.
 
void setBoundingBox (const vectord &lowerBound, const vectord &upperBound)
 Sets the bounding box. More...
 
- Public Member Functions inherited from bayesopt::BayesOptBase
 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 samplePoint ()
 Sample a single point in the input space. More...
 
void findOptimal (vectord &xOpt)
 Call the inner optimization method to find the optimal point acording to the criteria. More...
 
vectord remapPoint (const vectord &x)
 Remap the point x to the original space (e.g. More...
 
void generateInitialPoints (matrixd &xPoints)
 Selects the initial set of points to build the surrogate model. More...
 
- Protected Member Functions inherited from bayesopt::BayesOptBase
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...
 
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)
 

Private Member Functions

 ContinuousModel ()
 Default constructor forbidden.
 

Private Attributes

boost::scoped_ptr< utils::BoundingBox< vectord > > mBB
 Bounding Box (input space limits)
 
boost::scoped_ptr< NLOPT_OptimizationcOptimizer
 
boost::scoped_ptr< CritCallbackmCallback
 

Additional Inherited Members

- Protected Attributes inherited from bayesopt::BayesOptBase
Parameters mParameters
 Configuration parameters.
 
size_t mDims
 Number of dimensions.
 
size_t mCurrentIter
 Current iteration number.
 
boost::mt19937 mEngine
 Random number generator.
 

Detailed Description

Bayesian optimization for functions in continuous input spaces.

It requires box constrains for the input space. More exactly: $ f(x):\mathcal{D} \subset \mathbb{R}^n \Rightarrow \mathbb{R} $.

Usage:

ContinuousModel opt(dim,params);
vectord result(dim), lBound(dim), uBound(dim);
\\.. Define bounds
opt.setBoundingBox(lBound,uBound);

Optimization can be run in batch mode calling

opt.optimize(result);

or step by step.

opt.initiliazeOptimization();
\\...
opt.stepOptimization();
\\...
result getFinalResult();

This model can also be used for discrete/integer data, provided that the callback function provides the corresponding casting or nearest neighbour.

See also
BayesOptBase about how to run the optimization

Definition at line 78 of file bayesopt.hpp.

Constructor & Destructor Documentation

◆ ContinuousModel()

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

Constructor.

Parameters
dimnumber of input dimensions
paramsset of parameters (see parameters.h)

Definition at line 50 of file bayesoptcont.cpp.

References bayesopt::COMBINED, and bayesopt::Parameters::n_inner_iterations.

Member Function Documentation

◆ findOptimal()

void bayesopt::ContinuousModel::findOptimal ( vectord &  xOpt)
protectedvirtual

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

Parameters
xOptoptimal point

Implements bayesopt::BayesOptBase.

Definition at line 99 of file bayesoptcont.cpp.

References bayesopt::BayesOptBase::mEngine.

◆ generateInitialPoints()

void bayesopt::ContinuousModel::generateInitialPoints ( matrixd &  xPoints)
protectedvirtual

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

Implements bayesopt::BayesOptBase.

Definition at line 134 of file bayesoptcont.cpp.

References bayesopt::Parameters::init_method, bayesopt::BayesOptBase::mEngine, bayesopt::BayesOptBase::mParameters, and bayesopt::utils::samplePoints().

◆ remapPoint()

vectord bayesopt::ContinuousModel::remapPoint ( const vectord &  x)
protectedvirtual

Remap the point x to the original space (e.g.

: unnormalization)

Implements bayesopt::BayesOptBase.

Definition at line 129 of file bayesoptcont.cpp.

References mBB.

◆ samplePoint()

vectord bayesopt::ContinuousModel::samplePoint ( )
protectedvirtual

Sample a single point in the input space.

Used for epsilon greedy exploration.

Implements bayesopt::BayesOptBase.

Definition at line 88 of file bayesoptcont.cpp.

References bayesopt::BayesOptBase::mEngine.

◆ setBoundingBox()

void bayesopt::ContinuousModel::setBoundingBox ( const vectord &  lowerBound,
const vectord &  upperBound 
)

Sets the bounding box.

Parameters
lowerBoundvector with the lower bounds of the hypercube
upperBoundvector with the upper bounds of the hypercube

Definition at line 68 of file bayesoptcont.cpp.

References mBB.


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