BayesOpt
bayesopt::utils Namespace Reference

Extra utils: math functions, ublas helpers, etc. More...

Classes

class  BoundingBox
 Defines a bounding box or axis-alligned bound constraints. More...
 
class  CUnique
 Simple class to generate sequences of unique numbers. More...
 
class  DisplayProblem1D
 
class  DisplayProblem2D
 
class  FileParser
 
class  ParamLoader
 

Enumerations

enum  RunningStatus { RUN, STEP, STOP, NOT_READY }
 

Functions

void deepenGrid (size_t comp, const vectori ndivs, vectord &x, vecOfvec &result)
 
void buildGrid (const vectori &dims, vecOfvec &result)
 
std::vector< int > return_index_vector (size_t n)
 Generates a vector of indexes (1..n) More...
 
std::vector< int > return_index_vector (int a, size_t n)
 Generates a vector of indexes starting at A and size_t n. More...
 
void modify_index_vector (std::vector< int > &arr)
 Modify a vector of indexes (0..n) More...
 
template<class M >
void samplePoints (M &xPoints, int method, randEngine &mtRandom)
 Selects the sampling method. More...
 
template<class M >
void lhs (M &Result, randEngine &mtRandom)
 Latin hypercube sampling It is used to generate a uniform Latin hypercube.
 
template<class M >
void uniformSampling (M &Result, randEngine &mtRandom)
 Hypercube sampling based on Sobol sequences It uses the external Sobol library. More...
 
template<class D >
void randomPerms (D &arr, randEngine &mtRandom)
 Modify an array using ramdom permutations. More...
 
void parseExpresion (std::string input, std::string &parent, std::string &child1, std::string &child2)
 Parse expresions of the form Parent(Child1, Child2). More...
 
void parseExpresion (std::string input, std::string &parent, std::vector< std::string > &childs)
 Parse expresions of the form Parent(Child1, ... More...
 
void split (std::string &input, char delim, std::vector< std::string > &elems)
 Splits the input string with a delimiter to extract elements.
 
template<class MATRIX , class TRIA >
size_t cholesky_decompose (const MATRIX &A, TRIA &L)
 decompose the symmetric positive definit matrix A into product L L^T. More...
 
template<class MATRIX >
size_t cholesky_decompose (MATRIX &A)
 decompose the symmetric positive definit matrix A into product L L^T. More...
 
template<class MATRIX >
size_t incomplete_cholesky_decompose (MATRIX &A)
 decompose the symmetric positive definit matrix A into product L L^T. More...
 
template<class TRIA , class MATRIX >
void cholesky_solve (const TRIA &L, MATRIX &x, ublas::lower)
 solve system L L^T x = b inplace More...
 
template<class Min , class Mout >
size_t inverse_cholesky (const Min &M, Mout &inverse)
 Computes the inverse matrix of a symmetric positive definite matrix. More...
 
template<class TRIA , class VECTOR >
void cholesky_add_row (TRIA &L, const VECTOR &v)
 decompose the symmetric positive definit matrix A into product L L^T. More...
 
template<class v1 , class v2 >
v1 ublas_elementwise_prod (const v1 &a, const v2 &b)
 Computes the elementwise product of two vectors or matrices. More...
 
template<class v1 , class v2 >
v1 ublas_elementwise_div (const v1 &a, const v2 &b)
 Computes the elementwise division of two vectors or matrices. More...
 
boost::numeric::ublas::vector< double > array2vector (const double array[], const size_t n)
 
template<class V , class D >
void append (V &vect, D element)
 
template<class V , class I >
void erase (V &vect, I begin)
 
template<class M >
void erase_column (M &mat, size_t pos)
 
template<class M , class V >
void add_to_diagonal (M &mat, const V &vec)
 
template<class E >
E::value_type trace (const E &A)
 
template<class E >
E::value_type log_trace (const E &A)
 
template<class E1 , class E2 >
E1::value_type trace_prod (const E1 &A, const E2 &B)
 

Detailed Description

Extra utils: math functions, ublas helpers, etc.

Function Documentation

◆ cholesky_add_row()

template<class TRIA , class VECTOR >
void bayesopt::utils::cholesky_add_row ( TRIA &  L,
const VECTOR &  v 
)

decompose the symmetric positive definit matrix A into product L L^T.

Parameters
MATRIXtype of input matrix
TRIAtype of lower triangular output matrix
Asquare symmetric positive definite input matrix (only the lower triangle is accessed)
Llower triangular output matrix

Definition at line 264 of file ublas_cholesky.hpp.

Referenced by bayesopt::KernelRegressor::addNewPointToCholesky(), and bayesopt::KernelRegressor::updateSurrogateModel().

◆ cholesky_decompose() [1/2]

template<class MATRIX , class TRIA >
size_t bayesopt::utils::cholesky_decompose ( const MATRIX &  A,
TRIA &  L 
)

decompose the symmetric positive definit matrix A into product L L^T.

Parameters
MATRIXtype of input matrix
TRIAtype of lower triangular output matrix
Asquare symmetric positive definite input matrix (only the lower triangle is accessed)
Llower triangular output matrix
Returns
nonzero if decompositon fails (the value ist 1 + the numer of the failing row)

Definition at line 57 of file ublas_cholesky.hpp.

Referenced by bayesopt::KernelRegressor::computeCholeskyCorrelation(), inverse_cholesky(), bayesopt::GaussianProcess::negativeLogLikelihood(), bayesopt::HierarchicalGaussianProcess::negativeTotalLogLikelihood(), bayesopt::StudentTProcessJeffreys::precomputePrediction(), and bayesopt::GaussianProcessML::precomputePrediction().

◆ cholesky_decompose() [2/2]

template<class MATRIX >
size_t bayesopt::utils::cholesky_decompose ( MATRIX &  A)

decompose the symmetric positive definit matrix A into product L L^T.

Parameters
MATRIXtype of matrix A
Ainput: square symmetric positive definite matrix (only the lower triangle is accessed)
Aoutput: the lower triangle of A is replaced by the cholesky factor
Returns
nonzero if decompositon fails (the value ist 1 + the numer of the failing row)

Definition at line 99 of file ublas_cholesky.hpp.

◆ cholesky_solve()

template<class TRIA , class MATRIX >
void bayesopt::utils::cholesky_solve ( const TRIA &  L,
MATRIX &  x,
ublas::lower   
)

solve system L L^T x = b inplace

Parameters
La triangular matrix
xinput: right hand side b; output: solution x

Definition at line 222 of file ublas_cholesky.hpp.

Referenced by inverse_cholesky(), bayesopt::HierarchicalGaussianProcess::negativeTotalLogLikelihood(), bayesopt::StudentTProcessJeffreys::precomputePrediction(), and bayesopt::GaussianProcessML::precomputePrediction().

◆ incomplete_cholesky_decompose()

template<class MATRIX >
size_t bayesopt::utils::incomplete_cholesky_decompose ( MATRIX &  A)

decompose the symmetric positive definit matrix A into product L L^T.

Parameters
MATRIXtype of matrix A
Ainput: square symmetric positive definite matrix (only the lower triangle is accessed)
Aoutput: the lower triangle of A is replaced by the cholesky factor
Returns
nonzero if decompositon fails (the value ist 1 + the numer of the failing row)

Definition at line 175 of file ublas_cholesky.hpp.

◆ inverse_cholesky()

template<class Min , class Mout >
size_t bayesopt::utils::inverse_cholesky ( const Min &  M,
Mout &  inverse 
)

Computes the inverse matrix of a symmetric positive definite matrix.

Parameters
Moriginal matrix
inverseinverse of M
Returns
nonzero if decompositon fails (the value ist 1 + the numer of the failing row)

Definition at line 240 of file ublas_cholesky.hpp.

References cholesky_decompose(), and cholesky_solve().

◆ modify_index_vector()

void bayesopt::utils::modify_index_vector ( std::vector< int > &  arr)
inline

Modify a vector of indexes (0..n)

Parameters
arrvector

Definition at line 77 of file indexvector.hpp.

◆ parseExpresion() [1/2]

void bayesopt::utils::parseExpresion ( std::string  input,
std::string &  parent,
std::string &  child1,
std::string &  child2 
)

Parse expresions of the form Parent(Child1, Child2).

The "childs" can also be expressions of the same type.

Definition at line 35 of file parser.cpp.

Referenced by bayesopt::KernelFactory::create(), bayesopt::CriteriaFactory::create(), and bayesopt::MeanFactory::create().

◆ parseExpresion() [2/2]

void bayesopt::utils::parseExpresion ( std::string  input,
std::string &  parent,
std::vector< std::string > &  childs 
)

Parse expresions of the form Parent(Child1, ...

,ChildN). The "childs" can also be expressions of the same type.

Definition at line 70 of file parser.cpp.

◆ randomPerms()

template<class D >
void bayesopt::utils::randomPerms ( D &  arr,
randEngine &  mtRandom 
)

Modify an array using ramdom permutations.

It is used to generate a uniform Latin hypercube. Equivalent to std::random_shuffle but using boost::random

Definition at line 80 of file lhs.hpp.

Referenced by bayesopt::DiscreteModel::generateInitialPoints().

◆ return_index_vector() [1/2]

std::vector<int> bayesopt::utils::return_index_vector ( size_t  n)
inline

Generates a vector of indexes (1..n)

Parameters
nvector size
Returns
index vector

Definition at line 50 of file indexvector.hpp.

◆ return_index_vector() [2/2]

std::vector<int> bayesopt::utils::return_index_vector ( int  a,
size_t  n 
)
inline

Generates a vector of indexes starting at A and size_t n.

Parameters
astarting point
nvector size
Returns
index vector

Definition at line 64 of file indexvector.hpp.

◆ samplePoints()

template<class M >
void bayesopt::utils::samplePoints ( M &  xPoints,
int  method,
randEngine &  mtRandom 
)

Selects the sampling method.

Definition at line 141 of file lhs.hpp.

Referenced by bayesopt::ContinuousModel::generateInitialPoints().

◆ ublas_elementwise_div()

template<class v1 , class v2 >
v1 bayesopt::utils::ublas_elementwise_div ( const v1 &  a,
const v2 &  b 
)

Computes the elementwise division of two vectors or matrices.

c_i = a_i / b_i

Definition at line 53 of file ublas_elementwise.hpp.

◆ ublas_elementwise_prod()

template<class v1 , class v2 >
v1 bayesopt::utils::ublas_elementwise_prod ( const v1 &  a,
const v2 &  b 
)

Computes the elementwise product of two vectors or matrices.

c_i = a_i * b_i

Definition at line 40 of file ublas_elementwise.hpp.

◆ uniformSampling()

template<class M >
void bayesopt::utils::uniformSampling ( M &  Result,
randEngine &  mtRandom 
)

Hypercube sampling based on Sobol sequences It uses the external Sobol library.

Thus it do not depend on boost random.Uniform hypercube sampling It is used to generate a set of uniformly distributed samples in hypercube

Definition at line 126 of file lhs.hpp.